Index: modules/data.eval.inc =================================================================== --- modules/data.eval.inc (revision 2890) +++ modules/data.eval.inc (working copy) @@ -277,6 +277,20 @@ } /** +* Condition: List has count. +*/ +function rules_condition_list_has_count($list, $value, $op = '==') { + switch ($op) { + case '==': + return count($list) == $value; + case '<'; + return count($list) < $value; + case '>'; + return count($list) > $value; + } +} + +/** * Condition: Data value is empty. */ function rules_condition_data_is_empty($data) { Index: modules/data.rules.inc =================================================================== --- modules/data.rules.inc (revision 2890) +++ modules/data.rules.inc (working copy) @@ -475,6 +475,32 @@ 'form_alter' => 'rules_data_list_form_alter', ), ), + 'list_has_count' => array( + 'label' => t('List has count'), + 'parameter' => array( + 'list' => array( + 'type' => 'list', + 'label' => t('List to check'), + 'description' => t('A multi value data element to have its count compared, specified by using a data selector, e.g. "node:author:name".'), + ), + 'value' => array( + 'type' => 'integer', + 'label' => t('Count'), + 'description' => t('The count to compare the data count with.'), + ), + 'op' => array( + 'type' => 'text', + 'label' => t('Operator'), + 'description' => t('The comparison operator.'), + 'optional' => TRUE, + 'default value' => '==', + 'options list' => 'rules_condition_list_has_count_operator_options', + 'restriction' => 'input', + ), + ), + 'group' => t('Data'), + 'base' => 'rules_condition_list_has_count', + ), 'text_matches' => array( 'label' => t('Text comparison'), 'parameter' => array( @@ -612,5 +638,16 @@ } /** + * Options list callback for condition list_has_count. + */ +function rules_condition_list_has_count_operator_options() { + return array( + '==' => t('equals'), + '<' => t('is lower than'), + '>' => t('is greater than'), + ); +} + +/** * @} */