Révision b08d2851
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/flag/plugins/access/flag_is_flagged/flag_is_flagged.inc | ||
---|---|---|
46 | 46 |
* Settings form. |
47 | 47 |
*/ |
48 | 48 |
function flag_flag_is_flagged_access_settings(&$form, &$form_state, $conf) { |
49 |
$options = array(); |
|
49 |
$flag_name_options = array();
|
|
50 | 50 |
|
51 | 51 |
$plugin = $form_state['plugin']; |
52 | 52 |
$entity_type = explode(':', $plugin['name']); |
53 | 53 |
$entity_type = $entity_type[1]; |
54 | 54 |
|
55 | 55 |
foreach (flag_get_flags($entity_type) as $flag) { |
56 |
$options[$flag->name] = check_plain($flag->title); |
|
56 |
$flag_name_options[$flag->name] = check_plain($flag->title);
|
|
57 | 57 |
} |
58 | 58 |
|
59 |
$flag_user_options = array( |
|
60 |
'any' => t('Flagged by anyone'), |
|
61 |
'user' => t('Flagged by current user'), |
|
62 |
); |
|
63 |
$flag_user_default = isset($conf['flag_user']) ? $conf['flag_user'] : 'user'; |
|
64 |
|
|
59 | 65 |
$form['settings']['flag_name'] = array( |
60 | 66 |
'#title' => t('Flag name'), |
61 | 67 |
'#type' => 'radios', |
62 |
'#options' => $options, |
|
68 |
'#options' => $flag_name_options,
|
|
63 | 69 |
'#description' => t('Include only flagged content.'), |
64 | 70 |
'#default_value' => $conf['flag_name'], |
65 | 71 |
); |
72 |
$form['settings']['flag_user'] = array( |
|
73 |
'#title' => t('Filter by flag owner'), |
|
74 |
'#type' => 'radios', |
|
75 |
'#options' => $flag_user_options, |
|
76 |
'#description' => t('Show content flagged by anyone or only by current user.'), |
|
77 |
'#default_value' => $flag_user_default, |
|
78 |
); |
|
66 | 79 |
return $form; |
67 | 80 |
} |
68 | 81 |
|
... | ... | |
78 | 91 |
// Get the ID of the entity. |
79 | 92 |
list($id) = entity_extract_ids($flag->entity_type, $context->data); |
80 | 93 |
|
81 |
return $flag->is_flagged($id); |
|
94 |
// Get either the count of users who have flagged this entity or find out |
|
95 |
// whether the current user has flagged this node, depending on settings. |
|
96 |
if (isset($conf['flag_user']) && $conf['flag_user'] == 'any') { |
|
97 |
$count = count(flag_get_entity_flags($flag->entity_type, $id, $conf['flag_name'])); |
|
98 |
return $count; |
|
99 |
} |
|
100 |
else { |
|
101 |
return $flag->is_flagged($id); |
|
102 |
} |
|
82 | 103 |
} |
83 | 104 |
|
84 | 105 |
/** |
... | ... | |
88 | 109 |
$flag = flag_get_flag($conf['flag_name']); |
89 | 110 |
|
90 | 111 |
if ($flag) { |
91 |
return t('@identifier is flagged with "@flag"', array('@flag' => check_plain($flag->title), '@identifier' => $context->identifier)); |
|
112 |
$flag_limit_by = ''; |
|
113 |
if (isset($conf['flag_user']) && $conf['flag_user'] == 'user') { |
|
114 |
return t('@identifier is flagged with "@flag" by current user.', array('@flag' => $flag->title, '@identifier' => $context->identifier)); |
|
115 |
} |
|
116 |
elseif (isset($conf['flag_user']) && $conf['flag_user'] == 'any') { |
|
117 |
return t('@identifier is flagged with "@flag" by anyone.', array('@flag' => $flag->title, '@identifier' => $context->identifier)); |
|
118 |
} |
|
92 | 119 |
} |
93 | 120 |
else { |
94 |
return t('Missing/ deleted flag "@flag"', array('@flag' => $conf['flag_name']));
|
|
121 |
return t('Missing/deleted flag "@flag"', array('@flag' => $conf['flag_name'])); |
|
95 | 122 |
} |
96 | 123 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules