phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] [18637] Get event modified since some time and tests


From: Johan Gunnarsson
Subject: [Phpgroupware-cvs] [18637] Get event modified since some time and tests for it.
Date: Fri, 04 Jul 2008 16:18:50 +0000

Revision: 18637
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18637
Author:   johang
Date:     2008-07-04 16:18:49 +0000 (Fri, 04 Jul 2008)

Log Message:
-----------
Get event modified since some time and tests for it.

Modified Paths:
--------------
    trunk/calendar/inc/class.bocalendar.inc.php
    trunk/calendar/inc/class.ipc_calendar.inc.php
    trunk/calendar/inc/class.socalendar.inc.php
    trunk/calendar/inc/class.socalendar_sql.inc.php
    trunk/calendar/inc/class.uicalendar.inc.php
    trunk/calendar/test/all_test.php
    trunk/calendar/test/class.ipc_calendar_test.inc.php

Modified: trunk/calendar/inc/class.bocalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.bocalendar.inc.php 2008-07-04 14:59:04 UTC (rev 
18636)
+++ trunk/calendar/inc/class.bocalendar.inc.php 2008-07-04 16:18:49 UTC (rev 
18637)
@@ -436,10 +436,12 @@
                 * @return array Array of all event IDs.
                 */
                function list_events($startYear, $startMonth, $startDay, 
$endYear = 0,
-                       $endMonth = 0, $endDay = 0)
+                       $endMonth = 0, $endDay = 0, $lastmod = -1)
                {
-                       return $this->so->list_events($startYear, $startMonth, 
$startDay,
-                               $endYear, $endMonth, $endDay, $this->owner);
+                       return $this->so->list_events(
+                               $startYear, $startMonth, $startDay,
+                               $endYear, $endMonth, $endDay,
+                               $this->owner, $lastmod);
                }
                
                /**

Modified: trunk/calendar/inc/class.ipc_calendar.inc.php
===================================================================
--- trunk/calendar/inc/class.ipc_calendar.inc.php       2008-07-04 14:59:04 UTC 
(rev 18636)
+++ trunk/calendar/inc/class.ipc_calendar.inc.php       2008-07-04 16:18:49 UTC 
(rev 18637)
@@ -91,17 +91,10 @@
                 */
                function getIdList($time = -1)
                {
-                       if($time != -1)
-                       {
-                               $date = getdate($time);
-
-                               return $this->bocalendar->list_events(
-                                       $date['year'],
-                                       $date['month'],
-                                       $date['day']);
-                       }
-
-                       return $this->bocalendar->list_events(0, 0, 0);
+                       return $this->bocalendar->list_events(
+                               0, 0, 0,
+                               0, 0, 0,
+                               $time);
                }
 
                /**

Modified: trunk/calendar/inc/class.socalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.socalendar.inc.php 2008-07-04 14:59:04 UTC (rev 
18636)
+++ trunk/calendar/inc/class.socalendar.inc.php 2008-07-04 16:18:49 UTC (rev 
18637)
@@ -65,12 +65,14 @@
                        return $this->cal->fetch_event($id);
                }
 
-               function 
list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0,$owner_id=0)
+               function 
list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0,$owner_id=0,$lastmod=-1)
                {
                        $user_timezone = phpgwapi_datetime::user_timezone();
 
                        $extra = (strpos($this->filter,'private')?'AND 
phpgw_cal.is_public=0 ':'');
                        $extra .= ($this->cat_id?"AND phpgw_cal.category like 
'%".$this->cat_id."%' ":'');
+                       $extra .= sprintf(" AND phpgw_cal.mdatetime > %d ", 
$lastmod);
+                       
                        if($owner_id)
                        {
                                return 
$this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,
 $user_timezone, $owner_id);

Modified: trunk/calendar/inc/class.socalendar_sql.inc.php
===================================================================
--- trunk/calendar/inc/class.socalendar_sql.inc.php     2008-07-04 14:59:04 UTC 
(rev 18636)
+++ trunk/calendar/inc/class.socalendar_sql.inc.php     2008-07-04 16:18:49 UTC 
(rev 18637)
@@ -386,7 +386,15 @@
                        return False;
                }
 
-               $datetime = mktime(0,0,0,$startMonth,$startDay,$startYear) - 
$tz_offset;
+               if($startYear != 0 && $startMonth != 0 && $startDay != 0)
+               {
+                       $datetime = mktime(0, 0, 0,
+                               (int)$startMonth, (int)$startDay, 
(int)$startYear) - $tz_offset;
+               }
+               else
+               {
+                       $datetime = 0;
+               }
                
                $user_where = ' AND (phpgw_cal_user.cal_login in (';
                
@@ -442,6 +450,7 @@
                {
                        echo "SQL : 
".$user_where.$startDate.$endDate.$extra."<br />\n";
                }
+               
                return 
$this->get_event_ids(False,$user_where.$startDate.$endDate.$extra.$order_by);
        }
 

Modified: trunk/calendar/inc/class.uicalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.uicalendar.inc.php 2008-07-04 14:59:04 UTC (rev 
18636)
+++ trunk/calendar/inc/class.uicalendar.inc.php 2008-07-04 16:18:49 UTC (rev 
18637)
@@ -1111,7 +1111,7 @@
                        $p->set_block('day_t','day_event','day_event');
 
                        $param = 
array('date'=>sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day),'friendly'=>1);
-
+                       
                        $var = array
                        (
                                'daily_events'          => $this->print_day(
@@ -3407,7 +3407,7 @@
                                        
                                        $last_slot = $slot;
                                        $last_slot_end = $slot_end;
-                                       $user_timezone = 
phpgwapi_datetime::user_timezone;
+                                       $user_timezone = 
phpgwapi_datetime::user_timezone();
                                        
print_debug('Time',$GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['start'])
 - $user_timezone).' - 
'.$GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['end']) - 
$user_timezone));
                                        print_debug('Slot',$slot);
                                }

Modified: trunk/calendar/test/all_test.php
===================================================================
--- trunk/calendar/test/all_test.php    2008-07-04 14:59:04 UTC (rev 18636)
+++ trunk/calendar/test/all_test.php    2008-07-04 16:18:49 UTC (rev 18637)
@@ -18,8 +18,8 @@
        
        $_SERVER["HTTP_HOST"] = NULL;
        
-       define("TEST_USER", "demo");
-       define("TEST_PASSWORD", "test");
+       define("TEST_USER", "johan");
+       define("TEST_PASSWORD", "pannkaka");
        
        /*
                run this file from within the calendar/ directory.

Modified: trunk/calendar/test/class.ipc_calendar_test.inc.php
===================================================================
--- trunk/calendar/test/class.ipc_calendar_test.inc.php 2008-07-04 14:59:04 UTC 
(rev 18636)
+++ trunk/calendar/test/class.ipc_calendar_test.inc.php 2008-07-04 16:18:49 UTC 
(rev 18637)
@@ -125,6 +125,23 @@
                        $this->to_be_deleted[] = $a;
                }
 
+               function test_getIdList_with_lastmod()
+               {
+                       $now = time();
+
+                       $this->assertEqual($this->ipc->getIdlist($now + 10), 
array());
+                       $this->assertEqual($this->ipc->getIdlist($now - 10), 
array());
+
+                       $a = $this->ipc->addData($this->sample_item,
+                               "application/x-phpgw-calendar");
+
+                       $id_list_plus10 = $this->ipc->getIdlist($now + 10);
+                       $id_list_minus10 = $this->ipc->getIdlist($now - 10);
+
+                       $this->assertEqual($id_list_minus10, array($a));
+                       $this->assertEqual($id_list_plus10, array());
+               }
+
                function test_removeData()
                {
                        $id = $this->ipc->addData($this->sample_item,






reply via email to

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