function subscriptions_content_subscriptions in Subscriptions 7
Same name and namespace in other branches
- 5.2 subscriptions_content.module \subscriptions_content_subscriptions()
- 6 subscriptions_content.module \subscriptions_content_subscriptions()
- 2.0.x subscriptions_content/subscriptions_content.module \subscriptions_content_subscriptions()
Implements hook_subscriptions().
Parameters
string $op:
mixed|null $arg0:
mixed|null $arg1:
mixed|null $arg2:
Return value
array|string|null
File
- ./
subscriptions_content.module, line 26 - Subscriptions to content events
Code
function subscriptions_content_subscriptions($op, $arg0 = NULL, $arg1 = NULL, $arg2 = NULL) {
static $stypes = array(
'node' => array(
'node',
'nid',
),
'type' => array(
'node',
'type',
),
);
$function = '_subscriptions_content_' . $op;
if (function_exists($function)) {
return $function($arg0, $arg1, $arg2);
}
switch ($op) {
case 'queue':
// $arg0 is $event array.
if ($arg0['module'] == 'node') {
$node = $arg0['node'];
$params['node']['nid']['value'] = $node->nid;
$params['node']['type']['value'] = $node->type;
if ($arg0['type'] == 'comment') {
$where[] = array(
's.send_comments',
1,
'=',
);
}
elseif ($arg0['type'] == 'node' && $arg0['action'] == 'update') {
$where[] = array(
's.send_updates',
1,
'=',
);
}
if (isset($where)) {
$params['node']['nid']['where'] = $where;
$params['node']['type']['where'] = $where;
}
return $params;
}
break;
case 'fields':
// Parameter is module
if ($arg0 == 'node' || $arg0 == 'comment') {
return array(
'nid' => array(
'data_function' => 'subscriptions_content_data',
'subs_mod' => 'subscriptions_content',
'subs_type' => t('thread'),
'mailkey' => 'node-type-',
),
'type' => array(
'data_function' => 'subscriptions_content_data',
'subs_mod' => 'subscriptions_content',
'subs_type' => t('content type'),
'mailkey' => 'node-type-',
),
);
}
break;
case 'stypes':
return $stypes;
case 'stype':
return isset($stypes[$arg0]) ? array_merge($stypes[$arg0], array(
$arg1,
$arg2,
)) : NULL;
case 'mailkeys':
$mailkeys = array();
foreach (node_type_get_types() as $key => $type) {
$mailkeys['node-type-' . $key] = t('Notifications for %type !content_type subscriptions', array(
'%type' => $type->name,
'!content_type' => t('content type'),
));
}
return $mailkeys;
case 'mailkey_alter':
if ($arg0 == 'node-type-') {
return $arg0 . $arg1->type;
}
break;
case 'token_types':
if (strpos($arg0, 'node-type-') === 0) {
return array(
'node',
'comment',
);
}
break;
}
return NULL;
}