Calendar: refactor common ajax functions to OC_Calendar_App
This commit is contained in:
parent
3d1accab70
commit
4eb36b0ecf
|
@ -12,8 +12,9 @@ if(!OC_USER::isLoggedIn()) {
|
||||||
}
|
}
|
||||||
OC_JSON::checkAppEnabled('calendar');
|
OC_JSON::checkAppEnabled('calendar');
|
||||||
$calendarid = $_POST['calendarid'];
|
$calendarid = $_POST['calendarid'];
|
||||||
|
$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
|
||||||
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
|
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
|
$calendar = OC_Calendar_App::getCalendar($calendarid);
|
||||||
OC_JSON::success(array(
|
OC_JSON::success(array(
|
||||||
'active' => $calendar['active'],
|
'active' => $calendar['active'],
|
||||||
'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
|
'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
|
|
||||||
$l10n = new OC_L10N('calendar');
|
|
||||||
|
|
||||||
// Check if we are a user
|
// Check if we are a user
|
||||||
OC_JSON::checkLoggedIn();
|
OC_JSON::checkLoggedIn();
|
||||||
OC_JSON::checkAppEnabled('calendar');
|
OC_JSON::checkAppEnabled('calendar');
|
||||||
|
@ -17,7 +15,8 @@ OC_JSON::checkAppEnabled('calendar');
|
||||||
$userid = OC_User::getUser();
|
$userid = OC_User::getUser();
|
||||||
$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
|
$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
|
||||||
OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
|
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 = new OC_Template('calendar', 'part.choosecalendar.rowfields');
|
||||||
$tmpl->assign('calendar', $calendar);
|
$tmpl->assign('calendar', $calendar);
|
||||||
OC_JSON::success(array(
|
OC_JSON::success(array(
|
||||||
|
|
|
@ -7,19 +7,13 @@
|
||||||
*/
|
*/
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
|
|
||||||
$l10n = new OC_L10N('calendar');
|
|
||||||
|
|
||||||
if(!OC_USER::isLoggedIn()) {
|
if(!OC_USER::isLoggedIn()) {
|
||||||
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
||||||
}
|
}
|
||||||
OC_JSON::checkAppEnabled('calendar');
|
OC_JSON::checkAppEnabled('calendar');
|
||||||
|
|
||||||
$cal = $_POST["calendarid"];
|
$cal = $_POST["calendarid"];
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($cal);
|
$calendar = OC_Calendar_App::getCalendar($cal);
|
||||||
if($calendar["userid"] != OC_User::getUser()){
|
|
||||||
OC_JSON::error(array('error'=>'permission_denied'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$del = OC_Calendar_Calendar::deleteCalendar($cal);
|
$del = OC_Calendar_Calendar::deleteCalendar($cal);
|
||||||
if($del == true){
|
if($del == true){
|
||||||
OC_JSON::success();
|
OC_JSON::success();
|
||||||
|
|
|
@ -15,17 +15,7 @@ if(!OC_USER::isLoggedIn()) {
|
||||||
OC_JSON::checkAppEnabled('calendar');
|
OC_JSON::checkAppEnabled('calendar');
|
||||||
|
|
||||||
$id = $_POST['id'];
|
$id = $_POST['id'];
|
||||||
$data = OC_Calendar_Object::find($id);
|
$event_object = OC_Calendar_App::getEventObject($id);
|
||||||
if (!$data)
|
|
||||||
{
|
|
||||||
OC_JSON::error();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
|
|
||||||
if($calendar['userid'] != OC_User::getUser()){
|
|
||||||
OC_JSON::error();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$result = OC_Calendar_Object::delete($id);
|
$result = OC_Calendar_Object::delete($id);
|
||||||
OC_JSON::success();
|
OC_JSON::success();
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
$l10n = new OC_L10N('calendar');
|
|
||||||
if(!OC_USER::isLoggedIn()) {
|
if(!OC_USER::isLoggedIn()) {
|
||||||
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
|
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
|
||||||
}
|
}
|
||||||
OC_JSON::checkAppEnabled('calendar');
|
OC_JSON::checkAppEnabled('calendar');
|
||||||
|
|
||||||
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
|
$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 = new OC_Template("calendar", "part.editcalendar");
|
||||||
$tmpl->assign('new', false);
|
$tmpl->assign('new', false);
|
||||||
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
|
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
|
|
||||||
$l10n = new OC_L10N('calendar');
|
|
||||||
|
|
||||||
if(!OC_USER::isLoggedIn()) {
|
if(!OC_USER::isLoggedIn()) {
|
||||||
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
||||||
}
|
}
|
||||||
|
@ -23,26 +20,12 @@ if($errarr){
|
||||||
}else{
|
}else{
|
||||||
$id = $_POST['id'];
|
$id = $_POST['id'];
|
||||||
$cal = $_POST['calendar'];
|
$cal = $_POST['calendar'];
|
||||||
$data = OC_Calendar_Object::find($id);
|
$data = OC_Calendar_App::getEventObject($id);
|
||||||
if (!$data)
|
|
||||||
{
|
|
||||||
OC_JSON::error();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
|
|
||||||
if($calendar['userid'] != OC_User::getUser()){
|
|
||||||
OC_JSON::error();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$vcalendar = OC_VObject::parse($data['calendardata']);
|
$vcalendar = OC_VObject::parse($data['calendardata']);
|
||||||
|
|
||||||
$last_modified = $vcalendar->VEVENT->__get('LAST-MODIFIED');
|
OC_Calendar_App::isNotModified($vcalendar->VEVENT, $_POST['lastmodified']);
|
||||||
if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){
|
|
||||||
OC_JSON::error(array('modified'=>true));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar);
|
OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar);
|
||||||
|
|
||||||
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
|
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
|
||||||
if ($data['calendarid'] != $cal) {
|
if ($data['calendarid'] != $cal) {
|
||||||
OC_Calendar_Object::moveToCalendar($id, $cal);
|
OC_Calendar_Object::moveToCalendar($id, $cal);
|
||||||
|
|
|
@ -8,26 +8,16 @@
|
||||||
|
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
|
|
||||||
$l10n = new OC_L10N('calendar');
|
|
||||||
|
|
||||||
if(!OC_USER::isLoggedIn()) {
|
if(!OC_USER::isLoggedIn()) {
|
||||||
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
||||||
}
|
}
|
||||||
OC_JSON::checkAppEnabled('calendar');
|
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'];
|
$id = $_GET['id'];
|
||||||
$data = OC_Calendar_Object::find($id);
|
$data = OC_Calendar_App::getEventObject($id);
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
|
|
||||||
if($calendar['userid'] != OC_User::getUser()){
|
|
||||||
echo $l10n->t('Wrong calendar');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$object = OC_VObject::parse($data['calendardata']);
|
$object = OC_VObject::parse($data['calendardata']);
|
||||||
$vevent = $object->VEVENT;
|
$vevent = $object->VEVENT;
|
||||||
|
|
||||||
$dtstart = $vevent->DTSTART;
|
$dtstart = $vevent->DTSTART;
|
||||||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
||||||
switch($dtstart->getDateType()) {
|
switch($dtstart->getDateType()) {
|
||||||
|
@ -66,6 +56,10 @@ if ($last_modified){
|
||||||
$lastmodified = 0;
|
$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 = new OC_Template('calendar', 'part.editevent');
|
||||||
$tmpl->assign('id', $id);
|
$tmpl->assign('id', $id);
|
||||||
$tmpl->assign('lastmodified', $lastmodified);
|
$tmpl->assign('lastmodified', $lastmodified);
|
||||||
|
|
|
@ -5,31 +5,20 @@
|
||||||
* later.
|
* later.
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
error_reporting(E_ALL);
|
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
OC_JSON::checkLoggedIn();
|
OC_JSON::checkLoggedIn();
|
||||||
$data = OC_Calendar_Object::find($_POST["id"]);
|
|
||||||
$calendarid = $data["calendarid"];
|
|
||||||
$cal = $calendarid;
|
|
||||||
$id = $_POST['id'];
|
$id = $_POST['id'];
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
|
|
||||||
if(OC_User::getUser() != $calendar['userid']){
|
$vcalendar = OC_Calendar_App::getVCalendar($id);
|
||||||
OC_JSON::error();
|
$vevent = $vcalendar->VEVENT;
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$allday = $_POST['allDay'];
|
$allday = $_POST['allDay'];
|
||||||
$delta = new DateInterval('P0D');
|
$delta = new DateInterval('P0D');
|
||||||
$delta->d = $_POST['dayDelta'];
|
$delta->d = $_POST['dayDelta'];
|
||||||
$delta->i = $_POST['minuteDelta'];
|
$delta->i = $_POST['minuteDelta'];
|
||||||
|
|
||||||
$vcalendar = OC_VObject::parse($data['calendardata']);
|
OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
|
||||||
$vevent = $vcalendar->VEVENT;
|
|
||||||
|
|
||||||
$last_modified = $vevent->__get('LAST-MODIFIED');
|
|
||||||
if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){
|
|
||||||
OC_JSON::error();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$dtstart = $vevent->DTSTART;
|
$dtstart = $vevent->DTSTART;
|
||||||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
$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);
|
$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
|
||||||
|
|
||||||
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
|
$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')));
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
|
|
||||||
$l10n = new OC_L10N('calendar');
|
|
||||||
|
|
||||||
if(!OC_USER::isLoggedIn()) {
|
if(!OC_USER::isLoggedIn()) {
|
||||||
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
||||||
}
|
}
|
||||||
|
@ -34,8 +32,8 @@ $start->setTimezone(new DateTimeZone($timezone));
|
||||||
$end->setTimezone(new DateTimeZone($timezone));
|
$end->setTimezone(new DateTimeZone($timezone));
|
||||||
|
|
||||||
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
|
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
|
||||||
$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
|
$category_options = OC_Calendar_App::getCategoryOptions();
|
||||||
$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
|
$repeat_options = OC_Calendar_App::getRepeatOptions();
|
||||||
|
|
||||||
$tmpl = new OC_Template('calendar', 'part.newevent');
|
$tmpl = new OC_Template('calendar', 'part.newevent');
|
||||||
$tmpl->assign('calendar_options', $calendar_options);
|
$tmpl->assign('calendar_options', $calendar_options);
|
||||||
|
|
|
@ -5,45 +5,28 @@
|
||||||
* later.
|
* later.
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
error_reporting(E_ALL);
|
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
OC_JSON::checkLoggedIn();
|
OC_JSON::checkLoggedIn();
|
||||||
$data = OC_Calendar_Object::find($_POST["id"]);
|
|
||||||
$calendarid = $data["calendarid"];
|
|
||||||
$cal = $calendarid;
|
|
||||||
$id = $_POST['id'];
|
$id = $_POST['id'];
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
|
|
||||||
if(OC_User::getUser() != $calendar['userid']){
|
$vcalendar = OC_Calendar_App::getVCalendar($id);
|
||||||
OC_JSON::error();
|
$vevent = $vcalendar->VEVENT;
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$delta = new DateInterval('P0D');
|
$delta = new DateInterval('P0D');
|
||||||
$delta->d = $_POST['dayDelta'];
|
$delta->d = $_POST['dayDelta'];
|
||||||
$delta->i = $_POST['minuteDelta'];
|
$delta->i = $_POST['minuteDelta'];
|
||||||
|
|
||||||
$vcalendar = OC_Calendar_Object::parse($data['calendardata']);
|
OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
|
||||||
$vevent = $vcalendar->VEVENT;
|
|
||||||
|
|
||||||
$last_modified = $vevent->__get('LAST-MODIFIED');
|
|
||||||
if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){
|
|
||||||
OC_JSON::error();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
||||||
$end_type = $dtend->getDateType();
|
$end_type = $dtend->getDateType();
|
||||||
$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
|
$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
|
||||||
unset($vevent->DURATION);
|
unset($vevent->DURATION);
|
||||||
|
|
||||||
$now = new DateTime();
|
$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
|
||||||
$last_modified = new Sabre_VObject_Element_DateTime('LAST-MODIFIED');
|
$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
|
||||||
$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;
|
|
||||||
|
|
||||||
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
|
$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')));
|
||||||
|
|
|
@ -8,16 +8,16 @@
|
||||||
|
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
|
|
||||||
$l10n = new OC_L10N('calendar');
|
|
||||||
|
|
||||||
// Check if we are a user
|
// Check if we are a user
|
||||||
OC_JSON::checkLoggedIn();
|
OC_JSON::checkLoggedIn();
|
||||||
OC_JSON::checkAppEnabled('calendar');
|
OC_JSON::checkAppEnabled('calendar');
|
||||||
|
|
||||||
$calendarid = $_POST['id'];
|
$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::editCalendar($calendarid, $_POST['name'], null, null, null, $_POST['color']);
|
||||||
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
|
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 = new OC_Template('calendar', 'part.choosecalendar.rowfields');
|
||||||
$tmpl->assign('calendar', $calendar);
|
$tmpl->assign('calendar', $calendar);
|
||||||
OC_JSON::success(array(
|
OC_JSON::success(array(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
$l=new OC_L10N('calendar');
|
$l=new OC_L10N('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_Calendar'] = 'apps/calendar/lib/calendar.php';
|
||||||
OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php';
|
OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php';
|
||||||
OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
|
OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
|
||||||
|
|
|
@ -12,11 +12,7 @@ OC_Util::checkAppEnabled('calendar');
|
||||||
$cal = isset($_GET["calid"]) ? $_GET["calid"] : NULL;
|
$cal = isset($_GET["calid"]) ? $_GET["calid"] : NULL;
|
||||||
$event = isset($_GET["eventid"]) ? $_GET["eventid"] : NULL;
|
$event = isset($_GET["eventid"]) ? $_GET["eventid"] : NULL;
|
||||||
if(isset($cal)){
|
if(isset($cal)){
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($cal);
|
$calendar = OC_Calendar_App::getCalendar($cal);
|
||||||
if($calendar["userid"] != OC_User::getUser()){
|
|
||||||
OC_JSON::error();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$calobjects = OC_Calendar_Object::all($cal);
|
$calobjects = OC_Calendar_Object::all($cal);
|
||||||
header("Content-Type: text/Calendar");
|
header("Content-Type: text/Calendar");
|
||||||
header("Content-Disposition: inline; filename=calendar.ics");
|
header("Content-Disposition: inline; filename=calendar.ics");
|
||||||
|
@ -24,13 +20,9 @@ if(isset($cal)){
|
||||||
echo $calobjects[$i]["calendardata"] . "\n";
|
echo $calobjects[$i]["calendardata"] . "\n";
|
||||||
}
|
}
|
||||||
}elseif(isset($event)){
|
}elseif(isset($event)){
|
||||||
$data = OC_Calendar_Object::find($_GET["eventid"]);
|
$data = OC_Calendar_App::getEventObject($_GET["eventid"]);
|
||||||
$calendarid = $data["calendarid"];
|
$calendarid = $data["calendarid"];
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
|
$calendar = OC_Calendar_App::getCalendar($calendarid);
|
||||||
if($calendar["userid"] != OC_User::getUser()){
|
|
||||||
OC_JSON::error();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
header("Content-Type: text/Calendar");
|
header("Content-Type: text/Calendar");
|
||||||
header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics");
|
header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics");
|
||||||
echo $data["calendardata"];
|
echo $data["calendardata"];
|
||||||
|
|
|
@ -12,11 +12,7 @@ OC_Util::checkAppEnabled('calendar');
|
||||||
|
|
||||||
if($_GET["import"] == "existing"){
|
if($_GET["import"] == "existing"){
|
||||||
$calid = $_GET["calid"];
|
$calid = $_GET["calid"];
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($calid);
|
$calendar = OC_Calendar_App::getCalendar($calid);
|
||||||
if($calendar['userid'] != OC_User::getUser()){
|
|
||||||
OC_JSON::error();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
if($_GET["path"] != ""){
|
if($_GET["path"] != ""){
|
||||||
$filename = $_GET["path"] . "/" . $_GET["file"];
|
$filename = $_GET["path"] . "/" . $_GET["file"];
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
|
||||||
|
* 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');
|
||||||
|
class OC_Calendar_App{
|
||||||
|
public static $l10n;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
return $calendar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEventObject($id){
|
||||||
|
$event_object = OC_Calendar_Object::find( $id );
|
||||||
|
if( $event_object === false ){
|
||||||
|
OC_JSON::error();
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
self::getCalendar( $event_object['calendarid'] );//access check
|
||||||
|
return $event_object;
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
return $vcalendar;
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCategoryOptions()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
self::$l10n->t('Birthday'),
|
||||||
|
self::$l10n->t('Business'),
|
||||||
|
self::$l10n->t('Call'),
|
||||||
|
self::$l10n->t('Clients'),
|
||||||
|
self::$l10n->t('Deliverer'),
|
||||||
|
self::$l10n->t('Holidays'),
|
||||||
|
self::$l10n->t('Ideas'),
|
||||||
|
self::$l10n->t('Journey'),
|
||||||
|
self::$l10n->t('Jubilee'),
|
||||||
|
self::$l10n->t('Meeting'),
|
||||||
|
self::$l10n->t('Other'),
|
||||||
|
self::$l10n->t('Personal'),
|
||||||
|
self::$l10n->t('Projects'),
|
||||||
|
self::$l10n->t('Questions'),
|
||||||
|
self::$l10n->t('Work'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRepeatOptions()
|
||||||
|
{
|
||||||
|
OC_Calendar_Object::getRepeatOptions(self::$l10n);
|
||||||
|
}
|
||||||
|
}
|
|
@ -82,7 +82,7 @@ class OC_Calendar_Calendar{
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return associative array
|
* @return associative array
|
||||||
*/
|
*/
|
||||||
public static function findCalendar($id){
|
public static function find($id){
|
||||||
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE id = ?' );
|
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE id = ?' );
|
||||||
$result = $stmt->execute(array($id));
|
$result = $stmt->execute(array($id));
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class OC_Calendar_Calendar{
|
||||||
*/
|
*/
|
||||||
public static function editCalendar($id,$name=null,$components=null,$timezone=null,$order=null,$color=null){
|
public static function editCalendar($id,$name=null,$components=null,$timezone=null,$order=null,$color=null){
|
||||||
// Need these ones for checking uri
|
// Need these ones for checking uri
|
||||||
$calendar = self::findCalendar($id);
|
$calendar = self::find($id);
|
||||||
|
|
||||||
// Keep old stuff
|
// Keep old stuff
|
||||||
if(is_null($name)) $name = $calendar['name'];
|
if(is_null($name)) $name = $calendar['name'];
|
||||||
|
|
|
@ -367,7 +367,7 @@ class OC_Calendar_Object{
|
||||||
$errarr['title'] = 'true';
|
$errarr['title'] = 'true';
|
||||||
$errnum++;
|
$errnum++;
|
||||||
}
|
}
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($request['calendar']);
|
$calendar = OC_Calendar_Calendar::find($request['calendar']);
|
||||||
if($calendar['userid'] != OC_User::getUser()){
|
if($calendar['userid'] != OC_User::getUser()){
|
||||||
$errarr['cal'] = 'true';
|
$errarr['cal'] = 'true';
|
||||||
$errnum++;
|
$errnum++;
|
||||||
|
|
Loading…
Reference in New Issue