phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] [18626] * Implement list events in bocalendar.


From: Johan Gunnarsson
Subject: [Phpgroupware-cvs] [18626] * Implement list events in bocalendar.
Date: Thu, 26 Jun 2008 11:34:51 +0000

Revision: 18626
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18626
Author:   johang
Date:     2008-06-26 11:34:51 +0000 (Thu, 26 Jun 2008)

Log Message:
-----------
* Implement list events in bocalendar.
* Tests for list events.

Modified Paths:
--------------
    trunk/calendar/inc/class.bocalendar.inc.php
    trunk/calendar/inc/class.socalendar_sql.inc.php
    trunk/calendar/test/class.bocalendar_test.inc.php

Modified: trunk/calendar/inc/class.bocalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.bocalendar.inc.php 2008-06-26 10:22:26 UTC (rev 
18625)
+++ trunk/calendar/inc/class.bocalendar.inc.php 2008-06-26 11:34:51 UTC (rev 
18626)
@@ -429,6 +429,18 @@
                                        break;
                        }
                }
+               
+               /**
+                * List all events.
+                *
+                * @return array Array of all event IDs.
+                */
+               function list_events($startYear, $startMonth, $startDay, 
$endYear = 0,
+                       $endMonth = 0, $endDay = 0)
+               {
+                       return $this->so->list_events($startYear, $startMonth, 
$startDay,
+                               $endYear, $endMonth, $endDay, $this->owner);
+               }
 
                function set_owner_to_group($owner)
                {

Modified: trunk/calendar/inc/class.socalendar_sql.inc.php
===================================================================
--- trunk/calendar/inc/class.socalendar_sql.inc.php     2008-06-26 10:22:26 UTC 
(rev 18625)
+++ trunk/calendar/inc/class.socalendar_sql.inc.php     2008-06-26 11:34:51 UTC 
(rev 18626)
@@ -389,14 +389,20 @@
                $datetime = mktime(0,0,0,$startMonth,$startDay,$startYear) - 
$tz_offset;
                
                $user_where = ' AND (phpgw_cal_user.cal_login in (';
-               if($owner_id)
+               
+               if(is_array($owner_id))
                {
                        $user_where .= implode(',',$owner_id);
                }
+               else if($owner_id > 0)
+               {
+                       $user_where .= $owner_id;
+               }
                else
                {
                        $user_where .= $this->user;
                }
+               
                $member_groups = 
$GLOBALS['phpgw']->accounts->membership($this->user);
                @reset($member_groups);
                while($member_groups != False && list($key,$group_info) = 
each($member_groups))

Modified: trunk/calendar/test/class.bocalendar_test.inc.php
===================================================================
--- trunk/calendar/test/class.bocalendar_test.inc.php   2008-06-26 10:22:26 UTC 
(rev 18625)
+++ trunk/calendar/test/class.bocalendar_test.inc.php   2008-06-26 11:34:51 UTC 
(rev 18626)
@@ -106,6 +106,37 @@
 
                function test_list()
                {
+                       $id_list_before = array();
+
+                       foreach($this->bocalendar->list_events(0, 0, 0) as $id)
+                       {
+                               $id_list_before[] = $id;
+                       }
+                       
+                       // remove ID. we want to insert.
+                       $item = $this->sample_item;
+                       unset($item['cal']['id']);
+
+                       $this->bocalendar->update($item, false);
+                       $a = $GLOBALS['phpgw_info']['cal_new_event_id'];
+                       
+                       $this->assertTrue($a !== FALSE);
+                       
+                       $id_list_after = array();
+
+                       foreach($this->bocalendar->list_events(0, 0, 0) as $id)
+                       {
+                               $id_list_after[] = $id;
+                       }
+                       
+                       $id_list_expected_after = array_merge($id_list_before, 
array($a));
+                       
+                       sort($id_list_expected_after);
+                       sort($id_list_after);
+
+                       $this->assertEqual($id_list_after, 
$id_list_expected_after);
+
+                       $this->to_be_deleted[] = $a;
                }
 
                function test_delete()






reply via email to

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