Specifying which node types (by some criteria) should be affected by the voting actions

Artem - June 16, 2007 - 18:59
Project:Voting Actions
Version:4.7.x-1.x-dev
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi

I run a voting-based web-site. Whenever storylink is voted 2 times, it is promoted to the front page and touched, so that I could order items via views module by the promotion date (that is equal to the last change date).

Now see what happens, when I change the promotion limit to 3. Some already promoted items with only 2 votes can get a third one and.. voting_action will be fired against them - they will be promoted and touched. As a result the items promoted long time ago will appear on the top of the front page.

I wonder what I could do with it. Is there any way to specify that particular voting_actions should be considered for non-promoted items only?

Best regards,
Artem.

#1

Artem - June 17, 2007 - 09:07

I managed to hack the solution by creating a "promoteandtoucheifnotpromoted" action that includes a check for the promotion flag. However it's just a hack. Is it possible to somehow specify at least some "advanced" action conditions via the web interface?

function action_node_promoteandtoucheifnotpromoted($op, $edit = array(), &$node) {
  switch($op) {
    case 'metadata':
      return array(
        'description' => t('If node not yet promoted, promote node to front page and touch node change date'),
        'type' => t('Node'),
        'batchable' => true,
        'configurable' => false,
      );

      if($node->promote != 1){
        $node->changed = time();
        $node->promote = '1';
        $node->revision = '0';
        if (!$edit['defer']) {
          node_save($node);
        }
        watchdog('votingaction', t('Promoted node id %id to front page. Touched it', array('%id' => intval($node->nid))));
      } else {
        watchdog('votingaction', t('Not promoting and touching already promoted node id %id', array('%id' => intval($node->nid))));
      }
...

 
 

Drupal is a registered trademark of Dries Buytaert.