Esempio n. 1
0
 /**
  * create reminder for task
  * @param  int    $taskID
  * @param  string $type
  * @param  mixed  $action
  * @param  mixed  $date
  * @param  bool   $invert
  * @param  string $related
  * @param  mixed  $week
  * @param  mixed  $day
  * @param  mixed  $hour
  * @param  mixed  $minute
  * @param  mixed  $second
  * @return bool
  * @throws \Exception
  */
 public function createReminder($taskID, $type, $action, $date, $invert, $related = null, $week, $day, $hour, $minute, $second)
 {
     $types = array('DATE-TIME', 'DURATION');
     $vcalendar = \OC_Calendar_App::getVCalendar($taskID);
     $vtodo = $vcalendar->VTODO;
     $valarm = $vtodo->VALARM;
     if (in_array($type, $types)) {
         if ($valarm == null) {
             $valarm = $vcalendar->createComponent('VALARM');
             $valarm->ACTION = $action;
             $valarm->DESCRIPTION = 'Default Event Notification';
             $vtodo->add($valarm);
         } else {
             unset($valarm->TRIGGER);
         }
         $string = '';
         if ($type == 'DATE-TIME') {
             $string = $this->createReminderDateTime($date);
         } elseif ($type == 'DURATION') {
             $string = $this->createReminderDuration($week, $day, $hour, $minute, $second, $invert);
         }
         if ($related == 'END') {
             $valarm->add('TRIGGER', $string, array('VALUE' => $type, 'RELATED' => $related));
         } else {
             $valarm->add('TRIGGER', $string, array('VALUE' => $type));
         }
     } else {
         unset($vtodo->VALARM);
     }
     return $this->helper->editVCalendar($vcalendar, $taskID);
 }
Esempio n. 2
0
 /**
  * delete comment of task by id
  * @param  int   $taskID
  * @param  int   $commentID
  * @return bool
  * @throws \Exception
  */
 public function deleteComment($taskID, $commentID)
 {
     $vcalendar = \OC_Calendar_App::getVCalendar($taskID);
     $vtodo = $vcalendar->VTODO;
     $commentIndex = $this->getCommentById($vtodo, $commentID);
     $comment = $vtodo->children[$commentIndex];
     if ($comment['X-OC-USERID']->getValue() == $this->userId) {
         unset($vtodo->children[$commentIndex]);
         return $this->helper->editVCalendar($vcalendar, $taskID);
     } else {
         throw new \Exception('Not allowed.');
     }
 }
Esempio n. 3
0
<?php

/**
 * Copyright (c) 2011 Bart Visscher <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
$id = $_POST['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_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_Property_DateTime::DATE) {
<?php

/**
 * Copyright (c) 2012 Bart Visscher <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
$id = $_POST['id'];
$property = $_POST['type'];
$vcalendar = OC_Calendar_App::getVCalendar($id);
$vtodo = $vcalendar->VTODO;
switch ($property) {
    case 'summary':
        $summary = $_POST['summary'];
        $vtodo->setString('SUMMARY', $summary);
        break;
    case 'description':
        $description = $_POST['description'];
        $vtodo->setString('DESCRIPTION', $description);
        break;
    case 'location':
        $location = $_POST['location'];
        $vtodo->setString('LOCATION', $location);
        break;
    case 'categories':
        $categories = $_POST['categories'];
        $vtodo->setString('CATEGORIES', $categories);
Esempio n. 5
0
 /**
  * @NoAdminRequired
  */
 public function deleteComment()
 {
     $taskId = $this->params('taskID');
     $commentId = $this->params('commentID');
     $response = new JSONResponse();
     try {
         $vcalendar = \OC_Calendar_App::getVCalendar($taskId);
         $vtodo = $vcalendar->VTODO;
         $commentIndex = $this->getCommentById($vtodo, $commentId);
         $comment = $vtodo->children[$commentIndex];
         if ($comment['USERID'] == $this->userId) {
             unset($vtodo->children[$commentIndex]);
             \OC_Calendar_Object::edit($taskId, $vcalendar->serialize());
         } else {
             throw new \Exception('Not allowed.');
         }
     } catch (\Exception $e) {
         // throw new BusinessLayerException($e->getMessage());
     }
     return $response;
 }
Esempio n. 6
0
 /**
  * set property of a task
  * 
  * @param  int    $taskID
  * @param  string $property
  * @param  mixed  $value
  * @return bool
  * @throws \Exception
  */
 public function setProperty($taskID, $property, $value)
 {
     $vcalendar = \OC_Calendar_App::getVCalendar($taskID);
     $vtodo = $vcalendar->VTODO;
     if ($value) {
         $vtodo->{$property} = $value;
     } else {
         unset($vtodo->{$property});
     }
     return $this->editVCalendar($vcalendar, $taskID);
 }
Esempio n. 7
0
 /**
  * remove category from task by id
  * @param  int    $taskID
  * @param  string $category
  * @return bool
  * @throws \Exception
  */
 public function removeCategory($taskID, $category)
 {
     $vcalendar = \OC_Calendar_App::getVCalendar($taskID);
     $vtodo = $vcalendar->VTODO;
     // fetch categories from TODO
     $categories = $vtodo->CATEGORIES;
     if ($categories) {
         $taskcategories = $categories->getParts();
         // remove category
         $key = array_search($category, $taskcategories);
         if ($key !== null && $key !== false) {
             unset($taskcategories[$key]);
             if (count($taskcategories)) {
                 $vtodo->CATEGORIES = $taskcategories;
             } else {
                 unset($vtodo->{'CATEGORIES'});
             }
             return $this->helper->editVCalendar($vcalendar, $taskID);
         }
     }
     return true;
 }
<?php

// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
$id = $_GET['id'];
$details = OC_Calendar_App::getVCalendar($id)->VTODO;
$categories = $details->getAsString('CATEGORIES');
$category_options = OC_Calendar_App::getCategoryOptions();
$percent_options = range(0, 100, 10);
$priority_options = OC_Task_App::getPriorityOptions();
$tmpl = new OCP\Template('tasks', 'part.edittaskform');
$tmpl->assign('category_options', $category_options);
$tmpl->assign('percent_options', $percent_options);
$tmpl->assign('priority_options', $priority_options);
$tmpl->assign('id', $id);
$tmpl->assign('details', $details);
$tmpl->assign('categories', $categories);
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array('page' => $page)));