예제 #1
0
파일: Roles.php 프로젝트: isramv/camp-gdl
 /**
  * Override empty and not empty operator labels to be clearer for user roles.
  */
 function operators()
 {
     $operators = parent::operators();
     $operators['empty']['title'] = $this->t("Only has the 'authenticated user' role");
     $operators['not empty']['title'] = $this->t("Has roles in addition to 'authenticated user'");
     return $operators;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $field_storage = $this->getFieldStorageDefinition();
     // Set valueOptions here so getValueOptions() will just return it.
     $this->valueOptions = options_allowed_values($field_storage);
 }
 /**
  * {@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();
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $this->definition['field_name'] = $this->definition['entity field'];
     $field_storage = $this->getFieldStorageDefinition();
     // We may have not a valid workflow field.
     if (FALSE && $field_storage) {
         // Set valueOptions here so getValueOptions() will just return it.
         $this->valueOptions = options_allowed_values($field_storage);
         // $this->valueOptions = workflow_state_allowed_values($field_storage);
     } else {
         // TODO D8. This is a hack. It doesn't work.
         // The default options_allowed_values only reads field_name. Repair that.
         $field_name = $this->definition['entity field'];
         $field_storage = new FieldStorageConfig(['field_name' => $field_name, 'type' => 'testtype', 'entity_type' => $options['entity_type']]);
         $field_storage->set('allowed_values_function', 'workflow_state_allowed_values');
         $wid = '';
         // Set valueOptions here so getValueOptions() will just return it.
         // $this->valueOptions = options_allowed_values($field_storage);
         // $this->valueOptions = workflow_state_allowed_values($field_storage);
         $this->valueOptions = workflow_get_workflow_state_names($wid, $options['group_info']['widget'] == 'select');
     }
 }
예제 #5
0
 /**
  * {@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();
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function calculateDependencies()
 {
     $dependencies = parent::calculateDependencies();
     $vocabulary = $this->vocabularyStorage->load($this->options['vid']);
     $dependencies[$vocabulary->getConfigDependencyKey()][] = $vocabulary->getConfigDependencyName();
     foreach ($this->options['value'] as $tid) {
         $term = $this->termStorage->load($tid);
         $dependencies[$term->getConfigDependencyKey()][] = $term->getConfigDependencyName();
     }
     return $dependencies;
 }
예제 #7
0
 public function adminSummary()
 {
     // set up $this->value_options for the parent summary
     $this->value_options = array();
     if ($this->value) {
         $this->value = array_filter($this->value);
         $result = db_select('taxonomy_term_data', 'td')->fields('td')->condition('td.tid', $this->value)->execute();
         foreach ($result as $term_record) {
             $this->value_options[$term_record->tid] = $term_record->name;
         }
     }
     return parent::adminSummary();
 }
 /**
  * {@inheritdoc}
  */
 public function getCacheContexts()
 {
     $contexts = parent::getCacheContexts();
     // The result potentially depends on term access and so is just cacheable
     // per user.
     // @todo https://www.drupal.org/node/2352175
     $contexts[] = 'cache.context.user';
     return $contexts;
 }
예제 #9
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     unset($form['reduce_duplicates']);
 }
예제 #10
0
 public function adminSummary()
 {
     // set up $this->value_options for the parent summary
     $this->value_options = array();
     if ($this->value) {
         $this->value = array_filter($this->value);
         $terms = Term::loadMultiple($this->value);
         foreach ($terms as $term) {
             $this->value_options[$term->id()] = String::checkPlain(\Drupal::entityManager()->getTranslationFromContext($term)->label());
         }
     }
     return parent::adminSummary();
 }