Révision 76e2e7c3
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/flag/flag.rules.inc | ||
---|---|---|
81 | 81 |
'#required' => empty($info['optional']), |
82 | 82 |
'#multiple' => FALSE, |
83 | 83 |
'#default_value' => $settings[$name], |
84 |
'#empty' => t('There is no suiting flag available.') |
|
84 |
'#empty' => t('There is no suiting flag available.'),
|
|
85 | 85 |
); |
86 | 86 |
return $form; |
87 | 87 |
} |
... | ... | |
375 | 375 |
'access callback' => 'flag_rules_integration_access', |
376 | 376 |
); |
377 | 377 |
} |
378 |
// For backward compatibility sake. This was the original name of the 'fetch node by user'. |
|
378 |
// For backward compatibility sake. This was the original name of the |
|
379 |
// 'fetch node by user'. |
|
379 | 380 |
$items['flag_fetch_entity_by_user'] = $items['flag_fetch_node_by_user']; |
380 |
$items['flag_fetch_entity_by_user']['label'] .= ' '. t('(Legacy)'); |
|
381 |
$items['flag_fetch_entity_by_user']['label'] .= ' ' . t('(Legacy)');
|
|
381 | 382 |
return $items; |
382 | 383 |
} |
383 | 384 |
|
... | ... | |
424 | 425 |
} |
425 | 426 |
|
426 | 427 |
/** |
427 |
* Base action implementation: Fetch entities who were flagged a user.
|
|
428 |
* Base action implementation: Fetch entities flagged by a user.
|
|
428 | 429 |
*/ |
429 | 430 |
function flag_rules_action_fetch_entity_by_user($flag, $entity) { |
430 |
$user = entity_metadata_wrapper('user', $entity); |
|
431 |
$sid = $user->flag_sid->value(); |
|
432 | 431 |
$query = db_select('flagging', 'fc') |
433 | 432 |
->fields('fc', array('entity_id')) |
434 | 433 |
->condition('entity_type', $flag->entity_type) |
435 |
->condition('uid', $user->uid->value()) |
|
436 | 434 |
->condition('fid', $flag->fid); |
437 |
// Filter out any bad session ids and any users that aren't anonymous. |
|
438 |
if (!empty($sid) && $sid != -1) { |
|
439 |
$query->condition('sid', $sid); |
|
435 |
// For global flags the user parameter is ignored, so we add the |
|
436 |
// extra 'uid' condition when the flag is NOT global. |
|
437 |
if (!$flag->global) { |
|
438 |
$user = entity_metadata_wrapper('user', $entity); |
|
439 |
$sid = $user->flag_sid->value(); |
|
440 |
$query = $query->condition('uid', $user->uid->value()); |
|
441 |
// Filter out any bad session ids and any users that aren't anonymous. |
|
442 |
if (!empty($sid) && $sid != -1) { |
|
443 |
$query->condition('sid', $sid); |
|
444 |
} |
|
440 | 445 |
} |
441 | 446 |
$result = $query->execute(); |
442 | 447 |
$flagged = $result->fetchCol(); |
... | ... | |
469 | 474 |
} |
470 | 475 |
|
471 | 476 |
/** |
472 |
* Base action implementation: Fetch count of flags for a particular entity type. |
|
477 |
* Base action implementation: Fetch count of flags for a particular entity |
|
478 |
* type. |
|
473 | 479 |
* |
474 | 480 |
* During a flagging, the current flagging will be included in the count. |
475 | 481 |
* During an unflagging, the current flagging being removed will not yet have |
... | ... | |
509 | 515 |
'type' => 'flag', |
510 | 516 |
'label' => t('Flag'), |
511 | 517 |
'flag_type' => $type, |
512 |
'description' => t('The flag to check for.') |
|
518 |
'description' => t('The flag to check for.'),
|
|
513 | 519 |
), |
514 | 520 |
$type => array( |
515 | 521 |
'type' => $type, |
... | ... | |
545 | 551 |
'type' => 'flag', |
546 | 552 |
'label' => t('Flag'), |
547 | 553 |
'flag_type' => $type, |
548 |
'description' => t('The flag to check for.') |
|
554 |
'description' => t('The flag to check for.'),
|
|
549 | 555 |
), |
550 | 556 |
$type => array( |
551 | 557 |
'type' => $type, |
... | ... | |
566 | 572 |
} |
567 | 573 |
|
568 | 574 |
/** |
569 |
* Options list callback for the operator parameter of the flagging threshold condition. |
|
575 |
* Options list callback for the operator parameter of the flagging threshold |
|
576 |
* condition. |
|
570 | 577 |
*/ |
571 | 578 |
function flag_rules_condition_threshold_operator_options() { |
572 | 579 |
return array( |
... | ... | |
588 | 595 |
$count = $flag->get_count($flag->get_entity_id($entity)); |
589 | 596 |
|
590 | 597 |
switch ($operator) { |
591 |
case '>' : return $count > $number;
|
|
598 |
case '>': return $count > $number;
|
|
592 | 599 |
case '>=': return $count >= $number; |
593 |
case '=' : return $count == $number;
|
|
594 |
case '<' : return $count < $number;
|
|
600 |
case '=': return $count == $number; |
|
601 |
case '<': return $count < $number;
|
|
595 | 602 |
case '<=': return $count <= $number; |
596 | 603 |
} |
597 | 604 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules