class Notifications_Scheduler_Latest_Posts in Notifications 7
Test this schedule class, send latest created nodes
Hierarchy
- class \Notifications_Scheduler_Event extends \Notifications_Event
Expanded class hierarchy of Notifications_Scheduler_Latest_Posts
1 string reference to 'Notifications_Scheduler_Latest_Posts'
- notifications_scheduler_notifications in notifications_scheduler/
notifications_scheduler.module - Implements hook_notifications().
File
- notifications_scheduler/
notifications_scheduler.inc, line 186 - Drupal Notifications Framework - Default class file
View source
class Notifications_Scheduler_Latest_Posts extends Notifications_Scheduler_Event {
/**
* Set action parameters, get field mapping from context
*/
protected function prepare_context() {
if ($type = $this
->get_action_context('node_type')) {
$this
->add_object('node_type', $type);
}
// Some hack, try a field with array value ??
if ($tid = $this
->get_action_context('taxonomy_term')) {
$this
->add_object('taxonomy_term', $tid);
}
}
/**
* Load nodes created and published or updated since latest time. It doesn't check node access
*/
protected function load_content() {
$query = db_select('node', 'n')
->fields('n', array(
'nid',
'created',
))
->orderBy('n.created', 'DESC')
->condition('n.status', 1)
->extend('PagerDefault')
->limit($this
->get_action_context('node_number', variable_get('default_nodes_main', 10)));
if ($type = $this
->get_action_context('node_type')) {
$query
->condition('type', $type);
}
if ($tid = $this
->get_action_context('taxonomy_term')) {
$query
->join('taxonomy_index', 't', 'n.nid = t.nid');
$query
->condition('t.tid', $tid);
}
if ($nids = $query
->execute()
->fetchCol()) {
return node_load_multiple($nids);
}
}
/**
* Check user access to event's objects.
*/
public function user_access($account, $op = 'view') {
return user_access('access content', $account);
}
/**
* Get subscription types triggered by this event
*/
function subscription_types() {
$types = parent::subscription_types();
$type = $this
->get_action_context('node_type');
$term = $this
->get_action_context('taxonomy_term');
if ($type) {
$types[] = 'content_type';
}
if ($term) {
$types[] = 'taxonomy_term';
}
if ($type && $term) {
$types[] = 'content_type_term';
}
return $types;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Notifications_Scheduler_Event:: |
protected | property | ||
Notifications_Scheduler_Event:: |
protected | property | ||
Notifications_Scheduler_Event:: |
public | property | ||
Notifications_Scheduler_Event:: |
public | property | ||
Notifications_Scheduler_Event:: |
protected | property | ||
Notifications_Scheduler_Event:: |
protected | property | ||
Notifications_Scheduler_Event:: |
function | Create message template to build this event as text | ||
Notifications_Scheduler_Event:: |
public | function | When done these events cannot be just deleted, we need to keep track of last time it was executed | |
Notifications_Scheduler_Event:: |
public | function | Get property from action context | |
Notifications_Scheduler_Event:: |
function | Prepare this event to be triggered | ||
Notifications_Scheduler_Event:: |
protected | function | Groups subscriptions. This one will just create a group for all | |
Notifications_Scheduler_Event:: |
function | Process event, send pending notifications. Subscriptions start on $counter (min sid) | ||
Notifications_Scheduler_Event:: |
protected | function | Process group, add all to a message and send out | |
Notifications_Scheduler_Event:: |
function | Build query for subscriptions that match this event type | ||
Notifications_Scheduler_Event:: |
public | function | Set action parameters | |
Notifications_Scheduler_Latest_Posts:: |
protected | function |
Load nodes created and published or updated since latest time. It doesn't check node access Overrides Notifications_Scheduler_Event:: |
1 |
Notifications_Scheduler_Latest_Posts:: |
protected | function |
Set action parameters, get field mapping from context Overrides Notifications_Scheduler_Event:: |
1 |
Notifications_Scheduler_Latest_Posts:: |
function | Get subscription types triggered by this event | ||
Notifications_Scheduler_Latest_Posts:: |
public | function |
Check user access to event's objects. Overrides Notifications_Scheduler_Event:: |
1 |