Projet

Général

Profil

Révision 08475715

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ctools/plugins/relationships/user_category_edit_form_from_user.inc
15 15
  'description' => t('Adds user category edit form from a user context.'),
16 16
  'required context' => new ctools_context_required(t('User'), 'user'),
17 17
  'context' => 'ctools_user_category_edit_form_from_user_context',
18
  'edit form' => 'ctools_user_category_edit_form_from_user_settings_form',
19
  'defaults' => array('category' => NULL),
18 20
);
19 21

  
20 22
/**
......
25 27
    return ctools_context_create_empty('user_edit_form', NULL);
26 28
  }
27 29

  
30
  if(!empty($conf['category'])) {
31
    return ctools_context_create('user_edit_form', $context->data, array('category' => $conf['category']));
32
  }
33

  
28 34
  if (isset($context->data->user_category)) {
29 35
    return ctools_context_create('user_edit_form', $context->data, array('category' => $context->data->user_category));
30 36
  }
37

  
38
  return ctools_context_create('user_edit_form', $context->data);
39
}
40

  
41
/**
42
 * Settings form for the relationship.
43
 */
44
function ctools_user_category_edit_form_from_user_settings_form($form, &$form_state) {
45
  $conf = $form_state['conf'];
46

  
47
  $categories = _user_categories();
48
  $options = array();
49
  foreach($categories as $category) {
50
    $options[$category['name']] = $category['title'];
51
  }
52
  $form['category'] = array(
53
    '#type' => 'select',
54
    '#title' => t('Category'),
55
    '#options' => $options,
56
    '#default_value' => isset($conf['category']) ? $conf['category'] : NULL,
57
    '#empty_option' => 'Default',
58
  );
59

  
60
  return $form;
31 61
}

Formats disponibles : Unified diff