Révision 76e2e7c3
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/flag/includes/flag/flag_entity.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Contains the flag_entity class.
|
|
5 |
* Contains the flag_entity class. |
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
... | ... | |
58 | 58 |
} |
59 | 59 |
// Select the first display option by default if this is a new flag. |
60 | 60 |
if (empty($this->fid)) { |
61 |
$first_view_mode = reset(array_keys($entity_view_modes)); |
|
61 |
$first_view_mode_keys = array_keys($entity_view_modes); |
|
62 |
$first_view_mode = reset($first_view_mode_keys); |
|
62 | 63 |
$defaults[$first_view_mode] = $first_view_mode; |
63 | 64 |
} |
64 | 65 |
|
... | ... | |
159 | 160 |
); |
160 | 161 |
} |
161 | 162 |
|
163 |
/** |
|
164 |
* Invoke a Rules event in reaction to a flagging or unflagging. |
|
165 |
* |
|
166 |
* @param $action |
|
167 |
* Either 'flag' or 'unflag'. |
|
168 |
* @param $flagging |
|
169 |
* The flagging entity that is to be removed. |
|
170 |
* @param $entity_id |
|
171 |
* The entity ID of entity being unflagged. |
|
172 |
* @param $account |
|
173 |
* The account performing the unflagging. |
|
174 |
*/ |
|
175 |
protected function invoke_rules_event($action, $flagging, $entity_id, $account) { |
|
176 |
switch ($action) { |
|
177 |
case 'flag': |
|
178 |
$event_name = 'flag_flagged_' . $this->name; |
|
179 |
break; |
|
180 |
case 'unflag': |
|
181 |
$event_name = 'flag_unflagged_' . $this->name; |
|
182 |
break; |
|
183 |
} |
|
184 |
|
|
185 |
$variables = array( |
|
186 |
'flag' => $this, |
|
187 |
'flagged_' . $this->entity_type => $entity_id, |
|
188 |
'flagging_user' => $account, |
|
189 |
'flagging' => $flagging, |
|
190 |
); |
|
191 |
rules_invoke_event_by_args($event_name, $variables); |
|
192 |
} |
|
193 |
|
|
162 | 194 |
/** |
163 | 195 |
* Returns the entity id, if it already exists. |
164 | 196 |
*/ |
Formats disponibles : Unified diff
Weekly update of contrib modules