aboutsummaryrefslogtreecommitdiffstats
path: root/apps/calendar/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'apps/calendar/ajax')
-rw-r--r--apps/calendar/ajax/activation.php3
-rw-r--r--apps/calendar/ajax/createcalendar.php5
-rw-r--r--apps/calendar/ajax/deletecalendar.php8
-rw-r--r--apps/calendar/ajax/deleteevent.php12
-rw-r--r--apps/calendar/ajax/editcalendar.php4
-rw-r--r--apps/calendar/ajax/editevent.php23
-rw-r--r--apps/calendar/ajax/editeventform.php18
-rw-r--r--apps/calendar/ajax/moveevent.php26
-rw-r--r--apps/calendar/ajax/neweventform.php6
-rw-r--r--apps/calendar/ajax/resizeevent.php35
-rw-r--r--apps/calendar/ajax/updatecalendar.php6
11 files changed, 39 insertions, 107 deletions
diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php
index 72882496ab6..3c2bc6de23f 100644
--- a/apps/calendar/ajax/activation.php
+++ b/apps/calendar/ajax/activation.php
@@ -12,8 +12,9 @@ if(!OC_USER::isLoggedIn()) {
}
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['calendarid'];
+$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+$calendar = OC_Calendar_App::getCalendar($calendarid);
OC_JSON::success(array(
'active' => $calendar['active'],
'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
diff --git a/apps/calendar/ajax/createcalendar.php b/apps/calendar/ajax/createcalendar.php
index 325a5ec35bc..f8b5974f54c 100644
--- a/apps/calendar/ajax/createcalendar.php
+++ b/apps/calendar/ajax/createcalendar.php
@@ -8,8 +8,6 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
@@ -17,7 +15,8 @@ OC_JSON::checkAppEnabled('calendar');
$userid = OC_User::getUser();
$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+
+$calendar = OC_Calendar_Calendar::find($calendarid);
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
OC_JSON::success(array(
diff --git a/apps/calendar/ajax/deletecalendar.php b/apps/calendar/ajax/deletecalendar.php
index e8ffe0d0598..fc308da6dad 100644
--- a/apps/calendar/ajax/deletecalendar.php
+++ b/apps/calendar/ajax/deletecalendar.php
@@ -7,19 +7,13 @@
*/
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
$cal = $_POST["calendarid"];
-$calendar = OC_Calendar_Calendar::findCalendar($cal);
-if($calendar["userid"] != OC_User::getUser()){
- OC_JSON::error(array('error'=>'permission_denied'));
- exit;
-}
+$calendar = OC_Calendar_App::getCalendar($cal);
$del = OC_Calendar_Calendar::deleteCalendar($cal);
if($del == true){
OC_JSON::success();
diff --git a/apps/calendar/ajax/deleteevent.php b/apps/calendar/ajax/deleteevent.php
index 9e3c7dd87dd..269f4a47f42 100644
--- a/apps/calendar/ajax/deleteevent.php
+++ b/apps/calendar/ajax/deleteevent.php
@@ -15,17 +15,7 @@ if(!OC_USER::isLoggedIn()) {
OC_JSON::checkAppEnabled('calendar');
$id = $_POST['id'];
-$data = OC_Calendar_Object::find($id);
-if (!$data)
-{
- OC_JSON::error();
- exit;
-}
-$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
-if($calendar['userid'] != OC_User::getUser()){
- OC_JSON::error();
- exit;
-}
+$event_object = OC_Calendar_App::getEventObject($id);
$result = OC_Calendar_Object::delete($id);
OC_JSON::success();
?>
diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/editcalendar.php
index d23e5287868..e44763c9aaa 100644
--- a/apps/calendar/ajax/editcalendar.php
+++ b/apps/calendar/ajax/editcalendar.php
@@ -7,13 +7,13 @@
*/
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
OC_JSON::checkAppEnabled('calendar');
+
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
-$calendar = OC_Calendar_Calendar::findCalendar($_GET['calendarid']);
+$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']);
$tmpl = new OC_Template("calendar", "part.editcalendar");
$tmpl->assign('new', false);
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php
index e3c84520481..f00ab1d960b 100644
--- a/apps/calendar/ajax/editevent.php
+++ b/apps/calendar/ajax/editevent.php
@@ -7,9 +7,6 @@
*/
require_once('../../../lib/base.php');
-
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
@@ -23,26 +20,12 @@ if($errarr){
}else{
$id = $_POST['id'];
$cal = $_POST['calendar'];
- $data = OC_Calendar_Object::find($id);
- if (!$data)
- {
- OC_JSON::error();
- exit;
- }
- $calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
- if($calendar['userid'] != OC_User::getUser()){
- OC_JSON::error();
- exit;
- }
+ $data = OC_Calendar_App::getEventObject($id);
$vcalendar = OC_VObject::parse($data['calendardata']);
- $last_modified = $vcalendar->VEVENT->__get('LAST-MODIFIED');
- if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){
- OC_JSON::error(array('modified'=>true));
- exit;
- }
-
+ OC_Calendar_App::isNotModified($vcalendar->VEVENT, $_POST['lastmodified']);
OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar);
+
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
if ($data['calendarid'] != $cal) {
OC_Calendar_Object::moveToCalendar($id, $cal);
diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php
index c91f136e898..fe6c6f73570 100644
--- a/apps/calendar/ajax/editeventform.php
+++ b/apps/calendar/ajax/editeventform.php
@@ -8,26 +8,16 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
-$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
-$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
-$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
-
$id = $_GET['id'];
-$data = OC_Calendar_Object::find($id);
-$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
-if($calendar['userid'] != OC_User::getUser()){
- echo $l10n->t('Wrong calendar');
- exit;
-}
+$data = OC_Calendar_App::getEventObject($id);
$object = OC_VObject::parse($data['calendardata']);
$vevent = $object->VEVENT;
+
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
switch($dtstart->getDateType()) {
@@ -66,6 +56,10 @@ if ($last_modified){
$lastmodified = 0;
}
+$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+$category_options = OC_Calendar_App::getCategoryOptions();
+$repeat_options = OC_Calendar_App::getRepeatOptions();
+
$tmpl = new OC_Template('calendar', 'part.editevent');
$tmpl->assign('id', $id);
$tmpl->assign('lastmodified', $lastmodified);
diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php
index 51fafdfeb97..f2256d4eee6 100644
--- a/apps/calendar/ajax/moveevent.php
+++ b/apps/calendar/ajax/moveevent.php
@@ -5,31 +5,20 @@
* later.
* See the COPYING-README file.
*/
-error_reporting(E_ALL);
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
-$data = OC_Calendar_Object::find($_POST["id"]);
-$calendarid = $data["calendarid"];
-$cal = $calendarid;
+
$id = $_POST['id'];
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
-if(OC_User::getUser() != $calendar['userid']){
- OC_JSON::error();
- exit;
-}
+
+$vcalendar = OC_Calendar_App::getVCalendar($id);
+$vevent = $vcalendar->VEVENT;
+
$allday = $_POST['allDay'];
$delta = new DateInterval('P0D');
$delta->d = $_POST['dayDelta'];
$delta->i = $_POST['minuteDelta'];
-$vcalendar = OC_VObject::parse($data['calendardata']);
-$vevent = $vcalendar->VEVENT;
-
-$last_modified = $vevent->__get('LAST-MODIFIED');
-if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){
- OC_JSON::error();
- exit;
-}
+OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
@@ -50,4 +39,5 @@ $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC
$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
-OC_JSON::success(array('lastmodified'=>(int)$now->format('U')));
+$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime();
+OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U')));
diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php
index 68423adb344..e12e99219e6 100644
--- a/apps/calendar/ajax/neweventform.php
+++ b/apps/calendar/ajax/neweventform.php
@@ -8,8 +8,6 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
@@ -34,8 +32,8 @@ $start->setTimezone(new DateTimeZone($timezone));
$end->setTimezone(new DateTimeZone($timezone));
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
-$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
-$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
+$category_options = OC_Calendar_App::getCategoryOptions();
+$repeat_options = OC_Calendar_App::getRepeatOptions();
$tmpl = new OC_Template('calendar', 'part.newevent');
$tmpl->assign('calendar_options', $calendar_options);
diff --git a/apps/calendar/ajax/resizeevent.php b/apps/calendar/ajax/resizeevent.php
index 28a185411e0..68347906529 100644
--- a/apps/calendar/ajax/resizeevent.php
+++ b/apps/calendar/ajax/resizeevent.php
@@ -5,45 +5,28 @@
* later.
* See the COPYING-README file.
*/
-error_reporting(E_ALL);
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
-$data = OC_Calendar_Object::find($_POST["id"]);
-$calendarid = $data["calendarid"];
-$cal = $calendarid;
+
$id = $_POST['id'];
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
-if(OC_User::getUser() != $calendar['userid']){
- OC_JSON::error();
- exit;
-}
+
+$vcalendar = OC_Calendar_App::getVCalendar($id);
+$vevent = $vcalendar->VEVENT;
$delta = new DateInterval('P0D');
$delta->d = $_POST['dayDelta'];
$delta->i = $_POST['minuteDelta'];
-$vcalendar = OC_Calendar_Object::parse($data['calendardata']);
-$vevent = $vcalendar->VEVENT;
-
-$last_modified = $vevent->__get('LAST-MODIFIED');
-if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){
- OC_JSON::error();
- exit;
-}
+OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
$end_type = $dtend->getDateType();
$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
unset($vevent->DURATION);
-$now = new DateTime();
-$last_modified = new Sabre_VObject_Element_DateTime('LAST-MODIFIED');
-$last_modified->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
-$vevent->__set('LAST-MODIFIED', $last_modified);
-
-$dtstamp = new Sabre_VObject_Element_DateTime('DTSTAMP');
-$dtstamp->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
-$vevent->DTSTAMP = $dtstamp;
+$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
+$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
-OC_JSON::success(array('lastmodified'=>$now->format('U')));
+$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime();
+OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U')));
diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php
index e99ca16e22a..14f560da5a3 100644
--- a/apps/calendar/ajax/updatecalendar.php
+++ b/apps/calendar/ajax/updatecalendar.php
@@ -8,16 +8,16 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['id'];
+$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], null, null, null, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+
+$calendar = OC_Calendar_App::getCalendar($calendarid);
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
OC_JSON::success(array(