You are here

function auto_expire_nodeapi in Auto Expire 5

File

./auto_expire.module, line 347

Code

function auto_expire_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  $code = AUTO_EXPIRE_NODE_TYPE . $node->type;
  if (variable_get($code . '_e', 0)) {
    switch ($op) {
      case 'insert':
        $days = variable_get($code . '_d', 0);
        db_query('INSERT INTO {auto_expire} (nid, expire) VALUES (%d, %d)', $node->nid, $node->created + $days * 24 * 60 * 60);
        drupal_set_message(t('This %type will autoexpire in %days days.', array(
          '%type' => node_get_types('name', $node),
          '%days' => $days,
        )));
        break;
      case 'delete':
        db_query('DELETE FROM {auto_expire} WHERE nid = %d', $node->nid);
        break;
    }
  }
}