/[drupal]/contributions/modules/notify_by_views/notify_by_views.module
ViewVC logotype

Diff of /contributions/modules/notify_by_views/notify_by_views.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.7, Thu Oct 9 16:52:57 2008 UTC revision 1.8, Tue Apr 28 17:21:39 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /* $Id: notify_by_views.module,v 1.5 2008/10/02 21:45:40 matt2000 Exp $ */  /* $Id: notify_by_views.module,v 1.7 2008/10/09 16:52:57 matt2000 Exp $ */
3  /**  /**
4   * Display help and module information   * Display help and module information
5   * @param section which section of the site we're displaying help   * @param section which section of the site we're displaying help
# Line 285  function _notify_by_views_cron_send() { Line 285  function _notify_by_views_cron_send() {
285   */   */
286    
287  function _notify_by_views_mail_send($nodes, $frequency, $view_name, $test = FALSE) {  function _notify_by_views_mail_send($nodes, $frequency, $view_name, $test = FALSE) {
288      if (empty($view_name)) {
289        return;
290      }
291    
292    if ($frequency == 'never') {    if ($frequency == 'never') {
293      drupal_set_message(t("You're trying to send to users who have selected to 'never' receive notifications. This is not allowed."), 'error');      drupal_set_message(t("You're trying to send to users who have selected to 'never' receive notifications. This is not allowed."), 'error');
# Line 309  function _notify_by_views_mail_send($nod Line 312  function _notify_by_views_mail_send($nod
312                          AND s.frequency = '%s' ", variable_get('notify_attempts', 5), $frequency);                          AND s.frequency = '%s' ", variable_get('notify_attempts', 5), $frequency);
313    
314    while ($user = db_fetch_object($uresult)) {    while ($user = db_fetch_object($uresult)) {
315        if ($frequency == 'weekly' && $user->last_mailing + 604800 > time()) {
316          continue;
317        }
318      // Switch current user to this account to use node_access functions, etc.      // Switch current user to this account to use node_access functions, etc.
319      _notify_switch_user($user->uid);      _notify_switch_user($user->uid);
320    
# Line 328  function _notify_by_views_mail_send($nod Line 334  function _notify_by_views_mail_send($nod
334    
335      // Write new node content to e-mail if user has permissions and nodes are      // Write new node content to e-mail if user has permissions and nodes are
336      // ready to be sent.      // ready to be sent.
337      if (user_access('access content') && count($nodes)) {      if (user_access('access content') && count($included_nodes)) {
338        $node_count = 0;        $node_count = 0;
339    
340        //get a template        //get a template
# Line 336  function _notify_by_views_mail_send($nod Line 342  function _notify_by_views_mail_send($nod
342        //break up template into its parts        //break up template into its parts
343        $tpl = explode('!section',$template);        $tpl = explode('!section',$template);
344    
345        foreach ($nodes as $node) {        foreach ($included_nodes as $nid) {
346            $node = $nodes[$nid];
347          // Skip to next if this user is NOT allowed to view this node.          // Skip to next if this user is NOT allowed to view this node.
348          if (!node_access('view', $node)) {          if (!node_access('view', $node)) {
349            continue;            continue;
350          }          }
351    
         //Skip to next if this node is not in the specified views  
         if (!in_array($node->nid,$included_nodes)) {  
           continue;  
         }  
   
352          //Skip to the next node if this node was created before the last mailing to the user          //Skip to the next node if this node was created before the last mailing to the user
353          if ($node->created < $user->last_mailing){          if ($node->created < $user->last_mailing){
354            continue;            continue;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.2