本文整理汇总了PHP中user_role_names函数的典型用法代码示例。如果您正苦于以下问题:PHP user_role_names函数的具体用法?PHP user_role_names怎么用?PHP user_role_names使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_role_names函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$sanitized_id = ArgumentPluginBase::encodeValidatorId($this->definition['id']);
$form['restrict_roles'] = array('#type' => 'checkbox', '#title' => $this->t('Restrict user based on role'), '#default_value' => $this->options['restrict_roles']);
$form['roles'] = array('#type' => 'checkboxes', '#title' => $this->t('Restrict to the selected roles'), '#options' => array_map(array('\\Drupal\\Component\\Utility\\SafeMarkup', 'checkPlain'), user_role_names(TRUE)), '#default_value' => $this->options['roles'], '#description' => $this->t('If no roles are selected, users from any role will be allowed.'), '#states' => array('visible' => array(':input[name="options[validate][options][' . $sanitized_id . '][restrict_roles]"]' => array('checked' => TRUE))));
}
开发者ID:nstielau,项目名称:drops-8,代码行数:10,代码来源:User.php
示例2: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$default_role_choices = user_role_names(TRUE);
unset($default_role_choices[DRUPAL_AUTHENTICATED_RID]);
$roles_config = $this->config('uc_role.settings');
if (!count($default_role_choices)) {
$form['no_roles'] = array('#markup' => $this->t('You need to <a href=":url">create new roles</a> before any can be added as product features.', [':url' => Url::fromRoute('user.role_add', [], ['query' => ['destination' => 'admin/store/config/products']])->toString()]), '#prefix' => '<p>', '#suffix' => '</p>');
return $form;
}
$form['default_role'] = array('#type' => 'select', '#title' => $this->t('Default role'), '#default_value' => $roles_config->get('default_role'), '#description' => $this->t('The default role Ubercart grants on specified products.'), '#options' => _uc_role_get_choices());
$form['default_role_choices'] = array('#type' => 'checkboxes', '#title' => $this->t('Product roles'), '#default_value' => $roles_config->get('default_role_choices'), '#multiple' => TRUE, '#description' => $this->t('These are roles that Ubercart can grant to customers who purchase specified products. If you leave all roles unchecked, they will all be eligible for adding to a product.'), '#options' => $default_role_choices);
$form['role_lifetime'] = array('#type' => 'fieldset', '#title' => $this->t('Default role expiration'));
$form['role_lifetime']['default_end_expiration'] = array('#type' => 'select', '#title' => $this->t('Expiration type'), '#options' => array('rel' => $this->t('Relative to purchase date'), 'abs' => $this->t('Fixed date')), '#default_value' => $roles_config->get('default_end_expiration'));
$form['role_lifetime']['default_length'] = array('#type' => 'textfield', '#default_value' => $roles_config->get('default_granularity') == 'never' ? NULL : $roles_config->get('default_length'), '#size' => 4, '#maxlength' => 4, '#prefix' => '<div class="expiration">', '#suffix' => '</div>', '#states' => array('visible' => array('select[name="default_end_expiration"]' => array('value' => 'rel')), 'invisible' => array('select[name="default_granularity"]' => array('value' => 'never'))));
$form['role_lifetime']['default_granularity'] = array('#type' => 'select', '#default_value' => $roles_config->get('default_granularity'), '#options' => array('never' => $this->t('never'), 'day' => $this->t('day(s)'), 'week' => $this->t('week(s)'), 'month' => $this->t('month(s)'), 'year' => $this->t('year(s)')), '#description' => $this->t('From the time the role was purchased.'), '#prefix' => '<div class="expiration">', '#suffix' => '</div>', '#states' => array('visible' => array('select[name="default_end_expiration"]' => array('value' => 'rel'))));
$form['role_lifetime']['absolute'] = array('#type' => 'container', '#states' => array('visible' => array('select[name="default_end_expiration"]' => array('value' => 'abs'))));
$date = (int) $roles_config->get('default_end_time');
$date = !empty($date) ? DrupalDateTime::createFromTimestamp($date) : DrupalDateTime::createFromTimestamp(REQUEST_TIME);
$form['role_lifetime']['absolute']['default_end_time'] = array('#type' => 'datetime', '#description' => $this->t('Expire the role at the beginning of this day.'), '#date_date_element' => 'date', '#date_time_element' => 'none', '#default_value' => $date);
$form['role_lifetime']['default_by_quantity'] = array('#type' => 'checkbox', '#title' => $this->t('Multiply by quantity'), '#description' => $this->t('Check if the role duration should be multiplied by the quantity purchased.'), '#default_value' => $roles_config->get('default_by_quantity'));
$form['reminder']['reminder_length'] = array('#type' => 'textfield', '#title' => $this->t('Time before reminder'), '#default_value' => $roles_config->get('reminder_granularity') == 'never' ? NULL : $roles_config->get('reminder_length'), '#size' => 4, '#maxlength' => 4, '#prefix' => '<div class="expiration">', '#suffix' => '</div>', '#states' => array('disabled' => array('select[name="reminder_granularity"]' => array('value' => 'never'))));
$form['reminder']['reminder_granularity'] = array('#type' => 'select', '#default_value' => $roles_config->get('reminder_granularity'), '#options' => array('never' => $this->t('never'), 'day' => $this->t('day(s)'), 'week' => $this->t('week(s)'), 'month' => $this->t('month(s)'), 'year' => $this->t('year(s)')), '#description' => $this->t('The amount of time before a role expiration takes place that a customer is notified of its expiration.'), '#prefix' => '<div class="expiration">', '#suffix' => '</div>');
$form['default_show_expiration'] = array('#type' => 'checkbox', '#title' => $this->t('Show expirations on user page'), '#default_value' => $roles_config->get('default_show_expiration'), '#description' => $this->t('If users have any role expirations they will be displayed on their account page.'));
return parent::buildForm($form, $form_state);
}
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:28,代码来源:FeatureSettingsForm.php
示例3: buildConfigurationForm
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, array &$form_state)
{
$roles = user_role_names(TRUE);
unset($roles[DRUPAL_AUTHENTICATED_RID]);
$form['rid'] = array('#type' => 'radios', '#title' => t('Role'), '#options' => $roles, '#default_value' => $this->configuration['rid'], '#required' => TRUE);
return $form;
}
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:ChangeUserRoleBase.php
示例4: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
$row['to']['#markup'] = $this->stateStorage->load($entity->getToState())->label();
$row['label'] = $entity->label();
$row['roles']['#markup'] = implode(', ', user_role_names(FALSE, 'use ' . $entity->id() . ' transition'));
return $row + parent::buildRow($entity);
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:ModerationStateTransitionListBuilder.php
示例5: summary
/**
* {@inheritdoc}
*/
public function summary()
{
if (!$this->configuration['roles']) {
return $this->t('Any registered user');
}
$roles = array_intersect_key(user_role_names(), $this->configuration['roles']);
return $this->t(empty($this->configuration['negate']) ? 'User is a member of @roles' : 'User is not a member of @roles', ['@roles' => count($roles) > 1 ? implode(' and ', $roles) : reset($roles)]);
}
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:11,代码来源:UserRole.php
示例6: form
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state)
{
$format = $this->entity;
$is_fallback = $format->id() == $this->config('filter.settings')->get('fallback_format');
$form['#tree'] = TRUE;
$form['#attached']['library'][] = 'filter/drupal.filter.admin';
$form['name'] = array('#type' => 'textfield', '#title' => $this->t('Name'), '#default_value' => $format->label(), '#required' => TRUE, '#weight' => -30);
$form['format'] = array('#type' => 'machine_name', '#required' => TRUE, '#default_value' => $format->id(), '#maxlength' => 255, '#machine_name' => array('exists' => array($this, 'exists'), 'source' => array('name')), '#disabled' => !$format->isNew(), '#weight' => -20);
// Add user role access selection.
$form['roles'] = array('#type' => 'checkboxes', '#title' => $this->t('Roles'), '#options' => array_map('\\Drupal\\Component\\Utility\\String::checkPlain', user_role_names()), '#disabled' => $is_fallback, '#weight' => -10);
if ($is_fallback) {
$form['roles']['#description'] = $this->t('All roles for this text format must be enabled and cannot be changed.');
}
if (!$format->isNew()) {
// If editing an existing text format, pre-select its current permissions.
$form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($format));
} elseif ($admin_role = $this->config('user.settings')->get('admin_role')) {
// If adding a new text format and the site has an administrative role,
// pre-select that role so as to grant administrators access to the new
// text format permission by default.
$form['roles']['#default_value'] = array($admin_role);
}
// Create filter plugin instances for all available filters, including both
// enabled/configured ones as well as new and not yet unconfigured ones.
$filters = $format->filters();
foreach ($filters as $filter_id => $filter) {
// When a filter is missing, it is replaced by the null filter. Remove it
// here, so that saving the form will remove the missing filter.
if ($filter instanceof FilterNull) {
drupal_set_message($this->t('The %filter filter is missing, and will be removed once this format is saved.', array('%filter' => $filter_id)), 'warning');
$filters->removeInstanceID($filter_id);
}
}
// Filter status.
$form['filters']['status'] = array('#type' => 'item', '#title' => $this->t('Enabled filters'), '#prefix' => '<div id="filters-status-wrapper">', '#suffix' => '</div>', '#input' => FALSE);
// Filter order (tabledrag).
$form['filters']['order'] = array('#type' => 'table', '#attributes' => array('id' => 'filter-order'), '#title' => $this->t('Filter processing order'), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'sibling', 'group' => 'filter-order-weight')), '#tree' => FALSE, '#input' => FALSE, '#theme_wrappers' => array('form_element'));
// Filter settings.
$form['filter_settings'] = array('#type' => 'vertical_tabs', '#title' => $this->t('Filter settings'));
foreach ($filters as $name => $filter) {
$form['filters']['status'][$name] = array('#type' => 'checkbox', '#title' => $filter->getLabel(), '#default_value' => $filter->status, '#parents' => array('filters', $name, 'status'), '#description' => $filter->getDescription(), '#weight' => $filter->weight);
$form['filters']['order'][$name]['#attributes']['class'][] = 'draggable';
$form['filters']['order'][$name]['#weight'] = $filter->weight;
$form['filters']['order'][$name]['filter'] = array('#markup' => $filter->getLabel());
$form['filters']['order'][$name]['weight'] = array('#type' => 'weight', '#title' => $this->t('Weight for @title', array('@title' => $filter->getLabel())), '#title_display' => 'invisible', '#delta' => 50, '#default_value' => $filter->weight, '#parents' => array('filters', $name, 'weight'), '#attributes' => array('class' => array('filter-order-weight')));
// Retrieve the settings form of the filter plugin. The plugin should not be
// aware of the text format. Therefore, it only receives a set of minimal
// base properties to allow advanced implementations to work.
$settings_form = array('#parents' => array('filters', $name, 'settings'), '#tree' => TRUE);
$settings_form = $filter->settingsForm($settings_form, $form_state);
if (!empty($settings_form)) {
$form['filters']['settings'][$name] = array('#type' => 'details', '#title' => $filter->getLabel(), '#open' => TRUE, '#weight' => $filter->weight, '#parents' => array('filters', $name, 'settings'), '#group' => 'filter_settings');
$form['filters']['settings'][$name] += $settings_form;
}
}
return parent::form($form, $form_state);
}
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:60,代码来源:FilterFormatFormBase.php
示例7: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
// Get all available roles except for
// 'anonymous user' and 'authenticated user'.
$roles = user_role_names(TRUE);
unset($roles[RoleInterface::AUTHENTICATED_ID]);
// Show checkboxes with roles that can be delegated if any.
if ($roles) {
$config = $this->config('roleassign.settings');
$form['roleassign_roles'] = array('#type' => 'checkboxes', '#title' => $this->t('Roles'), '#default_value' => $config->get('roleassign_roles'), '#options' => $roles, '#description' => $this->t('Select roles that should be available for assignment.'));
}
return parent::buildForm($form, $form_state);
}
开发者ID:Codelab42,项目名称:roleassign,代码行数:16,代码来源:RoleAssignAdminForm.php
示例8: createConditionElements
/**
*
*/
public function createConditionElements() {
$elements['condition_config'] = [
'#tree' => TRUE,
];
// @todo Dynamically create condition for by call ConditionPluginBase::buildConfigurationForm?
$elements['condition_config']['roles'] = array(
'#type' => 'checkboxes',
'#title' => $this->t('When the user has the following roles'),
'#options' => array_map('\Drupal\Component\Utility\Html::escape', user_role_names()),
// '#description' => $this->t('If you select no roles, the condition will evaluate to TRUE for all users.'),.
);
return $elements;
}
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:16,代码来源:RolesConditionCreator.php
示例9: query
/**
* {@inheritdoc}
*
* Replace the configured permission with a filter by all roles that have this
* permission.
*/
public function query()
{
// @todo user_role_names() should maybe support multiple permissions.
$rids = array();
// Get all roles, that have the configured permissions.
foreach ($this->value as $permission) {
$roles = user_role_names(FALSE, $permission);
$rids += array_keys($roles);
}
$rids = array_unique($rids);
$this->value = $rids;
// $this->value contains the role IDs that have the configured permission.
parent::query();
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:20,代码来源:Permissions.php
示例10: summary
/**
* {@inheritdoc}
*/
public function summary()
{
// Use the role labels. They will be sanitized below.
$roles = array_intersect_key(user_role_names(), $this->configuration['roles']);
if (count($roles) > 1) {
$roles = implode(', ', $roles);
} else {
$roles = reset($roles);
}
if (!empty($this->configuration['negate'])) {
return $this->t('The user is not a member of @roles', array('@roles' => $roles));
} else {
return $this->t('The user is a member of @roles', array('@roles' => $roles));
}
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:UserRole.php
示例11: settingsForm
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state)
{
$form['num'] = array('#type' => 'number', '#title' => $this->t('How many users would you like to generate?'), '#default_value' => $this->getSetting('num'), '#required' => TRUE, '#min' => 0);
$form['kill'] = array('#type' => 'checkbox', '#title' => $this->t('Delete all users (except user id 1) before generating new users.'), '#default_value' => $this->getSetting('kill'));
$options = user_role_names(TRUE);
unset($options[DRUPAL_AUTHENTICATED_RID]);
$form['roles'] = array('#type' => 'checkboxes', '#title' => $this->t('Which roles should the users receive?'), '#description' => $this->t('Users always receive the <em>authenticated user</em> role.'), '#options' => $options);
$form['pass'] = array('#type' => 'textfield', '#title' => $this->t('Password to be set'), '#default_value' => $this->getSetting('pass'), '#size' => 32, '#description' => $this->t('Leave this field empty if you do not need to set a password'));
$options = array(1 => $this->t('Now'));
foreach (array(3600, 86400, 604800, 2592000, 31536000) as $interval) {
$options[$interval] = $this->dateFormatter->formatInterval($interval, 1) . ' ' . $this->t('ago');
}
$form['time_range'] = array('#type' => 'select', '#title' => $this->t('How old should user accounts be?'), '#description' => $this->t('User ages will be distributed randomly from the current time, back to the selected time.'), '#options' => $options, '#default_value' => 604800);
return $form;
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:18,代码来源:UserDevelGenerate.php
示例12: settingsForm
/**
* {@inheritdoc}
*/
public static function settingsForm(FieldDefinitionInterface $field_definition)
{
$selection_handler_settings = $field_definition->getSetting('handler_settings');
// Merge in default values.
$selection_handler_settings += array('filter' => array('type' => '_none'));
// Add user specific filter options.
$form['filter']['type'] = array('#type' => 'select', '#title' => t('Filter by'), '#options' => array('_none' => t('- None -'), 'role' => t('User role')), '#ajax' => TRUE, '#limit_validation_errors' => array(), '#default_value' => $selection_handler_settings['filter']['type']);
$form['filter']['settings'] = array('#type' => 'container', '#attributes' => array('class' => array('entity_reference-settings')), '#process' => array('_entity_reference_form_process_merge_parent'));
if ($selection_handler_settings['filter']['type'] == 'role') {
// Merge in default values.
$selection_handler_settings['filter'] += array('role' => NULL);
$form['filter']['settings']['role'] = array('#type' => 'checkboxes', '#title' => t('Restrict to the selected roles'), '#required' => TRUE, '#options' => array_diff_key(user_role_names(TRUE), array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID)), '#default_value' => $selection_handler_settings['filter']['role']);
}
$form += parent::settingsForm($field_definition);
return $form;
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:19,代码来源:UserSelection.php
示例13: buildForm
/**
* Implements \Drupal\Core\Form\FormInterface::buildForm().
*
* @param array $form
* The form array.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state.
*
* @return array $form
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$form['#tree'] = TRUE;
$form['config'] = ['#type' => 'fieldset', '#title' => $this->t('Options')];
$roles = user_role_names();
unset($roles['anonymous']);
$form['config']['roles'] = ['#type' => 'checkboxes', '#title' => $this->t('Roles'), '#options' => $roles];
// Special handling for the inevitable "Authenticated user" role.
$form['config']['roles'][RoleInterface::AUTHENTICATED_ID] = array('#default_value' => TRUE, '#disabled' => TRUE);
$form['file'] = ['#type' => 'file', '#title' => 'CSV file upload', '#upload_validators' => ['file_validate_extensions' => ['csv']]];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Import users'), '#button_type' => 'primary');
// By default, render the form using theme_system_config_form().
$form['#theme'] = 'system_config_form';
return $form;
}
开发者ID:steveoliver,项目名称:user_import,代码行数:26,代码来源:UserImportForm.php
示例14: buildConfigurationForm
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state)
{
$selection_handler_settings = $this->configuration['handler_settings'];
// Merge in default values.
$selection_handler_settings += array('filter' => array('type' => '_none'), 'include_anonymous' => TRUE);
$form['include_anonymous'] = array('#type' => 'checkbox', '#title' => $this->t('Include the anonymous user.'), '#default_value' => $selection_handler_settings['include_anonymous']);
// Add user specific filter options.
$form['filter']['type'] = array('#type' => 'select', '#title' => $this->t('Filter by'), '#options' => array('_none' => $this->t('- None -'), 'role' => $this->t('User role')), '#ajax' => TRUE, '#limit_validation_errors' => array(), '#default_value' => $selection_handler_settings['filter']['type']);
$form['filter']['settings'] = array('#type' => 'container', '#attributes' => array('class' => array('entity_reference-settings')), '#process' => array(array('\\Drupal\\Core\\Field\\Plugin\\Field\\FieldType\\EntityReferenceItem', 'formProcessMergeParent')));
if ($selection_handler_settings['filter']['type'] == 'role') {
// Merge in default values.
$selection_handler_settings['filter'] += array('role' => NULL);
$form['filter']['settings']['role'] = array('#type' => 'checkboxes', '#title' => $this->t('Restrict to the selected roles'), '#required' => TRUE, '#options' => array_diff_key(user_role_names(TRUE), array(RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID)), '#default_value' => $selection_handler_settings['filter']['role']);
}
$form += parent::buildConfigurationForm($form, $form_state);
return $form;
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:20,代码来源:UserSelection.php
示例15: query
/**
* {@inheritdoc}
*
* Replace the configured permission with a filter by all roles that have this
* permission.
*/
public function query()
{
// @todo user_role_names() should maybe support multiple permissions.
$rids = array();
// Get all role IDs that have the configured permissions.
foreach ($this->value as $permission) {
$roles = user_role_names(FALSE, $permission);
// user_role_names() returns an array with the role IDs as keys, so take
// the array keys and merge them with previously found role IDs.
$rids = array_merge($rids, array_keys($roles));
}
// Remove any duplicate role IDs.
$rids = array_unique($rids);
$this->value = $rids;
// $this->value contains the role IDs that have the configured permission.
parent::query();
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:23,代码来源:Permissions.php
示例16: testBulkForm
/**
* Tests the user bulk form.
*/
public function testBulkForm()
{
$this->drupalLogin($this->drupalCreateUser(array('administer permissions')));
// Test submitting the page with no selection.
$edit = array('action' => 'user_block_user_action');
$this->drupalPostForm('test-user-bulk-form', $edit, t('Apply'));
$this->assertText(t('No users selected.'));
// Assign a role to a user.
$account = entity_load('user', $this->users[0]->id());
$roles = user_role_names(TRUE);
unset($roles[DRUPAL_AUTHENTICATED_RID]);
$role = key($roles);
$this->assertFalse($account->hasRole($role), 'The user currently does not have a custom role.');
$edit = array('user_bulk_form[1]' => TRUE, 'action' => 'user_add_role_action.' . $role);
$this->drupalPostForm(NULL, $edit, t('Apply'));
// Re-load the user and check their roles.
$account = entity_load('user', $account->id(), TRUE);
$this->assertTrue($account->hasRole($role), 'The user now has the custom role.');
$edit = array('user_bulk_form[1]' => TRUE, 'action' => 'user_remove_role_action.' . $role);
$this->drupalPostForm(NULL, $edit, t('Apply'));
// Re-load the user and check their roles.
$account = entity_load('user', $account->id(), TRUE);
$this->assertFalse($account->hasRole($role), 'The user no longer has the custom role.');
// Block a user using the bulk form.
$this->assertTrue($account->isActive(), 'The user is not blocked.');
$this->assertRaw($account->label(), 'The user is found in the table.');
$edit = array('user_bulk_form[1]' => TRUE, 'action' => 'user_block_user_action');
$this->drupalPostForm(NULL, $edit, t('Apply'));
// Re-load the user and check their status.
$account = entity_load('user', $account->id(), TRUE);
$this->assertTrue($account->isBlocked(), 'The user is blocked.');
$this->assertNoRaw($account->label(), 'The user is not found in the table.');
// Remove the user status filter from the view.
$view = Views::getView('test_user_bulk_form');
$view->removeHandler('default', 'filter', 'status');
$view->storage->save();
// Ensure the anonymous user is found.
$this->drupalGet('test-user-bulk-form');
$this->assertText(\Drupal::config('user.settings')->get('anonymous'));
// Attempt to block the anonymous user.
$edit = array('user_bulk_form[0]' => TRUE, 'action' => 'user_block_user_action');
$this->drupalPostForm(NULL, $edit, t('Apply'));
$anonymous_account = user_load(0);
$this->assertTrue($anonymous_account->isBlocked(), 'Ensure the anonymous user got blocked.');
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:48,代码来源:BulkFormTest.php
示例17: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
$row['username']['data'] = array('#theme' => 'username', '#account' => $entity);
$row['status'] = $entity->isActive() ? $this->t('active') : $this->t('blocked');
$roles = array_map('\\Drupal\\Component\\Utility\\String::checkPlain', user_role_names(TRUE));
unset($roles[DRUPAL_AUTHENTICATED_RID]);
$users_roles = array();
foreach ($entity->getRoles() as $role) {
if (isset($roles[$role])) {
$users_roles[] = $roles[$role];
}
}
asort($users_roles);
$row['roles']['data'] = array('#theme' => 'item_list', '#items' => $users_roles);
$row['member_for'] = format_interval(REQUEST_TIME - $entity->getCreatedTime());
$row['access'] = $entity->access ? $this->t('@time ago', array('@time' => format_interval(REQUEST_TIME - $entity->getLastAccessedTime()))) : t('never');
return $row + parent::buildRow($entity);
}
开发者ID:alnutile,项目名称:drunatra,代码行数:21,代码来源:UserListBuilder.php
示例18: buildConfigurationForm
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['roles'] = array(
'#type' => 'checkboxes',
'#title' => $this->t('Restrict to the selected roles'),
'#options' => array_diff_key(user_role_names(TRUE), array(RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID)),
'#default_value' => $this->configuration['roles'],
'#description' => $this->t('If none of the checkboxes is checked, allow all roles.'),
'#element_validate' => [[get_class($this), 'elementValidateFilter']],
);
$form['include_blocked'] = [
'#title' => t('Include blocked user'),
'#type' => 'checkbox',
'#default_value' => $this->configuration['include_blocked'],
'#description' => t('In order to see blocked users, the requesting user must also have permissions to do so.'),
];
return $form;
}
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:24,代码来源:UserMatcher.php
示例19: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->config('cas.settings');
$form['server'] = array('#type' => 'details', '#title' => $this->t('CAS Server'), '#open' => TRUE, '#tree' => TRUE);
$form['server']['version'] = array('#type' => 'radios', '#title' => $this->t('Version'), '#options' => array('1.0' => $this->t('1.0'), '2.0' => $this->t('2.0 or higher')), '#default_value' => $config->get('server.version'));
$form['server']['hostname'] = array('#type' => 'textfield', '#title' => $this->t('Hostname'), '#description' => $this->t('Hostname or IP Address of the CAS server.'), '#size' => 30, '#default_value' => $config->get('server.hostname'));
$form['server']['port'] = array('#type' => 'textfield', '#title' => $this->t('Port'), '#size' => 5, '#description' => $this->t('443 is the standard SSL port. 8443 is the standard non-root port for Tomcat.'), '#default_value' => $config->get('server.port'));
$form['server']['path'] = array('#type' => 'textfield', '#title' => $this->t('URI'), '#description' => $this->t('If CAS is not at the root of the host, include a URI (e.g., /cas).'), '#size' => 30, '#default_value' => $config->get('server.path'));
$form['server']['verify'] = array('#type' => 'radios', '#title' => 'SSL Verification', '#description' => $this->t('Choose an appropriate option for verifying the certificate of your CAS server.'), '#options' => array(CasHelper::CA_DEFAULT => $this->t('Verify using web server\'s default certificates.'), CasHelper::CA_NONE => $this->t('Do not verify CAS server. (Note: this should NEVER be used in production.)'), CasHelper::CA_CUSTOM => $this->t('Verify using a custom certificate in the local filesystem. Use the field below to provide path.')), '#default_value' => $config->get('server.verify'));
$form['server']['cert'] = array('#type' => 'textfield', '#title' => $this->t('Custom Certificate Authority PEM Certificate'), '#description' => $this->t('The PEM certificate of the Certificate Authority that issued the certificate on the CAS server, used only with the custom certificate option above.'), '#default_value' => $config->get('server.cert'), '#states' => array('visible' => array(':input[name="server[verify]"]' => array('value' => CasHelper::CA_CUSTOM))));
$form['gateway'] = array('#type' => 'details', '#title' => $this->t('Gateway Feature (Auto Login)'), '#open' => FALSE, '#tree' => TRUE, '#description' => $this->t('This implements the <a href="@cas-gateway">Gateway feature</a> of the CAS Protocol. ' . 'When enabled, Drupal will check if a visitor is already logged into your CAS server before ' . 'serving a page request. If they have an active CAS session, they will be automatically ' . 'logged into the Drupal site. This is done by quickly redirecting them to the CAS server to perform the ' . 'active session check, and then redirecting them back to page they initially requested.<br/><br/>' . 'If enabled, all pages on your site will trigger this feature. You can instead enable ' . 'this feature for only specific pages by listing them below.<br/><br/>' . '<strong>WARNING:</strong> This feature is NOT compatible with the Internal Page Cache module or external ' . 'page caching software like Varnish.', array('@cas-gateway' => 'https://wiki.jasig.org/display/CAS/gateway')));
$form['gateway']['check_frequency'] = array('#type' => 'radios', '#title' => $this->t('Check Frequency'), '#default_value' => $config->get('gateway.check_frequency'), '#options' => array(CasHelper::CHECK_NEVER => 'Disable gateway feature', CasHelper::CHECK_ONCE => 'Once per browser session', CasHelper::CHECK_ALWAYS => 'Every page load (not recommended)'));
$this->gatewayPaths->setConfiguration($config->get('gateway.paths'));
$form['gateway']['paths'] = $this->gatewayPaths->buildConfigurationForm(array(), $form_state);
$form['forced_login'] = array('#type' => 'details', '#title' => $this->t('Forced Login'), '#open' => FALSE, '#tree' => TRUE, '#description' => $this->t('Anonymous users will be forced to login through CAS when enabled. ' . 'This differs from the "gateway feature" in that it will REQUIRE that a user be logged in to their CAS ' . 'account, instead of just checking if they already are.<br/><br/>' . '<strong>WARNING:</strong> This feature is NOT compatible with the Internal Page Cache module or external ' . 'page caching software like Varnish.'));
$form['forced_login']['enabled'] = array('#type' => 'checkbox', '#title' => $this->t('Enable'), '#description' => $this->t('When enabled, every path will force a CAS login, unless specific pages are listed below.'), '#default_value' => $config->get('forced_login.enabled'));
$this->forcedLoginPaths->setConfiguration($config->get('forced_login.paths'));
$form['forced_login']['paths'] = $this->forcedLoginPaths->buildConfigurationForm(array(), $form_state);
$form['user_accounts'] = array('#type' => 'details', '#title' => $this->t('User Account Handling'), '#open' => FALSE, '#tree' => TRUE);
$form['user_accounts']['auto_register'] = array('#type' => 'checkbox', '#title' => $this->t('Auto Register Users'), '#description' => $this->t('Enable to automatically create local Drupal accounts for first-time CAS logins. ' . 'If disabled, users must be pre-registered before being allowed to log in.'), '#default_value' => $config->get('user_accounts.auto_register'));
$auto_assigned_roles = $config->get('user_accounts.auto_assigned_roles');
$form['user_accounts']['auto_assigned_roles_enable'] = array('#type' => 'checkbox', '#title' => t('Automatically assign roles on user registration'), '#default_value' => count($auto_assigned_roles) > 0, '#states' => array('invisible' => array('input[name="user_accounts[auto_register]"]' => array('checked' => FALSE))));
$roles = user_role_names(TRUE);
unset($roles[RoleInterface::AUTHENTICATED_ID]);
$form['user_accounts']['auto_assigned_roles'] = array('#type' => 'select', '#multiple' => TRUE, '#title' => t('Roles'), '#description' => t('The selected roles will be automatically assigned to each CAS user on login. Use this to automatically give CAS users additional privileges or to identify CAS users to other modules.'), '#default_value' => $auto_assigned_roles, '#options' => $roles, '#states' => array('invisible' => array('input[name="user_accounts[auto_assigned_roles_enable]"]' => array('checked' => FALSE))));
$form['logout'] = array('#type' => 'details', '#title' => $this->t('Logout Behavior'), '#open' => FALSE, '#tree' => TRUE);
$form['logout']['cas_logout'] = array('#type' => 'checkbox', '#title' => $this->t('Drupal Logout Triggers CAS Logout'), '#description' => $this->t('When enabled, users that log out of your Drupal site will then be logged out of your CAS server as well. This is done by redirecting the user to the CAS logout page.'), '#default_value' => $config->get('logout.cas_logout'));
$form['logout']['logout_destination'] = array('#type' => 'textfield', '#title' => $this->t('Logout destination'), '#description' => $this->t('Drupal path or URL. Enter a destination if you want the CAS Server to ' . 'redirect the user after logging out of CAS.'), '#default_value' => $config->get('logout.logout_destination'));
$form['logout']['enable_single_logout'] = array('#type' => 'checkbox', '#title' => $this->t('Enable single log out?'), '#default_value' => $config->get('logout.enable_single_logout'), '#description' => $this->t('If enabled (and your CAS server supports it), ' . 'users will be logged out of your Drupal site when they log out of your ' . 'CAS server. NOTE: THIS WILL REMOVE A SECURITY HARDENING FEATURE ADDED ' . 'IN DRUPAL 8! Session IDs to be stored unhashed in the database.'));
$form['proxy'] = array('#type' => 'details', '#title' => $this->t('Proxy'), '#open' => FALSE, '#tree' => TRUE, '#description' => $this->t('These options relate to the proxy feature of the CAS protocol, ' . 'including configuring this client as a proxy and configuring ' . 'this client to accept proxied connections from other clients.'));
$form['proxy']['initialize'] = array('#type' => 'checkbox', '#title' => $this->t('Initialize this client as a proxy?'), '#description' => $this->t('Initializing this client as a proxy allows it to access ' . 'CAS-protected resources from other clients that have been ' . 'configured to accept it as a proxy.'), '#default_value' => $config->get('proxy.initialize'));
$form['proxy']['can_be_proxied'] = array('#type' => 'checkbox', '#title' => $this->t('Allow this client to be proxied?'), '#description' => $this->t('Allow other CAS clients to access this site\'s resources via the ' . 'CAS proxy protocol. You will need to configure a list of allowed ' . 'proxies below.'), '#default_value' => $config->get('proxy.can_be_proxied'));
$form['proxy']['proxy_chains'] = array('#type' => 'textarea', '#title' => $this->t('Allowed proxy chains'), '#description' => $this->t('A list of proxy chains to allow proxy connections from. Each line ' . 'is a chain, and each chain is a whitespace delimited list of ' . 'URLs for an allowed proxy in the chain, listed from most recent ' . '(left) to first (right). Each URL in the chain can be either a ' . 'plain URL or a URL-matching regular expression (delimited only by ' . 'slashes). Only if the proxy list returned by the CAS Server exactly ' . 'matches a chain in this list will a proxy connection be allowed.'), '#default_value' => $config->get('proxy.proxy_chains'));
|
请发表评论