| 5 |
$condition = array(); |
$condition = array(); |
| 6 |
|
|
| 7 |
$condition['individual_vote'] = array( |
$condition['individual_vote'] = array( |
| 8 |
'name' => t('Individual vote'), |
'name' => t('Any individual vote'), |
| 9 |
'description' => t('Return true if any item in the collection of cast votes matches these criteria.'), |
'description' => t('Return true if any item in the collection of cast votes matches these criteria.'), |
| 10 |
'eval_handler' => 'voting_actions_individual_vote_handler', |
'eval_handler' => 'voting_actions_individual_vote_handler', |
| 11 |
'edit_handler' => 'voting_actions_vote_form', |
'edit_handler' => 'voting_actions_vote_form', |
| 19 |
); |
); |
| 20 |
|
|
| 21 |
$condition['vote_result'] = array( |
$condition['vote_result'] = array( |
| 22 |
'name' => t('Vote result'), |
'name' => t('Any vote result'), |
| 23 |
'description' => t('Return true if a vote result matches these criteria.'), |
'description' => t('Return true if a vote result matches these criteria.'), |
| 24 |
'eval_handler' => 'voting_actions_vote_result_handler', |
'eval_handler' => 'voting_actions_vote_result_handler', |
| 25 |
'edit_handler' => 'voting_actions_vote_result_form', |
'edit_handler' => 'voting_actions_vote_result_form', |
| 45 |
function _voting_actions_string_operators() { |
function _voting_actions_string_operators() { |
| 46 |
return array( |
return array( |
| 47 |
'==' => t('Is'), |
'==' => t('Is'), |
| 48 |
|
'!=' => t('Is not'), |
| 49 |
'contains' => t('Contains'), |
'contains' => t('Contains'), |
| 50 |
'excludes' => t('Does not contain'), |
'excludes' => t('Does not contain'), |
| 51 |
'starts' => t('Stars with'), |
'starts' => t('Stars with'), |
| 130 |
|
|
| 131 |
$form['value_type'] = array( |
$form['value_type'] = array( |
| 132 |
'#type' => 'select', |
'#type' => 'select', |
| 133 |
'#options' => _voting_actions_table_values('value_type', 'vote', array('' => t('(Ignore)'), 'percent' => t('Percent'), 'points' => t('Points'))), |
'#options' => _voting_actions_table_values('value_type', 'vote', array('' => t('--'), 'percent' => t('Percent'), 'points' => t('Points'))), |
| 134 |
'#default_value' => $values['value_type'], |
'#default_value' => $values['value_type'], |
| 135 |
); |
); |
| 136 |
|
|
| 137 |
$form['tag'] = array( |
$form['tag'] = array( |
| 138 |
'#type' => 'select', |
'#type' => 'select', |
| 139 |
'#options' => _voting_actions_table_values('tag', 'vote', array('' => t('(Ignore)'), 'percent' => t('Vote'))), |
'#options' => _voting_actions_table_values('tag', 'vote', array('' => t('--'), 'vote' => t('Vote'))), |
| 140 |
'#default_value' => $values['tag'], |
'#default_value' => $values['tag'], |
| 141 |
); |
); |
| 142 |
|
|
| 195 |
|
|
| 196 |
$form['value_type'] = array( |
$form['value_type'] = array( |
| 197 |
'#type' => 'select', |
'#type' => 'select', |
| 198 |
'#options' => _voting_actions_table_values('value_type', 'cache', array('' => t('(Ignore)'), 'percent' => t('Percent'), 'points' => t('Points'))), |
'#options' => _voting_actions_table_values('value_type', 'cache', array('' => t('--'), 'percent' => t('Percent'), 'points' => t('Points'))), |
| 199 |
'#default_value' => $values['value_type'], |
'#default_value' => $values['value_type'], |
| 200 |
); |
); |
| 201 |
|
|
| 202 |
$form['tag'] = array( |
$form['tag'] = array( |
| 203 |
'#type' => 'select', |
'#type' => 'select', |
| 204 |
'#options' => _voting_actions_table_values('tag', 'cache', array('' => t('(Ignore)'), 'percent' => t('Vote'))), |
'#options' => _voting_actions_table_values('tag', 'cache', array('' => t('--'), 'vote' => t('Vote'))), |
| 205 |
'#default_value' => $values['tag'], |
'#default_value' => $values['tag'], |
| 206 |
); |
); |
| 207 |
|
|
| 208 |
$form['function'] = array( |
$form['function'] = array( |
| 209 |
'#type' => 'select', |
'#type' => 'select', |
| 210 |
'#options' => _voting_actions_table_values('function', 'cache', array('' => t('(Ignore)'), 'average' => t('Average'), 'count' => t('Count'))), |
'#options' => _voting_actions_table_values('function', 'cache', array('' => t('--'), 'average' => t('Average'), 'count' => t('Count'))), |
| 211 |
'#default_value' => $values['function'], |
'#default_value' => $values['function'], |
| 212 |
); |
); |
| 213 |
|
|
| 234 |
return FALSE; |
return FALSE; |
| 235 |
} |
} |
| 236 |
|
|
| 237 |
|
function voting_actions_content_property_form($values = array()) { |
| 238 |
|
if ($values === NULL) { |
| 239 |
|
$values = array(); |
| 240 |
|
} |
| 241 |
|
$values += array( |
| 242 |
|
'property' => '', |
| 243 |
|
'operator' => '', |
| 244 |
|
'value' => '', |
| 245 |
|
); |
| 246 |
|
|
| 247 |
|
$form['property'] = array( |
| 248 |
|
'#prefix' => '$node->', |
| 249 |
|
'#type' => 'textfield', |
| 250 |
|
'#default_value' => $values['property'], |
| 251 |
|
'#size' => 10, |
| 252 |
|
); |
| 253 |
|
|
| 254 |
|
$options = array_merge(_voting_actions_string_operators(), _voting_actions_number_operators()); |
| 255 |
|
|
| 256 |
|
$form['operator'] = array( |
| 257 |
|
'#type' => 'select', |
| 258 |
|
'#options' => $options, |
| 259 |
|
'#default_value' => $values['operator'], |
| 260 |
|
); |
| 261 |
|
|
| 262 |
|
$form['value'] = array( |
| 263 |
|
'#type' => 'textfield', |
| 264 |
|
'#default_value' => $values['value'], |
| 265 |
|
'#size' => 5, |
| 266 |
|
); |
| 267 |
|
return $form; |
| 268 |
|
} |
| 269 |
|
|
| 270 |
// Returns true if the author's content has the specified permission. |
// Returns true if the author's content has the specified permission. |
| 271 |
function voting_actions_content_author_perm_handler($context, $condition) { |
function voting_actions_content_author_perm_handler($context, $condition) { |
| 272 |
if (!empty($context['content']->uid)) { |
if (!empty($context['content']->uid)) { |
| 276 |
return FALSE; |
return FALSE; |
| 277 |
} |
} |
| 278 |
|
|
| 279 |
|
function voting_actions_content_author_perm_form($values = array()) { |
| 280 |
|
$perms = module_invoke_all('perm'); |
| 281 |
|
$form['perm'] = array( |
| 282 |
|
'#type' => 'select', |
| 283 |
|
'#options' => $perms, |
| 284 |
|
'#default_value' => $values['perm'], |
| 285 |
|
); |
| 286 |
|
return $form; |
| 287 |
|
} |
| 288 |
|
|
| 289 |
function _voting_actions_table_values($field = 'tag', $table = 'vote', $force = array()) { |
function _voting_actions_table_values($field = 'tag', $table = 'vote', $force = array()) { |
| 290 |
static $cached; |
static $cached; |
| 291 |
if (!isset($cached[$table][$field])) { |
if (!isset($cached[$table][$field])) { |