Projet

Général

Profil

Révision db9ffd17

Ajouté par Assos Assos il y a presque 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/date/date_repeat_field/date_repeat_field.module
115 115
}
116 116

  
117 117
/**
118
 * See if the user can access repeat date info for this field.
118
 * See if the user can access repeat date info for this entity.
119
 *
120
 * @param string $entity_type
121
 *   The entity type.
122
 * @param string $entity
123
 *   The specific entity to check (optional).
124
 *
125
 * @return bool
126
 *   Return TRUE if there is at least one date field attached to this entity,
127
 *   and the current user has the permission 'view date repeats'; FALSE otherwise.
119 128
 */
120 129
function date_repeat_field_show($entity_type = 'node', $entity = NULL) {
130
  if (!user_access('view date repeats')) {
131
    return FALSE;
132
  }
133

  
121 134
  $bundle = date_get_entity_bundle($entity_type, $entity);
122
  foreach (field_info_fields() as $field_name => $field) {
123
    if (in_array($field['type'], array('date', 'datestamp', 'datetime'))
124
        && array_key_exists($entity_type, $field['bundles'])
125
        && in_array($bundle, $field['bundles'][$entity_type])
126
        && date_is_repeat_field($field)) {
127
      return user_access('view date repeats');
135

  
136
  // In Drupal 7.22 the field_info_field_map() function was added, which is more
137
  // memory-efficient in certain cases than field_info_fields().
138
  // @see https://drupal.org/node/1915646
139
  $field_map_available = version_compare(VERSION, '7.22', '>=');
140
  $field_list = $field_map_available ? field_info_field_map() : field_info_fields();
141

  
142
  foreach ($field_list as $field_name => $data) {
143
    if (in_array($data['type'], array('date', 'datestamp', 'datetime'))
144
        && array_key_exists($entity_type, $data['bundles'])
145
        && in_array($bundle, $data['bundles'][$entity_type])) {
146
      $field_info = $field_map_available ? field_info_field($field_name) : $data;
147
      if (date_is_repeat_field($field_info)) {
148
        return TRUE;
149
      }
128 150
    }
129 151
  }
130 152
  return FALSE;

Formats disponibles : Unified diff