Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/modules/user/views_plugin_argument_validate_user.inc
13 13
 * argument's title to the username.
14 14
 */
15 15
class views_plugin_argument_validate_user extends views_plugin_argument_validate {
16
  function option_definition() {
16

  
17
  /**
18
   * {@inheritdoc}
19
   */
20
  public function option_definition() {
17 21
    $options = parent::option_definition();
18 22
    $options['type'] = array('default' => 'uid');
19 23
    $options['restrict_roles'] = array('default' => FALSE, 'bool' => TRUE);
......
22 26
    return $options;
23 27
  }
24 28

  
25
  function options_form(&$form, &$form_state) {
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function options_form(&$form, &$form_state) {
26 33
    $form['type'] = array(
27 34
      '#type' => 'radios',
28 35
      '#title' => t('Type of user filter value to allow'),
......
54 61
    );
55 62
  }
56 63

  
57
  function options_submit(&$form, &$form_state, &$options = array()) {
58
    // filter trash out of the options so we don't store giant unnecessary arrays
64
  /**
65
   * {@inheritdoc}
66
   */
67
  public function options_submit(&$form, &$form_state, &$options = array()) {
68
    // Filter trash out of the options so we don't store giant unnecessary
69
    // arrays.
59 70
    $options['roles'] = array_filter($options['roles']);
60 71
  }
61 72

  
62
  function convert_options(&$options) {
73
  /**
74
   * {@inheritdoc}
75
   */
76
  public function convert_options(&$options) {
63 77
    if (!isset($options['type']) && isset($this->argument->options['validate_user_argument_type'])) {
64 78
      $options['type'] = $this->argument->options['validate_user_argument_type'];
65 79
      $options['restrict_roles'] = $this->argument->options['validate_user_restrict_roles'];
......
67 81
    }
68 82
  }
69 83

  
70
  function validate_argument($argument) {
84
  /**
85
   * {@inheritdoc}
86
   */
87
  public function validate_argument($argument) {
71 88
    $type = $this->options['type'];
72 89
    // is_numeric() can return false positives, so we ensure it's an integer.
73 90
    // However, is_integer() will always fail, since $argument is a string.
74
    if (is_numeric($argument) && $argument == (int)$argument) {
91
    if (is_numeric($argument) && $argument == (int) $argument) {
75 92
      if ($type == 'uid' || $type == 'either') {
76 93
        if ($argument == $GLOBALS['user']->uid) {
77 94
          // If you assign an object to a variable in PHP, the variable
......
126 143
    return TRUE;
127 144
  }
128 145

  
129
  function process_summary_arguments(&$args) {
146
  /**
147
   * {@inheritdoc}
148
   */
149
  public function process_summary_arguments(&$args) {
130 150
    // If the validation says the input is an username, we should reverse the
131 151
    // argument so it works for example for generation summary urls.
132 152
    $uids_arg_keys = array_flip($args);
......
137 157
      }
138 158
    }
139 159
  }
160

  
140 161
}

Formats disponibles : Unified diff