fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [11969] property: fix bug in scheduler


From: Sigurd Nes
Subject: [Fmsystem-commits] [11969] property: fix bug in scheduler
Date: Tue, 13 May 2014 13:45:22 +0000

Revision: 11969
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11969
Author:   sigurdne
Date:     2014-05-13 13:45:21 +0000 (Tue, 13 May 2014)
Log Message:
-----------
property: fix bug in scheduler

Modified Paths:
--------------
    trunk/property/inc/class.boevent.inc.php
    trunk/property/inc/class.soevent.inc.php

Modified: trunk/property/inc/class.boevent.inc.php
===================================================================
--- trunk/property/inc/class.boevent.inc.php    2014-05-13 12:35:47 UTC (rev 
11968)
+++ trunk/property/inc/class.boevent.inc.php    2014-05-13 13:45:21 UTC (rev 
11969)
@@ -305,73 +305,73 @@
                                $dow = $rpt_day[$data['repeat_day'][0]];
                                switch($data['repeat_type'])
                                {
-                               case '0':
-                                       $times = $data['start_date'];
-                                       break;
-                               case '1': //'Daily'
-                                       if($data['repeat_interval'])
-                                       {
-                                               $times = array('day' => 
"*/{$data['repeat_interval']}");
-                                       }
-                                       else
-                                       {
-                                               $times = array('day' => "*/1");
-                                       }
-                                       break;
-                               case '2': //'Weekly'
-                                       if($data['repeat_interval'])
-                                       {
-                                               $day = $data['repeat_interval'] 
* 7;
-                                               $times = array('day' => 
"*/{$day}");
-                                       }
-                                       else
-                                       {
-                                               $times = array('day' => "*/7");
-                                       }
-                                       if ($data['repeat_day'])
-                                       {
-                                               $times['dow'] = $repeat_day;
-                                       }
-                                       break;
-                               case '3': //'Monthly (by day)'
-                                       if( !isset($data['repeat_day']) || 
!is_array($data['repeat_day']) )
-                                       {
-                                               $dow = 1;
-                                       }
+                                       case '0':
+                                               $times = $data['start_date'];
+                                               break;
+                                       case '1': //'Daily'
+                                               if($data['repeat_interval'])
+                                               {
+                                                       $times = array('day' => 
"*/{$data['repeat_interval']}");
+                                               }
+                                               else
+                                               {
+                                                       $times = array('day' => 
"*/1");
+                                               }
+                                               break;
+                                       case '2': //'Weekly'
+                                               if($data['repeat_interval'])
+                                               {
+                                                       $day = 
$data['repeat_interval'] * 7;
+                                                       $times = array('day' => 
"*/{$day}");
+                                               }
+                                               else
+                                               {
+                                                       $times = array('day' => 
"*/7");
+                                               }
+                                               if ($data['repeat_day'])
+                                               {
+                                                       $times['dow'] = 
$repeat_day;
+                                               }
+                                               break;
+                                       case '3': //'Monthly (by day)'
+                                               if( !isset($data['repeat_day']) 
|| !is_array($data['repeat_day']) )
+                                               {
+                                                       $dow = 1;
+                                               }
 
-                                       if($data['repeat_interval'])
-                                       {
-                                               $times = array('month' => 
"*/{$data['repeat_interval']}", 'dow' => $dow);
-                                       }
-                                       else
-                                       {
-                                               $times = array('month' => 
"*/1", 'dow' => $dow);
-                                       }
-                                       break;
-                               case '4': //'Monthly (by date)'
-                                       if($data['repeat_interval'])
-                                       {
-                                               $times = array('month' => 
"*/{$data['repeat_interval']}", 'day' => 1);
-                                       }
-                                       else
-                                       {
-                                               $times = array('day' => 1);
-                                       }
-                                       break;
-                               case '5': //'Yearly'
-                                       $month = date(n, $data['start_date']);
-                                       if($data['repeat_interval'])
-                                       {
-                                               $times = array('year' => 
"*/{$data['repeat_interval']}", 'month' => $month);
-                                       }
-                                       else
-                                       {
-                                               $times = array('month' => 
$month);
-                                       }
-                                       break;
-                               default:
-                                       $times = $data['start_date'];
-                                       break;
+                                               if($data['repeat_interval'])
+                                               {
+                                                       $times = array('month' 
=> "*/{$data['repeat_interval']}", 'dow' => $dow);
+                                               }
+                                               else
+                                               {
+                                                       $times = array('month' 
=> "*/1", 'dow' => $dow);
+                                               }
+                                               break;
+                                       case '4': //'Monthly (by date)'
+                                               if($data['repeat_interval'])
+                                               {
+                                                       $times = array('month' 
=> "*/{$data['repeat_interval']}", 'day' => 1);
+                                               }
+                                               else
+                                               {
+                                                       $times = array('day' => 
1);
+                                               }
+                                               break;
+                                       case '5': //'Yearly'
+                                               $month = date(n, 
$data['start_date']);
+                                               if($data['repeat_interval'])
+                                               {
+                                                       $times = array('year' 
=> "*/{$data['repeat_interval']}", 'month' => $month);
+                                               }
+                                               else
+                                               {
+                                                       $times = array('month' 
=> $month);
+                                               }
+                                               break;
+                                       default:
+                                               $times = $data['start_date'];
+                                               break;
                                }
                        }
 
@@ -431,9 +431,26 @@
                {
                        $parts = explode('::',$data['id']);
                        $id = end($parts);
+                       $now = time();
 
-                       if($data['enabled'] && 
!$this->so->check_event_exception($id,$data['time']))
+                       $event = $this->so->read_single($id);
+                       $_perform_action = false;
+                       
+                       foreach($event['event_schedule'] as $_schedule)
                        {
+                               if (in_array($_schedule, 
$event['event_receipt']) || in_array($_schedule, $event['repeat_exception']))
+                               {
+                                       continue;
+                               }
+                               if($_schedule < $now && $data['enabled'])
+                               {
+                                       $_perform_action = true;
+                                       break;
+                               }
+                       }
+                       
+                       if($_perform_action)
+                       {
                                list($module, $classname) = explode('.', 
$data['action'], 3);
                                $file = PHPGW_INCLUDE_ROOT . 
"/{$module}/inc/class.{$classname}.inc.php";
                                if ( is_file($file) )

Modified: trunk/property/inc/class.soevent.inc.php
===================================================================
--- trunk/property/inc/class.soevent.inc.php    2014-05-13 12:35:47 UTC (rev 
11968)
+++ trunk/property/inc/class.soevent.inc.php    2014-05-13 13:45:21 UTC (rev 
11969)
@@ -338,11 +338,32 @@
                                $values['end']['min']   = $end_date ? 
date('i',$end_date) : 0;
                                $values['end']['sec']   = $end_date ? 
date('s',$end_date) : 0;
 
-                               $sql = "SELECT * FROM fm_event_exception WHERE 
event_id ='{$id}'";
 
+                               $values['event_schedule'] = array();
+                               $values['event_receipt'] = array();
+                               $values['repeat_exception'] = array();
+
+                               $sql = "SELECT * FROM fm_event_schedule WHERE 
event_id ='{$id}' ORDER BY schedule_time";
+
                                $this->_db->query($sql,__LINE__,__FILE__);
                                while ($this->_db->next_record())
                                {
+                                       $values['event_schedule'][] = 
$this->_db->f('schedule_time');
+                               }
+
+                               $sql = "SELECT * FROM fm_event_receipt WHERE 
event_id ='{$id}' ORDER BY receipt_time";
+
+                               $this->_db->query($sql,__LINE__,__FILE__);
+                               while ($this->_db->next_record())
+                               {
+                                       $values['event_receipt'][] = 
$this->_db->f('receipt_time');
+                               }
+
+                               $sql = "SELECT * FROM fm_event_exception WHERE 
event_id ='{$id}' ORDER BY exception_time";
+
+                               $this->_db->query($sql,__LINE__,__FILE__);
+                               while ($this->_db->next_record())
+                               {
                                        $values['repeat_exception'][] = 
$this->_db->f('exception_time');
                                }
                        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]