You are here

function simplenews_roles_nodeapi in Simplenews Roles 5

Same name and namespace in other branches
  1. 6.2 simplenews_roles.module \simplenews_roles_nodeapi()
  2. 6 simplenews_roles.module \simplenews_roles_nodeapi()

Implementation of hook_nodeapi().

File

./simplenews_roles.module, line 53

Code

function simplenews_roles_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($node->type == 'simplenews') {
    switch ($op) {
      case 'insert':
      case 'update':

        // Strip out non-Simplenews terms from taxonomy for posterity.
        $term = simplenews_validate_taxonomy($node->taxonomy);
        $tid = is_array($term) ? array_shift(array_values($term)) : 0;
        $role_newsletters = variable_get('simplenews_roles_tids_rids', array());
        if (isset($role_newsletters[$tid])) {
          simplenews_roles_update_subscriptions($tid, $role_newsletters[$tid]);
        }
        break;
    }
  }
}