phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: calendar/inc class.boalarm.inc.php, 1.3.2.1, 1.


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: calendar/inc class.boalarm.inc.php, 1.3.2.1, 1.3.2.1.2.1 class.bocalendar.inc.php, 1.71.2.33.2.11, 1.71.2.33.2.12 class.html.inc.php, 1.1.2.1, 1.1.2.1.2.1 class.socalendar.inc.php, 1.22.2.5.2.1, 1.22.2.5.2.2 class.socalendar__.inc.php, 1.11.2.1.2.1, 1.11.2.1.2.2 class.socalendar_sql.inc.php, 1.28.2.4.2.2, 1.28.2.4.2.3 class.uialarm.inc.php, 1.4.2.1.2.1, 1.4.2.1.2.2 class.uicalendar.inc.php, 1.66.2.55.2.14, 1.66.2.55.2.15 hook_settings.inc.php, 1.1.2.7, 1.1.2.8
Date: Tue, 22 Jul 2003 21:42:05 -0400

Update of /cvsroot/phpgroupware/calendar/inc
In directory subversions:/tmp/cvs-serv18625/inc

Modified Files:
      Tag: Version-0_9_16-branch
        class.boalarm.inc.php class.bocalendar.inc.php 
        class.html.inc.php class.socalendar.inc.php 
        class.socalendar__.inc.php class.socalendar_sql.inc.php 
        class.uialarm.inc.php class.uicalendar.inc.php 
        hook_settings.inc.php 
Log Message:
first implemenation of the alarms, repetetive events do not work so far


Index: class.boalarm.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.boalarm.inc.php,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.1.2.1
diff -C2 -r1.3.2.1 -r1.3.2.1.2.1
*** class.boalarm.inc.php       31 Oct 2002 01:57:55 -0000      1.3.2.1
--- class.boalarm.inc.php       23 Jul 2003 01:42:02 -0000      1.3.2.1.2.1
***************
*** 15,18 ****
--- 15,22 ----
        /* $Id$ */
  
+       define('PHPGW_ACL_DELETEALARM',PHPGW_ACL_DELETE);       // for now
+       define('PHPGW_ACL_SETALARM',PHPGW_ACL_WRITE);
+       define('PHPGW_ACL_READALARM',PHPGW_ACL_READ);
+ 
        class boalarm
        {
***************
*** 27,52 ****
  
                var $public_functions = array(
                );
  
                function boalarm()
                {
!                       $cal_id = 
(isset($GLOBALS['HTTP_POST_VARS']['cal_id'])?intval($GLOBALS['HTTP_POST_VARS']['cal_id']):'');
                        if($cal_id)
                        {
                                $this->cal_id = $cal_id;
                        }
!                       $this->cal = CreateObject('calendar.bocalendar',1);
!                       $this->tz_offset = $this->cal->datetime->tz_offset;
  
                        if($this->debug)
                        {
!                               echo "BO Owner : ".$this->cal->owner."<br>\n";
                        }
  
!                       if($this->cal->use_session)
                        {
                                $this->save_sessiondata();
                        }
- 
                }
  
--- 31,58 ----
  
                var $public_functions = array(
+                       'add'       => True,
+                       'delete'    => True
                );
  
                function boalarm()
                {
!                       $cal_id = 
(isset($_POST['cal_id'])?intval($_POST['cal_id']):'');
                        if($cal_id)
                        {
                                $this->cal_id = $cal_id;
                        }
!                       $this->bo = CreateObject('calendar.bocalendar',1);
!                       $this->so = CreateObject('calendar.socalendar',1);
!                       $this->tz_offset = $this->bo->datetime->tz_offset;
  
                        if($this->debug)
                        {
!                               echo "BO Owner : ".$this->bo->owner."<br>\n";
                        }
  
!                       if($this->bo->use_session)
                        {
                                $this->save_sessiondata();
                        }
                }
  
***************
*** 54,71 ****
                {
                        $data = array(
!                               'filter' => $this->cal->filter,
!                               'cat_id' => $this->cal->cat_id,
!                               'owner' => $this->cal->owner,
!                               'year'  => $this->cal->year,
!                               'month' => $this->cal->month,
!                               'day'           => $this->cal->day
                        );
!                       $this->cal->save_sessiondata($data);
                }
  
                function read_entry($cal_id)
                {
!                       return $this->cal->read_entry($cal_id);
                }
-               /* Public functions */
        }
--- 60,209 ----
                {
                        $data = array(
!                               'filter' => $this->bo->filter,
!                               'cat_id' => $this->bo->cat_id,
!                               'owner'  => $this->bo->owner,
!                               'year'   => $this->bo->year,
!                               'month'  => $this->bo->month,
!                               'day'    => $this->bo->day
                        );
!                       $this->bo->save_sessiondata($data);
                }
  
                function read_entry($cal_id)
                {
!                       return $this->bo->read_entry(intval($cal_id));
!               }
! 
!               /*!
!               @function add
!               @abstract adds a new alarm to an event
!               @syntax add(&$event,$time,$login_id)
!               @param &$event event to add the alarm too
!               @param $time for the alarm in sec before the starttime of the 
event
!               @param $login_id user to alarm
!               @returns the alarm or False
!               */
!               function add(&$event,$time,$owner)
!               {
!                       if (!$this->check_perms(PHPGW_ACL_SETALARM,$owner) || 
!($cal_id = $event['id']))
!                       {
!                               return False;
!                       }
!                       $alarm = Array(
!                               'time'    => 
($etime=$this->bo->maketime($event['start'])) - $time,
!                               'offset'  => $time,
!                               'owner'   => $owner,
!                               'enabled' => 1
!                       );
!                       $alarm['id'] = $this->so->save_alarm($cal_id,$alarm);
! 
!                       $event['alarm'][$alarm['id']] = $alarm;
! 
!                       return $alarm;
!               }
! 
!               /*!
!               @function check_perms
!               @abstract checks if user has a certain grant from the owner of 
an alarm or event
!               @syntax check_perms($grant,$owner)
!               @param $grant PHPGW_ACL_{SET|READ|DELETE}ALARM (defined at the 
top of this file)
!               */
!               function check_perms($grant,$owner)
!               {
!                       return $this->bo->check_perms($grant,0,$owner);
!               }
! 
!               /*!
!               @function participants
!               @abstract get the participants of an event, the user has grants 
to alarm
!               @syntax participants($event,$fullnames=True)
!               @param $event or cal_id of an event
!               @param $fullnames if true return array with fullnames as values
!               @returns array with account_ids as keys
!               */
!               function participants($event,$fullnames=True)
!               {
!                       if (!is_array($event))
!                       {
!                               $event = $this->read_entry($event);
!                       }
!                       if (!$event)
!                       {
!                               return False;
!                       }
!                       $participants = array();
!                       foreach ($event['participants'] as $uid => $status)
!                       {
!                               if ($this->check_perms(PHPGW_ACL_SETALARM,$uid))
!                               {
!                                       $participants[$uid] = $fullnames ? 
$GLOBALS['phpgw']->common->grab_owner_name($uid) : True;
!                               }
!                       }
!                       return $participants;
!               }
! 
!               /*!
!               @function enable
!               @abstract enable or disable one or more alarms identified by 
its ids
!               @syntax enable($ids,$enable=True)
!               @param $ids array with alarm ids as keys (!)
!               @returns the number of alarms enabled or -1 for insuficent 
permission to do so
!               @note Not found alarms or insuficent perms stop the enableing 
of multiple alarms
!               */
!               function enable($alarms,$enable=True)
!               {
!                       $enabled = 0;
!                       foreach ($alarms as $id => $field)
!                       {
!                               if (!($alarm = $this->so->read_alarm($id)))
!                               {
!                                       return 0;       // alarm not found
!                               }
!                               if (!$alarm['enabled'] == !$enable)
!                               {
!                                       continue;       // nothing to do
!                               }
!                               if ($enable && 
!$this->check_perms(PHPGW_ACL_SETALARM,$alarm['owner']) ||
!                                       !$enable && 
!$this->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
!                               {
!                                       return -1;
!                               }
!                               $alarm['enabled'] = intval(!$alarm['enabled']);
!                               if 
($this->so->save_alarm($alarm['cal_id'],$alarm))
!                               {
!                                       ++$enabled;
!                               }
!                       }
!                       return $enabled;
!               }
! 
!               /*!
!               @function delete
!               @abstract delete one or more alarms identified by its ids
!               @syntax delete($ids)
!               @param $ids array with alarm ids as keys (!)
!               @returns the number of alarms deleted or -1 for insuficent 
permission to do so
!               @note Not found alarms or insuficent perms stop the deleting of 
multiple alarms
!               */
!               function delete($alarms)
!               {
!                       $deleted = 0;
!                       foreach ($alarms as $id => $field)
!                       {
!                               if (!($alarm = $this->so->read_alarm($id)))
!                               {
!                                       return 0;       // alarm not found
!                               }
!                               if 
(!$this->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
!                               {
!                                       return -1;
!                               }
!                               if ($this->so->delete_alarm($id))
!                               {
!                                       ++$deleted;
!                               }
!                       }
!                       return $deleted;
                }
        }
+ ?>

Index: class.bocalendar.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.bocalendar.inc.php,v
retrieving revision 1.71.2.33.2.11
retrieving revision 1.71.2.33.2.12
diff -C2 -r1.71.2.33.2.11 -r1.71.2.33.2.12
*** class.bocalendar.inc.php    6 Jul 2003 23:48:26 -0000       1.71.2.33.2.11
--- class.bocalendar.inc.php    23 Jul 2003 01:42:02 -0000      1.71.2.33.2.12
***************
*** 26,29 ****
--- 26,30 ----
                        'store_to_cache'  => True,
                        'export_event'    => True,
+                       'send_alarm'      => True,
                        'reinstate'       => True
                );
***************
*** 164,170 ****
                        $this->check_set_default_prefs();
  
-                       $owner = 
(isset($GLOBALS['owner'])?$GLOBALS['owner']:'');
-                       $owner = (isset($_GET['owner'])?$_GET['owner']:$owner);
-                       $owner = ($owner=='' && 
isset($_POST['owner'])?$_POST['owner']:$owner);
                        $owner = 
get_var('owner',array('GET','POST'),$GLOBALS['owner']);
                        
--- 165,168 ----
***************
*** 252,256 ****
                                Array(
                                        'owner'         => $this->owner,
!                                       'filter'                => 
$this->filter,
                                        'category'      => $this->cat_id,
                                        'g_owner'       => $this->g_owner
--- 250,254 ----
                                Array(
                                        'owner'         => $this->owner,
!                                       'filter'        => $this->filter,
                                        'category'      => $this->cat_id,
                                        'g_owner'       => $this->g_owner
***************
*** 867,872 ****
                                $event = $this->get_cached_event();
  
!                               $event['title'] = 
$GLOBALS['phpgw']->db->db_addslashes($event['title']);
!                               $event['description'] = 
$GLOBALS['phpgw']->db->db_addslashes($event['description']);
                                $this->store_to_appsession($event);
                                $datetime_check = 
$this->validate_update($event);
--- 865,883 ----
                                $event = $this->get_cached_event();
  
!                               if ($l_cal['alarmdays'] > 0 || 
$l_cal['alarmhours'] > 0 ||
!                                               $l_cal['alarmminutes'] > 0)
!                               {
!                                       $time = 
$this->maketime($event['start']) -
!                                               ($l_cal['alarmdays'] * 24 * 
3600) -
!                                               ($l_cal['alarmhours'] * 3600) -
!                                               ($l_cal['alarmminutes'] * 60);
! 
!                                       $event['alarm'][] = Array(
!                                               'time'    => $time,
!                                               'owner'   => $this->owner,
!                                               'enabled' => 1
!                                       );
!                               }
! 
                                $this->store_to_appsession($event);
                                $datetime_check = 
$this->validate_update($event);
***************
*** 943,947 ****
                                        if ($this->return_to)
                                        {
!                                               header('Location: 
'.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->return_to));
                                                
$GLOBALS['phpgw']->common->phpgw_exit();
                                        }
--- 954,958 ----
                                        if ($this->return_to)
                                        {
!                                               
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->return_to);
                                                
$GLOBALS['phpgw']->common->phpgw_exit();
                                        }
***************
*** 2130,2133 ****
--- 2141,2148 ----
                function 
update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event)
                {
+                       if ($msg_type == MSG_ALARM)
+                       {
+                               return True;    // always True for now
+                       }
                        $want_update = 0;
                        
***************
*** 2180,2190 ****
                @param $new_event Event after the change
                */
!               function 
send_update($msg_type,$to_notify,$old_event,$new_event=False)
                {
                        if (!is_array($to_notify))
                        {
                                $to_notify = array();
                        }
!                       if (!isset($to_notify[$old_event['owner']]))
                        {
                                $to_notify[$old_event['owner']] = 'owner';      
// always include the event-owner
--- 2195,2206 ----
                @param $new_event Event after the change
                */
!               function 
send_update($msg_type,$to_notify,$old_event,$new_event=False,$user=False)
                {
+                       //echo 
"<p>bocalendar::send_update(type=$msg_type,to_notify="; print_r($to_notify); 
echo ", old_event="; print_r($old_event); echo ", new_event="; 
print_r($new_event); echo ", user=$user)</p>\n";
                        if (!is_array($to_notify))
                        {
                                $to_notify = array();
                        }
!                       if (!isset($to_notify[$old_event['owner']]) && 
$msg_type != MSG_ALARM)
                        {
                                $to_notify[$old_event['owner']] = 'owner';      
// always include the event-owner
***************
*** 2212,2224 ****
                        $temp_user = $GLOBALS['phpgw_info']['user'];
  
!                       if($this->owner != $temp_user['account_id'])
                        {
                                $user = $this->owner;
                        }
-                       else
-                       {
-                               $user = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       }
- 
                        $GLOBALS['phpgw_info']['user']['preferences'] = 
$GLOBALS['phpgw']->preferences->create_email_preferences($user);
  
--- 2228,2235 ----
                        $temp_user = $GLOBALS['phpgw_info']['user'];
  
!                       if (!$user)
                        {
                                $user = $this->owner;
                        }
                        $GLOBALS['phpgw_info']['user']['preferences'] = 
$GLOBALS['phpgw']->preferences->create_email_preferences($user);
  
***************
*** 2269,2276 ****
--- 2280,2297 ----
                                        $method = 'reply';
                                        break;
+                               case MSG_ALARM:
+                                       $action = lang('Alarm');
+                                       $msg = 'Alarm';
+                                       $msgtype = '"calendar";';
+                                       $method = 'publish';    // duno if 
thats right
+                                       break;
                                default:
                                        $method = 'publish';
                        }
                        $notify_msg = $this->prefs['calendar']['notify'.$msg];
+                       if (empty($notify_msg))
+                       {
+                               $notify_msg = 
$this->prefs['calendar']['notifyAdded'];  // use a default
+                       }
                        $details = array(                       // 
event-details for the notify-msg
                                'id'          => $msg_type == MSG_ADDED ? 
$new_event['id'] : $old_event['id'],
***************
*** 2294,2298 ****
                                $userid = intval($userid);
  
!                               if($userid != 
$GLOBALS['phpgw_info']['user']['account_id'])
                                {
                                        print_debug('Msg Type',$msg_type);
--- 2315,2323 ----
                                $userid = intval($userid);
  
!                               if ($statusid == 'R')
!                               {
!                                       continue;       // dont notify rejected 
participants
!                               }
!                               if($userid != 
$GLOBALS['phpgw_info']['user']['account_id'] ||  $msg_type == MSG_ALARM)
                                {
                                        print_debug('Msg Type',$msg_type);
***************
*** 2301,2305 ****
                                        $preferences = 
CreateObject('phpgwapi.preferences',$userid);
                                        $part_prefs = 
$preferences->read_repository();
!                                       
                                        if 
(!$this->update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event))
                                        {
--- 2326,2330 ----
                                        $preferences = 
CreateObject('phpgwapi.preferences',$userid);
                                        $part_prefs = 
$preferences->read_repository();
! 
                                        if 
(!$this->update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event))
                                        {
***************
*** 2309,2316 ****
                                        $details['to-fullname'] = 
$GLOBALS['phpgw']->common->display_fullname('',$details['to-firstname'],$details['to-lastname']);
  
!                                       $part_prefs = 
$preferences->create_email_preferences($userid);
!                                       $to = $part_prefs['email']['address'];
! 
!                                       if (empty($to)) // we have no valid 
email-address
                                        {
                                                echo 
"<p>bocalendar::send_update: Empty email adress for user 
'".$details['to-fullname']."' ==> ignored !!!</p>\n";
--- 2334,2339 ----
                                        $details['to-fullname'] = 
$GLOBALS['phpgw']->common->display_fullname('',$details['to-firstname'],$details['to-lastname']);
  
!                                       $to = 
$preferences->email_address($userid);
!                                       if (empty($to) || $to[0] == '@' || 
$to[0] == '$')       // we have no valid email-address
                                        {
                                                echo 
"<p>bocalendar::send_update: Empty email adress for user 
'".$details['to-fullname']."' ==> ignored !!!</p>\n";
***************
*** 2322,2326 ****
                                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = 
$part_prefs['common']['timeformat'];
                                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = 
$part_prefs['common']['dateformat'];
!                               
                                        $GLOBALS['phpgw']->datetime->tz_offset 
= ((60 * 60) * 
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
  
--- 2345,2349 ----
                                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = 
$part_prefs['common']['timeformat'];
                                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = 
$part_prefs['common']['dateformat'];
! 
                                        $GLOBALS['phpgw']->datetime->tz_offset 
= ((60 * 60) * 
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
  
***************
*** 2340,2344 ****
                                                        foreach($event_arr as 
$key => $val)
                                                        {
!                                                               if ($key != 
'access' && $key != 'priority')
                                                                {
                                                                        $body 
.= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
--- 2363,2367 ----
                                                        foreach($event_arr as 
$key => $val)
                                                        {
!                                                               if ($key != 
'access' && $key != 'priority' && strlen($details[$key]))
                                                                {
                                                                        $body 
.= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
***************
*** 2387,2390 ****
--- 2410,2439 ----
                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = 
$temp_timeformat;
                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = 
$temp_dateformat;
+                       
+                       return $returncode;
+               }
+ 
+               function send_alarm($alarm)
+               {
+                       //echo "<p>bocalendar::send_alarm("; print_r($alarm); 
echo ")</p>\n";
+                       $GLOBALS['phpgw_info']['user']['account_id'] = 
$this->owner = $alarm['owner'];
+ 
+                       if (!$alarm['enabled'] || !$alarm['owner'] || 
!$alarm['cal_id'] || !($event = $this->so->read_entry($alarm['cal_id'])))
+                       {
+                               return False;   // event not found
+                       }
+                       if ($alarm['all'])
+                       {
+                               $to_notify = $event['participants'];
+                       }
+                       elseif ($this->check_perms(PHPGW_ACL_READ,$event))      
// checks agains $this->owner set to $alarm[owner]
+                       {
+                               $to_notify[$alarm['owner']] = 'A';
+                       }
+                       else
+                       {
+                               return False;   // no rights
+                       }
+                       return 
$this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
                }
  
***************
*** 2620,2666 ****
                        // Some browser add a \n when its entered in the 
database. Not a big deal
                        // this will be printed even though its not needed.
!                       if ($event['description'])
                        {
!                               $var['description'] = Array(
!                                       'field' => lang('Description'),
!                                       'data'  => $event['description']
!                               );
                        }
! 
!                       if ($event['category'])
                        {
!                               $cats = Array();
!                               
$this->cat->categories($this->bo->owner,'calendar');
!                               if(strpos($event['category'],','))
!                               {
!                                       $cats = explode(',',$event['category']);
!                               }
!                               else
!                               {
!                                       $cats[] = $event['category'];
!                               }
!                               foreach($cats as $cat_id)
!                               {
!                                       list($cat) = 
$this->cat->return_single($cat_id);
!                                       $cat_string[] = $cat['name'];
!                               }
!                               $var['category'] = Array(
!                                       'field' => lang('Category'),
!                                       'data'  => implode(', ',$cat_string)
!                               );
                        }
! 
!                       if ($event['location'])
                        {
!                               $var['location'] = Array(
!                                       'field' => lang('Location'),
!                                       'data'  => $event['location']
!                               );
                        }
                        $var['startdate'] = Array(
                                'field' => lang('Start Date/Time'),
                                'data'  => 
$GLOBALS['phpgw']->common->show_date($this->maketime($event['start']) - 
$GLOBALS['phpgw']->datetime->tz_offset),
                        );
!       
                        $var['enddate'] = Array(
                                'field' => lang('End Date/Time'),
--- 2669,2707 ----
                        // Some browser add a \n when its entered in the 
database. Not a big deal
                        // this will be printed even though its not needed.
!                       $var['description'] = Array(
!                               'field' => lang('Description'),
!                               'data'  => $event['description']
!                       );
! 
!                       $cats = Array();
!                       $this->cat->categories($this->bo->owner,'calendar');
!                       if(strpos($event['category'],','))
                        {
!                               $cats = explode(',',$event['category']);
                        }
!                       else
                        {
!                               $cats[] = $event['category'];
                        }
!                       foreach($cats as $cat_id)
                        {
!                               list($cat) = $this->cat->return_single($cat_id);
!                               $cat_string[] = $cat['name'];
                        }
+                       $var['category'] = Array(
+                               'field' => lang('Category'),
+                               'data'  => implode(', ',$cat_string)
+                       );
+ 
+                       $var['location'] = Array(
+                               'field' => lang('Location'),
+                               'data'  => $event['location']
+                       );
+ 
                        $var['startdate'] = Array(
                                'field' => lang('Start Date/Time'),
                                'data'  => 
$GLOBALS['phpgw']->common->show_date($this->maketime($event['start']) - 
$GLOBALS['phpgw']->datetime->tz_offset),
                        );
! 
                        $var['enddate'] = Array(
                                'field' => lang('End Date/Time'),
***************
*** 2682,2686 ****
                                'data'  => 
$GLOBALS['phpgw']->common->grab_owner_name($event['owner'])
                        );
!       
                        $var['updated'] = Array(
                                'field' => lang('Updated'),
--- 2723,2727 ----
                                'data'  => 
$GLOBALS['phpgw']->common->grab_owner_name($event['owner'])
                        );
! 
                        $var['updated'] = Array(
                                'field' => lang('Updated'),
***************
*** 2703,2707 ****
                                        }
                                }
!       
                                $var['groups'] = Array(
                                        'field' => lang('Groups'),
--- 2744,2748 ----
                                        }
                                }
! 
                                $var['groups'] = Array(
                                        'field' => lang('Groups'),
***************
*** 2770,2774 ****
                        return $var;
                }
!               
                /*!
                @function check_set_default_prefs
--- 2811,2815 ----
                        return $var;
                }
! 
                /*!
                @function check_set_default_prefs
***************
*** 2792,2800 ****
                                'summary'         => 'no',
                                'receive_updates' => 'no',
!                               'update_format'   => 'ical',
                                'notifyAdded'     => $subject . lang ('You have 
a meeting scheduled for %1','$$startdate$$'),
                                'notifyCanceled'  => $subject . lang ('Your 
meeting scheduled for %1 has been canceled','$$startdate$$'),
                                'notifyModified'  => $subject . lang ('Your 
meeting that had been scheduled for %1 has been rescheduled to 
%2','$$olddate$$','$$startdate$$'),
                                'notifyResponse'  => $subject . lang ('On %1 %2 
%3 your meeting request for 
%4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'),
                                'show_rejected'   => '0',
                                'display_status'  => '1',
--- 2833,2842 ----
                                'summary'         => 'no',
                                'receive_updates' => 'no',
!                               'update_format'   => 'extended',        // 
leave it to extended for now, as iCal kills the message-body
                                'notifyAdded'     => $subject . lang ('You have 
a meeting scheduled for %1','$$startdate$$'),
                                'notifyCanceled'  => $subject . lang ('Your 
meeting scheduled for %1 has been canceled','$$startdate$$'),
                                'notifyModified'  => $subject . lang ('Your 
meeting that had been scheduled for %1 has been rescheduled to 
%2','$$olddate$$','$$startdate$$'),
                                'notifyResponse'  => $subject . lang ('On %1 %2 
%3 your meeting request for 
%4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'),
+                               'notifyAlarm'     => lang('Alarm for %1 at %2 
in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your 
requested alarm.'),
                                'show_rejected'   => '0',
                                'display_status'  => '1',

Index: class.html.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.html.inc.php,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -C2 -r1.1.2.1 -r1.1.2.1.2.1
*** class.html.inc.php  25 Aug 2002 04:07:48 -0000      1.1.2.1
--- class.html.inc.php  23 Jul 2003 01:42:02 -0000      1.1.2.1.2.1
***************
*** 1,8 ****
  <?php
        
/**************************************************************************\
!       * phpGroupWare - InfoLog                                                
   *
        * http://www.phpgroupware.org                                           
   *
        * Written by Ralf Becker <address@hidden>                  *
-       * originaly based on todo written by Joseph Engo <address@hidden>  *
        * --------------------------------------------                          
   *
        *  This program is free software; you can redistribute it and/or modify 
it *
--- 1,7 ----
  <?php
        
/**************************************************************************\
!       * phpGroupWare - HTML creation class                                    
   *
        * http://www.phpgroupware.org                                           
   *
        * Written by Ralf Becker <address@hidden>                  *
        * --------------------------------------------                          
   *
        *  This program is free software; you can redistribute it and/or modify 
it *
***************
*** 16,24 ****
  class html
  {
        function html()
        {
        }
  
!       function input_hidden($vars,$value='')
        {
                if (!is_array($vars))
--- 15,86 ----
  class html
  {
+       var $user_agent,$ua_version;    // 'mozilla','msie','konqueror'
+       var $prefered_img_title;
+ 
        function html()
+       {                                                                       
                                                        // should be Ok for all 
HTML 4 compatible browsers
+               if (!eregi('compatible; ([a-z_]+)[/ 
]+([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts))
+               {
+                       
eregi('^([a-z_]+)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts);
+               }
+               list(,$this->user_agent,$this->ua_version) = $parts;
+               $this->user_agent = strtolower($this->user_agent);
+               
+               $this->prefered_img_title = $this->user_agent == 'mozilla' && 
$this->ua_version < 5 ? 'ALT' : 'TITLE';
+               //echo "<p>HTTP_USER_AGENT='$GLOBALS[HTTP_USER_AGENT]', 
UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: 
'$this->prefered_img_title'</p>\n";
+       }
+ 
+       /*
+       * Function:             Allows to show and select one item from an array
+       *       Parameters:             $name           string with name of the 
submitted var which holds the key of the selected item form array
+       *                                               $key            key(s) 
of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
+       *                                               $arr            array 
with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 
'maybe');
+       *                                               $no_lang        if 
!$no_lang send items through lang()
+       *                                               $options        
additional options (e.g. 'multiple')
+       * On submit             $XXX            is the key of the selected item 
(XXX is the content of $name)
+       * Returns:                      string to set for a template or to echo 
into html page
+       */
+       function select($name, $key, $arr=0,$no_lang=0,$options='',$multiple=0)
        {
+               // should be in class common.sbox
+               if (!is_array($arr))
+               {
+                       $arr = array('no','yes');
+               }
+               if (intval($multiple) > 0)
+               {
+                       $options .= ' MULTIPLE SIZE="'.intval($multiple).'"';
+                       if (substr($name,-2) != '[]')
+                       {
+                               $name .= '[]';
+                       }
+               }
+               $out = "<select name=\"$name\" $options>\n";
+ 
+               if (is_array($key))
+               {
+                       $key = implode(',',$key);
+               }
+               foreach($arr as $k => $text)
+               {
+                       $out .= '<option value="'.htmlspecialchars($k).'"';
+ 
+                       if("$k" == "$key" || strstr(",$key,",",$k,"))
+                       {
+                               $out .= " SELECTED";
+                       }
+                       $out .= ">" . ($no_lang || $text == '' ? $text : 
lang($text)) . "</option>\n";
+               }
+               $out .= "</select>\n";
+ 
+               return $out;
        }
  
!       function div($content,$options='')
!       {
!               return "<DIV $options>\n$content</DIV>\n";
!       }
! 
!       function input_hidden($vars,$value='',$ignore_empty=True)
        {
                if (!is_array($vars))
***************
*** 26,34 ****
                        $vars = array( $vars => $value );
                }
!               while (list($name,$value) = each($vars))
                {
!                       if ($value && !($name == 'filter' && $value == 'none')) 
// dont need to send all the empty vars
                        {
!                               $html .= "<input type=hidden name=\"$name\" 
value=\"$value\">\n";
                        }
                }
--- 88,100 ----
                        $vars = array( $vars => $value );
                }
!               foreach($vars as $name => $value)
                {
!                       if (is_array($value))
                        {
!                               $value = serialize($value);
!                       }
!                       if (!$ignore_empty || $value && !($name == 'filter' && 
$value == 'none'))       // dont need to send all the empty vars
!                       {
!                               $html .= "<INPUT TYPE=\"HIDDEN\" NAME=\"$name\" 
VALUE=\"".htmlspecialchars($value)."\">\n";
                        }
                }
***************
*** 36,73 ****
        }
  
!       function input($name,$value='',$type='',$options='' )
        {
!               if ($type) $type = "type=$type";
! 
!               return "<input $type name=\"$name\" value=\"$value\" 
$options>\n";
        }
  
!       function submit_button($name,$lang,$onClick='')
        {
!               return $this->input($name,lang($lang),'submit',$onClick ? 
"onClick=\"$onClick\"" : '');
        }
  
!       /*
!        * create absolute link: $url: phpgw-relative link, may include query
!        *                                                               $vars: 
query or array with query
!        */
!       function link($url,$vars='')
        {
!               if (is_array( $vars ))
                {
!                       $v = array( );
!                       while(list($name,$value) = each($vars))
                        {
!                               if ($value && !($name == 'filter' && $value == 
'none')) // dont need to send all the empty vars
!                               {
!                                       $v[] = "$name=$value";
!                               }
                        }
!                       $vars = implode('&',$v);
                }
                list($url,$v) = explode('?',$url);      // url may contain 
additional vars
                if ($v)
!                       $vars .= ($vars ? '&' : '') . $v;
! 
                return $GLOBALS['phpgw']->link($url,$vars);
        }
--- 102,181 ----
        }
  
!       function textarea($name,$value='',$options='' )
        {
!               return "<TEXTAREA name=\"$name\" 
$options>".htmlspecialchars($value)."</TEXTAREA>\n";
        }
  
!       function input($name,$value='',$type='',$options='' )
        {
!               if ($type)
!               {
!                       $type = 'TYPE="'.$type.'"';
!               }
!               return "<INPUT $type NAME=\"$name\" 
VALUE=\"".htmlspecialchars($value)."\" $options>\n";
        }
  
!       function 
submit_button($name,$lang,$onClick='',$no_lang=0,$options='',$image='',$app='')
        {
!               if ($image != '')
                {
!                       if (strpos($image,'.')) 
                        {
!                               $image = substr($image,0,strpos($image,'.'));
                        }
!                       if (!($path = 
$GLOBALS['phpgw']->common->image($app,$image)) &&
!                           !($path = 
$GLOBALS['phpgw']->common->image('phpgwapi',$image)))
!                       {
!                               $path = $image;         // name may already 
contain absolut path 
!                       }
!                       $image = ' SRC="'.$path.'"';
!               }
!               if (!$no_lang)
!               {
!                       $lang = lang($lang);
!               }
!               if (($accesskey = strstr($lang,'&')) && $accesskey[1] != ' ' &&
!                       (($pos = strpos($accesskey,';')) === False || $pos > 5))
!               {
!                       $lang_u = 
str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$lang);
!                       $lang = str_replace('&','',$lang);
!                       $options = 'ACCESSKEY="'.$accesskey[1].'" '.$options;
!               }
!               else
!               {
!                       $accesskey = '';
!                       $lang_u = $lang;
!               }
!               if ($onClick) $options .= " onClick=\"$onClick\"";
! 
!               // <button> is not working in all cases if ($this->user_agent 
== 'mozilla' && $this->ua_version < 5 || $image)
!               {
!                       return $this->input($name,$lang,$image != '' ? 'IMAGE' 
: 'SUBMIT',$options.$image);
!               }
!               return '<button TYPE="submit" NAME="'.$name.'" 
VALUE="'.$lang.'" '.$options.'>'.
!                       ($image != '' ? "<img$image 
$this->prefered_img_title=\"$lang\"> " : '').
!                       ($image == '' || $accesskey ? $lang_u : '').'</button>';
!       }
! 
!       /*!
!       @function link
!       @abstract creates an absolut link + the query / get-variables
!       @param $url phpgw-relative link, may include query / get-vars
!       @parm $vars query or array ('name' => 'value', ...) with query
!       @example 
link('/index.php?menuaction=infolog.uiinfolog.get_list',array('info_id' => 123))
!       @example  = 
'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123'
!       @result absolut link already run through $phpgw->link
!       */
!       function link($url,$vars='')
!       {
!               if (!is_array($vars))
!               {
!                       $vars = explode('&',$vars);
                }
                list($url,$v) = explode('?',$url);      // url may contain 
additional vars
                if ($v)
!               {
!                       $vars += explode('&',$v);
!               }
                return $GLOBALS['phpgw']->link($url,$vars);
        }
***************
*** 78,87 ****
        }
  
!       function form($content,$hidden_vars,$url,$url_vars='',$method='POST')
        {
!               $html = "<form method=\"$method\" 
action=\"".$this->link($url,$url_vars)."\">\n";
                $html .= $this->input_hidden($hidden_vars);
  
!               if ($content) {
                        $html .= $content;
                        $html .= "</form>\n";
--- 186,196 ----
        }
  
!       function 
form($content,$hidden_vars,$url,$url_vars='',$name='',$options='',$method='POST')
        {
!               $html = "<form method=\"$method\" ".($name != '' ? 
"name=\"$name\" " : '')."action=\"".$this->link($url,$url_vars)."\" 
$options>\n";
                $html .= $this->input_hidden($hidden_vars);
  
!               if ($content) 
!               {
                        $html .= $content;
                        $html .= "</form>\n";
***************
*** 90,124 ****
        }
  
!       function form_1button($name,$lang,$hidden_vars,$url,$url_vars='',
!                                                                $method='POST')
        {
                return $this->form($this->submit_button($name,$lang),
!                                                                
$hidden_vars,$url,$url_vars,$method);
        }
  
!       /*
!        * Example: $rows = array ( '1' => array( 1 => 'cell1', '.1' => 
'colspan=3',
!        *                                                                      
                                         2 => 'cell2',
!        *                                                                      
                                         3 => '3,, '.3' => 'width="10%"' ),
!        *                                                                      
 '.1'   => 'bgcolor="#0000FF"' );
!        * table($rows,'width="100%"');
!        */
!       function table($rows,$params = '')
        {
!               $html = "<table $params>\n";
  
!               while (list($key,$row) = each($rows)) {
                        if (!is_array($row))
                                continue;                                       
// parameter
!                       $html .= "\t<tr ".$rows['.'.$key].">\n";
!                       while (list($key,$cell) = each($row)) {
                                if ($key[0] == '.')
                                        continue;                               
// parameter
!                               $html .= "\t\t<td 
".$row['.'.$key].">$cell</td>\n";
                        }
!                       $html .= "\t</tr>\n";
                }
-               $html .= "</table>\n";
-               
                return $html;
        }
--- 199,257 ----
        }
  
!       function 
form_1button($name,$lang,$hidden_vars,$url,$url_vars='',$form_name='',$method='POST')
        {
                return $this->form($this->submit_button($name,$lang),
!                       $hidden_vars,$url,$url_vars,$form_name,'',$method);
        }
  
!       /*!
!       @function table
!       @abstracts creates table from array with rows
!       @discussion abstract the html stuff
!       @param $rows array with rows, each row is an array of the cols
!       @param $options options for the table-tag
!       @example $rows = array ( '1'  => array( 1 => 'cell1', '.1' => 
'colspan=3',
!       @example                                2 => 'cell2', 3 => 'cell3', 
'.3' => 'width="10%"' ),
!       @example                 '.1' => 'BGCOLOR="#0000FF"' );
!       @example table($rows,'WIDTH="100%"') = '<table WIDTH="100%"><tr><td 
colspan=3>cell1</td><td>cell2</td><td width="10%">cell3</td></tr></table>'
!       @result string with html-code of the table
!       */
!       function table($rows,$options = '',$no_table_tr=False)
        {
!               $html = $no_table_tr ? '' : "<TABLE $options>\n";
  
!               foreach($rows as $key => $row)
!               {
                        if (!is_array($row))
+                       {
                                continue;                                       
// parameter
!                       }
!                       $html .= $no_table_tr && $key == 1 ? '' : "\t<TR 
".$rows['.'.$key].">\n";
! 
!                       foreach($row as $key => $cell)
!                       {
                                if ($key[0] == '.')
+                               {
                                        continue;                               
// parameter
!                               }
!                               $table_pos = strpos($cell,'<TABLE');
!                               $td_pos = strpos($cell,'<TD');
!                               if ($td_pos !== False && ($table_pos === False 
|| $td_pos < $table_pos))
!                               {
!                                       $html .= $cell;
!                               }
!                               else
!                               {
!                                       $html .= "\t\t<TD 
".$row['.'.$key].">$cell</TD>\n";
!                               }
                        }
!                       $html .= "\t</TR>\n";
!               }
!               $html .= "</TABLE>\n";
! 
!               if ($no_table_tr)
!               {
!                       $html = substr($html,0,-16);
                }
                return $html;
        }
***************
*** 135,161 ****
        }
  
!       function image( $app,$name,$title='',$opts='' )
        {
!               $html = '<img 
src="'.$GLOBALS['phpgw']->common->image($app,$name).'"';
! 
!               if ($title)
                {
!                       $html .= " alt=\"$title\" title=\"$title\"";
                }
!               if ($opts)
                {
!                       $html .= " $opts";
                }
!               return $html . '>';
        }
  
        function a_href( $content,$url,$vars='',$options='')
        {
                return '<a href="'.$this->link($url,$vars).'" 
'.$options.'>'.$content.'</a>';
        }
!       
        function bold($content)
        {
                return '<b>'.$content.'</b>';
        }
  }
--- 268,382 ----
        }
  
!       function image( $app,$name,$title='',$options='' )
        {
!               if (strstr($name,'.') === False)
!               {
!                       $name .= '.gif';
!               }
!               if (!($path = $GLOBALS['phpgw']->common->image($app,$name)))
!               {
!                       $path = $name;          // name may already contain 
absolut path
!               }
!               if (address@hidden($_SERVER['DOCUMENT_ROOT'] . $path))
                {
!                       return $title;
                }
!               if ($title)
                {
!                       $options .= " 
$this->prefered_img_title=\"".htmlspecialchars($title).'"';
                }
!               return "<IMG SRC=\"$path\" $options>";
        }
  
        function a_href( $content,$url,$vars='',$options='')
        {
+               if (!strstr($url,'/') && count(explode('.',$url)) == 3)
+               {
+                       $url = "/index.php?menuaction=$url";
+               }
+               if (is_array($url))
+               {
+                       $vars = $url;
+                       $url = '/index.php';
+               }
                return '<a href="'.$this->link($url,$vars).'" 
'.$options.'>'.$content.'</a>';
        }
! 
        function bold($content)
        {
                return '<b>'.$content.'</b>';
+       }
+ 
+       function italic($content)
+       {
+               return '<i>'.$content.'</i>';
+       }
+ 
+       function hr($width,$options='')
+       {
+               if ($width)
+                       $options .= " WIDTH=$width";
+               return "<hr $options>\n";
+       }
+ 
+       /*!
+       @function formatOptions
+       @abstract formats option-string for most of the above functions
+       @param $options String (or Array) with option-values eg. '100%,,1'
+       @param $names String (or Array) with the option-names eg. 
'WIDTH,HEIGHT,BORDER'
+       @example formatOptions('100%,,1','WIDTH,HEIGHT,BORDER') = ' 
WIDTH="100%" BORDER="1"'
+       @result option string
+       */
+       function formatOptions($options,$names)
+       {
+               if (!is_array($options)) $options = explode(',',$options);
+               if (!is_array($names))   $names   = explode(',',$names);
+ 
+               while (list($n,$val) = each($options))
+                       if ($val != '' && $names[$n] != '')
+                               $html .= ' '.$names[$n].'="'.$val.'"';
+ 
+               return $html;
+       }
+ 
+       /*!
+       @function themeStyles
+       @abstract returns simple stylesheet (incl. <STYLE> tags) for nextmatch 
row-colors
+       @result the classes 'th' = nextmatch header, 'row_on'+'row_off' = 
alternating rows
+       */
+       function themeStyles()
+       {
+               return $this->style($this->theme2css());
+       }
+ 
+       /*!
+       @function theme2css
+       @abstract returns simple stylesheet for nextmatch row-colors
+       @result the classes 'th' = nextmatch header, 'row_on'+'row_off' = 
alternating rows
+       */
+       function theme2css()
+       {
+               return 
+                       ".th { background: 
".$GLOBALS['phpgw_info']['theme']['th_bg']."; font-weight: bold; }\n".
+                       ".row_on,.th_bright { background: 
".$GLOBALS['phpgw_info']['theme']['row_on']."; }\n".
+                       ".row_off { background: 
".$GLOBALS['phpgw_info']['theme']['row_off']."; }\n";
+       }
+ 
+       function style($styles)
+       {
+               return $styles ? "<STYLE 
type=\"text/css\">\n<!--\n$styles\n-->\n</STYLE>" : '';
+       }
+ 
+       function label($content,$id='',$accesskey='',$options='')
+       {
+               if ($id != '')
+               {
+                       $id = " FOR=\"$id\"";
+               }
+               if ($accesskey != '')
+               {
+                       $accesskey = " ACCESSKEY=\"$accesskey\"";
+               }
+               return "<LABEL$id$accesskey $options>$content</LABEL>";
        }
  }

Index: class.socalendar.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.socalendar.inc.php,v
retrieving revision 1.22.2.5.2.1
retrieving revision 1.22.2.5.2.2
diff -C2 -r1.22.2.5.2.1 -r1.22.2.5.2.2
*** class.socalendar.inc.php    6 Jul 2003 23:48:26 -0000       1.22.2.5.2.1
--- class.socalendar.inc.php    23 Jul 2003 01:42:02 -0000      1.22.2.5.2.2
***************
*** 200,203 ****
--- 200,213 ----
                }
  
+               function save_alarm($cal_id,$alarm,$id=0)
+               {
+                       $this->cal->save_alarm($cal_id,$alarm,$id);
+               }
+ 
+               function delete_alarm($id)
+               {
+                       $this->cal->delete_alarm($id);
+               }
+ 
                function delete_entry($id)
                {
***************
*** 225,228 ****
--- 235,239 ----
                                        $id = $this->cal->stream->f('cal_id');
                                        $db2->query('SELECT count(*) FROM 
phpgw_cal_user WHERE cal_id='.$id.' AND 
cal_login='.$new_owner,__LINE__,__FILE__);
+                                       $db2->next_record();
                                        if($db2->f(0) == 0)
                                        {
***************
*** 243,255 ****
                }
  
!               function get_alarm($id)
                {
!                       if($GLOBALS['phpgw_info']['server']['calendar_type'] == 
'sql')
                        {
!                               return $this->cal->get_alarm($id);      
                        }
!                       else
                        {
                        }
                }
  
--- 254,282 ----
                }
  
!               function get_alarm($cal_id)
                {
!                       if (!method_exists($this->cal,'get_alarm'))
                        {
!                               return False;
                        }
!                       return $this->cal->get_alarm($cal_id);
!               }
! 
!               function read_alarm($id)
!               {
!                       if (!method_exists($this->cal,'read_alarm'))
!                       {
!                               return False;
!                       }
!                       return $this->cal->read_alarm($id);
!               }
! 
!               function read_alarms($cal_id)
!               {
!                       if (!method_exists($this->cal,'read_alarms'))
                        {
+                               return False;
                        }
+                       return $this->cal->read_alarms($cal_id);
                }
  

Index: class.socalendar__.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.socalendar__.inc.php,v
retrieving revision 1.11.2.1.2.1
retrieving revision 1.11.2.1.2.2
diff -C2 -r1.11.2.1.2.1 -r1.11.2.1.2.2
*** class.socalendar__.inc.php  19 May 2003 23:29:22 -0000      1.11.2.1.2.1
--- class.socalendar__.inc.php  23 Jul 2003 01:42:03 -0000      1.11.2.1.2.2
***************
*** 52,55 ****
--- 52,56 ----
  define('MSG_TENTATIVE',4);
  define('MSG_ACCEPTED',5);
+ define('MSG_ALARM',6);
  
  define('REJECTED',0);

Index: class.socalendar_sql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.socalendar_sql.inc.php,v
retrieving revision 1.28.2.4.2.2
retrieving revision 1.28.2.4.2.3
diff -C2 -r1.28.2.4.2.2 -r1.28.2.4.2.3
*** class.socalendar_sql.inc.php        4 May 2003 00:21:33 -0000       
1.28.2.4.2.2
--- class.socalendar_sql.inc.php        23 Jul 2003 01:42:03 -0000      
1.28.2.4.2.3
***************
*** 32,35 ****
--- 32,41 ----
        {
                $this->socalendar__();
+               
+               if (!is_object($GLOBALS['phpgw']->asyncservice))
+               {
+                       $GLOBALS['phpgw']->asyncservice = 
CreateObject('phpgwapi.asyncservice');
+               }
+               $this->async = &$GLOBALS['phpgw']->asyncservice;
        }
  
***************
*** 97,100 ****
--- 103,211 ----
        }
  
+       /*!
+       @function read_alarms
+       @abstract read the alarms of a calendar-event specified by $cal_id
+       @returns array of alarms with alarm-id as key
+       @note the alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr, it is 
used as the job-id too
+       */
+       function read_alarms($cal_id)
+       {
+               $alarms = array();
+ 
+               if ($jobs = $this->async->read('cal:'.intval($cal_id).':%'))
+               {
+                       foreach($jobs as $id => $job)
+                       {
+                               $alarm         = $job['data'];  // text, enabled
+                               $alarm['id']   = $id;
+                               $alarm['time'] = $job['next'];
+ 
+                               $alarms[$id] = $alarm;
+                       }
+               }
+               return $alarms;
+       }
+ 
+       /*!
+       @function read_alarm
+       @abstract read a single alarm specified by it's $id
+       @returns array with data of the alarm
+       @note the alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr, it is 
used as the job-id too
+       */
+       function read_alarm($id)
+       {
+               if (!($jobs = $this->async->read($id)))
+               {
+                       return False;
+               }
+               list($id,$job) = each($jobs);
+               $alarm         = $job['data'];  // text, enabled
+               $alarm['id']   = $id;
+               $alarm['time'] = $job['next'];
+ 
+               //echo "<p>read_alarm('$id')="; print_r($alarm); echo "</p>\n";
+               return $alarm;
+       }
+ 
+       /*!
+       @function save_alarm
+       @abstract saves a new or updated alarm
+       @syntax save_alarm($cal_id,$alarm,$id=False)
+       @param $cal_id Id of the calendar-entry
+       @param $alarm array with fields: text, owner, enabled, ..
+       */
+       function save_alarm($cal_id,$alarm)
+       {
+               //echo "<p>save_alarm(cal_id=$cal_id, alarm="; print_r($alarm); 
echo ")</p>\n";
+               if (!($id = $alarm['id']))
+               {
+                       $alarms = $this->read_alarms($cal_id);  // find a free 
alarm#
+                       $n = count($alarms);
+                       do
+                       {
+                               $id = 'cal:'.intval($cal_id).':'.$n;
+                               ++$n;
+                       }
+                       while (@isset($alarms[$id]));
+               }
+               else
+               {
+                       $this->async->cancel_timer($id);
+               }
+               $alarm['cal_id'] = $cal_id;             // we need the 
back-reference
+ 
+               if 
(!$this->async->set_timer($alarm['time'],$id,'calendar.bocalendar.send_alarm',$alarm))
+               {
+                       return False;
+               }
+               return $id;
+       }
+       
+       /*!
+       @function delete_alarms($cal_id)
+       @abstract delete all alarms of a calendar-entry
+       @returns the number of alarms deleted
+       */
+       function delete_alarms($cal_id)
+       {
+               $alarms = $this->read_alarms($cal_id);
+               
+               foreach($alarms as $id => $alarm)
+               {
+                       $this->async->cancel_timer($id);
+               }
+               return count($alarms);
+       }
+       
+       /*!
+       @function delete_alarm($id)
+       @abstract delete one alarms identified by its id
+       @returns the number of alarms deleted
+       */
+       function delete_alarm($id)
+       {
+               return $this->async->cancel_timer($id);
+       }
+ 
        function fetch_event($event_id,$options='')
        {
***************
*** 211,216 ****
--- 322,329 ----
                        }
  
+ /* OLD-ALARM
                        if($this->event['reference'])
                        {
+                               // What is event['reference']???
                                $alarm_cal_id = 
$event_id.','.$this->event['reference'];
                        }
***************
*** 220,224 ****
                        }
  
!                       $this->stream->query('SELECT * FROM phpgw_cal_alarm 
WHERE cal_id in ('.$alarm_cal_id.') AND 
cal_owner='.$this->user,__LINE__,__FILE__);
                        if($this->stream->num_rows())
                        {
--- 333,339 ----
                        }
  
!                       //echo '<!-- cal_id='.$alarm_cal_id.' -->'."\n";
!                       //$this->stream->query('SELECT * FROM phpgw_cal_alarm 
WHERE cal_id in ('.$alarm_cal_id.') AND 
cal_owner='.$this->user,__LINE__,__FILE__);
!                       $this->stream->query('SELECT * FROM phpgw_cal_alarm 
WHERE cal_id='.$event_id.' AND cal_owner='.$this->user,__LINE__,__FILE__);
                        if($this->stream->num_rows())
                        {
***************
*** 233,236 ****
--- 348,352 ----
                                }
                        }
+ */
                }
                else
***************
*** 241,244 ****
--- 357,369 ----
                $this->stream->unlock();
  
+               if ($this->event)
+               {
+                       $this->event['alarm'] = $this->read_alarms($event_id);
+ 
+                       if($this->event['reference'])
+                       {
+                               $this->event['alarm'] += 
$this->read_alarms($event_id);
+                       }
+               }
                return $this->event;
        }
***************
*** 341,345 ****
        function expunge()
        {
-               reset($this->deleted_events);
                if(count($this->deleted_events) <= 0)
                {
--- 466,469 ----
***************
*** 351,365 ****
                        'phpgw_cal_user',
                        'phpgw_cal_repeats',
!                       'phpgw_cal_alarm'
                );
                $this->stream->lock($locks);
!               for($i=0;$i<count($this->deleted_events);$i++)
                {
!                       for($k=0;$k<count($locks);$k++)
                        {
!                               $this->stream->query('DELETE FROM 
'.$locks[$k].' WHERE cal_id='.$this->deleted_events[$i],__LINE__,__FILE__);
                        }
                }
                $this->stream->unlock();
                $this->event = $this_event;
                return 1;
--- 475,496 ----
                        'phpgw_cal_user',
                        'phpgw_cal_repeats',
! // OLD-ALARM                  'phpgw_cal_alarm'
                );
                $this->stream->lock($locks);
!               foreach($this->deleted_events as $cal_id)
                {
!                       foreach ($locks as $table)
                        {
!                               $this->stream->query('DELETE FROM '.$table.' 
WHERE cal_id='.$cal_id,__LINE__,__FILE__);
                        }
                }
                $this->stream->unlock();
+ 
+               foreach($this->deleted_events as $cal_id)
+               {
+                       $this->delete_alarms($cal_id);
+               }
+               $this->deleted_events = array();
+ 
                $this->event = $this_event;
                return 1;
***************
*** 422,426 ****
                        'phpgw_cal',
                        'phpgw_cal_user',
!                       'phpgw_cal_repeats'
                );
                $this->stream->lock($locks);
--- 553,558 ----
                        'phpgw_cal',
                        'phpgw_cal_user',
!                       'phpgw_cal_repeats',
! // OLD-ALARM                  'phpgw_cal_alarm'
                );
                $this->stream->lock($locks);
***************
*** 452,463 ****
                                $event['uid'] = 
$part[0].'-'.$part[1].'@'.$id_suffix;
                        }
- /*    makes problems if tempnam is to long for title column, see bug #3162
-                       $temp_name = 
tempnam($GLOBALS['phpgw_info']['server']['temp_dir'],'cal');
-                       $this->stream->query('INSERT INTO 
phpgw_cal(uid,title,owner,priority,is_public,category) '
-                               . 
"values('".$event['uid']."','".$temp_name."',".$event['owner'].','.$event['priority'].','.$event['public'].",'".$event['category']."')");
-                       $this->stream->query("SELECT cal_id FROM phpgw_cal 
WHERE title='".$temp_name."'");
-                       $this->stream->next_record();
-                       $event['id'] = $this->stream->f('cal_id');
- */
                        $this->stream->query('INSERT INTO 
phpgw_cal(uid,title,owner,priority,is_public,category) '
                                . 
"values('".$event['uid']."','".$this->stream->db_addslashes($event['title'])
--- 584,587 ----
***************
*** 491,495 ****
                                . 
"title='".$this->stream->db_addslashes($event['title'])."', "
                                . 
"description='".$this->stream->db_addslashes($event['description'])."', "
!                               . "location='".$event['location']."', "
                                . 
($event['groups']?"groups='".(count($event['groups'])>1?implode(',',$event['groups']):','.$event['groups'][0].',')."',
 ":'')
                                . 'reference='.$event['reference'].' '
--- 615,619 ----
                                . 
"title='".$this->stream->db_addslashes($event['title'])."', "
                                . 
"description='".$this->stream->db_addslashes($event['description'])."', "
!                               . 
"location='".$this->stream->db_addslashes($event['location'])."', "
                                . 
($event['groups']?"groups='".(count($event['groups'])>1?implode(',',$event['groups']):','.$event['groups'][0].',')."',
 ":'')
                                . 'reference='.$event['reference'].' '
***************
*** 503,507 ****
                while (list($key,$value) = @each($event['participants']))
                {
- //                    if(intval($key) == intval($this->user))
                        if(intval($key) == $event['owner'])
                        {
--- 627,630 ----
***************
*** 546,559 ****
                        $this->stream->query('DELETE FROM phpgw_cal_repeats 
WHERE cal_id='.$event['id'],__LINE__,__FILE__);
                }
  
                print_debug('Event Saved: ID #',$event['id']);
  
                $this->stream->unlock();
                $GLOBALS['phpgw_info']['cal_new_event_id'] = $event['id']; 
                return True;
        }
  
!       function get_alarm($id)
        {
                $this->stream->query('SELECT cal_time, cal_text FROM 
phpgw_cal_alarm WHERE cal_id='.$id.' AND 
cal_owner='.$this->user,__LINE__,__FILE__);
                if($this->stream->num_rows())
--- 669,714 ----
                        $this->stream->query('DELETE FROM phpgw_cal_repeats 
WHERE cal_id='.$event['id'],__LINE__,__FILE__);
                }
+ /*
+               $alarmcount = count($event['alarm']);
+               if ($alarmcount > 1)
+               {
+                       // this should never happen, $event['alarm'] should 
only be set
+                       // if creating a new event and uicalendar only sets up 
1 alarm
+                       // the user must use "Alarm Management" to 
create/establish multiple
+                       // alarms or to edit/change an alarm
+                       echo '<!-- how did this happen, too many alarms 
-->'."\n";
+                       $this->stream->unlock();
+                       return True;
+               }
+ 
+               if ($alarmcount == 1)
+               {
+ 
+                       list($key,$alarm) = @each($event['alarm']);
  
+                       $this->stream->query('INSERT INTO 
phpgw_cal_alarm(cal_id,cal_owner,cal_time,cal_text,alarm_enabled) 
VALUES('.$event['id'].','.$event['owner'].','.$alarm['time'].",'".$alarm['text']."',".$alarm['enabled'].')',__LINE__,__FILE__);
+                       $this->stream->query('SELECT LAST_INSERT_ID()');
+                       $this->stream->next_record();
+                       $alarm['id'] = $this->stream->f(0);
+               }
+ */
                print_debug('Event Saved: ID #',$event['id']);
  
                $this->stream->unlock();
+ 
+               if (is_array($event['alarm']))
+               {
+                       foreach ($event['alarm'] as $alarm)     // this are all 
new alarms
+                       {
+                               $this->save_alarm($event['id'],$alarm);
+                       }
+               }
                $GLOBALS['phpgw_info']['cal_new_event_id'] = $event['id']; 
                return True;
        }
  
!       function get_alarm($cal_id)
        {
+ /* OLD-ALARM          
                $this->stream->query('SELECT cal_time, cal_text FROM 
phpgw_cal_alarm WHERE cal_id='.$id.' AND 
cal_owner='.$this->user,__LINE__,__FILE__);
                if($this->stream->num_rows())
***************
*** 570,573 ****
--- 725,740 ----
                        return False;
                }
+ */
+               $alarms = $this->read_alarms($cal_id);
+               $ret = False;
+ 
+               foreach($alarms as $alarm)
+               {
+                       if ($alarm['owner'] == $this->user || !$alarm['owner'])
+                       {
+                               $ret[$alarm['time']] = $alarm['text'];
+                       }
+               }
+               return $ret;
        }
  
***************
*** 582,585 ****
--- 749,757 ----
                
                $this->stream->query("UPDATE phpgw_cal_user SET 
cal_status='".$status_code_short[$status]."' WHERE cal_id=".$id." AND 
cal_login=".$owner,__LINE__,__FILE__);
+               if ($status == 'R') 
+               {
+                       $this->stream->query('UPDATE phpgw_cal_alarm set 
alarm_enabled=0 where cal_id='.$id.' and cal_owner='.$owner,__LINE__,__FILE__);
+               }
+ 
                return True;
        }
***************
*** 659,661 ****
--- 831,847 ----
                return 
$this->get_event_ids($repeats,$user_where.$wheremod.$extra.$order_by);
        }
+ 
+ /* OLD-ALARM
+       function add_alarm($eventid,$alarm,$owner)
+       {
+               $this->stream->query('INSERT INTO 
phpgw_cal_alarm(cal_id,cal_owner,cal_time,cal_text,alarm_enabled) 
VALUES('.$eventid.','.$owner.','.$alarm['time'].",'".$alarm['text']."',1)",__LINE__,__FILE__);
+               $this->stream->query('SELECT LAST_INSERT_ID()');
+               $this->stream->next_record();
+               return($this->stream->f(0));
+       }
+       function delete_alarm($alarmid)
+       {
+               $this->stream->query('DELETE FROM phpgw_cal_alarm WHERE 
alarm_id='.$alarmid,__LINE__,__FILE__);
+       }
+ */
  }

Index: class.uialarm.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.uialarm.inc.php,v
retrieving revision 1.4.2.1.2.1
retrieving revision 1.4.2.1.2.2
diff -C2 -r1.4.2.1.2.1 -r1.4.2.1.2.2
*** class.uialarm.inc.php       19 Apr 2003 21:11:48 -0000      1.4.2.1.2.1
--- class.uialarm.inc.php       23 Jul 2003 01:42:03 -0000      1.4.2.1.2.2
***************
*** 47,52 ****
                                echo "BO Owner : ".$this->bo->owner."<br>\n";
                        }
- 
                        $this->template_dir = 
$GLOBALS['phpgw']->common->get_tpl_dir('calendar');
                }
  
--- 47,53 ----
                                echo "BO Owner : ".$this->bo->owner."<br>\n";
                        }
                        $this->template_dir = 
$GLOBALS['phpgw']->common->get_tpl_dir('calendar');
+ 
+                       $this->html = CreateObject('calendar.html');
                }
  
***************
*** 54,71 ****
                {
                        $this->event = $this->bo->read_entry($this->bo->cal_id);
! 
!                       $can_edit = 
$this->bo->cal->check_perms(PHPGW_ACL_EDIT,$this->event);
  
                        if(!$can_edit)
                        {
!                               Header('Location : 
'.$GLOBALS['phpgw']->link('/index.php',
!                                               Array(
!                                                       'menuaction'    => 
'calendar.uicalendar.view',
!                                                       'cal_id'                
=> $this->bo->cal_id
!                                               )
!                                       )
!                               );
                        }
! 
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
--- 55,69 ----
                {
                        $this->event = $this->bo->read_entry($this->bo->cal_id);
! /*
!                       $can_edit = 
$this->bo->bo->check_perms(PHPGW_ACL_EDIT,$this->event);
  
                        if(!$can_edit)
                        {
!                               
$GLOBALS['phpgw']->redirect_link('/index.php',Array(
!                                       'menuaction'    => 
'calendar.uicalendar.view',
!                                       'cal_id'                => 
$this->bo->cal_id
!                               ));
                        }
! */
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
***************
*** 75,79 ****
                        $this->template = 
CreateObject('phpgwapi.Template',$this->template_dir);
  
!                       $this->template->set_unknowns('keep');
                        $this->template->set_file(
                                Array(
--- 73,77 ----
                        $this->template = 
CreateObject('phpgwapi.Template',$this->template_dir);
  
!                       $this->template->set_unknowns('remove');
                        $this->template->set_file(
                                Array(
***************
*** 85,92 ****
--- 83,95 ----
                        $this->template->set_block('alarm','list','list');
                        $this->template->set_block('alarm','hr','hr');
+                       $this->template->set_block('alarm','buttons','buttons');
                }
  
                function output_template_array($row,$list,$var)
                {
+                       if (!isset($var['tr_color']))
+                       {
+                               $var['tr_color'] = 
$GLOBALS['phpgw']->nextmatchs->alternate_row_color();
+                       }
                        $this->template->set_var($var);
                        $this->template->parse($row,$list,True);
***************
*** 97,101 ****
--- 100,133 ----
                function manager()
                {
+                       if ($_POST['delete'] && count($_POST['alarm']))
+                       {
+                               if ($this->bo->delete($_POST['alarm']) < 0)
+                               {
+                                       echo '<center>'.lang('You do not have 
permission to delete this alarm !!!').'</center>';
+                                       
$GLOBALS['phpgw']->common->phpgw_exit(True);
+                               }
+                       }
+                       if (($_POST['enable'] || $_POST['disable']) && 
count($_POST['alarm']))
+                       {
+                               if 
($this->bo->enable($_POST['alarm'],$_POST['enable']) < 0)
+                               {
+                                       echo '<center>'.lang('You do not have 
permission to enable/disable this alarm !!!').'</center>';
+                                       
$GLOBALS['phpgw']->common->phpgw_exit(True);
+                               }
+                       }
                        $this->prep_page();
+ 
+                       if ($_POST['add'])
+                       {
+                               $time = intval($_POST['time']['days'])*24*3600 +
+                                       intval($_POST['time']['hours'])*3600 +
+                                       intval($_POST['time']['mins'])*60;
+ 
+                               if ($time > 0 && 
!$this->bo->add($this->event,$time,$_POST['owner']))
+                               {
+                                       echo '<center>'.lang('You do not have 
permission to add alarms to this event !!!').'</center>';
+                                       
$GLOBALS['phpgw']->common->phpgw_exit(True);
+                               }
+                       }
                        if 
(!ExecMethod('calendar.uicalendar.view_event',$this->event))
                        {
***************
*** 109,144 ****
                        
$GLOBALS['phpgw']->template->pfp('phpgw_body','view_event');
  
-                       
                        $var = Array(
                                'tr_color'              => 
$this->theme['th_bg'],
!                               'action_url'    => 
$GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uialarm.form_handler')),
!                               'time_lang'             => lang('Time'),
!                               'text_lang'             => lang('Text'),
!                               'enabled_pict'  => 
$GLOBALS['phpgw']->common->image('calendar','enabled.gif'),
!                               'disabled_pict' => 
$GLOBALS['phpgw']->common->image('calendar','disabled.gif')
                        );
-                       
$this->output_template_array('row','alarm_headers',$var);
- 
                        if($this->event['alarm'])
                        {
!                               @reset($this->event['alarm']);
!                               while(list($key,$alarm) = 
each($this->event['alarm']))
                                {
                                        $var = Array(
!                                               'edit_box'      => '<input 
type="checkbox" name="alarm[id]" value="'.$alarm['id'].'">',
!                                               'field' => 
$icon.$GLOBALS['phpgw']->common->show_date($alarm['time']),
!                                               'data'  => $alarm['text'],
!                                               'alarm_enabled' => 
($alarm['enabled']?'<img 
src="'.$GLOBALS['phpgw']->common->image('calendar','enabled.gif').'" width="13" 
height="13" alt="enabled">':'&nbsp;'),
!                                               'alarm_disabled'        => 
(!$alarm['enabled']?'<img 
src="'.$GLOBALS['phpgw']->common->image('calendar','disabled.gif').'" 
width="13" height="13" alt="disabled">':'&nbsp;')
                                        );
!                                       
$this->output_template_array('row','list',$var);
                                }
                        }
!                       echo $this->template->fp('out','alarm_management');
!               }
! 
!               function add_alarm()
!               {
!                       $this->prep_page();
                }
        }
--- 141,204 ----
                        
$GLOBALS['phpgw']->template->pfp('phpgw_body','view_event');
  
                        $var = Array(
                                'tr_color'              => 
$this->theme['th_bg'],
!                               'action_url'    => 
$GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uialarm.manager')),
!                               'hidden_vars'   => 
$this->html->input_hidden('cal_id',$this->bo->cal_id),
!                               'lang_select'   => lang('Select'),
!                               'lang_time'             => lang('Time'),
!                               'lang_text'             => lang('Text'),
!                               'lang_owner'    => lang('Owner'),
!                               'lang_enabled'  => lang('enabled'),
!                               'lang_disabled' => lang('disabled'),
!                               'lang_enabled'  => lang('enabled'),
!                               'lang_disabled' => lang('disabled')
                        );
                        if($this->event['alarm'])
                        {
!                               
$this->output_template_array('rows','alarm_headers',$var);
! 
!                               foreach($this->event['alarm'] as $key => $alarm)
                                {
+                                       if 
(!$this->bo->check_perms(PHPGW_ACL_READALARM,$alarm['owner']))
+                                       {
+                                               continue;
+                                       }
                                        $var = Array(
!                                               'field'    => 
$GLOBALS['phpgw']->common->show_date($alarm['time']),
!                                               //'data'   => $alarm['text'],
!                                               'data'     => 'Email 
Notification',
!                                               'owner'    => 
$GLOBALS['phpgw']->common->grab_owner_name($alarm['owner']),
!                                               'enabled'  => 
($alarm['enabled']?'<img 
src="'.$GLOBALS['phpgw']->common->image('calendar','enabled.gif').'" width="13" 
height="13" title="'.lang('enabled').'">':
!                                                       '<img 
src="'.$GLOBALS['phpgw']->common->image('calendar','disabled.gif').'" 
width="13" height="13" title="'.lang('disabled').'">'),
!                                               'select'   => '<input 
type="checkbox" name="alarm['.$alarm['id'].']">'
                                        );
!                                       if 
($this->bo->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
!                                       {
!                                               ++$to_delete;
!                                       }
!                                       
$this->output_template_array('rows','list',$var);
                                }
+                               
$this->template->set_var('enable_button',$this->html->submit_button('enable','Enable'));
+                               
$this->template->set_var('disable_button',$this->html->submit_button('disable','Disable'));
+                               if ($to_delete)
+                               {
+                                       
$this->template->set_var('delete_button',$this->html->submit_button('delete','Delete',"return
 confirm('".lang("Are you sure\\nyou want to\\ndelete these alarms?")."')"));
+                               }
+                               $this->template->parse('rows','buttons',True);
                        }
!                       if 
(isset($this->event['participants'][intval($GLOBALS['phpgw_info']['user']['account_id'])]))
!                       {
!                               $this->template->set_var(Array(
!                                       'input_text'    => lang('Email 
reminder'),
!                                       'input_days'    => 
$this->html->select('time[days]',$_POST['time']['days'],range(0,31),True).' 
'.lang('days'),
!                                       'input_hours'   => 
$this->html->select('time[hours]',$_POST['time']['hours'],range(0,24),True).' 
'.lang('hours'),
!                                       'input_minutes' => 
$this->html->select('time[mins]',$_POST['time']['mins'],range(0,60),True).' 
'.lang('minutes').' '.lang('before the event'),
!                                       'input_owner'   => 
$this->html->select('owner',$GLOBALS['phpgw_info']['user']['account_id'],$this->bo->participants($this->event,True),True),
!                                       'input_add'     => 
$this->html->submit_button('add','Add Alarm')
!                               ));
!                       }
! //echo 
"<p>alarm_management='".htmlspecialchars($this->template->get_var('alarm_management'))."'</p>\n";
!                       $this->template->pfp('out','alarm_management');
                }
        }
+ ?>

Index: class.uicalendar.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.uicalendar.inc.php,v
retrieving revision 1.66.2.55.2.14
retrieving revision 1.66.2.55.2.15
diff -C2 -r1.66.2.55.2.14 -r1.66.2.55.2.15
*** class.uicalendar.inc.php    1 Jun 2003 09:57:10 -0000       1.66.2.55.2.14
--- class.uicalendar.inc.php    23 Jul 2003 01:42:03 -0000      1.66.2.55.2.15
***************
*** 25,29 ****
                var $holidays;
                var $holiday_color;
!               
                var $debug = False;
  //            var $debug = True;
--- 25,29 ----
                var $holidays;
                var $holiday_color;
! 
                var $debug = False;
  //            var $debug = True;
***************
*** 815,818 ****
--- 815,838 ----
                                }
                        }
+                       else
+                       {
+                               // allow me (who I am logged in as) to set up 
an alarm
+                               // if I am a participant, but not the owner
+                               reset($event['participants']);
+                               while (list($user,$short_status) = 
each($event['participants']))
+                               {
+                                       if 
($GLOBALS['phpgw_info']['user']['account_id'] == $user)
+                                       {
+                                               $var = Array(
+                                                       'action_url_button'     
=> $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'),
+                                                       'action_text_button'    
=> lang('Alarm Management'),
+                                                       'action_confirm_button' 
=> '',
+                                                       'action_extra_field'    
=> '<input type="hidden" name="cal_id" value="'.$cal_id.'">'
+                                               );
+                                               $p->set_var($var);
+                                               echo 
$p->fp('out','form_button');
+                                       }
+                               }
+                       }
  
                        $var = Array(
***************
*** 1348,1352 ****
                                return;
                        }
!                       $home = strstr($GLOBALS['PHP_SELF'],'home') !== False;
                        // generate header and set global/member variables
                        //
--- 1368,1372 ----
                                return;
                        }
!                       $home = strstr($_SERVER['PHP_SELF'],'home') !== False;
                        // generate header and set global/member variables
                        //
***************
*** 1700,1704 ****
                        if (!$is_private)
                        {
!                               $opt .= '" onClick="location=\''.$view.'\'" 
style="cursor:pointer; cursor:hand;"';
                                $cel = '<a href="'.$view.'">';
                        }
--- 1720,1724 ----
                        if (!$is_private)
                        {
!                               $opt .= '" onClick="location=\''.$view.'\'" 
class="planner-cell"';
                                $cel = '<a href="'.$view.'">';
                        }
***************
*** 2494,2498 ****
                                . '  .event-holiday { background: 
'.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100 
80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n"
                                . '  .time { background: 
'.$this->theme['navbar_bg'].'; color: '.$this->theme['bg_text'].'; font: 
80%/110% '.$this->theme['font'].'; width: '.$time_width.'%; border: 1px 
'.$this->theme['navbar_text'].'; vertical-align: middle }'."\n"
!                               . '  .tablecell { width: 80px; height: 80px }';
                }
  
--- 2514,2519 ----
                                . '  .event-holiday { background: 
'.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100 
80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n"
                                . '  .time { background: 
'.$this->theme['navbar_bg'].'; color: '.$this->theme['bg_text'].'; font: 
80%/110% '.$this->theme['font'].'; width: '.$time_width.'%; border: 1px 
'.$this->theme['navbar_text'].'; vertical-align: middle }'."\n"
!                               . '  .tablecell { width: 80px; height: 80px 
}'."\n"
!                               . '  .planner-cell { cursor:pointer; 
cursor:hand; border: thin solid black; }';
                }
  
***************
*** 2634,2637 ****
--- 2655,2661 ----
                                if(@isset($event['alarm']) && 
count($event['alarm']) >= 1)
                                {
+                                       // if the alarm is to go off the day 
before the event
+                                       // the icon does not show up because of 
'alarm_today'
+                                       // - TOM
                                        
if($this->bo->alarm_today($event,$rawdate_offset,$starttime))
                                        {
***************
*** 3132,3139 ****
                        foreach($vars as $var)
                        {
!                               
$this->output_template_array($p,'row','list',$var);
                        }
  
!                       if($alarms && @isset($event['alarm']))
                        {
                                $p->set_var('th_bg',$this->theme['th_bg']);
--- 3156,3166 ----
                        foreach($vars as $var)
                        {
!                               if (strlen($var['data']))
!                               {
!                                       
$this->output_template_array($p,'row','list',$var);
!                               }
                        }
  
!                       if($alarms && count($event['alarm']))
                        {
                                $p->set_var('th_bg',$this->theme['th_bg']);
***************
*** 3146,3150 ****
                                        $var = Array(
                                                'field' => 
$icon.$GLOBALS['phpgw']->common->show_date($alarm['time']),
!                                               'data'  => $alarm['text']
                                        );
                                        
$this->output_template_array($p,'row','list',$var);
--- 3173,3177 ----
                                        $var = Array(
                                                'field' => 
$icon.$GLOBALS['phpgw']->common->show_date($alarm['time']),
!                                               'data'  => 'Email Notification'
                                        );
                                        
$this->output_template_array($p,'row','list',$var);
***************
*** 3747,3750 ****
--- 3774,3836 ----
                        }
                        
+ // Reminder
+                       // The user must use "Alarm Management" to 
change/modify an alarm
+                       // so only display the email reminder fields if this is 
a new event
+                       // i.e. not editing an existing event
+ 
+                       if ($event['id'] == 0) {
+                               // get defaults
+                               $days = 
$this->bo->prefs['calendar']['default_email_days'];
+                               $hours = 
$this->bo->prefs['calendar']['default_email_hours'];
+                               $min = 
$this->bo->prefs['calendar']['default_email_min'];
+                               if (count($event['alarm']) > 1)
+                               {
+                                       // this should not happen because when 
creating a new event
+                                       // only 1 alarm is displayed on the 
screen
+                                       // if the user wants more than 1 alarm 
they should
+                                       // use "Alarm Management"
+                                       echo '<!-- how did this happen, too 
many alarms -->'."\n";
+                               }
+                               // if there was an error pick up what the user 
entered
+                               if (@isset($event['alarm']))
+                               {
+                                       @reset($event['alarm']);
+                                       // just get the first one see above!!!
+                                       list($key,$alarm) = 
@each($event['alarm']);
+                                       $diff = $start - $alarm['time'];
+                                       $days = intval($diff / (24*3600));
+                                       $hours = intval(($diff - ($days * 24 * 
3600))/3600);
+                                       $min = intval(($diff - ($days * 24 * 
3600) - ($hours * 3600))/60);
+                               } 
+ 
+                               // days
+                               $dout = '<select name="cal[alarmdays]">'."\n";
+                               for($i=0;$i<32;$i++)
+                               {
+                                       $dout .= '<option 
value="'.$i.'"'.($i==$days?' selected':'').'>'.$i.'</option>'."\n";
+                               }
+                               $dout .= '</select>'."\n".' '.lang('days').' ';
+                               // hours
+                               $hout = '<select name="cal[alarmhours]">'."\n";
+                               for($i=0;$i<25;$i++)
+                               {
+                                       $hout .= '<option 
value="'.$i.'"'.($i==$hours?' selected':'').'>'.$i.'</option>'."\n";
+                               }
+                               $hout .= '</select>'."\n".' '.lang('hours').' ';
+                               // minutes
+                               $mout = '<select 
name="cal[alarmminutes]">'."\n";
+                               for($i=0;$i<61;$i++)
+                               {
+                                       $mout .= '<option 
value="'.$i.'"'.($i==$min?' selected':'').'>'.$i.'</option>'."\n";
+                               }
+                               $mout .= '</select>'."\n".' '.lang('minutes').' 
';
+ 
+                               $var[] = Array(
+                                       'field' => lang('Email Reminder'),
+                                       'data'  => 
$dout.$hout.$mout.lang('before the event')
+                               );
+ 
+                       }
+ 
                        for($i=0;$i<count($var);$i++)
                        {

Index: hook_settings.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/hook_settings.inc.php,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -r1.1.2.7 -r1.1.2.8
*** hook_settings.inc.php       29 May 2003 10:45:41 -0000      1.1.2.7
--- hook_settings.inc.php       23 Jul 2003 01:42:03 -0000      1.1.2.8
***************
*** 39,43 ****
        create_select_box('Receive summary of appointments','summary',$summary,
                'Do you want to receive a regulary summary of your 
appointsments via email?<br>The summary is sent to your standard email-address 
on the morning of that day or on Monday for weekly summarys.<br>It is only sent 
when you have any appointments on that day or week.');
! */    
        $updates = array(
                'no'             => lang('Never'),
--- 39,43 ----
        create_select_box('Receive summary of appointments','summary',$summary,
                'Do you want to receive a regulary summary of your 
appointsments via email?<br>The summary is sent to your standard email-address 
on the morning of that day or on Monday for weekly summarys.<br>It is only sent 
when you have any appointments on that day or week.');
! */
        $updates = array(
                'no'             => lang('Never'),
***************
*** 86,90 ****
                'This message is sent when you accept, tentative accept or 
reject an event.',
                '',$event_details,False);
!       
        create_check_box('Show invitations you rejected','show_rejected',
                'Should invitations you rejected still be shown in your 
calendar ?<br>You can only accept them later (eg. when your scheduling conflict 
is removed), if they are still shown in your calendar!');
--- 86,93 ----
                'This message is sent when you accept, tentative accept or 
reject an event.',
                '',$event_details,False);
!       create_notify('Notification messages for your 
alarms','notifyAlarm',5,50,
!               'This message is sent when you set an Alarm for a certain 
event. Include all information you might need.',
!               '',$event_details,False);
! 
        create_check_box('Show invitations you rejected','show_rejected',
                'Should invitations you rejected still be shown in your 
calendar ?<br>You can only accept them later (eg. when your scheduling conflict 
is removed), if they are still shown in your calendar!');





reply via email to

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