2006-12-15 21:05:47 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Calendar - ajax class
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Christian Binder <christian.binder@freakmail.de>
|
|
|
|
* @package calendar
|
|
|
|
* @copyright (c) 2006 by Christian Binder <christian.binder@freakmail.de>
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2008-06-07 20:11:56 +02:00
|
|
|
* @version $Id$
|
2006-12-15 21:05:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* General object of the calendar ajax class
|
|
|
|
*/
|
2008-06-07 19:45:33 +02:00
|
|
|
class calendar_ajax {
|
2006-12-15 21:05:47 +01:00
|
|
|
|
|
|
|
/**
|
2007-04-29 16:33:17 +02:00
|
|
|
* calendar object to handle events
|
2008-06-07 19:45:33 +02:00
|
|
|
*
|
|
|
|
* @var calendar_boupdate
|
2006-12-15 21:05:47 +01:00
|
|
|
*/
|
|
|
|
var $calendar;
|
|
|
|
|
2008-06-07 19:45:33 +02:00
|
|
|
function __construct()
|
2007-04-29 16:33:17 +02:00
|
|
|
{
|
2008-06-07 19:45:33 +02:00
|
|
|
$this->calendar = new calendar_boupdate();
|
2006-12-15 21:05:47 +01:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
/**
|
|
|
|
* moves an event to another date/time
|
|
|
|
*
|
|
|
|
* @param string $eventID id of the event which has to be moved
|
|
|
|
* @param string $calendarOwner the owner of the calendar the event is in
|
|
|
|
* @param string $targetDateTime the datetime where the event should be moved to, format: YYYYMMDD
|
|
|
|
* @param string $targetOwner the owner of the target calendar
|
|
|
|
* @return string XML response if no error occurs
|
|
|
|
*/
|
|
|
|
function moveEvent($eventId,$calendarOwner,$targetDateTime,$targetOwner)
|
|
|
|
{
|
|
|
|
// we do not allow dragging into another users calendar ATM
|
|
|
|
if(!$calendarOwner == $targetOwner)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-07-13 16:35:34 +02:00
|
|
|
$old_event=$event=$this->calendar->read($eventId);
|
2006-12-15 21:05:47 +01:00
|
|
|
$duration=$event['end']-$event['start'];
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
$event['start'] = $this->calendar->date2ts($targetDateTime);
|
|
|
|
$event['end'] = $event['start']+$duration;
|
2010-07-13 16:35:34 +02:00
|
|
|
$status_reset_to_unknown = false;
|
2010-11-02 12:00:41 +01:00
|
|
|
$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
|
|
|
|
foreach((array)$event['participants'] as $uid => $status)
|
2010-07-13 16:35:34 +02:00
|
|
|
{
|
2010-11-02 12:00:41 +01:00
|
|
|
calendar_so::split_status($status,$q,$r);
|
|
|
|
if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->calendar->user && $status != 'U')
|
|
|
|
{
|
|
|
|
$preferences = CreateObject('phpgwapi.preferences',$uid);
|
|
|
|
$part_prefs = $preferences->read_repository();
|
|
|
|
switch ($part_prefs['calendar']['reset_stati'])
|
2010-07-13 16:35:34 +02:00
|
|
|
{
|
2010-11-02 12:00:41 +01:00
|
|
|
case 'no':
|
|
|
|
break;
|
|
|
|
case 'startday':
|
|
|
|
if ($sameday) break;
|
|
|
|
default:
|
|
|
|
$status_reset_to_unknown = true;
|
2010-07-13 16:35:34 +02:00
|
|
|
$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
|
2010-11-02 12:00:41 +01:00
|
|
|
// todo: report reset status to user
|
2010-07-13 16:35:34 +02:00
|
|
|
}
|
2010-11-02 12:00:41 +01:00
|
|
|
}
|
2010-07-13 16:35:34 +02:00
|
|
|
}
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2007-01-15 23:58:32 +01:00
|
|
|
$conflicts=$this->calendar->update($event);
|
|
|
|
|
2009-06-08 18:21:14 +02:00
|
|
|
$response = new xajaxResponse();
|
2007-01-15 23:58:32 +01:00
|
|
|
if(!is_array($conflicts))
|
|
|
|
{
|
2013-04-18 14:28:07 +02:00
|
|
|
//$response->addRedirect(''); // old method, triggers IE on dragndrop to jump to the default app (idots/jerryr)
|
|
|
|
$response->addRedirect($GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiviews.index');
|
2007-01-15 23:58:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$response->addScriptCall(
|
|
|
|
'egw_openWindowCentered2',
|
2008-06-07 19:45:33 +02:00
|
|
|
$GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit
|
2007-01-15 23:58:32 +01:00
|
|
|
&cal_id='.$event['id']
|
|
|
|
.'&start='.$event['start']
|
|
|
|
.'&end='.$event['end']
|
|
|
|
.'&non_interactive=true'
|
|
|
|
.'&cancel_needs_refresh=true',
|
|
|
|
'',750,410);
|
|
|
|
}
|
2010-07-13 16:35:34 +02:00
|
|
|
if ($status_reset_to_unknown)
|
|
|
|
{
|
|
|
|
foreach((array)$event['participants'] as $uid => $status)
|
|
|
|
{
|
|
|
|
if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->calendar->user)
|
|
|
|
{
|
|
|
|
calendar_so::split_status($status,$q,$r);
|
|
|
|
$status = calendar_so::combine_status('U',$q,$r);
|
|
|
|
$this->calendar->set_status($event['id'], $uid, $status, 0, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-01-15 23:58:32 +01:00
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
return $response->getXML();
|
|
|
|
}
|
|
|
|
}
|