Esempio n. 1
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     if (defined('DEBUG') && DEBUG) {
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular');
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular-route');
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular-animate');
         \OCP\Util::addScript('tasks', 'vendor/momentjs/moment');
         \OCP\Util::addScript('tasks', 'vendor/bootstrap/ui-bootstrap-custom-tpls-0.10.0');
     } else {
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular.min');
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular-route.min');
         \OCP\Util::addScript('tasks', 'vendor/angularjs/angular-animate.min');
         \OCP\Util::addScript('tasks', 'vendor/momentjs/moment.min');
         \OCP\Util::addScript('tasks', 'vendor/bootstrap/ui-bootstrap-custom-tpls-0.10.0.min');
     }
     \OCP\Util::addScript('tasks', 'public/app');
     \OCP\Util::addScript('tasks', 'vendor/appframework/app');
     \OCP\Util::addScript('tasks', 'vendor/timepicker/jquery.ui.timepicker');
     \OCP\Util::addStyle('tasks', 'style');
     \OCP\Util::addStyle('tasks', 'vendor/bootstrap/bootstrap');
     $date = new \DateTimeZone(\OC_Calendar_App::getTimezone());
     $day = new \DateTime('today', $date);
     $day = $day->format('d');
     // TODO: Make a HTMLTemplateResponse class
     $response = new TemplateResponse('tasks', 'main');
     $response->setParams(array('DOM' => $day));
     return $response;
 }
Esempio n. 2
0
 /**
  * Search for query in tasks
  *
  * @param string $query
  * @return array list of \OCA\Tasks\Controller\Task
  */
 function search($query)
 {
     $calendars = \OC_Calendar_Calendar::allCalendars(\OC::$server->getUserSession()->getUser()->getUID(), true);
     $user_timezone = \OC_Calendar_App::getTimezone();
     // check if the calenar is enabled
     if (count($calendars) == 0 || !\OCP\App::isEnabled('tasks')) {
         return array();
     }
     $results = array();
     foreach ($calendars as $calendar) {
         // $calendar_entries = \OC_Calendar_Object::all($calendar['id']);
         $objects = \OC_Calendar_Object::all($calendar['id']);
         // $date = strtotime($query);
         // 	// search all calendar objects, one by one
         foreach ($objects as $object) {
             // skip non-todos
             if ($object['objecttype'] != 'VTODO') {
                 continue;
             }
             if (!($vtodo = Helper::parseVTODO($object))) {
                 continue;
             }
             $id = $object['id'];
             $calendarId = $object['calendarid'];
             // check these properties
             $properties = array('SUMMARY', 'DESCRIPTION', 'LOCATION', 'CATEGORIES');
             foreach ($properties as $property) {
                 $string = $vtodo->{$property};
                 if (stripos($string, $query) !== false) {
                     // $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,$property,$query,$user_timezone);
                     $results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
                     continue 2;
                 }
             }
             $comments = $vtodo->COMMENT;
             if ($comments) {
                 foreach ($comments as $com) {
                     if (stripos($com->getValue(), $query) !== false) {
                         // $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'COMMENTS',$query,$user_timezone);
                         $results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
                         continue 2;
                     }
                 }
             }
         }
     }
     usort($results, array($this, 'sort_completed'));
     return $results;
 }
Esempio n. 3
0
 function search($query)
 {
     $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), true);
     if (count($calendars) == 0 || !OCP\App::isEnabled('calendar')) {
         //return false;
     }
     $results = array();
     $searchquery = array();
     if (substr_count($query, ' ') > 0) {
         $searchquery = explode(' ', $query);
     } else {
         $searchquery[] = $query;
     }
     $user_timezone = OC_Calendar_App::getTimezone();
     $l = new OC_l10n('calendar');
     foreach ($calendars as $calendar) {
         $objects = OC_Calendar_Object::all($calendar['id']);
         foreach ($objects as $object) {
             if ($object['objecttype'] != 'VEVENT') {
                 continue;
             }
             if (substr_count(strtolower($object['summary']), strtolower($query)) > 0) {
                 $calendardata = OC_VObject::parse($object['calendardata']);
                 $vevent = $calendardata->VEVENT;
                 $dtstart = $vevent->DTSTART;
                 $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
                 $start_dt = $dtstart->getDateTime();
                 $start_dt->setTimezone(new DateTimeZone($user_timezone));
                 $end_dt = $dtend->getDateTime();
                 $end_dt->setTimezone(new DateTimeZone($user_timezone));
                 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');
                     } else {
                         $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
                     }
                 } else {
                     $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
                 }
                 $link = OCP\Util::linkTo('calendar', 'index.php') . '?showevent=' . urlencode($object['id']);
                 $results[] = new OC_Search_Result($object['summary'], $info, $link, (string) $l->t('Cal.'));
                 //$name,$text,$link,$type
             }
         }
     }
     return $results;
 }
Esempio n. 4
0
 /**
  * add comment to task by id
  * @param  int    $taskID
  * @param  string $comment
  * @param  int    $tmpID
  * @return array
  * @throws \Exception
  */
 public function addComment($taskID, $comment, $tmpID)
 {
     $vcalendar = \OC_Calendar_App::getVCalendar($taskID);
     $vtodo = $vcalendar->VTODO;
     if ($vtodo->COMMENT == "") {
         // if this is the first comment set the id to 0
         $commentId = 0;
     } else {
         // Determine new commentId by looping through all comments
         $commentIds = array();
         foreach ($vtodo->COMMENT as $com) {
             $commentIds[] = (int) $com['X-OC-ID']->getValue();
         }
         $commentId = 1 + max($commentIds);
     }
     $now = new \DateTime();
     $vtodo->add('COMMENT', $comment, array('X-OC-ID' => $commentId, 'X-OC-USERID' => $this->userId, 'X-OC-DATE-TIME' => $now->format('Ymd\\THis\\Z')));
     $this->helper->editVCalendar($vcalendar, $taskID);
     $user_timezone = \OC_Calendar_App::getTimezone();
     $now->setTimezone(new \DateTimeZone($user_timezone));
     $comment = array('taskID' => $taskID, 'id' => $commentId, 'tmpID' => $tmpID, 'name' => \OC::$server->getUserManager()->get($this->userId)->getDisplayName(), 'userID' => $this->userId, 'comment' => $comment, 'time' => $now->format('Ymd\\THis'));
     return $comment;
 }
Esempio n. 5
0
 /**
  * @brief updates an VCalendar Object from the request data
  * @param array $request
  * @param object $vcalendar
  * @return object updated $vcalendar
  */
 public static function updateVCalendarFromRequest($request, $vcalendar)
 {
     $accessclass = $request["accessclass"];
     $title = $request["title"];
     $location = $request["location"];
     $categories = $request["categories"];
     $allday = isset($request["allday"]);
     $from = $request["from"];
     $to = $request["to"];
     if (!$allday) {
         $fromtime = $request['fromtime'];
         $totime = $request['totime'];
     }
     $vevent = $vcalendar->VEVENT;
     $description = $request["description"];
     $repeat = $request["repeat"];
     if ($repeat != 'doesnotrepeat') {
         $rrule = '';
         $interval = $request['interval'];
         $end = $request['end'];
         $byoccurrences = $request['byoccurrences'];
         switch ($repeat) {
             case 'daily':
                 $rrule .= 'FREQ=DAILY';
                 break;
             case 'weekly':
                 $rrule .= 'FREQ=WEEKLY';
                 if (array_key_exists('weeklyoptions', $request)) {
                     $byday = '';
                     $daystrings = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
                     foreach ($request['weeklyoptions'] as $days) {
                         if ($byday == '') {
                             $byday .= $daystrings[$days];
                         } else {
                             $byday .= ',' . $daystrings[$days];
                         }
                     }
                     $rrule .= ';BYDAY=' . $byday;
                 }
                 break;
             case 'weekday':
                 $rrule .= 'FREQ=WEEKLY';
                 $rrule .= ';BYDAY=MO,TU,WE,TH,FR';
                 break;
             case 'biweekly':
                 $rrule .= 'FREQ=WEEKLY';
                 $interval = $interval * 2;
                 break;
             case 'monthly':
                 $rrule .= 'FREQ=MONTHLY';
                 if ($request['advanced_month_select'] == 'monthday') {
                     break;
                 } elseif ($request['advanced_month_select'] == 'weekday') {
                     if ($request['weekofmonthoptions'] == 'auto') {
                         list($_day, $_month, $_year) = explode('-', $from);
                         $weekofmonth = floor($_day / 7);
                     } else {
                         $weekofmonth = $request['weekofmonthoptions'];
                     }
                     $days = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
                     $byday = '';
                     foreach ($request['weeklyoptions'] as $day) {
                         if ($byday == '') {
                             $byday .= $weekofmonth . $days[$day];
                         } else {
                             $byday .= ',' . $weekofmonth . $days[$day];
                         }
                     }
                     if ($byday == '') {
                         $byday = 'MO,TU,WE,TH,FR,SA,SU';
                     }
                     $rrule .= ';BYDAY=' . $byday;
                 }
                 break;
             case 'yearly':
                 $rrule .= 'FREQ=YEARLY';
                 if ($request['advanced_year_select'] == 'bydate') {
                 } elseif ($request['advanced_year_select'] == 'byyearday') {
                     list($_day, $_month, $_year) = explode('-', $from);
                     $byyearday = date('z', mktime(0, 0, 0, $_month, $_day, $_year)) + 1;
                     if (array_key_exists('byyearday', $request)) {
                         foreach ($request['byyearday'] as $yearday) {
                             $byyearday .= ',' . $yearday;
                         }
                     }
                     $rrule .= ';BYYEARDAY=' . $byyearday;
                 } elseif ($request['advanced_year_select'] == 'byweekno') {
                     list($_day, $_month, $_year) = explode('-', $from);
                     $rrule .= ';BYDAY=' . strtoupper(substr(date('l', mktime(0, 0, 0, $_month, $_day, $_year)), 0, 2));
                     $byweekno = '';
                     foreach ($request['byweekno'] as $weekno) {
                         if ($byweekno == '') {
                             $byweekno = $weekno;
                         } else {
                             $byweekno .= ',' . $weekno;
                         }
                     }
                     $rrule .= ';BYWEEKNO=' . $byweekno;
                 } elseif ($request['advanced_year_select'] == 'bydaymonth') {
                     if (array_key_exists('weeklyoptions', $request)) {
                         $days = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
                         $byday = '';
                         foreach ($request['weeklyoptions'] as $day) {
                             if ($byday == '') {
                                 $byday .= $days[$day];
                             } else {
                                 $byday .= ',' . $days[$day];
                             }
                         }
                         $rrule .= ';BYDAY=' . $byday;
                     }
                     if (array_key_exists('bymonth', $request)) {
                         $monthes = array_flip(self::getByMonthOptions(OC_Calendar_App::$l10n));
                         $bymonth = '';
                         foreach ($request['bymonth'] as $month) {
                             if ($bymonth == '') {
                                 $bymonth .= $monthes[$month];
                             } else {
                                 $bymonth .= ',' . $monthes[$month];
                             }
                         }
                         $rrule .= ';BYMONTH=' . $bymonth;
                     }
                     if (array_key_exists('bymonthday', $request)) {
                         $bymonthday = '';
                         foreach ($request['bymonthday'] as $monthday) {
                             if ($bymonthday == '') {
                                 $bymonthday .= $monthday;
                             } else {
                                 $bymonthday .= ',' . $monthday;
                             }
                         }
                         $rrule .= ';BYMONTHDAY=' . $bymonthday;
                     }
                 }
                 break;
             default:
                 break;
         }
         if ($interval != '') {
             $rrule .= ';INTERVAL=' . $interval;
         }
         if ($end == 'count') {
             $rrule .= ';COUNT=' . $byoccurrences;
         }
         if ($end == 'date') {
             list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']);
             $rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day;
         }
         $vevent->setString('RRULE', $rrule);
         $repeat = "true";
     } else {
         $repeat = "false";
     }
     $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre\VObject\Property\DateTime::UTC);
     $vevent->setDateTime('DTSTAMP', 'now', Sabre\VObject\Property\DateTime::UTC);
     $vevent->setString('SUMMARY', $title);
     if ($allday) {
         $start = new DateTime($from);
         $end = new DateTime($to . ' +1 day');
         $vevent->setDateTime('DTSTART', $start, Sabre\VObject\Property\DateTime::DATE);
         $vevent->setDateTime('DTEND', $end, Sabre\VObject\Property\DateTime::DATE);
     } else {
         $timezone = OC_Calendar_App::getTimezone();
         $timezone = new DateTimeZone($timezone);
         $start = new DateTime($from . ' ' . $fromtime, $timezone);
         $end = new DateTime($to . ' ' . $totime, $timezone);
         $vevent->setDateTime('DTSTART', $start, Sabre\VObject\Property\DateTime::LOCALTZ);
         $vevent->setDateTime('DTEND', $end, Sabre\VObject\Property\DateTime::LOCALTZ);
     }
     unset($vevent->DURATION);
     $vevent->setString('CLASS', $accessclass);
     $vevent->setString('LOCATION', $location);
     $vevent->setString('DESCRIPTION', $description);
     $vevent->setString('CATEGORIES', $categories);
     /*if($repeat == "true") {
     			$vevent->RRULE = $repeat;
     		}*/
     return $vcalendar;
 }
Esempio n. 6
0
 /**
  * Cache the user timezone to avoid multiple requests (it looks like it
  * uses a DB call in config to return this)
  *
  * @staticvar null $timezone
  * @return DateTimeZone
  */
 public static function getUserTimezone()
 {
     static $timezone = null;
     if ($timezone === null) {
         $timezone = new \DateTimeZone(\OC_Calendar_App::getTimezone());
     }
     return $timezone;
 }
Esempio n. 7
0
 public static function updateVCalendarFromRequest($request, $vcalendar)
 {
     $vtodo = $vcalendar->VTODO;
     $lastModified = $vtodo->{'LAST-MODIFIED'};
     if (is_null($lastModified)) {
         $lastModified = $vtodo->add('LAST-MODIFIED');
     }
     $lastModified->setValue(new \DateTime('now', new \DateTimeZone('UTC')));
     $vtodo->DTSTAMP = new \DateTime('now', new \DateTimeZone('UTC'));
     $vtodo->SUMMARY = $request['summary'];
     if ($request['location']) {
         $vtodo->LOCATION = $request['location'];
     }
     if ($request['description']) {
         $vtodo->DESCRIPTION = $request['description'];
     }
     if ($request["categories"]) {
         $vtodo->CATEGORIES = $request["categories"];
     }
     if ($request['priority']) {
         $vtodo->PRIORITY = 5;
         // prio: medium
     } else {
         $vtodo->PRIORITY = 0;
         // prio: undefined
     }
     $percentComplete = $vtodo->{'PERCENT-COMPLETE'};
     if (is_null($percentComplete)) {
         $percentComplete = $vtodo->add('PERCENT-COMPLETE');
     }
     if (isset($request['complete'])) {
         $percentComplete->setValue($request['complete']);
     } else {
         $percentComplete->setValue('0');
     }
     $due = $request['due'];
     if ($due) {
         $timezone = \OC_Calendar_App::getTimezone();
         $timezone = new \DateTimeZone($timezone);
         $due = new \DateTime($due, $timezone);
         $vtodo->DUE = $due;
     } else {
         unset($vtodo->DUE);
     }
     $start = $request['start'];
     if ($start) {
         $timezone = \OC_Calendar_App::getTimezone();
         $timezone = new \DateTimeZone($timezone);
         $start = new \DateTime($start, $timezone);
         $vtodo->DTSTART = $start;
     } else {
         unset($vtodo->DTSTART);
     }
     return $vcalendar;
 }
Esempio n. 8
0
 public static function setComplete($vtodo, $percent_complete, $completed)
 {
     if (!empty($percent_complete)) {
         $vtodo->setString('PERCENT-COMPLETE', $percent_complete);
     } else {
         $vtodo->__unset('PERCENT-COMPLETE');
     }
     if ($percent_complete == 100) {
         if (!$completed) {
             $completed = 'now';
         }
     } else {
         $completed = null;
     }
     if ($completed) {
         $timezone = OC_Calendar_App::getTimezone();
         $timezone = new DateTimeZone($timezone);
         $completed = new DateTime($completed, $timezone);
         $vtodo->setDateTime('COMPLETED', $completed);
         OCP\Util::emitHook('OC_Task', 'taskCompleted', $vtodo);
     } else {
         unset($vtodo->COMPLETED);
     }
 }
Esempio n. 9
0
<?php

/**
 * Copyright (c) 2011 Bart Visscher <*****@*****.**>
 * Copyright (c) 2012 Georg Ehrke <*****@*****.**>
 * 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 = OCP\Util::getL10N('calendar');
OC_Calendar_App::$tz = OC_Calendar_App::getTimezone();
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;
    /**
     * @brief timezone of the user
     */
    public static $tz;
    /**
     * @brief returns informations about a calendar
Esempio n. 10
0
$id = $_POST['id'];
$data = OC_Calendar_App::getEventObject($id, false, false);
if (!$data) {
    OCP\JSON::error(array('data' => array('message' => OC_Calendar_App::$l10n->t('Wrong calendar'))));
    exit;
}
$object = OC_VObject::parse($data['calendardata']);
$vevent = $object->VEVENT;
$object = OC_Calendar_Object::cleanByAccessClass($id, $object);
$accessclass = $vevent->getAsString('CLASS');
$permissions = OC_Calendar_App::getPermissions($id, OC_Calendar_App::EVENT, $accessclass);
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
switch ($dtstart->getDateType()) {
    case Sabre\VObject\Property\DateTime::UTC:
        $timezone = new DateTimeZone(OC_Calendar_App::getTimezone());
        $newDT = $dtstart->getDateTime();
        $newDT->setTimezone($timezone);
        $dtstart->setDateTime($newDT);
        $newDT = $dtend->getDateTime();
        $newDT->setTimezone($timezone);
        $dtend->setDateTime($newDT);
    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\Property\DateTime::DATE:
 public static function updateVCalendarFromRequest($request, $vcalendar)
 {
     $vtodo = $vcalendar->VTODO;
     $vtodo->setDateTime('LAST-MODIFIED', 'now', \Sabre\VObject\Property\DateTime::UTC);
     $vtodo->setDateTime('DTSTAMP', 'now', \Sabre\VObject\Property\DateTime::UTC);
     $vtodo->setString('SUMMARY', $request['summary']);
     $vtodo->setString('LOCATION', $request['location']);
     $vtodo->setString('DESCRIPTION', $request['description']);
     $vtodo->setString('CATEGORIES', $request["categories"]);
     $vtodo->setString('PRIORITY', $request['priority']);
     $vtodo->setString('PERCENT-COMPLETE', $request['complete']);
     $due = $request['due'];
     if ($due) {
         $timezone = \OC_Calendar_App::getTimezone();
         $timezone = new \DateTimeZone($timezone);
         $due = new \DateTime($due, $timezone);
         $vtodo->setDateTime('DUE', $due);
     } else {
         unset($vtodo->DUE);
     }
     $start = $request['start'];
     if ($start) {
         $timezone = \OC_Calendar_App::getTimezone();
         $timezone = new \DateTimeZone($timezone);
         $start = new \DateTime($start, $timezone);
         $vtodo->setDateTime('DTSTART', $start);
     } else {
         unset($vtodo->DTSTART);
     }
     return $vcalendar;
 }
Esempio n. 12
0
}
OCP\JSON::checkAppEnabled('calendar');
if (!isset($_POST['start'])) {
    OCP\JSON::error();
    die;
}
$start = $_POST['start'];
$end = $_POST['end'];
$allday = $_POST['allday'];
if (!$end) {
    $duration = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'duration', '60');
    $end = $start + $duration * 60;
}
$start = new DateTime('@' . $start);
$end = new DateTime('@' . $end);
$timezone = OC_Calendar_App::getTimezone();
$start->setTimezone(new DateTimeZone($timezone));
$end->setTimezone(new DateTimeZone($timezone));
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
$calendar_options = array();
foreach ($calendars as $calendar) {
    if ($calendar['userid'] != OCP\User::getUser()) {
        $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $calendar['id']);
        if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_CREATE) {
            array_push($calendar_options, $calendar);
        }
    } else {
        array_push($calendar_options, $calendar);
    }
}
$access_class_options = OC_Calendar_App::getAccessClassOptions();
Esempio n. 13
0
 /**
  * @NoAdminRequired
  */
 public function addComment()
 {
     $taskId = $this->params('taskID');
     $comment = $this->params('comment');
     $response = new JSONResponse();
     try {
         $vcalendar = \OC_Calendar_App::getVCalendar($taskId);
         $vtodo = $vcalendar->VTODO;
         // Determine new commentId by looping through all comments
         $commentIds = array();
         foreach ($vtodo->COMMENT as $com) {
             $commentIds[] = (int) $com['ID']->value;
         }
         $commentId = 1 + max($commentIds);
         $now = new \DateTime();
         $vtodo->addProperty('COMMENT', $comment, array('ID' => $commentId, 'USERID' => $this->userId, 'DATE-TIME' => $now->format('Ymd\\THis\\Z')));
         \OC_Calendar_Object::edit($taskId, $vcalendar->serialize());
         $user_timezone = \OC_Calendar_App::getTimezone();
         $now->setTimezone(new \DateTimeZone($user_timezone));
         $comment = array('taskID' => $taskId, 'id' => $commentId, 'tmpID' => $this->params('tmpID'), 'name' => \OCP\User::getDisplayName(), 'userID' => $this->userId, 'comment' => $comment, 'time' => $now->format('Ymd\\THis'));
         $result = array('data' => array('comment' => $comment));
         $response->setData($result);
     } catch (\Exception $e) {
         // throw new BusinessLayerException($e->getMessage());
     }
     return $response;
 }
Esempio n. 14
0
 /**
  * Generates the message to send to the user
  * @param  \OCP\Template    &$tpl      the template
  * @param  Array            $alarm     the pdo row to user
  * @return string                      the rendered template
  */
 private static function genMessage(&$tpl, $alarm)
 {
     $tz = OC_Calendar_App::getTimezone();
     $lang = OCP\Config::getUserValue($alarm['userid'], 'calendar', 'lang');
     $l = OC_L10N::get('calendar', $lang);
     $startDate = new DateTime($alarm['startdate'], new DateTimeZone('UTC'));
     $endDate = new DateTime($alarm['enddate'], new DateTimeZone('UTC'));
     $startDate->setTimezone(new DateTimeZone($tz));
     $endDate->setTimezone(new DateTimeZone($tz));
     $timeFormat = OCP\Config::getUserValue($alarm['userid'], 'calendar', 'timeformat', '24') == 24 ? 'H:i' : 'h:i a';
     $dateFormat = OCP\Config::getUserValue($alarm['userid'], 'calendar', 'dateformat', 'dd-mm-yy') == 'dd-mm-yy' ? 'd-m-Y' : 'm-d-Y';
     $dateTimeFormat = $dateFormat . ' ' . $timeFormat;
     $tpl->assign('calendarName', $alarm['displayname']);
     $tpl->assign('event', $alarm['summary']);
     $tpl->assign('date', $startDate->format($dateTimeFormat) . ' - ' . $endDate->format($dateTimeFormat));
     $tpl->assign('when', $l->t('When: '));
     $tpl->assign('calendar', $l->t('Calendar: '));
     return $tpl->fetchPage();
 }
Esempio n. 15
0
 /**
  * update task from request
  *
  * @param array $request
  * @param mixed $vcalendar
  * @return mixed
  */
 public function addVTODO($vcalendar, $request)
 {
     $vtodo = $vcalendar->VTODO;
     $timezone = \OC_Calendar_App::getTimezone();
     $timezone = new \DateTimeZone($timezone);
     $vtodo->{'LAST-MODIFIED'} = new \DateTime('now', new \DateTimeZone('UTC'));
     $vtodo->DTSTAMP = new \DateTime('now', new \DateTimeZone('UTC'));
     $vtodo->SUMMARY = $request['summary'];
     if ($request['starred']) {
         $vtodo->PRIORITY = 1;
         // prio: high
     }
     $due = $request['due'];
     if ($due) {
         $vtodo->DUE = new \DateTime($due, $timezone);
     }
     $start = $request['start'];
     if ($start) {
         $vtodo->DTSTART = new \DateTime($start, $timezone);
     }
     $related = $request['related'];
     if ($related) {
         $vtodo->{'RELATED-TO'} = $related;
     }
     return $vcalendar;
 }