Pester
Categories
Component ID
1859728
Component name
Pester
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
A little Features-based module that kludges the Date project's Date Repeat field to schedule email notifications on a per-user basis. Developers can implement one or more of this module's hooks to specify what is sent. See the included pester_watchdog.module for an example.
Basic usage:
We assume all views take a user ID as their first argument, or accept no arguments. Arrays returned from hook implementations are keyed by user permission; If a user hasn't been granted that permission they won't be sent the output of the corresponding view.
/**
* Implements hook_pester_views().
*/
function mymodule_pester_views() {
return array(
'access content' => array(
array(
'view' => 'myview',
'display' => 'block', // Defaults to 'default', rather sensibly.
'weight' => 0, // To order output of multiple views.
),
),
);
}
This module is intended to be as lightweight as possible (i.e. I'm lazy). If you want to do anything fancy with the output, you'll have to implement one or more Views hooks, eg.:
/**
* Implements hook_views_pre_build().
*/
function mymodule_views_pre_build(&$view) {
if ($view->name == 'myview' && $view->current_display == 'block' && ($user = user_load($view->args[0]))) {
// Limit min and max post date.
list($created_min, $created_max) = pester_user_between($user);
$view->filter['created']->value['min'] = $created_min->format(DATE_FORMAT_DATETIME, TRUE);
$view->filter['created']->value['max'] = $created_max->format(DATE_FORMAT_DATETIME, TRUE);
}
}