function edit_status()
 {
     unset($GLOBALS['phpgw_info']['flags']['noheader']);
     unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
     $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
     $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
     $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'] . ' - ' . lang('Change Status');
     //$GLOBALS['phpgw']->common->phpgw_header();
     $this->header(false);
     $cal_id = phpgw::get_var('cal_id', 'int', 'GET');
     $event = $this->bo->read_entry($cal_id);
     reset($event['participants']);
     if (!$event['participants'][$this->bo->owner]) {
         echo '<center>' . lang('The user %1 is not participating in this event!', $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)) . '</center>';
         return;
     }
     if (!$this->bo->check_perms(PHPGW_ACL_EDIT)) {
         $this->no_edit();
         return;
     }
     $freetime = phpgwapi_datetime::localdates(mktime(0, 0, 0, $event['start']['month'], $event['start']['mday'], $event['start']['year']) - phpgwapi_datetime::user_timezone());
     echo $this->timematrix(array('date' => $freetime, 'starttime' => $this->bo->splittime('000000', False), 'endtime' => 0, 'participants' => $event['participants'])) . '<br />';
     $event = $this->bo->read_entry($cal_id);
     $this->view_event($event);
     $GLOBALS['phpgw']->template->pfp('phpgw_body', 'view_event');
     echo $this->get_response($event['id']);
 }
Exemplo n.º 2
0
/**************************************************************************\
  * phpGroupWare - Calendar                                                  *
  * http://www.phpgroupware.org                                              *
  * Based on Webcalendar by Craig Knudsen <*****@*****.**>               *
  *          http://www.radix.net/~cknudsen                                  *
  * Written by Mark Peters <*****@*****.**>                        *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/
/* $Id$ */
global $calendar_id;
$d1 = strtolower(substr($GLOBALS['phpgw_info']['server']['app_inc'], 0, 3));
if ($d1 == 'htt' || $d1 == 'ftp') {
    echo 'Failed attempt to break in via an old Security Hole!<br />' . "\n";
    $phpgw->common->phpgw_exit();
}
unset($d1);
if ($calendar_id) {
    $GLOBALS['phpgw']->translation->add_app('calendar');
    $cal = CreateObject('calendar.uicalendar');
    //echo "Event ID: $calendar_id<br />\n";
    phpgw::import_class('phpgwapi.datetime');
    if ($event = $cal->bo->read_entry($calendar_id)) {
        echo $cal->timematrix(array('date' => phpgwapi_datetime::localdates(mktime(0, 0, 0, $event['start']['month'], $event['start']['mday'], $event['start']['year']) - $phpgw->calendar->tz_offset), 'starttime' => $cal->bo->splittime('000000', False), 'endtime' => 0, 'participants' => $event['participants'])) . '</td></tr><tr><td>' . $cal->view_event($event) . '</td></tr><tr><td align="center">' . $cal->get_response($calendar_id);
    }
    unset($cal);
    unset($event);
}
 function fetch_event($event_id, $options = '')
 {
     if (!isset($this->stream)) {
         return False;
     }
     $event_id = intval($event_id);
     $this->stream->lock(array('phpgw_cal', 'phpgw_cal_user', 'phpgw_cal_repeats', 'phpgw_cal_extra'));
     $this->stream->query('SELECT * FROM phpgw_cal WHERE cal_id=' . $event_id, __LINE__, __FILE__);
     if ($this->stream->num_rows() > 0) {
         $this->event_init();
         $this->stream->next_record();
         // Load the calendar event data from the db into $event structure
         // Use http://www.php.net/manual/en/function.mcal-fetch-event.php as the reference
         $this->add_attribute('owner', intval($this->stream->f('owner')));
         $this->add_attribute('id', intval($this->stream->f('cal_id')));
         $this->add_attribute('uid', "phpgw://{$_SERVER['SERVER_NAME']}/calendar/" . (int) $this->stream->f('cal_id'));
         $this->set_class(!!$this->stream->f('is_public'));
         $this->set_category($this->stream->f('category'));
         $this->set_title($GLOBALS['phpgw']->strip_html($this->stream->f('title', true)));
         $this->set_description($GLOBALS['phpgw']->strip_html($this->stream->f('description', true)));
         $this->add_attribute('location', $GLOBALS['phpgw']->strip_html($this->stream->f('location', true)));
         $this->add_attribute('reference', intval($this->stream->f('reference')));
         // This is the preferred method once everything is normalized...
         //$this->event->alarm = intval($this->stream->f('alarm'));
         // But until then, do it this way...
         //Legacy Support (New)
         $datetime = phpgwapi_datetime::localdates($this->stream->f('datetime'));
         $this->set_start($datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second']);
         $datetime = phpgwapi_datetime::localdates($this->stream->f('mdatetime'));
         $this->set_date('modtime', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second']);
         $datetime = phpgwapi_datetime::localdates($this->stream->f('edatetime'));
         $this->set_end($datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second']);
         //Legacy Support
         $this->add_attribute('priority', intval($this->stream->f('priority')));
         if ($this->stream->f('cal_group') || $this->stream->f('groups') != 'NULL') {
             $groups = explode(',', $this->stream->f('groups'));
             for ($j = 1; $j < count($groups) - 1; $j++) {
                 $this->add_attribute('groups', $groups[$j], $j - 1);
             }
         }
         $this->stream->query('SELECT * FROM phpgw_cal_repeats WHERE cal_id=' . $event_id, __LINE__, __FILE__);
         if ($this->stream->num_rows()) {
             $this->stream->next_record();
             $this->add_attribute('recur_type', intval($this->stream->f('recur_type')));
             $this->add_attribute('recur_interval', intval($this->stream->f('recur_interval')));
             $enddate = $this->stream->f('recur_enddate');
             if ($enddate != 0 && $enddate != Null) {
                 $datetime = phpgwapi_datetime::localdates($enddate);
                 $this->add_attribute('recur_enddate', $datetime['year'], 'year');
                 $this->add_attribute('recur_enddate', $datetime['month'], 'month');
                 $this->add_attribute('recur_enddate', $datetime['day'], 'mday');
                 $this->add_attribute('recur_enddate', $datetime['hour'], 'hour');
                 $this->add_attribute('recur_enddate', $datetime['minute'], 'min');
                 $this->add_attribute('recur_enddate', $datetime['second'], 'sec');
             } else {
                 $this->add_attribute('recur_enddate', 0, 'year');
                 $this->add_attribute('recur_enddate', 0, 'month');
                 $this->add_attribute('recur_enddate', 0, 'mday');
                 $this->add_attribute('recur_enddate', 0, 'hour');
                 $this->add_attribute('recur_enddate', 0, 'min');
                 $this->add_attribute('recur_enddate', 0, 'sec');
             }
             $this->add_attribute('recur_enddate', 0, 'alarm');
             if ($this->debug) {
                 echo 'Event ID#' . $this->event['id'] . ' : Enddate = ' . $enddate . "<br />\n";
             }
             $this->add_attribute('recur_data', $this->stream->f('recur_data'));
             $exception_list = $this->stream->f('recur_exception');
             $exceptions = array();
             if (strpos(' ' . $exception_list, ',')) {
                 $exceptions = explode(',', $exception_list);
             } elseif ($exception_list != '') {
                 $exceptions[] = $exception_list;
             }
             $this->add_attribute('recur_exception', $exceptions);
         } else {
             $this->add_attribute('recur_type', 0);
         }
         //Legacy Support
         $this->stream->query('SELECT * FROM phpgw_cal_user WHERE cal_id=' . $event_id, __LINE__, __FILE__);
         if ($this->stream->num_rows()) {
             while ($this->stream->next_record()) {
                 if (intval($this->stream->f('cal_login')) == intval($this->user)) {
                     $this->add_attribute('users_status', $this->stream->f('cal_status'));
                 }
                 $this->add_attribute('participants', $this->stream->f('cal_status'), intval($this->stream->f('cal_login')));
             }
         }
         // Custom fields
         $this->stream->query('SELECT * FROM phpgw_cal_extra WHERE cal_id=' . $event_id, __LINE__, __FILE__);
         if ($this->stream->num_rows()) {
             while ($this->stream->next_record()) {
                 $this->add_attribute('#' . $this->stream->f('cal_extra_name'), $this->stream->f('cal_extra_value'));
             }
         }
         /* OLD-ALARM
         			if($this->event['reference'])
         			{
         				// What is event['reference']???
         				$alarm_cal_id = $event_id.','.$this->event['reference'];
         			}
         			else
         			{
         				$alarm_cal_id = $event_id;
         			}
         
         			//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())
         			{
         				while($this->stream->next_record())
         				{
         					$this->event['alarm'][] = array(
         						'id'		=> intval($this->stream->f('alarm_id')),
         						'time'	=> intval($this->stream->f('cal_time')),
         						'text'	=> $this->stream->f('cal_text'),
         						'enabled'	=> intval($this->stream->f('alarm_enabled'))
         					);
         				}
         			}
         */
     } else {
         $this->event = False;
     }
     $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;
 }