diff options
Diffstat (limited to 'apps/calendar')
70 files changed, 1730 insertions, 688 deletions
diff --git a/apps/calendar/ajax/calendar/activation.php b/apps/calendar/ajax/calendar/activation.php index 7677d85aff3..3523590aa27 100644..100755 --- a/apps/calendar/ajax/calendar/activation.php +++ b/apps/calendar/ajax/calendar/activation.php @@ -6,14 +6,14 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $calendarid = $_POST['calendarid']; $calendar = OC_Calendar_App::getCalendar($calendarid);//access check OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); $calendar = OC_Calendar_App::getCalendar($calendarid); -OC_JSON::success(array( +OCP\JSON::success(array( 'active' => $calendar['active'], 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), )); diff --git a/apps/calendar/ajax/calendar/delete.php b/apps/calendar/ajax/calendar/delete.php index a2f5311731c..a36a0534650 100644..100755 --- a/apps/calendar/ajax/calendar/delete.php +++ b/apps/calendar/ajax/calendar/delete.php @@ -5,17 +5,17 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $cal = $_POST["calendarid"]; $calendar = OC_Calendar_App::getCalendar($cal); $del = OC_Calendar_Calendar::deleteCalendar($cal); if($del == true){ - OC_JSON::success(); + OCP\JSON::success(); }else{ - OC_JSON::error(array('error'=>'dberror')); + OCP\JSON::error(array('error'=>'dberror')); } ?> diff --git a/apps/calendar/ajax/calendar/edit.form.php b/apps/calendar/ajax/calendar/edit.form.php index 8922b3eba4e..17118c5165f 100644..100755 --- a/apps/calendar/ajax/calendar/edit.form.php +++ b/apps/calendar/ajax/calendar/edit.form.php @@ -6,9 +6,9 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); $calendar = OC_Calendar_App::getCalendar($_GET['calendarid']); diff --git a/apps/calendar/ajax/calendar/edit.php b/apps/calendar/ajax/calendar/edit.php index 8922b3eba4e..17118c5165f 100644..100755 --- a/apps/calendar/ajax/calendar/edit.php +++ b/apps/calendar/ajax/calendar/edit.php @@ -6,9 +6,9 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); $calendar = OC_Calendar_App::getCalendar($_GET['calendarid']); diff --git a/apps/calendar/ajax/calendar/new.form.php b/apps/calendar/ajax/calendar/new.form.php index 6e7423cbe92..fa30b871e42 100644..100755 --- a/apps/calendar/ajax/calendar/new.form.php +++ b/apps/calendar/ajax/calendar/new.form.php @@ -6,10 +6,9 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); $calendar = array( 'id' => 'new', diff --git a/apps/calendar/ajax/calendar/new.php b/apps/calendar/ajax/calendar/new.php index 228e6247724..4b8688e3d1d 100644..100755 --- a/apps/calendar/ajax/calendar/new.php +++ b/apps/calendar/ajax/calendar/new.php @@ -6,32 +6,32 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); if(trim($_POST['name']) == ''){ - OC_JSON::error(array('message'=>'empty')); + OCP\JSON::error(array('message'=>'empty')); exit; } -$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); foreach($calendars as $cal){ if($cal['displayname'] == $_POST['name']){ - OC_JSON::error(array('message'=>'namenotavailable')); + OCP\JSON::error(array('message'=>'namenotavailable')); exit; } } -$userid = OC_User::getUser(); +$userid = OCP\USER::getUser(); $calendarid = OC_Calendar_Calendar::addCalendar($userid, strip_tags($_POST['name']), 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']); OC_Calendar_Calendar::setCalendarActive($calendarid, 1); $calendar = OC_Calendar_Calendar::find($calendarid); $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $calendar); -OC_JSON::success(array( +OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), )); diff --git a/apps/calendar/ajax/calendar/overview.php b/apps/calendar/ajax/calendar/overview.php index 2f73f5d0710..586bf3db814 100644..100755 --- a/apps/calendar/ajax/calendar/overview.php +++ b/apps/calendar/ajax/calendar/overview.php @@ -6,10 +6,10 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); + +$l10n = OC_L10N::get('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $output = new OC_TEMPLATE("calendar", "part.choosecalendar"); $output -> printpage(); ?> diff --git a/apps/calendar/ajax/calendar/update.php b/apps/calendar/ajax/calendar/update.php index f400c8c14b4..408ac900912 100644..100755 --- a/apps/calendar/ajax/calendar/update.php +++ b/apps/calendar/ajax/calendar/update.php @@ -6,20 +6,20 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); if(trim($_POST['name']) == ''){ - OC_JSON::error(array('message'=>'empty')); + OCP\JSON::error(array('message'=>'empty')); exit; } -$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); foreach($calendars as $cal){ if($cal['displayname'] == $_POST['name'] && $cal['id'] != $_POST['id']){ - OC_JSON::error(array('message'=>'namenotavailable')); + OCP\JSON::error(array('message'=>'namenotavailable')); exit; } } @@ -32,7 +32,7 @@ OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); $calendar = OC_Calendar_App::getCalendar($calendarid); $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $calendar); -OC_JSON::success(array( +OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), )); diff --git a/apps/calendar/ajax/categories/rescan.php b/apps/calendar/ajax/categories/rescan.php index 0fd878ed8f9..93e8c50954a 100644..100755 --- a/apps/calendar/ajax/categories/rescan.php +++ b/apps/calendar/ajax/categories/rescan.php @@ -6,24 +6,24 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); foreach ($_POST as $key=>$element) { debug('_POST: '.$key.'=>'.print_r($element, true)); } function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); - OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG); + OCP\JSON::error(array('data' => array('message' => $msg))); + OCP\Util::writeLog('calendar','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG); exit(); } function debug($msg) { - OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG); + OCP\Util::writeLog('calendar','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG); } -$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); if(count($calendars) == 0) { bailOut(OC_Calendar_App::$l10n->t('No calendars found.')); } @@ -39,4 +39,4 @@ if(count($events) == 0) { OC_Calendar_App::scanCategories($events); $categories = OC_Calendar_App::getCategoryOptions(); -OC_JSON::success(array('data' => array('categories'=>$categories))); +OCP\JSON::success(array('data' => array('categories'=>$categories))); diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php index ae48b229b16..2c2d09ccb12 100644..100755 --- a/apps/calendar/ajax/changeview.php +++ b/apps/calendar/ajax/changeview.php @@ -1,14 +1,12 @@ <?php /** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ - -require_once ("../../../lib/base.php"); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $view = $_GET['v']; switch($view){ case 'agendaWeek': @@ -16,9 +14,9 @@ switch($view){ case 'list': break; default: - OC_JSON::error(array('message'=>'unexspected parameter: ' . $view)); + OCP\JSON::error(array('message'=>'unexspected parameter: ' . $view)); exit; } -OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'currentview', $view); -OC_JSON::success(); +OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'currentview', $view); +OCP\JSON::success(); ?> diff --git a/apps/calendar/ajax/event/delete.php b/apps/calendar/ajax/event/delete.php index 862dec6bf5b..cb30621af4d 100644..100755 --- a/apps/calendar/ajax/event/delete.php +++ b/apps/calendar/ajax/event/delete.php @@ -5,15 +5,16 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + -$l10n = new OC_L10N('calendar'); - -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $id = $_POST['id']; -$event_object = OC_Calendar_App::getEventObject($id); +$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); +if($access != 'owner' && $access != 'rw'){ + OCP\JSON::error(array('message'=>'permission denied')); + exit; +} $result = OC_Calendar_Object::delete($id); -OC_JSON::success(); -?> +OCP\JSON::success(); diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index 98c22eb0206..91d07d3897a 100644..100755 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -6,30 +6,36 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + -if(!OC_USER::isLoggedIn()) { +if(!OCP\User::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkAppEnabled('calendar'); $id = $_GET['id']; -$data = OC_Calendar_App::getEventObject($id); +$data = OC_Calendar_App::getEventObject($id, true, true); + +if(!$data){ + OCP\JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar')))); + exit; +} +$access = OC_Calendar_App::getaccess($id, OC_Calendar_Share::EVENT); $object = OC_VObject::parse($data['calendardata']); $vevent = $object->VEVENT; $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); switch($dtstart->getDateType()) { - case Sabre_VObject_Element_DateTime::LOCALTZ: - case Sabre_VObject_Element_DateTime::LOCAL: + case Sabre_VObject_Property_DateTime::LOCALTZ: + case Sabre_VObject_Property_DateTime::LOCAL: $startdate = $dtstart->getDateTime()->format('d-m-Y'); $starttime = $dtstart->getDateTime()->format('H:i'); $enddate = $dtend->getDateTime()->format('d-m-Y'); $endtime = $dtend->getDateTime()->format('H:i'); $allday = false; break; - case Sabre_VObject_Element_DateTime::DATE: + case Sabre_VObject_Property_DateTime::DATE: $startdate = $dtstart->getDateTime()->format('d-m-Y'); $starttime = ''; $dtend->getDateTime()->modify('-1 day'); @@ -182,8 +188,12 @@ if($data['repeating'] == 1){ }else{ $repeat['repeat'] = 'doesnotrepeat'; } - -$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +if($access == 'owner'){ + $calendar_options = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); +}else{ + $calendar_options = array(OC_Calendar_App::getCalendar($data['calendarid'], false)); +} +$category_options = OC_Calendar_App::getCategoryOptions(); $repeat_options = OC_Calendar_App::getRepeatOptions(); $repeat_end_options = OC_Calendar_App::getEndOptions(); $repeat_month_options = OC_Calendar_App::getMonthOptions(); @@ -195,8 +205,14 @@ $repeat_bymonth_options = OC_Calendar_App::getByMonthOptions(); $repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions(); $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); -$tmpl = new OC_Template('calendar', 'part.editevent'); -$tmpl->assign('id', $id); +if($access == 'owner' || $access == 'rw'){ + $tmpl = new OC_Template('calendar', 'part.editevent'); +}elseif($access == 'r'){ + $tmpl = new OC_Template('calendar', 'part.showevent'); +} + +$tmpl->assign('eventid', $id); +$tmpl->assign('access', $access); $tmpl->assign('lastmodified', $lastmodified); $tmpl->assign('calendar_options', $calendar_options); $tmpl->assign('repeat_options', $repeat_options); diff --git a/apps/calendar/ajax/event/edit.php b/apps/calendar/ajax/event/edit.php index 64daffddef0..e615fb093de 100644..100755 --- a/apps/calendar/ajax/event/edit.php +++ b/apps/calendar/ajax/event/edit.php @@ -6,28 +6,41 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); + +$id = $_POST['id']; + +if(!array_key_exists('calendar', $_POST)){ + $cal = OC_Calendar_Object::getCalendarid($id); + $_POST['calendar'] = $cal; +}else{ + $cal = $_POST['calendar']; +} + +$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); +if($access != 'owner' && $access != 'rw'){ + OCP\JSON::error(array('message'=>'permission denied')); + exit; +} $errarr = OC_Calendar_Object::validateRequest($_POST); if($errarr){ //show validate errors - OC_JSON::error($errarr); + OCP\JSON::error($errarr); exit; }else{ - $id = $_POST['id']; - $cal = $_POST['calendar']; - $data = OC_Calendar_App::getEventObject($id); + $data = OC_Calendar_App::getEventObject($id, false, false); $vcalendar = OC_VObject::parse($data['calendardata']); OC_Calendar_App::isNotModified($vcalendar->VEVENT, $_POST['lastmodified']); OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar); - $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); + OC_Calendar_Object::edit($id, $vcalendar->serialize()); if ($data['calendarid'] != $cal) { OC_Calendar_Object::moveToCalendar($id, $cal); } - OC_JSON::success(); + OCP\JSON::success(); } ?> diff --git a/apps/calendar/ajax/event/move.php b/apps/calendar/ajax/event/move.php index 8150fdbaa32..8added69143 100644..100755 --- a/apps/calendar/ajax/event/move.php +++ b/apps/calendar/ajax/event/move.php @@ -5,39 +5,42 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); + +OCP\JSON::checkLoggedIn(); $id = $_POST['id']; - -$vcalendar = OC_Calendar_App::getVCalendar($id); +$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); +if($access != 'owner' && $access != 'rw'){ + OCP\JSON::error(array('message'=>'permission denied')); + exit; +} +$vcalendar = OC_Calendar_App::getVCalendar($id, false, false); $vevent = $vcalendar->VEVENT; $allday = $_POST['allDay']; $delta = new DateInterval('P0D'); $delta->d = $_POST['dayDelta']; $delta->i = $_POST['minuteDelta']; - OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']); $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); $start_type = $dtstart->getDateType(); $end_type = $dtend->getDateType(); -if ($allday && $start_type != Sabre_VObject_Element_DateTime::DATE){ - $start_type = $end_type = Sabre_VObject_Element_DateTime::DATE; +if ($allday && $start_type != Sabre_VObject_Property_DateTime::DATE){ + $start_type = $end_type = Sabre_VObject_Property_DateTime::DATE; $dtend->setDateTime($dtend->getDateTime()->modify('+1 day'), $end_type); } -if (!$allday && $start_type == Sabre_VObject_Element_DateTime::DATE){ - $start_type = $end_type = Sabre_VObject_Element_DateTime::LOCALTZ; +if (!$allday && $start_type == Sabre_VObject_Property_DateTime::DATE){ + $start_type = $end_type = Sabre_VObject_Property_DateTime::LOCALTZ; } $dtstart->setDateTime($dtstart->getDateTime()->add($delta), $start_type); $dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type); unset($vevent->DURATION); -$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); -$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); +$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Property_DateTime::UTC); +$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Property_DateTime::UTC); $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); $lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); -OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); +OCP\JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php index 838002a3a09..42cdb81642e 100644..100755 --- a/apps/calendar/ajax/event/new.form.php +++ b/apps/calendar/ajax/event/new.form.php @@ -6,15 +6,15 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + -if(!OC_USER::isLoggedIn()) { +if(!OCP\User::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkAppEnabled('calendar'); if (!isset($_POST['start'])){ - OC_JSON::error(); + OCP\JSON::error(); die; } $start = $_POST['start']; @@ -22,16 +22,16 @@ $end = $_POST['end']; $allday = $_POST['allday']; if (!$end){ - $duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', '60'); + $duration = OCP\Config::getUserValue( OCP\USER::getUser(), 'calendar', 'duration', '60'); $end = $start + ($duration * 60); } $start = new DateTime('@'.$start); $end = new DateTime('@'.$end); -$timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $start->setTimezone(new DateTimeZone($timezone)); $end->setTimezone(new DateTimeZone($timezone)); -$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$calendar_options = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); $repeat_options = OC_Calendar_App::getRepeatOptions(); $repeat_end_options = OC_Calendar_App::getEndOptions(); $repeat_month_options = OC_Calendar_App::getMonthOptions(); @@ -44,6 +44,7 @@ $repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions(); $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); $tmpl = new OC_Template('calendar', 'part.newevent'); +$tmpl->assign('access', 'owner'); $tmpl->assign('calendar_options', $calendar_options); $tmpl->assign('repeat_options', $repeat_options); $tmpl->assign('repeat_month_options', $repeat_month_options); diff --git a/apps/calendar/ajax/event/new.php b/apps/calendar/ajax/event/new.php index 59fda79da73..72d57be03bf 100644..100755 --- a/apps/calendar/ajax/event/new.php +++ b/apps/calendar/ajax/event/new.php @@ -6,22 +6,20 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + -$l10n = new OC_L10N('calendar'); - -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $errarr = OC_Calendar_Object::validateRequest($_POST); if($errarr){ //show validate errors - OC_JSON::error($errarr); + OCP\JSON::error($errarr); exit; }else{ $cal = $_POST['calendar']; $vcalendar = OC_Calendar_Object::createVCalendarFromRequest($_POST); $result = OC_Calendar_Object::add($cal, $vcalendar->serialize()); - OC_JSON::success(); + OCP\JSON::success(); } ?> diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php index aa2d420e77d..0dc0a5fca7f 100644..100755 --- a/apps/calendar/ajax/event/resize.php +++ b/apps/calendar/ajax/event/resize.php @@ -5,12 +5,18 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); + +OCP\JSON::checkLoggedIn(); $id = $_POST['id']; -$vcalendar = OC_Calendar_App::getVCalendar($id); +$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); +if($access != 'owner' && $access != 'rw'){ + OCP\JSON::error(array('message'=>'permission denied')); + exit; +} + +$vcalendar = OC_Calendar_App::getVCalendar($id, false, false); $vevent = $vcalendar->VEVENT; $delta = new DateInterval('P0D'); @@ -24,9 +30,9 @@ $end_type = $dtend->getDateType(); $dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type); unset($vevent->DURATION); -$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); -$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); +$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Property_DateTime::UTC); +$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Property_DateTime::UTC); -$result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); +OC_Calendar_Object::edit($id, $vcalendar->serialize()); $lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); -OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); +OCP\JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index c62f93c540e..b86620329e3 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -1,109 +1,24 @@ <?php /** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ -require_once ('../../../lib/base.php'); + require_once('when/When.php'); -$l = new OC_L10N('calendar'); -$unnamed = $l->t('unnamed'); -function create_return_event($event, $vevent){ - $return_event = array(); - global $unnamed; - $return_event['id'] = (int)$event['id']; - $return_event['title'] = htmlspecialchars(($event['summary']!=NULL || $event['summary'] != '')?$event['summary']: $unnamed); - $return_event['description'] = isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):''; - $last_modified = $vevent->__get('LAST-MODIFIED'); - if ($last_modified){ - $lastmodified = $last_modified->getDateTime()->format('U'); - }else{ - $lastmodified = 0; - } - $return_event['lastmodified'] = (int)$lastmodified; - return $return_event; -} -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); -if(version_compare(PHP_VERSION, '5.3.0', '>=')){ - $start = DateTime::createFromFormat('U', $_GET['start']); - $end = DateTime::createFromFormat('U', $_GET['end']); -}else{ - $start = new DateTime('@' . $_GET['start']); - $end = new DateTime('@' . $_GET['end']); -} +$start = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['start']):new DateTime('@' . $_GET['start']); +$end = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['end']):new DateTime('@' . $_GET['end']); -$calendar_id = $_GET['calendar_id']; -if (is_numeric($calendar_id)) { - $calendar = OC_Calendar_App::getCalendar($calendar_id); - OC_Response::enableCaching(0); - OC_Response::setETagHeader($calendar['ctag']); - $events = OC_Calendar_Object::allInPeriod($calendar_id, $start, $end); -} else { - $events = array(); - OC_Hook::emit('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events)); -} +$events = OC_Calendar_App::getrequestedEvents($_GET['calendar_id'], $start, $end); -$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); -$return = array(); +$output = array(); foreach($events as $event){ - if (isset($event['calendardata'])) { - $object = OC_VObject::parse($event['calendardata']); - $vevent = $object->VEVENT; - } else { - $vevent = $event['vevent']; - } - - $return_event = create_return_event($event, $vevent); - - $dtstart = $vevent->DTSTART; - $start_dt = $dtstart->getDateTime(); - $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); - $end_dt = $dtend->getDateTime(); - if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ - $return_event['allDay'] = true; - }else{ - $return_event['allDay'] = false; - $start_dt->setTimezone(new DateTimeZone($user_timezone)); - $end_dt->setTimezone(new DateTimeZone($user_timezone)); - } - - //Repeating Events - if($event['repeating'] == 1){ - $duration = (double) $end_dt->format('U') - (double) $start_dt->format('U'); - $r = new When(); - $r->recur($start_dt)->rrule((string) $vevent->RRULE); - while($result = $r->next()){ - if($result < $start){ - continue; - } - if($result > $end){ - break; - } - if($return_event['allDay'] == true){ - $return_event['start'] = $result->format('Y-m-d'); - $return_event['end'] = date('Y-m-d', $result->format('U') + --$duration); - }else{ - $return_event['start'] = $result->format('Y-m-d H:i:s'); - $return_event['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration); - } - $return[] = $return_event; - } - }else{ - if($return_event['allDay'] == true){ - $return_event['start'] = $start_dt->format('Y-m-d'); - $end_dt->modify('-1 sec'); - $return_event['end'] = $end_dt->format('Y-m-d'); - }else{ - $return_event['start'] = $start_dt->format('Y-m-d H:i:s'); - $return_event['end'] = $end_dt->format('Y-m-d H:i:s'); - } - $return[] = $return_event; - } + $output = $output + OC_Calendar_App::generateEventOutput($event, $start, $end); } -OC_JSON::encodedPrint($return); -?> +OCP\JSON::encodedPrint($output); diff --git a/apps/calendar/ajax/import/dialog.php b/apps/calendar/ajax/import/dialog.php index 2e002092150..e686066a993 100644..100755 --- a/apps/calendar/ajax/import/dialog.php +++ b/apps/calendar/ajax/import/dialog.php @@ -6,10 +6,9 @@ * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_Util::checkAppEnabled('calendar'); -$l10n = new OC_L10N('calendar'); + +OCP\JSON::checkLoggedIn(); +OCP\App::checkAppEnabled('calendar'); $tmpl = new OC_Template('calendar', 'part.import'); $tmpl->assign('path', $_POST['path']); $tmpl->assign('filename', $_POST['filename']); diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php index d0bdab4f0d5..202af1eb46e 100644..100755 --- a/apps/calendar/ajax/import/import.php +++ b/apps/calendar/ajax/import/import.php @@ -7,11 +7,11 @@ */ //check for calendar rights or create new one ob_start(); -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_Util::checkAppEnabled('calendar'); -$nl = "\n\r"; -$progressfile = OC::$APPSROOT . '/apps/calendar/import_tmp/' . md5(session_id()) . '.txt'; +OCP\JSON::checkLoggedIn(); +OCP\App::checkAppEnabled('calendar'); +$nl="\r\n"; +$comps = array('VEVENT'=>true, 'VTODO'=>true, 'VJOURNAL'=>true); +$progressfile = 'import_tmp/' . md5(session_id()) . '.txt'; if(is_writable('import_tmp/')){ $progressfopen = fopen($progressfile, 'w'); fwrite($progressfopen, '10'); @@ -19,95 +19,104 @@ if(is_writable('import_tmp/')){ } $file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); if($_POST['method'] == 'new'){ - $id = OC_Calendar_Calendar::addCalendar(OC_User::getUser(), $_POST['calname']); + $id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), $_POST['calname']); OC_Calendar_Calendar::setCalendarActive($id, 1); }else{ $calendar = OC_Calendar_App::getCalendar($_POST['id']); - if($calendar['userid'] != OC_USER::getUser()){ - OC_JSON::error(); + if($calendar['userid'] != OCP\USER::getUser()){ + OCP\JSON::error(); exit(); } $id = $_POST['id']; } -//analyse the calendar file if(is_writable('import_tmp/')){ $progressfopen = fopen($progressfile, 'w'); fwrite($progressfopen, '20'); fclose($progressfopen); } -$searchfor = array('VEVENT', 'VTODO', 'VJOURNAL'); -$parts = $searchfor; -$filearr = explode($nl, $file); -$inelement = false; -$parts = array(); +// normalize the newlines +$file = str_replace(array("\r","\n\n"), array("\n","\n"), $file); +$lines = explode("\n", $file); +unset($file); +if(is_writable('import_tmp/')){ + $progressfopen = fopen($progressfile, 'w'); + fwrite($progressfopen, '30'); + fclose($progressfopen); +} +// analyze the file, group components by uid, and keep refs to originating calendar object +// $cals is array calendar objects, keys are 1st line# $cal, ie array( $cal => $caldata ) +// $caldata is array( 'first' => 1st component line#, 'last' => last comp line#, 'end' => end line# ) +// $caldata is used to create prefix/suffix strings when building import text +// $uids is array of component arrays, keys are $uid, ie array( $uid => array( $beginlineno => $component ) ) +// $component is array( 'end' => end line#, 'cal'=> $cal ) +$comp=$uid=$cal=false; +$cals=$uids=array(); $i = 0; -foreach($filearr as $line){ - foreach($searchfor as $search){ - if(substr_count($line, $search) == 1){ - list($attr, $val) = explode(':', $line); - if($attr == 'BEGIN'){ - $parts[]['begin'] = $i; - $inelement = true; +foreach($lines as $line) { + + if(strpos($line, ':')!==false) { + list($attr, $val) = explode(':', strtoupper($line)); + if ($attr == 'BEGIN' && $val == 'VCALENDAR') { + $cal = $i; + $cals[$cal] = array('first'=>$i,'last'=>$i,'end'=>$i); + } elseif ($attr =='BEGIN' && $cal!==false && isset($comps[$val])) { + $comp = $val; + $beginNo = $i; + } elseif ($attr == 'END' && $cal!==false && $val == 'VCALENDAR') { + if($comp!==false) { + unset($cals[$cal]); // corrupt calendar, unset it + } else { + $cals[$cal]['end'] = $i; + } + $comp=$uid=$cal=false; // reset calendar + } elseif ($attr == 'END' && $comp!==false && $val == $comp) { + if(! $uid) { + $uid = OC_Calendar_Object::createUID(); } - if($attr == 'END'){ - $parts[count($parts) - 1]['end'] = $i; - $inelement = false; + $uids[$uid][$beginNo] = array('end'=>$i, 'cal'=>$cal); + if ($cals[$cal]['first'] == $cal) { + $cals[$cal]['first'] = $beginNo; } + $cals[$cal]['last'] = $i; + $comp=$uid=false; // reset component + } elseif ($attr =="UID" && $comp!==false) { + list($attr, $uid) = explode(':', $line); } } $i++; } -//import the calendar +// import the calendar if(is_writable('import_tmp/')){ $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '40'); + fwrite($progressfopen, '60'); fclose($progressfopen); } -$start = ''; -for ($i = 0; $i < $parts[0]['begin']; $i++) { - if($i == 0){ - $start = $filearr[0]; - }else{ - $start .= $nl . $filearr[$i]; - } -} -$end = ''; -for($i = $parts[count($parts) - 1]['end'] + 1;$i <= count($filearr) - 1; $i++){ - if($i == $parts[count($parts) - 1]['end'] + 1){ - $end = $filearr[$parts[count($parts) - 1]['end'] + 1]; - }else{ - $end .= $nl . $filearr[$i]; - } -} -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '50'); - fclose($progressfopen); -} -$importready = array(); -foreach($parts as $part){ - for($i = $part['begin']; $i <= $part['end'];$i++){ - if($i == $part['begin']){ - $content = $filearr[$i]; - }else{ - $content .= $nl . $filearr[$i]; +foreach($uids as $uid) { + + $prefix=$suffix=$content=array(); + foreach($uid as $begin=>$details) { + + $cal = $details['cal']; + if(!isset($cals[$cal])) { + continue; // from corrupt/incomplete calendar + } + $cdata = $cals[$cal]; + // if we have multiple components from different calendar objects, + // we should really merge their elements (enhancement?) -- 1st one wins for now. + if(! count($prefix)) { + $prefix = array_slice($lines, $cal, $cdata['first'] - $cal); } + if(! count($suffix)) { + $suffix = array_slice($lines, $cdata['last']+1, $cdata['end'] - $cdata['last']); + } + $content = array_merge($content, array_slice($lines, $begin, $details['end'] - $begin + 1)); } - $importready[] = $start . $nl . $content . $nl . $end; -} -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '70'); - fclose($progressfopen); -} -if(count($parts) == 1){ - OC_Calendar_Object::add($id, $file); -}else{ - foreach($importready as $import){ + if(count($content)) { + $import = join($nl, array_merge($prefix, $content, $suffix)) . $nl; OC_Calendar_Object::add($id, $import); } } -//done the import +// finished import if(is_writable('import_tmp/')){ $progressfopen = fopen($progressfile, 'w'); fwrite($progressfopen, '100'); @@ -117,4 +126,4 @@ sleep(3); if(is_writable('import_tmp/')){ unlink($progressfile); } -OC_JSON::success(); +OCP\JSON::success(); diff --git a/apps/calendar/ajax/settings/getfirstday.php b/apps/calendar/ajax/settings/getfirstday.php index cab5870509a..23b71bba043 100644..100755 --- a/apps/calendar/ajax/settings/getfirstday.php +++ b/apps/calendar/ajax/settings/getfirstday.php @@ -5,8 +5,8 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -$firstday = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstday', 'mo'); -OC_JSON::encodedPrint(array('firstday' => $firstday)); + +OCP\JSON::checkLoggedIn(); +$firstday = OCP\Config::getUserValue( OCP\USER::getUser(), 'calendar', 'firstday', 'mo'); +OCP\JSON::encodedPrint(array('firstday' => $firstday)); ?> diff --git a/apps/calendar/ajax/settings/gettimezonedetection.php b/apps/calendar/ajax/settings/gettimezonedetection.php index 11255fe8ef3..6bc9a07a1e9 100644..100755 --- a/apps/calendar/ajax/settings/gettimezonedetection.php +++ b/apps/calendar/ajax/settings/gettimezonedetection.php @@ -5,7 +5,7 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); -OC_JSON::success(array('detection' => OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection')));
\ No newline at end of file + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::success(array('detection' => OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection')));
\ No newline at end of file diff --git a/apps/calendar/ajax/settings/guesstimezone.php b/apps/calendar/ajax/settings/guesstimezone.php index d45a70e1ce3..13092777b78 100755 --- a/apps/calendar/ajax/settings/guesstimezone.php +++ b/apps/calendar/ajax/settings/guesstimezone.php @@ -5,23 +5,23 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); -$l = new OC_L10N('calendar'); +$l = OC_L10N::get('calendar'); $lat = $_GET['lat']; $lng = $_GET['long']; $timezone = OC_Geo::timezone($lat, $lng); -if($timezone == OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone')){ - OC_JSON::success(); +if($timezone == OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone')){ + OCP\JSON::success(); exit; } -OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $timezone); +OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezone', $timezone); $message = array('message'=> $l->t('New Timezone:') . $timezone); -OC_JSON::success($message); +OCP\JSON::success($message); ?>
\ No newline at end of file diff --git a/apps/calendar/ajax/settings/setfirstday.php b/apps/calendar/ajax/settings/setfirstday.php index 3b652212205..373eeee7968 100644..100755 --- a/apps/calendar/ajax/settings/setfirstday.php +++ b/apps/calendar/ajax/settings/setfirstday.php @@ -5,13 +5,13 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); + +OCP\JSON::checkLoggedIn(); if(isset($_POST["firstday"])){ - OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'firstday', $_POST["firstday"]); - OC_JSON::success(); + OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'firstday', $_POST["firstday"]); + OCP\JSON::success(); }else{ - OC_JSON::error(); + OCP\JSON::error(); } ?> diff --git a/apps/calendar/ajax/settings/settimeformat.php b/apps/calendar/ajax/settings/settimeformat.php index 8f65447065c..eae7be54e80 100644..100755 --- a/apps/calendar/ajax/settings/settimeformat.php +++ b/apps/calendar/ajax/settings/settimeformat.php @@ -5,13 +5,13 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); + +OCP\JSON::checkLoggedIn(); if(isset($_POST["timeformat"])){ - OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]); - OC_JSON::success(); + OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]); + OCP\JSON::success(); }else{ - OC_JSON::error(); + OCP\JSON::error(); } ?> diff --git a/apps/calendar/ajax/settings/settimezone.php b/apps/calendar/ajax/settings/settimezone.php index c639753fe2f..d2797a08aae 100644..100755 --- a/apps/calendar/ajax/settings/settimezone.php +++ b/apps/calendar/ajax/settings/settimezone.php @@ -7,21 +7,21 @@ */ // Init owncloud -require_once('../../../../lib/base.php'); + -$l=new OC_L10N('calendar'); +$l=OC_L10N::get('calendar'); // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); // Get data if( isset( $_POST['timezone'] ) ){ $timezone=$_POST['timezone']; - OC_Preferences::setValue( OC_User::getUser(), 'calendar', 'timezone', $timezone ); - OC_JSON::success(array('data' => array( 'message' => $l->t('Timezone changed') ))); + OCP\Config::setUserValue( OCP\USER::getUser(), 'calendar', 'timezone', $timezone ); + OCP\JSON::success(array('data' => array( 'message' => $l->t('Timezone changed') ))); }else{ - OC_JSON::error(array('data' => array( 'message' => $l->t('Invalid request') ))); + OCP\JSON::error(array('data' => array( 'message' => $l->t('Invalid request') ))); } ?> diff --git a/apps/calendar/ajax/settings/timeformat.php b/apps/calendar/ajax/settings/timeformat.php index e0dbe8d3cd7..809164e870a 100644..100755 --- a/apps/calendar/ajax/settings/timeformat.php +++ b/apps/calendar/ajax/settings/timeformat.php @@ -5,8 +5,8 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24"); -OC_JSON::encodedPrint(array("timeformat" => $timeformat)); + +OCP\JSON::checkLoggedIn(); +$timeformat = OCP\Config::getUserValue( OCP\USER::getUser(), 'calendar', 'timeformat', "24"); +OCP\JSON::encodedPrint(array("timeformat" => $timeformat)); ?> diff --git a/apps/calendar/ajax/settings/timezonedetection.php b/apps/calendar/ajax/settings/timezonedetection.php index f67bab901e7..ba5f2af5fd9 100644..100755 --- a/apps/calendar/ajax/settings/timezonedetection.php +++ b/apps/calendar/ajax/settings/timezonedetection.php @@ -5,13 +5,16 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); -if($_POST['timezonedetection'] == 'on'){ - OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'true'); + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); +if(array_key_exists('timezonedetection', $_POST)){ + if($_POST['timezonedetection'] == 'on'){ + OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection', 'true'); + }else{ + OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection', 'false'); + } + OCP\JSON::success(); }else{ - OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'false'); -} -OC_JSON::success(); - + OCP\JSON::error(); +}
\ No newline at end of file diff --git a/apps/calendar/ajax/share/activation.php b/apps/calendar/ajax/share/activation.php new file mode 100755 index 00000000000..5526e5230f4 --- /dev/null +++ b/apps/calendar/ajax/share/activation.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../../lib/base.php'); +$id = strip_tags($_GET['id']); +$activation = strip_tags($_GET['activation']); +OC_Calendar_Share::set_active(OCP\USER::getUser(), $id, $activation); +OCP\JSON::success();
\ No newline at end of file diff --git a/apps/calendar/ajax/share/changepermission.php b/apps/calendar/ajax/share/changepermission.php index d91f87b613f..e4a4f186ab0 100644..100755 --- a/apps/calendar/ajax/share/changepermission.php +++ b/apps/calendar/ajax/share/changepermission.php @@ -5,7 +5,7 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + $id = strip_tags($_GET['id']); $idtype = strip_tags($_GET['idtype']); $permission = (int) strip_tags($_GET['permission']); @@ -14,7 +14,7 @@ switch($idtype){ case 'event': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } $sharewith = $_GET['sharewith']; @@ -25,16 +25,16 @@ switch($sharetype){ case 'public': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } -if($sharetype == 'user' && !OC_User::userExists($sharewith)){ - OC_JSON::error(array('message'=>'user not found')); +if($sharetype == 'user' && !OCP\User::userExists($sharewith)){ + OCP\JSON::error(array('message'=>'user not found')); exit; } if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){ - OC_JSON::error(array('message'=>'group not found')); + OCP\JSON::error(array('message'=>'group not found')); exit; } -$success = OC_Calendar_Share::changepermission($sharewith, $sharetype, $id, $permission, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event)); -OC_JSON::success();
\ No newline at end of file +$success = OC_Calendar_Share::changepermission($sharewith, $sharetype, $id, $permission, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT)); +OCP\JSON::success();
\ No newline at end of file diff --git a/apps/calendar/ajax/share/dropdown.php b/apps/calendar/ajax/share/dropdown.php index eb396d38fd9..bac487f0d0b 100644..100755 --- a/apps/calendar/ajax/share/dropdown.php +++ b/apps/calendar/ajax/share/dropdown.php @@ -5,12 +5,12 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); -$user = OC_USER::getUser(); + +$user = OCP\USER::getUser(); $calid = $_GET['calid']; $calendar = OC_Calendar_Calendar::find($calid); if($calendar['userid'] != $user){ - OC_JSON::error(); + OCP\JSON::error(); exit; } $tmpl = new OC_Template('calendar', 'share.dropdown'); diff --git a/apps/calendar/ajax/share/share.php b/apps/calendar/ajax/share/share.php index d892727701a..3ce2bf1e217 100644..100755 --- a/apps/calendar/ajax/share/share.php +++ b/apps/calendar/ajax/share/share.php @@ -5,7 +5,7 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + $id = strip_tags($_GET['id']); $idtype = strip_tags($_GET['idtype']); switch($idtype){ @@ -13,9 +13,17 @@ switch($idtype){ case 'event': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } +if($idtype == 'calendar' && !OC_Calendar_App::getCalendar($id)){ + OCP\JSON::error(array('message'=>'permission denied')); + exit; +} +if($idtype == 'event' && !OC_Calendar_App::getEventObject($id)){ + OCP\JSON::error(array('message'=>'permission denied')); + exit; +} $sharewith = $_GET['sharewith']; $sharetype = strip_tags($_GET['sharetype']); switch($sharetype){ @@ -24,28 +32,28 @@ switch($sharetype){ case 'public': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } -if($sharetype == 'user' && !OC_User::userExists($sharewith)){ - OC_JSON::error(array('message'=>'user not found')); +if($sharetype == 'user' && !OCP\User::userExists($sharewith)){ + OCP\JSON::error(array('message'=>'user not found')); exit; } if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){ - OC_JSON::error(array('message'=>'group not found')); + OCP\JSON::error(array('message'=>'group not found')); exit; } -if($sharetype == 'user' && OC_User::getUser() == $sharewith){ - OC_JSON::error(array('meesage'=>'you can not share with yourself')); +if($sharetype == 'user' && OCP\USER::getUser() == $sharewith){ + OCP\JSON::error(array('meesage'=>'you can not share with yourself')); } -$success = OC_Calendar_Share::share(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event)); +$success = OC_Calendar_Share::share(OCP\USER::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT)); if($success){ if($sharetype == 'public'){ - OC_JSON::success(array('message'=>$success)); + OCP\JSON::success(array('message'=>$success)); }else{ - OC_JSON::success(array('message'=>'shared')); + OCP\JSON::success(array('message'=>'shared')); } }else{ - OC_JSON::error(array('message'=>'can not share')); + OCP\JSON::error(array('message'=>'can not share')); exit; }
\ No newline at end of file diff --git a/apps/calendar/ajax/share/unshare.php b/apps/calendar/ajax/share/unshare.php index ec3150a89aa..cbd5ed8e505 100644..100755 --- a/apps/calendar/ajax/share/unshare.php +++ b/apps/calendar/ajax/share/unshare.php @@ -5,7 +5,7 @@ * later. * See the COPYING-README file. */ -require_once('../../../../lib/base.php'); + $id = strip_tags($_GET['id']); $idtype = strip_tags($_GET['idtype']); switch($idtype){ @@ -13,7 +13,7 @@ switch($idtype){ case 'event': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } $sharewith = $_GET['sharewith']; @@ -24,21 +24,20 @@ switch($sharetype){ case 'public': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } -if($sharetype == 'user' && !OC_User::userExists($sharewith)){ - OC_JSON::error(array('message'=>'user not found')); +if($sharetype == 'user' && !OCP\User::userExists($sharewith)){ + OCP\JSON::error(array('message'=>'user not found')); exit; -} -if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){ - OC_JSON::error(array('message'=>'group not found')); +}elseif($sharetype == 'group' && !OC_Group::groupExists($sharewith)){ + OCP\JSON::error(array('message'=>'group not found')); exit; } -$success = OC_Calendar_Share::unshare(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event)); +$success = OC_Calendar_Share::unshare(OCP\USER::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT)); if($success){ - OC_JSON::success(); + OCP\JSON::success(); }else{ - OC_JSON::error(array('message'=>'can not unshare')); + OCP\JSON::error(array('message'=>'can not unshare')); exit; }
\ No newline at end of file diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index f297c4d16d4..7b5db834fb5 100644..100755 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -1,23 +1,25 @@ <?php -$l=new OC_L10N('calendar'); +$l=OC_L10N::get('calendar'); OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php'; OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php'; OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php'; OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php'; OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php'; +OC::$CLASSPATH['OC_Calendar_Share'] = 'apps/calendar/lib/share.php'; OC::$CLASSPATH['OC_Search_Provider_Calendar'] = 'apps/calendar/lib/search.php'; OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser'); -OC_Hook::connect('OC_DAV', 'initialize', 'OC_Calendar_Hooks', 'initializeCalDAV'); -OC_Util::addScript('calendar','loader'); -OC_App::register( array( +OCP\Util::addscript('calendar','loader'); +OCP\Util::addscript("3rdparty", "chosen/chosen.jquery.min"); +OCP\Util::addStyle("3rdparty", "chosen/chosen"); +OCP\App::register( array( 'order' => 10, 'id' => 'calendar', 'name' => 'Calendar' )); -OC_App::addNavigationEntry( array( +OCP\App::addNavigationEntry( array( 'id' => 'calendar_index', 'order' => 10, - 'href' => OC_Helper::linkTo( 'calendar', 'index.php' ), - 'icon' => OC_Helper::imagePath( 'calendar', 'icon.svg' ), + 'href' => OCP\Util::linkTo( 'calendar', 'index.php' ), + 'icon' => OCP\Util::imagePath( 'calendar', 'icon.svg' ), 'name' => $l->t('Calendar'))); -OC_App::registerPersonal('calendar', 'settings'); -OC_Search::registerProvider('OC_Search_Provider_Calendar');
\ No newline at end of file +OCP\App::registerPersonal('calendar', 'settings'); +OC_Search::registerProvider('OC_Search_Provider_Calendar'); diff --git a/apps/calendar/appinfo/database.xml b/apps/calendar/appinfo/database.xml index 7f7b6457559..b065ab3f94a 100644 --- a/apps/calendar/appinfo/database.xml +++ b/apps/calendar/appinfo/database.xml @@ -187,5 +187,107 @@ </declaration> </table> + + <table> + + <name>*dbprefix*calendar_share_event</name> + + <declaration> + + <field> + <name>owner</name> + <type>text</type> + <notnull>true</notnull> + <length>255</length> + </field> + + <field> + <name>share</name> + <type>text</type> + <notnull>true</notnull> + <length>255</length> + </field> + + <field> + <name>sharetype</name> + <type>text</type> + <notnull>true</notnull> + <length>6</length> + </field> + + <field> + <name>eventid</name> + <type>integer</type> + <default></default> + <notnull>true</notnull> + <unsigned>true</unsigned> + <length>11</length> + </field> + + <field> + <name>permissions</name> + <type>integer</type> + <notnull>true</notnull> + <length>1</length> + </field> + + </declaration> + + </table> + + <table> + + <name>*dbprefix*calendar_share_calendar</name> + + <declaration> + + <field> + <name>owner</name> + <type>text</type> + <notnull>true</notnull> + <length>255</length> + </field> + + <field> + <name>share</name> + <type>text</type> + <notnull>true</notnull> + <length>255</length> + </field> + + <field> + <name>sharetype</name> + <type>text</type> + <notnull>true</notnull> + <length>6</length> + </field> + + <field> + <name>calendarid</name> + <type>integer</type> + <default></default> + <notnull>true</notnull> + <unsigned>true</unsigned> + <length>11</length> + </field> + + <field> + <name>permissions</name> + <type>integer</type> + <notnull>true</notnull> + <length>1</length> + </field> + <field> + <name>active</name> + <type>integer</type> + <default>1</default> + <notnull>true</notnull> + <length>4</length> + </field> + + </declaration> + + </table> + </database> diff --git a/apps/calendar/appinfo/info.xml b/apps/calendar/appinfo/info.xml index 4ac3c5bf099..101840aa1fa 100644 --- a/apps/calendar/appinfo/info.xml +++ b/apps/calendar/appinfo/info.xml @@ -2,7 +2,6 @@ <info> <id>calendar</id> <name>Calendar</name> - <version>0.2.1</version> <licence>AGPL</licence> <author>Georg Ehrke, Bart Visscher, Jakob Sack</author> <require>2</require> diff --git a/apps/calendar/appinfo/install.php b/apps/calendar/appinfo/install.php new file mode 100644 index 00000000000..fc5cd892394 --- /dev/null +++ b/apps/calendar/appinfo/install.php @@ -0,0 +1,4 @@ +<?php +if(!file_exists(OC::$WEBROOT.'/remote/caldav.php')){ + file_put_contents(OC::$WEBROOT.'/remote/caldav.php', file_get_contents(OC::$APPSROOT . '/apps/calendar/appinfo/remote.php')); +} diff --git a/apps/calendar/caldav.php b/apps/calendar/appinfo/remote.php index b710b99ea43..32b454ee90c 100644..100755 --- a/apps/calendar/caldav.php +++ b/apps/calendar/appinfo/remote.php @@ -5,12 +5,11 @@ * later. * See the COPYING-README file. */ - // Do not load FS ... $RUNTIME_NOSETUPFS = true; +require_once('../lib/base.php'); -require_once('../../lib/base.php'); -OC_Util::checkAppEnabled('calendar'); +OCP\App::checkAppEnabled('calendar'); // Backends $authBackend = new OC_Connector_Sabre_Auth(); @@ -25,7 +24,7 @@ $nodes = array( // Fire up server $server = new Sabre_DAV_Server($nodes); -$server->setBaseUri(OC::$APPSWEBROOT.'/apps/calendar/caldav.php'); +$server->setBaseUri(OC::$WEBROOT.'/remote/caldav.php'); // Add plugins $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud')); $server->addPlugin(new Sabre_CalDAV_Plugin()); diff --git a/apps/calendar/appinfo/update.php b/apps/calendar/appinfo/update.php index 375816a403e..1c042428089 100644..100755 --- a/apps/calendar/appinfo/update.php +++ b/apps/calendar/appinfo/update.php @@ -1,8 +1,8 @@ <?php -$installedVersion=OC_Appconfig::getValue('calendar', 'installed_version'); +$installedVersion=OCP\Config::getAppValue('calendar', 'installed_version'); if (version_compare($installedVersion, '0.2.1', '<')) { - $stmt = OC_DB::prepare( 'SELECT id, calendarcolor FROM *PREFIX*calendar_calendars WHERE calendarcolor IS NOT NULL' ); + $stmt = OCP\DB::prepare( 'SELECT id, calendarcolor FROM *PREFIX*calendar_calendars WHERE calendarcolor IS NOT NULL' ); $result = $stmt->execute(); while( $row = $result->fetchRow()) { $id = $row['id']; @@ -11,7 +11,10 @@ if (version_compare($installedVersion, '0.2.1', '<')) { continue; } $color = '#' .$color; - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET calendarcolor=? WHERE id=?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET calendarcolor=? WHERE id=?' ); $r = $stmt->execute(array($color,$id)); } } +if(!file_exists(OC::$WEBROOT.'/remote/caldav.php')){ + file_put_contents(OC::$WEBROOT.'/remote/caldav.php', file_get_contents(OC::$APPROOT . '/apps/calendar/appinfo/remote.php')); +}
\ No newline at end of file diff --git a/apps/calendar/appinfo/version b/apps/calendar/appinfo/version new file mode 100644 index 00000000000..1d71ef97443 --- /dev/null +++ b/apps/calendar/appinfo/version @@ -0,0 +1 @@ +0.3
\ No newline at end of file diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css index cffaf356402..373a4565638 100644 --- a/apps/calendar/css/style.css +++ b/apps/calendar/css/style.css @@ -56,6 +56,12 @@ button.category{margin:0 3px;} .calendar-colorpicker-color{display:inline-block;width:20px;height:20px;margin-right:2px;cursor:pointer;border:2px solid transparent;} .calendar-colorpicker-color.active{border:2px solid black;} +#event {padding: 0;margin: 0;margin-top:-5px} + +.calendar_share_dropdown{ display:block; position:absolute; z-index:100; width:16em; right:0; margin-right:7em; background:#F8F8F8; padding:1em; +-moz-box-shadow:0 1px 1px #777; -webkit-box-shadow:0 1px 1px #777; box-shadow:0 1px 1px #777; +-moz-border-radius:0 0 1em 1em; -webkit-border-radius:0 0 1em 1em; border-radius:0 0 1em 1em;} + .fc-list-table { margin: 10px; diff --git a/apps/calendar/export.php b/apps/calendar/export.php index 2736eec96c2..0756e1df20e 100644..100755 --- a/apps/calendar/export.php +++ b/apps/calendar/export.php @@ -6,14 +6,14 @@ * See the COPYING-README file. */ -require_once ('../../lib/base.php'); -OC_Util::checkLoggedIn(); -OC_Util::checkAppEnabled('calendar'); + +OCP\User::checkLoggedIn(); +OCP\App::checkAppEnabled('calendar'); $cal = isset($_GET['calid']) ? $_GET['calid'] : NULL; $event = isset($_GET['eventid']) ? $_GET['eventid'] : NULL; -$nl = "\n\r"; +$nl = "\r\n"; if(isset($cal)){ - $calendar = OC_Calendar_App::getCalendar($cal); + $calendar = OC_Calendar_App::getCalendar($cal, true); $calobjects = OC_Calendar_Object::all($cal); header('Content-Type: text/Calendar'); header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics'); @@ -21,7 +21,7 @@ if(isset($cal)){ echo $calobject['calendardata'] . $nl; } }elseif(isset($event)){ - $data = OC_Calendar_App::getEventObject($_GET['eventid']); + $data = OC_Calendar_App::getEventObject($_GET['eventid'], true); $calendarid = $data['calendarid']; $calendar = OC_Calendar_App::getCalendar($calendarid); header('Content-Type: text/Calendar'); diff --git a/apps/calendar/img/icon.svg b/apps/calendar/img/icon.svg index 211f74df066..211f74df066 100755..100644 --- a/apps/calendar/img/icon.svg +++ b/apps/calendar/img/icon.svg diff --git a/apps/calendar/import.php b/apps/calendar/import.php deleted file mode 100644 index b1c6f91df84..00000000000 --- a/apps/calendar/import.php +++ /dev/null @@ -1,120 +0,0 @@ -<?php -/** - * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ -//check for calendar rights or create new one -ob_start(); -require_once ('../../lib/base.php'); -OC_JSON::checkLoggedIn(); -OC_Util::checkAppEnabled('calendar'); -$nl = "\n"; -$progressfile = 'import_tmp/' . md5(session_id()) . '.txt'; -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '10'); - fclose($progressfopen); -} -$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); -if($_POST['method'] == 'new'){ - $id = OC_Calendar_Calendar::addCalendar(OC_User::getUser(), $_POST['calname']); - OC_Calendar_Calendar::setCalendarActive($id, 1); -}else{ - $calendar = OC_Calendar_App::getCalendar($_POST['id']); - if($calendar['userid'] != OC_USER::getUser()){ - OC_JSON::error(); - exit(); - } - $id = $_POST['id']; -} -//analyse the calendar file -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '20'); - fclose($progressfopen); -} -$searchfor = array('VEVENT', 'VTODO', 'VJOURNAL'); -$parts = $searchfor; -$filearr = explode($nl, $file); -$inelement = false; -$parts = array(); -$i = 0; -foreach($filearr as $line){ - foreach($searchfor as $search){ - if(substr_count($line, $search) == 1){ - list($attr, $val) = explode(':', $line); - if($attr == 'BEGIN'){ - $parts[]['begin'] = $i; - $inelement = true; - } - if($attr == 'END'){ - $parts[count($parts) - 1]['end'] = $i; - $inelement = false; - } - } - } - $i++; -} -//import the calendar -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '40'); - fclose($progressfopen); -} -$start = ''; -for ($i = 0; $i < $parts[0]['begin']; $i++) { - if($i == 0){ - $start = $filearr[0]; - }else{ - $start .= $nl . $filearr[$i]; - } -} -$end = ''; -for($i = $parts[count($parts) - 1]['end'] + 1;$i <= count($filearr) - 1; $i++){ - if($i == $parts[count($parts) - 1]['end'] + 1){ - $end = $filearr[$parts[count($parts) - 1]['end'] + 1]; - }else{ - $end .= $nl . $filearr[$i]; - } -} -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '50'); - fclose($progressfopen); -} -$importready = array(); -foreach($parts as $part){ - for($i = $part['begin']; $i <= $part['end'];$i++){ - if($i == $part['begin']){ - $content = $filearr[$i]; - }else{ - $content .= $nl . $filearr[$i]; - } - } - $importready[] = $start . $nl . $content . $nl . $end; -} -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '70'); - fclose($progressfopen); -} -if(count($parts) == 1){ - OC_Calendar_Object::add($id, $file); -}else{ - foreach($importready as $import){ - OC_Calendar_Object::add($id, $import); - } -} -//done the import -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '100'); - fclose($progressfopen); -} -sleep(3); -if(is_writable('import_tmp/')){ - unlink($progressfile); -} -OC_JSON::success();
\ No newline at end of file diff --git a/apps/calendar/index.php b/apps/calendar/index.php index f964a13ef79..3a3915b9669 100644..100755 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -6,49 +6,53 @@ * See the COPYING-README file. */ -require_once ('../../lib/base.php'); -OC_Util::checkLoggedIn(); -OC_Util::checkAppEnabled('calendar'); + +OCP\User::checkLoggedIn(); +OCP\App::checkAppEnabled('calendar'); // Create default calendar ... -$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1); +$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1); if( count($calendars) == 0){ - OC_Calendar_Calendar::addCalendar(OC_User::getUser(),'Default calendar'); - $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1); + OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(),'Default calendar'); + $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1); } $eventSources = array(); foreach($calendars as $calendar){ $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar); } + +$eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_rw', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'true'); +$eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false'); + OC_Hook::emit('OC_Calendar', 'getSources', array('sources' => &$eventSources)); $categories = OC_Calendar_App::getCategoryOptions(); //Fix currentview for fullcalendar -if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){ - OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "agendaWeek"); +if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){ + OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "agendaWeek"); } -if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview"){ - OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "month"); +if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview"){ + OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "month"); } -if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "listview"){ - OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "list"); +if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "listview"){ + OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "list"); } -OC_Util::addScript('3rdparty/fullcalendar', 'fullcalendar'); -OC_Util::addStyle('3rdparty/fullcalendar', 'fullcalendar'); -OC_Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker'); -OC_Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker'); -if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == null || OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection') == 'true'){ - OC_UTIL::addScript('calendar', 'geo'); +OCP\Util::addscript('3rdparty/fullcalendar', 'fullcalendar'); +OCP\Util::addStyle('3rdparty/fullcalendar', 'fullcalendar'); +OCP\Util::addscript('3rdparty/timepicker', 'jquery.ui.timepicker'); +OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker'); +if(OCP\Config::getUserValue(OCP\USER::getUser(), "calendar", "timezone") == null || OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection') == 'true'){ + OCP\Util::addscript('calendar', 'geo'); } -OC_Util::addScript('calendar', 'calendar'); -OC_Util::addStyle('calendar', 'style'); -OC_Util::addScript('', 'jquery.multiselect'); -OC_Util::addStyle('', 'jquery.multiselect'); -OC_Util::addScript('contacts','jquery.multi-autocomplete'); -OC_Util::addScript('','oc-vcategories'); -OC_App::setActiveNavigationEntry('calendar_index'); +OCP\Util::addscript('calendar', 'calendar'); +OCP\Util::addStyle('calendar', 'style'); +OCP\Util::addscript('', 'jquery.multiselect'); +OCP\Util::addStyle('', 'jquery.multiselect'); +OCP\Util::addscript('contacts','jquery.multi-autocomplete'); +OCP\Util::addscript('','oc-vcategories'); +OCP\App::setActiveNavigationEntry('calendar_index'); $tmpl = new OC_Template('calendar', 'calendar', 'user'); $tmpl->assign('eventSources', $eventSources); $tmpl->assign('categories', $categories); diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 858990fb89d..a16856938ce 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -46,6 +46,7 @@ Calendar={ $('#advanced_month').change(function(){ Calendar.UI.repeat('month'); }); + $( "#event" ).tabs({ selected: 0}); $('#event').dialog({ width : 500, close : function(event, ui) { @@ -455,7 +456,7 @@ Calendar={ $('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url); $('#calendar_holder').fullCalendar('addEventSource', data.eventSource); if (calendarid == 'new'){ - $('#choosecalendar_dialog > table').append('<tr><td colspan="6"><a href="#" onclick="Calendar.UI.Calendar.newCalendar(this);"><input type="button" value="' + newcalendar + '"></a></td></tr>'); + $('#choosecalendar_dialog > table:first').append('<tr><td colspan="6"><a href="#" onclick="Calendar.UI.Calendar.newCalendar(this);"><input type="button" value="' + newcalendar + '"></a></td></tr>'); } }else{ $("#displayname_"+calendarid).css('background-color', '#FF2626'); @@ -494,6 +495,109 @@ Calendar={ left: -10000 }); } + }, + Share:{ + currentid: 'false', + idtype: '', + activation:function(object,owner,id){ + $.getJSON(OC.filePath('calendar', 'ajax/share', 'activation.php'),{id:id, idtype:'calendar', activation:object.checked?1:0}); + $('#calendar_holder').fullCalendar('refetchEvents'); + }, + dropdown:function(userid, calid){ + $('.calendar_share_dropdown').remove(); + $('<div class="calendar_share_dropdown"></div>').appendTo('#'+userid+'_'+calid); + $.get(OC.filePath('calendar', 'ajax/share', 'dropdown.php') + '?calid=' + calid, function(data){ + $('#'+userid+'_'+calid+' > .calendar_share_dropdown').html(data); + $('#'+userid+'_'+calid+' > .calendar_share_dropdown').show('blind'); + $('#share_user').chosen(); + $('#share_group').chosen(); + }); + Calendar.UI.Share.currentid = calid; + Calendar.UI.Share.idtype = 'calendar'; + }, + share:function(id, idtype, sharewith, sharetype){ + $.getJSON(OC.filePath('calendar', 'ajax/share', 'share.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(data){ + + }); + }, + unshare:function(id, idtype, sharewith, sharetype){ + $.getJSON(OC.filePath('calendar', 'ajax/share', 'unshare.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(){ + if(sharetype == 'public'){ + $('#public_token').val(''); + $('#public_token').css('display', 'none'); + } + }); + }, + changepermission:function(id, idtype, sharewith, sharetype, permission){ + $.getJSON(OC.filePath('calendar', 'ajax/share', 'changepermission.php'),{id:id, idtype:idtype, sharewith: sharewith, sharetype:sharetype, permission: (permission?1:0)}); + }, + init:function(){ + $('.calendar_share_dropdown').live('mouseleave', function(){ + $('.calendar_share_dropdown').hide('blind', function(){ + $('.calendar_share_dropdown').remove(); + }); + }); + $('#share_user').live('change', function(){ + if($('#sharewithuser_' + $('#share_user option:selected').text()).length == 0){ + Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $('#share_user option:selected').text(), 'user'); + var newitem = '<li id="sharewithuser_' + $('#share_user option:selected').text() +'"><input type="checkbox" width="12px" style="visibility:hidden;" title="' + $('#share_user option:selected').text() + '">' + $('#share_user option:selected').text() + '<img src="/owncloud/core/img/actions/delete.svg" class="svg action" style="display:none;float:right;"></li>'; + $('#sharewithuser_list').append(newitem); + $('#sharewithuser_' + $('#share_user option:selected').text() + ' > img').click(function(){ + $('#share_user option[value="' + $(this).parent().text() + '"]').removeAttr('disabled'); + Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'user' ); + $("#share_user").trigger("liszt:updated"); + $(this).parent().remove(); + }); + $('#share_user option:selected').attr('disabled', 'disabled'); + $("#share_user").trigger("liszt:updated"); + } + }); + $('#share_group').live('change', function(){ + if($('#sharewithgroup_' + $('#share_group option:selected').text()).length == 0){ + Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $('#share_group option:selected').text(), 'group'); + var newitem = '<li id="sharewithgroup_' + $('#share_group option:selected').text() +'"><input type="checkbox" width="12px" style="visibility:hidden;" title="' + $('#share_group option:selected').text() + '">' + $('#share_group option:selected').text() + '<img src="/owncloud/core/img/actions/delete.svg" class="svg action" style="display:none;float:right;"></li>'; + $('#sharewithgroup_list').append(newitem); + $('#sharewithgroup_' + $('#share_group option:selected').text() + ' > img').click(function(){ + $('#share_group option[value="' + $(this).parent().text() + '"]').removeAttr('disabled'); + Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'group'); + $("#share_group").trigger("liszt:updated"); + $(this).parent().remove(); + }); + $('#share_group option:selected').attr('disabled', 'disabled'); + $("#share_group").trigger("liszt:updated"); + } + }); + $('#sharewithuser_list > li > input:checkbox').live('change', function(){ + Calendar.UI.Share.changepermission(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'user', this.checked); + }); + $('#sharewithgroup_list > li > input:checkbox').live('change', function(){ + Calendar.UI.Share.changepermission(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'group', this.checked); + }); + $('#publish').live('change', function(){ + if(this.checked == 1){ + Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, '', 'public'); + }else{ + Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, '', 'public'); + } + }); + $('#sharewithuser_list').live('mouseenter', function(){ + $('#sharewithuser_list > li > img').css('display', 'block'); + $('#sharewithuser_list > li > input').css('visibility', 'visible'); + }); + $('#sharewithuser_list').live('mouseleave', function(){ + $('#sharewithuser_list > li > img').css('display', 'none'); + $('#sharewithuser_list > li > input').css('visibility', 'hidden'); + }); + $('#sharewithgroup_list').live('mouseenter', function(){ + $('#sharewithgroup_list > li > img').css('display', 'block'); + $('#sharewithgroup_list > li > input').css('visibility', 'visible'); + }); + $('#sharewithgroup_list').live('mouseleave', function(){ + $('#sharewithgroup_list > li > img').css('display', 'none'); + $('#sharewithgroup_list > li > input').css('visibility', 'hidden'); + }); + /*var permissions = (this.checked) ? 1 : 0;*/ + } } } } @@ -749,4 +853,5 @@ $(document).ready(function(){ $('#datecontrol_right').click(function(){ $('#calendar_holder').fullCalendar('next'); }); + Calendar.UI.Share.init(); }); diff --git a/apps/calendar/js/geo.js b/apps/calendar/js/geo.js index 7018c6298a2..092d8547469 100755..100644 --- a/apps/calendar/js/geo.js +++ b/apps/calendar/js/geo.js @@ -6,7 +6,7 @@ */ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { - $.getJSON(OC.filePath('calendar', 'ajax/settings', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''), + $.getJSON(OC.filePath('calendar', 'ajax/settings', 'guesstimezone.php') + '?lat=' + position.coords.latitude + '&long=' + position.coords.longitude, function(data){ if (data.status == 'success' && typeof(data.message) != 'undefined'){ $('#notification').html(data.message); diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js index 54003879759..60d92f448ee 100644 --- a/apps/calendar/js/loader.js +++ b/apps/calendar/js/loader.js @@ -44,7 +44,7 @@ Calendar_Import={ $('#newcalendar').attr('readonly', 'readonly'); $('#calendar').attr('disabled', 'disabled'); var progressfile = $('#progressfile').val(); - $.post(OC.filePath('calendar', '', 'import.php'), {method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){ + $.post(OC.filePath('calendar', 'ajax/import', 'import.php'), {method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){ if(data.status == 'success'){ $('#progressbar').progressbar('option', 'value', 100); $('#import_done').css('display', 'block'); diff --git a/apps/calendar/lib/alarm.php b/apps/calendar/lib/alarm.php new file mode 100644 index 00000000000..a71cc086827 --- /dev/null +++ b/apps/calendar/lib/alarm.php @@ -0,0 +1,13 @@ +<?php +/** + * Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +/* + * This class manages reminders for calendars + */ +class OC_Calendar_Alarm{ + +}
\ No newline at end of file diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 660aa928a76..98e430b8863 100644..100755 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -1,60 +1,121 @@ <?php /** * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> + * Copyright (c) 2012 Georg Ehrke <georg@owncloud.com> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. - */ - -/** + * * This class manages our app actions */ OC_Calendar_App::$l10n = new OC_L10N('calendar'); +OC_Calendar_App::$tz = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); class OC_Calendar_App{ + const CALENDAR = 'calendar'; + const EVENT = 'event'; + /* + * @brief language object for calendar app + */ public static $l10n; + + /* + * @brief categories of the user + */ protected static $categories = null; - public static function getCalendar($id){ - $calendar = OC_Calendar_Calendar::find( $id ); - if( $calendar === false || $calendar['userid'] != OC_User::getUser()){ - OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar')))); - exit(); + /* + * @brief timezone of the user + */ + public static $tz; + + /* + * @brief returns informations about a calendar + * @param int $id - id of the calendar + * @param bool $security - check access rights or not + * @param bool $shared - check if the user got access via sharing + * @return mixed - bool / array + */ + public static function getCalendar($id, $security = true, $shared = false){ + $calendar = OC_Calendar_Calendar::find($id); + if($shared === true){ + if(OC_Calendar_Share::check_access(OCP\USER::getUser(), $id, OC_Calendar_Share::CALENDAR)){ + return $calendar; + } + } + if($security === true){ + if($calendar['userid'] != OCP\USER::getUser()){ + return false; + } } - return $calendar; + if($calendar === false){ + return false; + } + return OC_Calendar_Calendar::find($id); } - - public static function getEventObject($id){ - $event_object = OC_Calendar_Object::find( $id ); - if( $event_object === false ){ - OC_JSON::error(); - exit(); + + /* + * @brief returns informations about an event + * @param int $id - id of the event + * @param bool $security - check access rights or not + * @param bool $shared - check if the user got access via sharing + * @return mixed - bool / array + */ + public static function getEventObject($id, $security = true, $shared = false){ + $event = OC_Calendar_Object::find($id); + if($shared === true){ + if(OC_Calendar_Share::check_access(OCP\USER::getUser(), $id, OC_Calendar_Share::EVENT)){ + return $event; + } } - - self::getCalendar( $event_object['calendarid'] );//access check - return $event_object; + if($security === true){ + $calendar = self::getCalendar($event['calendarid'], false); + if($calendar['userid'] != OCP\USER::getUser()){ + return false; + } + } + if($event === false){ + return false; + } + return $event; } - - public static function getVCalendar($id){ - $event_object = self::getEventObject( $id ); - - $vcalendar = OC_VObject::parse($event_object['calendardata']); - // Check if the vcalendar is valid - if(is_null($vcalendar)){ - OC_JSON::error(); - exit(); + + /* + * @brief returns the parsed calendar data + * @param int $id - id of the event + * @param bool $security - check access rights or not + * @return mixed - bool / object + */ + public static function getVCalendar($id, $security = true, $shared = false){ + $event_object = self::getEventObject($id, $security, $shared); + if($event_object === false){ + return false; + } + $vobject = OC_VObject::parse($event_object['calendardata']); + if(is_null($vobject)){ + return false; } - return $vcalendar; + return $vobject; } - - public static function isNotModified($vevent, $lastmodified) - { + + /* + * @brief checks if an event was edited and dies if it was + * @param (object) $vevent - vevent object of the event + * @param (int) $lastmodified - time of last modification as unix timestamp + * @return (bool) + */ + public static function isNotModified($vevent, $lastmodified){ $last_modified = $vevent->__get('LAST-MODIFIED'); if($last_modified && $lastmodified != $last_modified->getDateTime()->format('U')){ - OC_JSON::error(array('modified'=>true)); + OCP\JSON::error(array('modified'=>true)); exit; } + return true; } - + + /* + * @brief returns the default categories of ownCloud + * @return (array) $categories + */ protected static function getDefaultCategories() { return array( @@ -75,14 +136,22 @@ class OC_Calendar_App{ self::$l10n->t('Work'), ); } - + + /* + * @brief returns the vcategories object of the user + * @return (object) $vcategories + */ protected static function getVCategories() { if (is_null(self::$categories)) { self::$categories = new OC_VCategories('calendar', null, self::getDefaultCategories()); } return self::$categories; } - + + /* + * @brief returns the categories of the vcategories object + * @return (array) $categories + */ public static function getCategoryOptions() { $categories = self::getVCategories()->categories(); @@ -95,7 +164,7 @@ class OC_Calendar_App{ */ public static function scanCategories($events = null) { if (is_null($events)) { - $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); + $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); if(count($calendars) > 0) { $events = array(); foreach($calendars as $calendar) { @@ -136,40 +205,246 @@ class OC_Calendar_App{ public static function getRepeatOptions(){ return OC_Calendar_Object::getRepeatOptions(self::$l10n); } - + + /* + * @brief returns the options for the end of an repeating event + * @return array - valid inputs for the end of an repeating events + */ public static function getEndOptions(){ return OC_Calendar_Object::getEndOptions(self::$l10n); } - + + /* + * @brief returns the options for an monthly repeating event + * @return array - valid inputs for monthly repeating events + */ public static function getMonthOptions(){ return OC_Calendar_Object::getMonthOptions(self::$l10n); } - + + /* + * @brief returns the options for an weekly repeating event + * @return array - valid inputs for weekly repeating events + */ public static function getWeeklyOptions(){ return OC_Calendar_Object::getWeeklyOptions(self::$l10n); } - + + /* + * @brief returns the options for an yearly repeating event + * @return array - valid inputs for yearly repeating events + */ public static function getYearOptions(){ return OC_Calendar_Object::getYearOptions(self::$l10n); } - + + /* + * @brief returns the options for an yearly repeating event which occurs on specific days of the year + * @return array - valid inputs for yearly repeating events + */ public static function getByYearDayOptions(){ return OC_Calendar_Object::getByYearDayOptions(); } - + + /* + * @brief returns the options for an yearly repeating event which occurs on specific month of the year + * @return array - valid inputs for yearly repeating events + */ public static function getByMonthOptions(){ return OC_Calendar_Object::getByMonthOptions(self::$l10n); } + /* + * @brief returns the options for an yearly repeating event which occurs on specific week numbers of the year + * @return array - valid inputs for yearly repeating events + */ public static function getByWeekNoOptions(){ return OC_Calendar_Object::getByWeekNoOptions(); } - + + /* + * @brief returns the options for an yearly or monthly repeating event which occurs on specific days of the month + * @return array - valid inputs for yearly or monthly repeating events + */ public static function getByMonthDayOptions(){ return OC_Calendar_Object::getByMonthDayOptions(); } + /* + * @brief returns the options for an monthly repeating event which occurs on specific weeks of the month + * @return array - valid inputs for monthly repeating events + */ public static function getWeekofMonth(){ return OC_Calendar_Object::getWeekofMonth(self::$l10n); } + + /* + * @brief checks the access for a calendar / an event + * @param (int) $id - id of the calendar / event + * @param (string) $type - type of the id (calendar/event) + * @return (string) $access - level of access + */ + public static function getaccess($id, $type){ + if($type == self::CALENDAR){ + $calendar = self::getCalendar($id, false, false); + if($calendar['userid'] == OCP\USER::getUser()){ + return 'owner'; + } + $isshared = OC_Calendar_Share::check_access(OCP\USER::getUser(), $id, OC_Calendar_Share::CALENDAR); + if($isshared){ + $writeaccess = OC_Calendar_Share::is_editing_allowed(OCP\USER::getUser(), $id, OC_Calendar_Share::CALENDAR); + if($writeaccess){ + return 'rw'; + }else{ + return 'r'; + } + }else{ + return false; + } + }elseif($type == self::EVENT){ + if(OC_Calendar_Object::getowner($id) == OCP\USER::getUser()){ + return 'owner'; + } + $isshared = OC_Calendar_Share::check_access(OCP\USER::getUser(), $id, OC_Calendar_Share::EVENT); + if($isshared){ + $writeaccess = OC_Calendar_Share::is_editing_allowed(OCP\USER::getUser(), $id, OC_Calendar_Share::EVENT); + if($writeaccess){ + return 'rw'; + }else{ + return 'r'; + } + }else{ + return false; + } + } + } + + /* + * @brief analyses the parameter for calendar parameter and returns the objects + * @param (string) $calendarid - calendarid + * @param (int) $start - unixtimestamp of start + * @param (int) $end - unixtimestamp of end + * @return (array) $events + */ + public static function getrequestedEvents($calendarid, $start, $end){ + $events = array(); + if($calendarid == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){ + $calendars = OC_Calendar_Share::allSharedwithuser(OCP\USER::getUser(), OC_Calendar_Share::CALENDAR, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r'); + foreach($calendars as $calendar){ + $calendarevents = OC_Calendar_Object::allInPeriod($calendar['calendarid'], $start, $end); + $events = array_merge($events, $calendarevents); + } + $singleevents = OC_Calendar_Share::allSharedwithuser(OCP\USER::getUser(), OC_Calendar_Share::EVENT, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r'); + foreach($singleevents as $singleevent){ + $event = OC_Calendar_Object::find($singleevent['eventid']); + $events[] = $event; + } + }else{ + $calendar_id = $_GET['calendar_id']; + if (is_numeric($calendar_id)) { + $calendar = self::getCalendar($calendar_id); + OCP\Response::enableCaching(0); + OCP\Response::setETagHeader($calendar['ctag']); + $events = OC_Calendar_Object::allInPeriod($calendar_id, $start, $end); + } else { + OC_Hook::emit('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events)); + } + } + return $events; + } + + /* + * @brief generates the output for an event which will be readable for our js + * @param (mixed) $event - event object / array + * @param (int) $start - unixtimestamp of start + * @param (int) $end - unixtimestamp of end + * @return (array) $output - readable output + */ + public static function generateEventOutput($event, $start, $end){ + $output = array(); + + if(isset($event['calendardata'])){ + $object = OC_VObject::parse($event['calendardata']); + $vevent = $object->VEVENT; + }else{ + $vevent = $event['vevent']; + } + + $last_modified = @$vevent->__get('LAST-MODIFIED'); + $lastmodified = ($last_modified)?$last_modified->getDateTime()->format('U'):0; + + $output = array('id'=>(int)$event['id'], + 'title' => htmlspecialchars(($event['summary']!=NULL || $event['summary'] != '')?$event['summary']: self::$l10n->t('unnamed')), + 'description' => isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):'', + 'lastmodified'=>$lastmodified); + + $dtstart = $vevent->DTSTART; + $start_dt = $dtstart->getDateTime(); + $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); + $end_dt = $dtend->getDateTime(); + + if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ + $output['allDay'] = true; + }else{ + $output['allDay'] = false; + $start_dt->setTimezone(new DateTimeZone(self::$tz)); + $end_dt->setTimezone(new DateTimeZone(self::$tz)); + } + + // Handle exceptions to recurring events + $exceptionDateObjects = $vevent->select('EXDATE'); + $exceptionDateMap = Array(); + foreach ($exceptionDateObjects as $exceptionObject) { + foreach($exceptionObject->getDateTimes() as $datetime) { + $ts = $datetime->getTimestamp(); + $exceptionDateMap[idate('Y',$ts)][idate('m', $ts)][idate('d', $ts)] = true; + } + } + + $return = array(); + if($event['repeating'] == 1){ + $duration = (double) $end_dt->format('U') - (double) $start_dt->format('U'); + $r = new When(); + $r->recur($start_dt)->rrule((string) $vevent->RRULE); + /*$r = new iCal_Repeat_Generator(array('RECUR' => $start_dt, + * 'RRULE' => (string)$vevent->RRULE + * 'RDATE' => (string)$vevent->RDATE + * 'EXRULE' => (string)$vevent->EXRULE + * 'EXDATE' => (string)$vevent->EXDATE));*/ + while($result = $r->next()){ + if($result < $start){ + continue; + } + if($result > $end){ + break; + } + // Check for exceptions to recurring events + $ts = $result->getTimestamp(); + if (isset($exceptionDateMap[idate('Y',$ts)][idate('m', $ts)][idate('d', $ts)])) { + continue; + } + unset($ts); + + if($output['allDay'] == true){ + $output['start'] = $result->format('Y-m-d'); + $output['end'] = date('Y-m-d', $result->format('U') + --$duration); + }else{ + $output['start'] = $result->format('Y-m-d H:i:s'); + $output['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration); + } + $return[] = $output; + } + }else{ + if($output['allDay'] == true){ + $output['start'] = $start_dt->format('Y-m-d'); + $end_dt->modify('-1 sec'); + $output['end'] = $end_dt->format('Y-m-d'); + }else{ + $output['start'] = $start_dt->format('Y-m-d H:i:s'); + $output['end'] = $end_dt->format('Y-m-d H:i:s'); + } + $return[] = $output; + } + return $return; + } } diff --git a/apps/calendar/lib/attendees.php b/apps/calendar/lib/attendees.php new file mode 100644 index 00000000000..ac30e11b3be --- /dev/null +++ b/apps/calendar/lib/attendees.php @@ -0,0 +1,13 @@ +<?php +/** + * Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +/* + * This class manages Attendees for calendars + */ +class OC_Calendar_Attendees{ + +}
\ No newline at end of file diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 321f4c73ba0..1d008508040 100644..100755 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -54,7 +54,7 @@ class OC_Calendar_Calendar{ $active_where = ' AND active = ?'; $values[] = $active; } - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE userid = ?' . $active_where ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE userid = ?' . $active_where ); $result = $stmt->execute($values); $calendars = array(); @@ -81,7 +81,7 @@ class OC_Calendar_Calendar{ * @return associative array */ public static function find($id){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE id = ?' ); $result = $stmt->execute(array($id)); return $result->fetchRow(); @@ -106,10 +106,10 @@ class OC_Calendar_Calendar{ $uri = self::createURI($name, $uris ); - $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' ); + $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' ); $result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components)); - return OC_DB::insertid('*PREFIX*calendar_calendar'); + return OCP\DB::insertid('*PREFIX*calendar_calendar'); } /** @@ -126,10 +126,10 @@ class OC_Calendar_Calendar{ public static function addCalendarFromDAVData($principaluri,$uri,$name,$components,$timezone,$order,$color){ $userid = self::extractUserID($principaluri); - $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' ); + $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' ); $result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components)); - return OC_DB::insertid('*PREFIX*calendar_calendars'); + return OCP\DB::insertid('*PREFIX*calendar_calendars'); } /** @@ -155,7 +155,7 @@ class OC_Calendar_Calendar{ if(is_null($order)) $order = $calendar['calendarorder']; if(is_null($color)) $color = $calendar['calendarcolor']; - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET displayname=?,calendarorder=?,calendarcolor=?,timezone=?,components=?,ctag=ctag+1 WHERE id=?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET displayname=?,calendarorder=?,calendarcolor=?,timezone=?,components=?,ctag=ctag+1 WHERE id=?' ); $result = $stmt->execute(array($name,$order,$color,$timezone,$components,$id)); return true; @@ -168,7 +168,7 @@ class OC_Calendar_Calendar{ * @return boolean */ public static function setCalendarActive($id,$active){ - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET active = ? WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET active = ? WHERE id = ?' ); $stmt->execute(array($active, $id)); return true; @@ -180,7 +180,7 @@ class OC_Calendar_Calendar{ * @return boolean */ public static function touchCalendar($id){ - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET ctag = ctag + 1 WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET ctag = ctag + 1 WHERE id = ?' ); $stmt->execute(array($id)); return true; @@ -192,10 +192,10 @@ class OC_Calendar_Calendar{ * @return boolean */ public static function deleteCalendar($id){ - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_calendars WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*calendar_calendars WHERE id = ?' ); $stmt->execute(array($id)); - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ?' ); $stmt->execute(array($id)); return true; @@ -241,7 +241,7 @@ class OC_Calendar_Calendar{ public static function getEventSourceInfo($calendar){ return array( - 'url' => OC_Helper::linkTo('calendar', 'ajax/events.php').'?calendar_id='.$calendar['id'], + 'url' => OCP\Util::linkTo('calendar', 'ajax/events.php').'?calendar_id='.$calendar['id'], 'backgroundColor' => $calendar['calendarcolor'], 'borderColor' => '#888', 'textColor' => 'black', diff --git a/apps/calendar/lib/hooks.php b/apps/calendar/lib/hooks.php index 54f1680a36e..22e8d8e20f2 100644 --- a/apps/calendar/lib/hooks.php +++ b/apps/calendar/lib/hooks.php @@ -24,17 +24,4 @@ class OC_Calendar_Hooks{ return true; } - - /** - * @brief Adds the CardDAV resource to the DAV server - * @param paramters parameters from initialize-Hook - * @return array - */ - public static function initializeCalDAV($parameters){ - // We need a backend, the root node and the caldav plugin - $parameters['backends']['caldav'] = new OC_Connector_Sabre_CalDAV(); - $parameters['nodes'][] = new Sabre_CalDAV_CalendarRootNode($parameters['backends']['principal'], $parameters['backends']['caldav']); - $parameters['plugins'][] = new Sabre_CalDAV_Plugin(); - return true; - } } diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index d5622f6251f..3d4174a57be 100644..100755 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -19,7 +19,7 @@ class OC_Calendar_Object{ * ['calendardata'] */ public static function all($id){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' ); $result = $stmt->execute(array($id)); $calendarobjects = array(); @@ -41,7 +41,7 @@ class OC_Calendar_Object{ * in ['calendardata'] */ public static function allInPeriod($id, $start, $end){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' .' AND ((startdate >= ? AND startdate <= ? AND repeating = 0)' .' OR (enddate >= ? AND enddate <= ? AND repeating = 0)' .' OR (startdate <= ? AND repeating = 1))' ); @@ -66,7 +66,7 @@ class OC_Calendar_Object{ * @return associative array */ public static function find($id){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE id = ?' ); $result = $stmt->execute(array($id)); return $result->fetchRow(); @@ -79,7 +79,7 @@ class OC_Calendar_Object{ * @return associative array */ public static function findWhereDAVDataIs($cid,$uri){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri = ?' ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri = ?' ); $result = $stmt->execute(array($cid,$uri)); return $result->fetchRow(); @@ -103,12 +103,12 @@ class OC_Calendar_Object{ $uri = 'owncloud-'.md5($data.rand().time()).'.ics'; - $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); - $result = $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time())); + $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); + $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time())); OC_Calendar_Calendar::touchCalendar($id); - return OC_DB::insertid('*PREFIX*calendar_objects'); + return OCP\DB::insertid('*PREFIX*calendar_objects'); } /** @@ -122,12 +122,12 @@ class OC_Calendar_Object{ $object = OC_VObject::parse($data); list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object); - $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); - $result = $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time())); + $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); + $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time())); OC_Calendar_Calendar::touchCalendar($id); - return OC_DB::insertid('*PREFIX*calendar_objects'); + return OCP\DB::insertid('*PREFIX*calendar_objects'); } /** @@ -143,8 +143,8 @@ class OC_Calendar_Object{ OC_Calendar_App::loadCategoriesFromVCalendar($object); list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object); - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); - $result = $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$id)); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); + $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$id)); OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']); @@ -164,8 +164,8 @@ class OC_Calendar_Object{ $object = OC_VObject::parse($data); list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object); - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); - $result = $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$oldobject['id'])); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); + $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$oldobject['id'])); OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']); @@ -179,7 +179,7 @@ class OC_Calendar_Object{ */ public static function delete($id){ $oldobject = self::find($id); - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE id = ?' ); $stmt->execute(array($id)); OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']); @@ -193,7 +193,7 @@ class OC_Calendar_Object{ * @return boolean */ public static function deleteFromDAVData($cid,$uri){ - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri=?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri=?' ); $stmt->execute(array($cid,$uri)); OC_Calendar_Calendar::touchCalendar($cid); @@ -201,8 +201,8 @@ class OC_Calendar_Object{ } public static function moveToCalendar($id, $calendarid){ - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET calendarid=? WHERE id = ?' ); - $result = $stmt->execute(array($calendarid,$id)); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_objects SET calendarid=? WHERE id = ?' ); + $stmt->execute(array($calendarid,$id)); OC_Calendar_Calendar::touchCalendar($id); @@ -432,11 +432,6 @@ class OC_Calendar_Object{ $errarr['title'] = 'true'; $errnum++; } - $calendar = OC_Calendar_Calendar::find($request['calendar']); - if($calendar['userid'] != OC_User::getUser()){ - $errarr['cal'] = 'true'; - $errnum++; - } $fromday = substr($request['from'], 0, 2); $frommonth = substr($request['from'], 3, 2); @@ -461,11 +456,11 @@ class OC_Calendar_Object{ if($request['repeat'] != 'doesnotrepeat'){ if(is_nan($request['interval']) && $request['interval'] != ''){ $errarr['interval'] = 'true'; - $ernum++; + $errnum++; } if(array_key_exists('repeat', $request) && !array_key_exists($request['repeat'], self::getRepeatOptions(OC_Calendar_App::$l10n))){ $errarr['repeat'] = 'true'; - $ernum++; + $errnum++; } if(array_key_exists('advanced_month_select', $request) && !array_key_exists($request['advanced_month_select'], self::getMonthOptions(OC_Calendar_App::$l10n))){ $errarr['advanced_month_select'] = 'true'; @@ -595,7 +590,7 @@ class OC_Calendar_Object{ $vevent = new OC_VObject('VEVENT'); $vcalendar->add($vevent); - $vevent->setDateTime('CREATED', 'now', Sabre_VObject_Element_DateTime::UTC); + $vevent->setDateTime('CREATED', 'now', Sabre_VObject_Property_DateTime::UTC); $vevent->setUID(); return self::updateVCalendarFromRequest($request, $vcalendar); @@ -756,24 +751,22 @@ class OC_Calendar_Object{ } - $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); - $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); + $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Property_DateTime::UTC); + $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Property_DateTime::UTC); $vevent->setString('SUMMARY', $title); - $dtstart = new Sabre_VObject_Element_DateTime('DTSTART'); - $dtend = new Sabre_VObject_Element_DateTime('DTEND'); if($allday){ $start = new DateTime($from); $end = new DateTime($to.' +1 day'); - $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Element_DateTime::DATE); - $vevent->setDateTime('DTEND', $end, Sabre_VObject_Element_DateTime::DATE); + $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Property_DateTime::DATE); + $vevent->setDateTime('DTEND', $end, Sabre_VObject_Property_DateTime::DATE); }else{ - $timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $timezone = new DateTimeZone($timezone); $start = new DateTime($from.' '.$fromtime, $timezone); $end = new DateTime($to.' '.$totime, $timezone); - $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Element_DateTime::LOCALTZ); - $vevent->setDateTime('DTEND', $end, Sabre_VObject_Element_DateTime::LOCALTZ); + $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Property_DateTime::LOCALTZ); + $vevent->setDateTime('DTEND', $end, Sabre_VObject_Property_DateTime::LOCALTZ); } unset($vevent->DURATION); @@ -787,4 +780,15 @@ class OC_Calendar_Object{ return $vcalendar; } + + public static function getowner($id){ + $event = self::find($id); + $cal = OC_Calendar_Calendar::find($event['calendarid']); + return $cal['userid']; + } + + public static function getCalendarid($id){ + $event = self::find($id); + return $event['calendarid']; + } } diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php index da5fa35bc21..03516b3b70c 100644..100755 --- a/apps/calendar/lib/search.php +++ b/apps/calendar/lib/search.php @@ -1,8 +1,8 @@ <?php class OC_Search_Provider_Calendar extends OC_Search_Provider{ function search($query){ - $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1); - if(count($calendars)==0 || !OC_App::isEnabled('calendar')){ + $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1); + if(count($calendars)==0 || !OCP\App::isEnabled('calendar')){ //return false; } $results=array(); @@ -12,7 +12,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{ }else{ $searchquery[] = $query; } - $user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $user_timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $l = new OC_l10n('calendar'); foreach($calendars as $calendar){ $objects = OC_Calendar_Object::all($calendar['id']); @@ -26,7 +26,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{ $start_dt->setTimezone(new DateTimeZone($user_timezone)); $end_dt = $dtend->getDateTime(); $end_dt->setTimezone(new DateTimeZone($user_timezone)); - if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ + if ($dtstart->getDateType() == Sabre_VObject_Property_DateTime::DATE){ $end_dt->modify('-1 sec'); if($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')){ $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y'); @@ -36,7 +36,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{ }else{ $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i'); } - $link = OC_Helper::linkTo('calendar', 'index.php').'?showevent='.urlencode($object['id']); + $link = OCP\Util::linkTo('calendar', 'index.php').'?showevent='.urlencode($object['id']); $results[]=new OC_Search_Result($object['summary'],$info, $link,$l->t('Cal.'));//$name,$text,$link,$type } } diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php new file mode 100755 index 00000000000..a53bf763324 --- /dev/null +++ b/apps/calendar/lib/share.php @@ -0,0 +1,259 @@ +<?php +/** + * Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +/* + * This class manages shared calendars + */ +class OC_Calendar_Share{ + const CALENDAR = 'calendar'; + const EVENT = 'event'; + /* + * @brief: returns informations about all calendar or events which users are sharing with the user - userid + * @param: (string) $userid - id of the user + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return: (array) $return - information about calendars + */ + public static function allSharedwithuser($userid, $type, $active=null, $permission=null){ + $group_where = self::group_sql(OC_Group::getUserGroups($userid)); + $permission_where = self::permission_sql($permission); + if($type == self::CALENDAR){ + $active_where = self::active_sql($active); + }else{ + $active_where = ''; + } + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . $active_where); + $result = $stmt->execute(array($userid, $userid)); + $return = array(); + while( $row = $result->fetchRow()){ + $return[] = $row; + } + return $return; + } + /* + * @brief: returns all users a calendar / event is shared with + * @param: (int) id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return: (array) $users - information about users a calendar / event is shared with + */ + public static function allUsersSharedwith($id, $type){ + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ' . $type . 'id = ? ORDER BY share'); + $result = $stmt->execute(array($id)); + $users = array(); + while( $row = $result->fetchRow()){ + $users[] = $row; + } + return $users; + } + /* + * @brief: shares a calendar / event + * @param: (string) $owner - userid of the owner + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $sharetype - type of sharing (can be: user/group/public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (mixed) - token (if $sharetype == public) / bool (if $sharetype != public) + */ + public static function share($owner, $share, $sharetype, $id, $type){ + if(self::is_already_shared($owner, $share, $sharetype, $id, $type)){ + return false; + } + switch($sharetype){ + case 'user': + case 'group': + case 'public': + break; + default: + return false; + } + if($sharetype == 'public'){ + $share = self::generate_token($id, $type); + } + $stmt = OCP\DB::prepare('INSERT INTO *PREFIX*calendar_share_' . $type . ' (owner,share,sharetype,' . $type . 'id,permissions' . (($type == self::CALENDAR)?', active':'') . ') VALUES(?,?,?,?,0' . (($type == self::CALENDAR)?', 1':'') . ')' ); + $result = $stmt->execute(array($owner,$share,$sharetype,$id)); + if($sharetype == 'public'){ + return $share; + }else{ + return true; + } + } + /* + * @brief: stops sharing a calendar / event + * @param: (string) $owner - userid of the owner + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $sharetype - type of sharing (can be: user/group/public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function unshare($owner, $share, $sharetype, $id, $type){ + $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*calendar_share_' . $type . ' WHERE owner = ? ' . (($sharetype != 'public')?'AND share = ?':'') . ' AND sharetype = ? AND ' . $type . 'id = ?'); + if($sharetype != 'public'){ + $stmt->execute(array($owner,$share,$sharetype,$id)); + }else{ + $stmt->execute(array($owner,$sharetype,$id)); + } + return true; + } + /* + * @brief: changes the permission for a calendar / event + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $sharetype - type of sharing (can be: user/group/public) + * @param: (string) $id - id of the calendar / event + * @param: (int) $permission - permission of user the calendar / event is shared with (if $sharetype == public then $permission = 0) + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function changepermission($share, $sharetype, $id, $permission, $type){ + if($sharetype == 'public' && $permission == 1){ + $permission = 0; + } + $stmt = OCP\DB::prepare('UPDATE *PREFIX*calendar_share_' . $type . ' SET permissions = ? WHERE share = ? AND sharetype = ? AND ' . $type . 'id = ?'); + $stmt->execute(array($permission, $share, $sharetype, $id)); + return true; + } + /* + * @brief: generates a token for public calendars / events + * @return: (string) $token + */ + private static function generate_token($id, $type){ + $uniqid = uniqid(); + if($type == self::CALENDAR){ + $events = OC_Calendar_Object::all($id); + $string = ''; + foreach($events as $event){ + $string .= $event['calendardata']; + } + }else{ + $string = OC_Calendar_Object::find($id); + } + $string = sha1($string['calendardata']); + $id = sha1($id); + $array = array($uniqid,$string,$id); + shuffle($array); + $string = implode('', $array); + $token = md5($string); + return substr($token, rand(0,16), 15); + } + /* + * @brief: checks if it is already shared + * @param: (string) $owner - userid of the owner + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $sharetype - type of sharing (can be: user/group/public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function is_already_shared($owner, $share, $sharetype, $id, $type){ + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE owner = ? AND share = ? AND sharetype = ? AND ' . $type . 'id = ?'); + $result = $stmt->execute(array($owner, $share, $sharetype, $id)); + if($result->numRows() > 0){ + return true; + } + return false; + } + private static function group_sql($groups){ + $group_where = ''; + $i = 0; + foreach($groups as $group){ + $group_where .= ' OR '; + $group_where .= ' (share = "' . $group . '" AND sharetype = "group") '; + $i++; + } + return $group_where; + } + private static function permission_sql($permission = null){ + $permission_where = ''; + if(!is_null($permission)){ + $permission_where = ' AND permissions = '; + $permission_where .= ($permission=='rw')?'"1"':'"0"'; + } + return $permission_where; + } + private static function active_sql($active = null){ + $active_where = ''; + if(!is_null($active)){ + $active_where = 'AND active = '; + $active_where .= (!is_null($active) && $active)?'1':'0'; + } + return $active_where; + } + /* + * @brief: checks the permission for editing an event + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function is_editing_allowed($share, $id, $type){ + $group_where = self::group_sql(OC_Group::getUserGroups($share)); + $permission_where = self::permission_sql('rw'); + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') ' . $permission_where); + $result = $stmt->execute(array($share)); + if($result->numRows() == 1){ + return true; + } + if($type == self::EVENT){ + $event = OC_Calendar_App::getEventObject($id, false, false); + return self::is_editing_allowed($share, $event['calendarid'], self::CALENDAR); + } + return false; + } + /* + * @brief: checks the access of + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function check_access($share, $id, $type){ + $group_where = self::group_sql(OC_Group::getUserGroups($share)); + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE (' . $type . 'id = ? AND (share = ? AND sharetype = "user") ' . $group_where . ')'); + $result = $stmt->execute(array($id,$share)); + $rows = $result->numRows(); + if($rows > 0){ + return true; + }elseif($type == self::EVENT){ + $event = OC_Calendar_App::getEventObject($id, false, false); + return self::check_access($share, $event['calendarid'], self::CALENDAR); + }else{ + return false; + } + } + /* + * @brief: returns the calendardata of an event or a calendar + * @param: (string) $token - token which should be searched + * @return: mixed - bool if false, array with type and id if true + */ + public static function getElementByToken($token){ + $stmt_calendar = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::CALENDAR . ' WHERE sharetype = "public" AND share = ?'); + $result_calendar = $stmt_calendar->execute(array($token)); + $stmt_event = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::EVENT . ' WHERE sharetype = "public" AND share = ?'); + $result_event = $stmt_event->execute(array($token)); + $return = array(); + if($result_calendar->numRows() == 0 && $result_event->numRows() == 0){ + return false; + }elseif($result_calendar->numRows() != 0){ + $return ['type'] = 'calendar'; + $calendar = $result_calendar->fetchRow(); + $return ['id'] = $calendar['calendarid']; + }else{ + $return ['type'] = 'event'; + $event = $result_event->fetchRow(); + $return ['id'] = $event['eventid']; + } + return $return; + } + + /* + * @brief sets the active status of the calendar + * @param (string) $ + */ + public static function set_active($share, $id, $active){ + $stmt = OCP\DB::prepare('UPDATE *PREFIX*calendar_share_calendar SET active = ? WHERE share = ? AND sharetype = "user" AND calendarid = ?'); + $stmt->execute(array($active, $share, $id)); + } +}
\ No newline at end of file diff --git a/apps/calendar/resettimezone.php b/apps/calendar/resettimezone.php deleted file mode 100644 index 1ef9591ae39..00000000000 --- a/apps/calendar/resettimezone.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php -require_once ("../../lib/base.php"); -OC_Preferences::deleteKey(OC_USER::getUser(), 'calendar', 'timezone'); -?>
\ No newline at end of file diff --git a/apps/calendar/settings.php b/apps/calendar/settings.php index b5922802716..981df9ffafd 100644..100755 --- a/apps/calendar/settings.php +++ b/apps/calendar/settings.php @@ -7,10 +7,10 @@ */ $tmpl = new OC_Template( 'calendar', 'settings'); -$timezone=OC_Preferences::getValue(OC_User::getUser(),'calendar','timezone',''); +$timezone=OCP\Config::getUserValue(OCP\USER::getUser(),'calendar','timezone',''); $tmpl->assign('timezone',$timezone); $tmpl->assign('timezones',DateTimeZone::listIdentifiers()); -OC_Util::addScript('calendar','settings'); +OCP\Util::addscript('calendar','settings'); return $tmpl->fetchPage(); diff --git a/apps/calendar/share.php b/apps/calendar/share.php new file mode 100644 index 00000000000..1cc8a2ef15e --- /dev/null +++ b/apps/calendar/share.php @@ -0,0 +1,23 @@ +<?php +require_once('../../lib/base.php'); +$token = strip_tags($_GET['t']); +$shared = OC_Calendar_Share::getElementByToken($token); +$nl = "\n\r"; +if($shared['type'] == OC_Calendar_Share::CALENDAR){ + $calendar = OC_Calendar_App::getCalendar($shared['id'], false); + $calobjects = OC_Calendar_Object::all($shared['id']); + header('Content-Type: text/Calendar'); + header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics'); + foreach($calobjects as $calobject){ + echo $calobject['calendardata'] . $nl; + } +}elseif($shared['type'] == OC_Calendar_Share::EVENT){ + $data = OC_Calendar_App::getEventObject($shared['id'], false); + $calendarid = $data['calendarid']; + $calendar = OC_Calendar_App::getCalendar($calendarid); + header('Content-Type: text/Calendar'); + header('Content-Disposition: inline; filename=' . $data['summary'] . '.ics'); + echo $data['calendardata']; +}else{ + header('Error 404: Not Found'); +}
\ No newline at end of file diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index ba9423a66f1..7e767e36732 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -1,13 +1,13 @@ <script type='text/javascript'> - var defaultView = '<?php echo OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') ?>'; + var defaultView = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') ?>'; var eventSources = <?php echo json_encode($_['eventSources']) ?>; var categories = <?php echo json_encode($_['categories']); ?>; var dayNames = <?php echo json_encode($l->tA(array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'))) ?>; var dayNamesShort = <?php echo json_encode($l->tA(array('Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'))) ?>; var monthNames = <?php echo json_encode($l->tA(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'))) ?>; var monthNamesShort = <?php echo json_encode($l->tA(array('Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'))) ?>; - var agendatime = '<?php echo ((int) OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>{ - <?php echo ((int) OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>}'; - var defaulttime = '<?php echo ((int) OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>'; + var agendatime = '<?php echo ((int) OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>{ - <?php echo ((int) OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>}'; + var defaulttime = '<?php echo ((int) OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>'; var allDayText = '<?php echo addslashes($l->t('All day')) ?>'; var newcalendar = '<?php echo addslashes($l->t('New Calendar')) ?>'; var missing_field = '<?php echo addslashes($l->t('Missing fields')) ?>'; @@ -19,8 +19,8 @@ var missing_field_totime = '<?php echo addslashes($l->t('To Time')) ?>'; var missing_field_startsbeforeends = '<?php echo addslashes($l->t('The event ends before it starts')) ?>'; var missing_field_dberror = '<?php echo addslashes($l->t('There was a database fail')) ?>'; - var totalurl = '<?php echo OC_Helper::linkToAbsolute('calendar', 'caldav.php'); ?>/calendars'; - var firstDay = '<?php echo (OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'firstday', 'mo') == 'mo' ? '1' : '0'); ?>'; + var totalurl = '<?php echo OCP\Util::linkToAbsolute('calendar', 'caldav.php'); ?>/calendars'; + var firstDay = '<?php echo (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'firstday', 'mo') == 'mo' ? '1' : '0'); ?>'; $(document).ready(function() { <?php if(array_key_exists('showevent', $_)){ @@ -40,7 +40,7 @@ <input type="button" value="<?php echo $l->t('Week');?>" id="oneweekview_radio"/> <input type="button" value="<?php echo $l->t('Month');?>" id="onemonthview_radio"/> <input type="button" value="<?php echo $l->t('List');?>" id="listview_radio"/> - <img id="loading" src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /> + <img id="loading" src="<?php echo OCP\Util::imagePath('core', 'loading.gif'); ?>" /> </div> </form> <form> diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php index 86f09d62076..af3b82a48fc 100644..100755 --- a/apps/calendar/templates/part.choosecalendar.php +++ b/apps/calendar/templates/part.choosecalendar.php @@ -1,11 +1,18 @@ <div id="choosecalendar_dialog" title="<?php echo $l->t("Choose active calendars"); ?>"> +<p><b><?php echo $l->t('Your calendars'); ?>:</b></p> <table width="100%" style="border: 0;"> <?php -$option_calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$option_calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); for($i = 0; $i < count($option_calendars); $i++){ echo "<tr>"; $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $option_calendars[$i]); + if(OC_Calendar_Share::allUsersSharedwith($option_calendars[$i]['id'], OC_Calendar_Share::CALENDAR) == array()){ + $shared = false; + }else{ + $shared = true; + } + $tmpl->assign('shared', $shared); $tmpl->printpage(); echo "</tr>"; } @@ -20,4 +27,25 @@ for($i = 0; $i < count($option_calendars); $i++){ <p style="margin: 0 auto;width: 90%;"><input style="display:none;width: 90%;float: left;" type="text" id="caldav_url" onmouseover="$('#caldav_url').select();" title="<?php echo $l->t("CalDav Link"); ?>"><img id="caldav_url_close" style="height: 20px;vertical-align: middle;display: none;" src="../../core/img/actions/delete.svg" alt="close" onclick="$('#caldav_url').hide();$('#caldav_url_close').hide();"/></p> </td> </tr> +</table><br> +<p><b><?php echo $l->t('Shared calendars'); ?>: </b></p> +<table width="100%" style="border: 0;"> +<?php +$share = OC_Calendar_Share::allSharedwithuser(OCP\USER::getUser(), OC_Calendar_Share::CALENDAR); +$count = count($share); +for($i = 0; $i < $count; $i++){ + $share[$i]['calendar'] = OC_Calendar_App::getCalendar($share[$i]['calendarid'], false, false); + echo '<tr>'; + $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields.shared'); + $tmpl->assign('share', $share[$i]); + $tmpl->printpage(); + echo '</tr>'; +} +?> </table> +<?php +if($count == 0){ + echo '<p style="text-align:center;"><b>' . $l->t('No shared calendars') . '</b></p>'; +} +?> +</div>
\ No newline at end of file diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php index a789be45a43..8848d228054 100644..100755 --- a/apps/calendar/templates/part.choosecalendar.rowfields.php +++ b/apps/calendar/templates/part.choosecalendar.rowfields.php @@ -1,4 +1,8 @@ <?php - echo "<td width=\"20px\"><input id=\"active_" . $_['calendar']["id"] . "\" type=\"checkbox\" onClick=\"Calendar.UI.Calendar.activation(this, " . $_['calendar']["id"] . ")\"" . ($_['calendar']["active"] ? ' checked="checked"' : '') . "></td>"; - echo "<td><label for=\"active_" . $_['calendar']["id"] . "\">" . $_['calendar']["displayname"] . "</label></td>"; - echo "<td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.showCalDAVUrl('" . OC_User::getUser() . "', '" . $_['calendar']["uri"] . "');\" title=\"" . $l->t("CalDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?calid=" . $_['calendar']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.Calendar.deleteCalendar('" . $_['calendar']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>"; +echo '<td width="20px"><input id="active_' . $_['calendar']['id'] . '" type="checkbox" onClick="Calendar.UI.Calendar.activation(this,' . $_['calendar']['id'] . ')"' . ($_['calendar']['active'] ? ' checked="checked"' : '') . '></td>'; +echo '<td id="' . OCP\USER::getUser() . '_' . $_['calendar']['id'] . '"><label for="active_' . $_['calendar']['id'] . '">' . $_['calendar']['displayname'] . '</label></td>'; +echo '<td width="20px"><a href="#" onclick="Calendar.UI.Share.dropdown(\'' . OCP\USER::getUser() . '\', \'' . $_['calendar']['id'] . '\');" title="' . $l->t("Share Calendar") . '" class="action"><img class="svg action" src="' . ((!$_['shared']) ? '../../core/img/actions/share.svg' : '../../core/img/actions/shared.svg') . '"></a></td>'; +echo '<td width="20px"><a href="#" onclick="Calendar.UI.showCalDAVUrl(\'' . OCP\USER::getUser() . '\', \'' . $_['calendar']['uri'] . '\');" title="' . $l->t("CalDav Link") . '" class="action"><img class="svg action" src="../../core/img/actions/public.svg"></a></td>'; +echo '<td width="20px"><a href="export.php?calid=' . $_['calendar']['id'] . '" title="' . $l->t('Download') . '" class="action"><img class="svg action" src="../../core/img/actions/download.svg"></a></td>'; +echo '<td width="20px"><a href="#" title="' . $l->t('Edit') . '" class="action" onclick="Calendar.UI.Calendar.edit(this, ' . $_['calendar']['id'] . ');"><img class="svg action" src="../../core/img/actions/rename.svg"></a></td>'; +echo '<td width="20px"><a href="#" onclick="Calendar.UI.Calendar.deleteCalendar(\'' . $_['calendar']['id'] . '\');" title="' . $l->t('Delete') . '" class="action"><img class="svg action" src="../../core/img/actions/delete.svg"></a></td>';
\ No newline at end of file diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.shared.php b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php new file mode 100644 index 00000000000..a23266da0c3 --- /dev/null +++ b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php @@ -0,0 +1,4 @@ +<?php +echo '<td width="20px"><input id="active_' . $_['share']['owner'] . '_' . $_['share']['calendar']['id'] . '" type="checkbox" onClick="Calendar.UI.Share.activation(this,\'' . $_['share']['owner'] . '\',' . $_['share']['calendar']['id'] . ')"' . ($_['share']['active'] ? ' checked="checked"' : '') . '></td>'; +echo '<td><label for="active_' . $_['share']['owner'] . '_' . $_['share']['calendar']['id'] . '">' . $_['share']['calendar']['displayname'] . '</label></td>'; +echo '<td style="font-style: italic;">' . $l->t('shared with you by') . ' ' . $_['share']['owner'] . '</td>';
\ No newline at end of file diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php index 6e319e1b4e0..102366f8f08 100644 --- a/apps/calendar/templates/part.editevent.php +++ b/apps/calendar/templates/part.editevent.php @@ -1,13 +1,13 @@ <div id="event" title="<?php echo $l->t("Edit an event");?>"> <form id="event_form"> - <input type="hidden" name="id" value="<?php echo $_['id'] ?>"> + <input type="hidden" name="id" value="<?php echo $_['eventid'] ?>"> <input type="hidden" name="lastmodified" value="<?php echo $_['lastmodified'] ?>"> <?php echo $this->inc("part.eventform"); ?> <div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div> <span id="actions"> - <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/event/edit.php');"> - <input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/event/delete.php');"> - <input type="button" class="submit" style="float: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='export.php?eventid=<?php echo $_['id'] ?>';"> + <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('?app=calendar&getfile=ajax/event/edit.php');"> + <input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('?app=calendar&getfile=ajax/event/delete.php');"> + <input type="button" class="submit" style="float: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='?app=calendar&getfile=export.php?eventid=<?php echo $_['eventid'] ?>';"> </span> </form> </div> diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 3830c273a73..1eee099d0d1 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -1,3 +1,19 @@ +<script type="text/javascript"> +<?php +echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid = "' . $_['eventid'] . '";'; +?> +</script> + +<ul> + <li><a href="#tabs-1"><?php echo $l->t('Eventinfo'); ?></a></li> + <li><a href="#tabs-2"><?php echo $l->t('Repeating'); ?></a></li> + <!--<li><a href="#tabs-3"><?php echo $l->t('Alarm'); ?></a></li> + <li><a href="#tabs-4"><?php echo $l->t('Attendees'); ?></a></li>--> + <?php if($_['access'] == 'owner') { ?> + <li><a href="#tabs-5"><?php echo $l->t('Share'); ?></a></li> + <?php } ?> +</ul> +<div id="tabs-1"> <table width="100%"> <tr> <th width="75px"><?php echo $l->t("Title");?>:</th> @@ -26,7 +42,7 @@ <?php } else { ?> <th width="75px"> </th> <td> - <input type="hidden" name="calendar" value="<?php echo $_['calendar_options'][0]['id'] ?>"> + <input type="hidden" name="calendar" value="<?php echo $_['calendar_options'][0]['id']; ?>"> </td> <?php } ?> </tr> @@ -59,7 +75,27 @@ </table> <input type="button" class="submit" value="<?php echo $l->t("Advanced options"); ?>" onclick="Calendar.UI.showadvancedoptions();" id="advanced_options_button"> <div id="advanced_options" style="display: none;"> - <table style="width:100%"> + <hr> + <table> + <tr> + <th width="85px"><?php echo $l->t("Location");?>:</th> + <td> + <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" value="<?php echo isset($_['location']) ? htmlspecialchars($_['location']) : '' ?>" maxlength="100" name="location" /> + </td> + </tr> + </table> + <table> + <tr> + <th width="85px" style="vertical-align: top;"><?php echo $l->t("Description");?>:</th> + <td> + <textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo isset($_['description']) ? htmlspecialchars($_['description']) : '' ?></textarea> + </td> + </tr> + </table> + </div> + </div> +<div id="tabs-2"> + <table style="width:100%"> <tr> <th width="75px"><?php echo $l->t("Repeat");?>:</th> <td> @@ -112,7 +148,7 @@ <tr id="advanced_weekday" style="display:none;"> <th width="75px"></th> <td id="weeklycheckbox"> - <select id="weeklyoptions" name="weeklyoptions[]" multiple="multiple" title="<?php echo $l->t("Select weekdays") ?>"> + <select id="weeklyoptions" name="weeklyoptions[]" multiple="multiple" style="width: 150px;" title="<?php echo $l->t("Select weekdays") ?>"> <?php if (!isset($_['weekdays'])) {$_['weekdays'] = array();} echo html_select_options($_['repeat_weekly_options'], $_['repeat_weekdays'], array('combine'=>true)); @@ -185,6 +221,7 @@ <td> <select id="end" name="end"> <?php + if($_['repeat_end'] == '') $_['repeat_end'] = 'never'; echo html_select_options($_['repeat_end_options'], $_['repeat_end']); ?> </select> @@ -203,23 +240,13 @@ </td> </tr> </table> + <?php echo $l->t('Summary'); ?>:<span id="repeatsummary"></span> </div> - <hr> - <!-- support for attendees will be added in following versions --> - <table> - <tr> - <th width="85px"><?php echo $l->t("Location");?>:</th> - <td> - <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" value="<?php echo isset($_['location']) ? htmlspecialchars($_['location']) : '' ?>" maxlength="100" name="location" /> - </td> - </tr> - </table> - <table> - <tr> - <th width="85px" style="vertical-align: top;"><?php echo $l->t("Description");?>:</th> - <td> - <textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo isset($_['description']) ? htmlspecialchars($_['description']) : '' ?></textarea> - </td> - </tr> - </table> - </div> +</div> +<!--<div id="tabs-3">//Alarm</div> +<div id="tabs-4">//Attendees</div>--> +<?php if($_['access'] == 'owner') { ?> +<div id="tabs-5"> + <?php echo $this->inc('share.dropdown'); ?> +</div> +<?php } ?> diff --git a/apps/calendar/templates/part.import.php b/apps/calendar/templates/part.import.php index 8f46484b42b..80375c3ef78 100644..100755 --- a/apps/calendar/templates/part.import.php +++ b/apps/calendar/templates/part.import.php @@ -3,10 +3,10 @@ <input type="hidden" id="filename" value="<?php echo $_['filename'];?>"> <input type="hidden" id="path" value="<?php echo $_['path'];?>"> <input type="hidden" id="progressfile" value="<?php echo md5(session_id()) . '.txt';?>"> -<p style="text-align:center;"><b><?php echo $l->t('Please choose the calendar'); ?></b> +<p style="text-align:center;"><b><?php echo $l->t('Please choose the calendar'); ?></b></p> <select style="width:100%;" id="calendar" name="calendar"> <?php -$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$calendar_options = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); $calendar_options[] = array('id'=>'newcal', 'displayname'=>$l->t('create a new calendar')); echo html_select_options($calendar_options, $calendar_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); ?> @@ -17,7 +17,7 @@ echo html_select_options($calendar_options, $calendar_options[0]['id'], array('v <input type="button" value="<?php echo $l->t("Import");?>!" id="startimport"> </div> <div id="progressbar_container" style="display: none"> -<p style="text-align:center;"><b><?php echo $l->t('Importing calendar'); ?></b> +<p style="text-align:center;"><b><?php echo $l->t('Importing calendar'); ?></b></p> <div id="progressbar"></div> <div id="import_done" style="display: none;"> <p style="text-align:center;"><b><?php echo $l->t('Calendar imported successfully'); ?></b></p> diff --git a/apps/calendar/templates/part.newevent.php b/apps/calendar/templates/part.newevent.php index 11416260344..f4bb867b180 100644 --- a/apps/calendar/templates/part.newevent.php +++ b/apps/calendar/templates/part.newevent.php @@ -3,7 +3,7 @@ <?php echo $this->inc("part.eventform"); ?> <div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div> <span id="actions"> - <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/event/new.php');"> + <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('?app=calendar&getfile=ajax/event/new.php');"> </span> </form> </div> diff --git a/apps/calendar/templates/part.showevent.php b/apps/calendar/templates/part.showevent.php new file mode 100644 index 00000000000..6baf0415d54 --- /dev/null +++ b/apps/calendar/templates/part.showevent.php @@ -0,0 +1,247 @@ +<div id="event" title="<?php echo $l->t("View an event");?>"> +<ul> + <li><a href="#tabs-1"><?php echo $l->t('Eventinfo'); ?></a></li> + <li><a href="#tabs-2"><?php echo $l->t('Repeating'); ?></a></li> + <!--<li><a href="#tabs-3"><?php echo $l->t('Alarm'); ?></a></li> + <li><a href="#tabs-4"><?php echo $l->t('Attendees'); ?></a></li>--> +</ul> +<div id="tabs-1"> + <table width="100%"> + <tr> + <th width="75px"><?php echo $l->t("Title");?>:</th> + <td> + <?php echo isset($_['title']) ? htmlspecialchars($_['title']) : '' ?> + </td> + </tr> + </table> + <table width="100%"> + <tr> + <th width="75px"><?php echo $l->t("Category");?>:</th> + <td> + <?php + if(count($_['categories']) == 0){ + echo $l->t('No categories selected'); + }else{ + echo '<select id="category" name="categories[]" multiple="multiple" title="' . $l->t("Select category") . '">'; + echo html_select_options($_['categories'], $_['categories'], array('combine'=>true)); + echo '</select>'; + } + ?> + </td> + <th width="75px"> <?php echo $l->t("Calendar");?>:</th> + <td> + <select name="calendar" disabled="disabled"> + <option> + <?php + $calendar = OC_Calendar_App::getCalendar($_['calendar']); + echo $calendar['displayname'] . ' ' . $l->t('of') . ' ' . $calendar['userid']; + ?> + </option> + + </select> + </td> + <th width="75px"> </th> + <td> + <input type="hidden" name="calendar" value="<?php echo $_['calendar_options'][0]['id'] ?>"> + </td> + </tr> + </table> + <hr> + <table width="100%"> + <tr> + <th width="75px"></th> + <td> + <input onclick="Calendar.UI.lockTime();" type="checkbox"<?php if($_['allday']){echo 'checked="checked"';} ?> id="allday_checkbox" name="allday" disabled="disabled"> + <?php echo $l->t("All Day Event");?> + </td> + </tr> + <tr> + <th width="75px"><?php echo $l->t("From");?>:</th> + <td> + <?php echo $_['startdate'];?> + <?php echo (!$_['allday'])?$l->t('at'):''; ?> + <?php echo $_['starttime'];?> + </td> + </tr> + <tr> + <th width="75px"><?php echo $l->t("To");?>:</th> + <td> + <?php echo $_['enddate'];?> + <?php echo (!$_['allday'])?$l->t('at'):''; ?> + <?php echo $_['endtime'];?> + </td> + </tr> + </table> + <input type="button" class="submit" value="<?php echo $l->t("Advanced options"); ?>" onclick="Calendar.UI.showadvancedoptions();" id="advanced_options_button"> + <div id="advanced_options" style="display: none;"> + <hr> + <table> + <tr> + <th width="85px"><?php echo $l->t("Location");?>:</th> + <td> + <?php echo isset($_['location']) ? htmlspecialchars($_['location']) : '' ?> + </td> + </tr> + </table> + <table> + <tr> + <th width="85px" style="vertical-align: top;"><?php echo $l->t("Description");?>:</th> + <td> + <?php echo isset($_['description']) ? htmlspecialchars($_['description']) : '' ?></textarea> + </tr> + </table> + </div> + </div> +<div id="tabs-2"> + <table style="width:100%"> + <tr> + <th width="75px"><?php echo $l->t("Repeat");?>:</th> + <td> + <select id="repeat" name="repeat"> + <?php + echo html_select_options(array($_['repeat_options'][$_['repeat']]), $_['repeat']); + ?> + </select></td> + <td><input type="button" style="float:right;" class="submit" value="<?php echo $l->t("Advanced"); ?>" onclick="Calendar.UI.showadvancedoptionsforrepeating();" id="advanced_options_button"></td> + </tr> + </table> + <div id="advanced_options_repeating" style="display:none;"> + <table style="width:100%"> + <tr id="advanced_month" style="display:none;"> + <th width="75px"></th> + <td> + <select id="advanced_month_select" name="advanced_month_select"> + <?php + echo html_select_options(array($_['repeat_month_options'][$_['repeat_month']]), $_['repeat_month']); + ?> + </select> + </td> + </tr> + </table> + <table style="width:100%"> + <tr id="advanced_year" style="display:none;"> + <th width="75px"></th> + <td> + <select id="advanced_year_select" name="advanced_year_select"> + <?php + echo html_select_options(array($_['repeat_year_options'][$_['repeat_year']]), $_['repeat_year']); + ?> + </select> + </td> + </tr> + </table> + <table style="width:100%"> + <tr id="advanced_weekofmonth" style="display:none;"> + <th width="75px"></th> + <td id="weekofmonthcheckbox"> + <select id="weekofmonthoptions" name="weekofmonthoptions"> + <?php + echo html_select_options(array($_['repeat_weekofmonth_options'][$_['repeat_weekofmonth']]), $_['repeat_weekofmonth']); + ?> + </select> + </td> + </tr> + </table> + <table style="width:100%"> + <tr id="advanced_weekday" style="display:none;"> + <th width="75px"></th> + <td id="weeklycheckbox"> + <select id="weeklyoptions" name="weeklyoptions[]" multiple="multiple" style="width: 150px;" title="<?php echo $l->t("Select weekdays") ?>"> + <?php + if (!isset($_['weekdays'])) {$_['weekdays'] = array();} + echo html_select_options(array($_['repeat_weekly_options'][$_['repeat_weekdays']]), $_['repeat_weekdays'], array('combine'=>true)); + ?> + </select> + </td> + </tr> + </table> + <table style="width:100%"> + <tr id="advanced_byyearday" style="display:none;"> + <th width="75px"></th> + <td id="byyeardaycheckbox"> + <select id="byyearday" name="byyearday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>"> + <?php + if (!isset($_['repeat_byyearday'])) {$_['repeat_byyearday'] = array();} + echo html_select_options(array($_['repeat_byyearday_options'][$_['repeat_byyearday']]), $_['repeat_byyearday'], array('combine'=>true)); + ?> + </select><?php echo $l->t('and the events day of year.'); ?> + </td> + </tr> + </table> + <table style="width:100%"> + <tr id="advanced_bymonthday" style="display:none;"> + <th width="75px"></th> + <td id="bymonthdaycheckbox"> + <select id="bymonthday" name="bymonthday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>"> + <?php + if (!isset($_['repeat_bymonthday'])) {$_['repeat_bymonthday'] = array();} + echo html_select_options(array($_['repeat_bymonthday_options'][$_['repeat_bymonthday']]), $_['repeat_bymonthday'], array('combine'=>true)); + ?> + </select><?php echo $l->t('and the events day of month.'); ?> + </td> + </tr> + </table> + <table style="width:100%"> + <tr id="advanced_bymonth" style="display:none;"> + <th width="75px"></th> + <td id="bymonthcheckbox"> + <select id="bymonth" name="bymonth[]" multiple="multiple" title="<?php echo $l->t("Select months") ?>"> + <?php + if (!isset($_['repeat_bymonth'])) {$_['repeat_bymonth'] = array();} + echo html_select_options(array($_['repeat_bymonth_options'][$_['repeat_bymonth']]), $_['repeat_bymonth'], array('combine'=>true)); + ?> + </select> + </td> + </tr> + </table> + <table style="width:100%"> + <tr id="advanced_byweekno" style="display:none;"> + <th width="75px"></th> + <td id="bymonthcheckbox"> + <select id="byweekno" name="byweekno[]" multiple="multiple" title="<?php echo $l->t("Select weeks") ?>"> + <?php + if (!isset($_['repeat_byweekno'])) {$_['repeat_byweekno'] = array();} + echo html_select_options(array($_['repeat_byweekno_options'][$_['repeat_byweekno']]), $_['repeat_byweekno'], array('combine'=>true)); + ?> + </select><?php echo $l->t('and the events week of year.'); ?> + </td> + </tr> + </table> + <table style="width:100%"> + <tr> + <th width="75px"><?php echo $l->t('Interval'); ?>:</th> + <td> + <?php echo isset($_['repeat_interval']) ? $_['repeat_interval'] : '1'; ?> + </td> + </tr> + <tr> + <th width="75px"><?php echo $l->t('End'); ?>:</th> + <td> + <select id="end" name="end"> + <?php + if($_['repeat_end'] == '') $_['repeat_end'] = 'never'; + echo html_select_options(array($_['repeat_end_options'][$_['repeat_end']]), $_['repeat_end']); + ?> + </select> + </td> + </tr> + <tr> + <th></th> + <td id="byoccurrences" style="display:none;"> + <?php echo $_['repeat_count'] . ' ' . $l->t('occurrences'); ?> + </td> + </tr> + <tr> + <th></th> + <td id="bydate" style="display:none;"> + <?php echo $_['repeat_date']; ?> + </td> + </tr> + </table> + <?php echo $l->t('Summary'); ?>:<span id="repeatsummary"></span> + </div> +</div> +<!--<div id="tabs-3">//Alarm</div> +<div id="tabs-4">//Attendees</div>--> + +</div>
\ No newline at end of file diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index fb2a04a6498..ac32b79215f 100644..100755 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -9,7 +9,7 @@ ?> <form id="calendar"> <fieldset class="personalblock"> - <strong><?php echo $l->t('Calendar'); ?></strong> + <legend><?php echo $l->t('Calendar'); ?></legend> <table class="nostyle"> <tr><td><label for="timezone" class="bold"><?php echo $l->t('Timezone');?></label></td><td><select style="display: none;" id="timezone" name="timezone"> <?php @@ -47,6 +47,6 @@ </table> <?php echo $l->t('Calendar CalDAV syncing address:');?> - <?php echo OC_Helper::linkToAbsolute('calendar', 'caldav.php'); ?><br /> + <code><?php echo OCP\Util::linkToAbsolute('calendar', 'caldav.php'); ?></code><br /> </fieldset> </form> diff --git a/apps/calendar/templates/share.dropdown.php b/apps/calendar/templates/share.dropdown.php new file mode 100755 index 00000000000..b11a4ef94cf --- /dev/null +++ b/apps/calendar/templates/share.dropdown.php @@ -0,0 +1,77 @@ +<?php +if(array_key_exists('calid', $_)){ + $id = $_['calid']; + $sharedelements = OC_Calendar_Share::allUsersSharedwith($_['calid'], OC_Calendar_Share::CALENDAR); +}else{ + $sharedelements = OC_Calendar_Share::allUsersSharedwith($_['eventid'], OC_Calendar_Share::EVENT); + $id = $_['eventid']; +} +$users = array();$groups = array();$public = array(); +foreach($sharedelements as $sharedelement){ + if($sharedelement['sharetype'] == 'user'){ + $users[] = $sharedelement; + }elseif($sharedelement['sharetype'] == 'group'){ + $groups[] = $sharedelement; + }elseif($sharedelement['sharetype'] == 'public'){ + $public = $sharedelement; + } +} +?> +<strong><?php echo $l->t('Users');?>:</strong><br> +<select id="share_user" title="<?php echo $l->t('select users');?>" data-placeholder="<?php echo $l->t('select users'); ?>"> +<option value=""></option> +<?php +$allocusers = OCP\USER::getUsers(); +$allusers = array(); +foreach($allocusers as $ocuser){ + $allusers[$ocuser] = $ocuser; +} +unset($allusers[OCP\USER::getUser()]); +$allusers = array_flip($allusers); +echo html_select_options($allusers, array()); +?> +</select><br> +<ul id="sharewithuser_list"> +<?php foreach($users as $user): ?> + <li id="sharewithuser_<?php echo $user['share']; ?>"><input type="checkbox" width="12px" <?php echo ($user['permissions']?'checked="checked"':'')?> style="visibility:hidden;" title="<?php echo $l->t('Editable'); ?>"><?php echo $user['share']; ?><img src="<?php echo OC::$WEBROOT; ?>/core/img/actions/delete.svg" class="svg action" style="display:none;float:right;"></li> + <script> + $('#sharewithuser_<?php echo $user['share']; ?> > img').click(function(){ + $('#share_user option[value="<?php echo $user['share']; ?>"]').removeAttr('disabled'); + Calendar.UI.Share.unshare(<?php echo $id; ?>, '<?php echo (array_key_exists('calid', $_)?'calendar':'event');?>', '<?php echo $user['share']; ?>', 'user'); + $('#sharewithuser_<?php echo $user['share']; ?>').remove(); + $("#share_user").trigger("liszt:updated"); + }); + $('#share_user option[value="<?php echo $user['share']; ?>"]').attr('disabled', 'disabled'); + </script> +<?php endforeach; ?> +</ul> +<strong><?php echo $l->t('Groups');?>:</strong><br> +<select id="share_group" title="<?php echo $l->t('select groups');?>" data-placeholder="<?php echo $l->t('select groups'); ?>"> +<option value=""></option> +<?php +$allocgroups = OC_Group::getGroups(); +$allgroups = array(); +foreach($allocgroups as $ocgroup){ + $allgroups[$ocgroup] = $ocgroup; +} +echo html_select_options($allgroups, array()); +?> +</select><br> +<ul id="sharewithgroup_list"> +<?php foreach($groups as $group): ?> + <li id="sharewithgroup_<?php echo $group['share']; ?>"><input type="checkbox" width="12px" <?php echo ($group['permissions']?'checked="checked"':'')?> style="visibility:hidden;" title="<?php echo $l->t('Editable'); ?>"><?php echo $group['share']; ?><img src="<?php echo OC::$WEBROOT; ?>/core/img/actions/delete.svg" class="svg action" style="display:none;float:right;"></li> + <script> + $('#sharewithgroup_<?php echo $group['share']; ?> > img').click(function(){ + $('#share_group option[value="<?php echo $group['share']; ?>"]').removeAttr('disabled'); + Calendar.UI.Share.unshare(<?php echo $id; ?>, '<?php echo (array_key_exists('calid', $_)?'calendar':'event');?>, '<?php echo $group['share']; ?>', 'group'); ?> + $('#sharewithgroup_<?php echo $group['share']; ?>').remove(); + $("#share_group").trigger("liszt:updated"); + }); + $('#share_group option[value="<?php echo $group['share']; ?>"]').attr('disabled', 'disabled'); + </script> +<?php endforeach; ?> +</ul> +<div id="public"> + <input type="checkbox" id="publish" <?php echo ($public['share'])?'checked="checked"':'' ?>><label for="publish"><?php echo $l->t('make public'); ?></label><br> + <input type="text" id="public_token" value="<?php echo OCP\Util::linkToAbsolute('apps/calendar', 'share.php?t=' . $public['share'], null, true) ; ?>" onmouseover="$('#public_token').select();" style="<?php echo (!$public['share'])?'display:none':'' ?>"> +</div>
\ No newline at end of file |