You are here

function ad_operations_callback in Advertisement 6

Same name and namespace in other branches
  1. 5.2 ad.module \ad_operations_callback()
  2. 5 ad.module \ad_operations_callback()
  3. 6.3 ad.admin.inc \ad_operations_callback()
  4. 6.2 ad.admin.inc \ad_operations_callback()
  5. 7 ad.admin.inc \ad_operations_callback()

Callback function for admin mass approving ads. TODO: Update activated and expired when appropriate. TODO: Publish/unpublish nodes when appropriate.

1 string reference to 'ad_operations_callback'
ad_ad_operations in ./ad.admin.inc
Implementation of hook_ad_operations().

File

./ad.admin.inc, line 113
Advertisement admin pages and functions.

Code

function ad_operations_callback($ads, $action) {
  $placeholders = implode(',', array_fill(0, count($ads), '%d'));
  db_query("UPDATE {ads} SET adstatus = '" . $action . "' WHERE aid IN(" . $placeholders . ')', $ads);
  foreach ($ads as $aid) {
    $node = node_load($aid);
    ad_statistics_increment($aid, 'update');
    ad_statistics_increment($aid, $action);

    // Allow ad type module to act on nodeapi events.  The adapi hook provides
    // access to additional variables not available in the nodeapi hook.
    if (isset($node->adtype)) {

      // Don't use module_invoke, as in pre-PHP5 the changes to $node won't be
      // passed back.
      $function = "ad_{$node->adtype}" . '_adapi';
      if (function_exists($function)) {
        $function('update', $node);
      }
    }

    // Allow ad cache module to act on nodeapi events.
    $cache = variable_get('ad_cache', 'none');
    if ($cache != 'none') {
      $function = "ad_cache_{$cache}" . '_adcacheapi';
      if (function_exists($function)) {
        $function($action, $node);
      }
    }
  }
}