/[drupal]/contributions/modules/voting_actions/voting_actions.inc
ViewVC logotype

Diff of /contributions/modules/voting_actions/voting_actions.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.7.2.2, Wed Apr 18 15:04:41 2007 UTC revision 1.7.2.3, Thu Apr 19 21:20:43 2007 UTC
# Line 5  function voting_actions_voting_actions_c Line 5  function voting_actions_voting_actions_c
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',
# Line 19  function voting_actions_voting_actions_c Line 19  function voting_actions_voting_actions_c
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',
# Line 45  function voting_actions_voting_actions_c Line 45  function voting_actions_voting_actions_c
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'),
# Line 129  function voting_actions_vote_form($value Line 130  function voting_actions_vote_form($value
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    
# Line 194  function voting_actions_vote_result_form Line 195  function voting_actions_vote_result_form
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    
# Line 233  function voting_actions_content_property Line 234  function voting_actions_content_property
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)) {
# Line 242  function voting_actions_content_author_p Line 276  function voting_actions_content_author_p
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])) {

Legend:
Removed from v.1.7.2.2  
changed lines
  Added in v.1.7.2.3

  ViewVC Help
Powered by ViewVC 1.1.2