Example #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);
 }
Example #2
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;
 }
Example #3
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.');
     }
 }
Example #4
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;
 }
Example #5
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;
 }
Example #6
0
 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     $readprincipal = $this->getOwner();
     $writeprincipal = $this->getOwner();
     $uid = OC_Calendar_Calendar::extractUserID($this->getOwner());
     if ($uid != OCP\USER::getUser()) {
         $object = OC_VObject::parse($this->objectData['calendardata']);
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
         $sharedAccessClassPermissions = OC_Calendar_App::getAccessClassPermissions($object->VEVENT->CLASS->value);
         if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_READ && $sharedAccessClassPermissions & OCP\PERMISSION_READ) {
             $readprincipal = 'principals/' . OCP\USER::getUser();
         }
         if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_UPDATE && $sharedAccessClassPermissions & OCP\PERMISSION_UPDATE) {
             $writeprincipal = 'principals/' . OCP\USER::getUser();
         }
     }
     return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true));
 }
Example #7
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.
 */
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
$cal = isset($_GET['calid']) ? $_GET['calid'] : null;
$event = isset($_GET['eventid']) ? $_GET['eventid'] : null;
if (!is_null($cal)) {
    $calendar = OC_Calendar_App::getCalendar($cal, true);
    if (!$calendar) {
        header('HTTP/1.0 403 Forbidden');
        exit;
    }
    header('Content-Type: text/calendar');
    header('Content-Disposition: inline; filename=' . str_replace(' ', '-', $calendar['displayname']) . '.ics');
    echo OC_Calendar_Export::export($cal, OC_Calendar_Export::CALENDAR);
} elseif (!is_null($event)) {
    $data = OC_Calendar_App::getEventObject($_GET['eventid'], true);
    if (!$data) {
        header('HTTP/1.0 403 Forbidden');
        exit;
    }
    header('Content-Type: text/calendar');
    header('Content-Disposition: inline; filename=' . str_replace(' ', '-', $data['summary']) . '.ics');
    echo OC_Calendar_Export::export($event, OC_Calendar_Export::EVENT);
}
Example #8
0
 /**
  * @brief Converts the shared item sources back into the item in the specified format
  * @param array Shared items
  * @param int Format
  * @return ?
  *
  * The items array is a 3-dimensional array with the item_source as the first key and the share id as the second key to an array with the share info.
  * The key/value pairs included in the share info depend on the function originally called:
  * If called by getItem(s)Shared: id, item_type, item, item_source, share_type, share_with, permissions, stime, file_source
  * If called by getItem(s)SharedWith: id, item_type, item, item_source, item_target, share_type, share_with, permissions, stime, file_source, file_target
  * This function allows the backend to control the output of shared items with custom formats.
  * It is only called through calls to the public getItem(s)Shared(With) functions.
  */
 public function formatItems($items, $format, $parameters = null)
 {
     $calendars = array();
     if ($format == self::FORMAT_CALENDAR) {
         foreach ($items as $item) {
             $calendar = OC_Calendar_App::getCalendar($item['item_source'], false);
             if (!$calendar) {
                 continue;
             }
             // TODO: really check $parameters['permissions'] == 'rw'/'r'
             if ($parameters['permissions'] == 'rw') {
                 continue;
                 // TODO
             }
             $calendar['displaynamename'] = $item['item_target'];
             $calendar['permissions'] = $item['permissions'];
             $calendar['calendarid'] = $calendar['id'];
             $calendar['owner'] = $calendar['userid'];
             $calendars[] = $calendar;
         }
     }
     return $calendars;
 }
 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;
 }
Example #10
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;
 }
Example #11
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);
     }
 }
Example #12
0
if ($_POST['method'] == 'new') {
    $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser());
    foreach ($calendars as $calendar) {
        if ($calendar['displayname'] == $_POST['calname']) {
            $id = $calendar['id'];
            $newcal = false;
            break;
        }
        $newcal = true;
    }
    if ($newcal) {
        $id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), strip_tags($_POST['calname']), 'VEVENT,VTODO,VJOURNAL', null, 0, strip_tags($_POST['calcolor']));
        OC_Calendar_Calendar::setCalendarActive($id, 1);
    }
} else {
    $calendar = OC_Calendar_App::getCalendar($_POST['id']);
    if ($calendar['userid'] != OCP\USER::getUser()) {
        OCP\JSON::error(array('error' => 'missingcalendarrights'));
        exit;
    }
    $id = $_POST['id'];
    $import->setOverwrite($_POST['overwrite']);
}
$import->setCalendarID($id);
try {
    $import->import();
} catch (Exception $e) {
    OCP\JSON::error(array('message' => OC_Calendar_App::$l10n->t('Import failed'), 'debug' => $e->getMessage()));
    //write some log
}
$count = $import->getCount();
Example #13
0
 * 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) {
    $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_Property_DateTime::UTC);
Example #14
0
} else {
    echo '<ul>';
    foreach ($_['categories'] as $categorie) {
        echo '<li>' . $categorie . '</li>';
    }
    echo '</ul>';
}
?>
			</td>
			<th width="75px">&nbsp;&nbsp;&nbsp;<?php 
echo $l->t("Calendar");
?>
:</th>
			<td>
			<?php 
$calendar = OC_Calendar_App::getCalendar($_['calendar'], false, false);
echo $calendar['displayname'] . ' ' . $l->t('of') . ' ' . $calendar['userid'];
?>
			</td>
			<th width="75px">&nbsp;</th>
			<td>
				<input type="hidden" name="calendar" value="<?php 
echo $_['calendar_options'][0]['id'];
?>
">
			</td>
		</tr>
	</table>
	<hr>
	<table width="100%">
		<tr>
				var missing_field_dberror = '<?php 
echo addslashes($l->t('There was a database fail'));
?>
';
				var totalurl = '<?php 
echo OCP\Util::linkToRemote('caldav');
?>
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', $_)) {
    $data = OC_Calendar_App::getEventObject($_['showevent']);
    $date = substr($data['startdate'], 0, 10);
    list($year, $month, $day) = explode('-', $date);
    echo '$(\'#calendar_holder\').fullCalendar(\'gotoDate\', ' . $year . ', ' . --$month . ', ' . $day . ');';
    echo '$(\'#dialog_holder\').load(OC.filePath(\'calendar\', \'ajax\', \'editeventform.php\') + \'?id=\' +  ' . $_['showevent'] . ' , Calendar.UI.startEventDialog);';
}
?>
				});
				</script>
				<div id="controls">
					<div>
						<form>
							<div id="view">
								<input type="button" value="<?php 
echo $l->t('Week');
?>
Example #16
0
 */
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
    OCP\JSON::error($errarr);
    exit;
} else {
    $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);
    OC_Calendar_Object::edit($id, $vcalendar->serialize());
    if ($data['calendarid'] != $cal) {
        OC_Calendar_Object::moveToCalendar($id, $cal);
    }
    OCP\JSON::success();
}
} else {
    echo '<select id="category" name="categories[]" multiple="multiple" title="' . $l->t("Select category") . '">';
    echo OCP\html_select_options($_['categories'], $_['categories'], array('combine' => true));
    echo '</select>';
}
?>
			</td>
			<th width="75px">&nbsp;&nbsp;&nbsp;<?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">&nbsp;</th>
			<td>
				<input type="hidden" name="calendar" value="<?php 
echo $_['calendar_options'][0]['id'];
?>
">
			</td>
		</tr>
	</table>
Example #18
0
<?php

/**
 * 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 'when/When.php';
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
session_write_close();
// Look for the calendar id
$calendar_id = OC_Calendar_App::getCalendar($_GET['calendar_id'], false, false);
if ($calendar_id !== false) {
    if (!is_numeric($calendar_id['userid']) && $calendar_id['userid'] != OCP\User::getUser()) {
        OCP\JSON::error();
        exit;
    }
} else {
    $calendar_id = $_GET['calendar_id'];
}
$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']);
$events = OC_Calendar_App::getrequestedEvents($_GET['calendar_id'], $start, $end);
$output = array();
foreach ($events as $event) {
    $output = array_merge($output, OC_Calendar_App::generateEventOutput($event, $start, $end));
}
OCP\JSON::encodedPrint(OCP\Util::sanitizeHTML($output));
Example #19
0
<?php

/**
 * ownCloud - Addressbook
 *
 * @author Jakob Sack
 * @copyright 2011 Jakob Sack mail@jakobsack.de
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
OCP\JSON::callCheck();
$id = $_POST['id'];
$task = OC_Calendar_App::getEventObject($id);
OC_Calendar_Object::delete($id);
OCP\JSON::success(array('data' => array('id' => $id)));
Example #20
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();
OCP\JSON::checkAppEnabled('calendar');
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']);
$tmpl = new OCP\Template("calendar", "part.editcalendar");
$tmpl->assign('new', false);
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
$tmpl->assign('calendar', $calendar);
$tmpl->printPage();
Example #21
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();
OCP\JSON::checkAppEnabled('calendar');
$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;
}
$result = OC_Calendar_Object::delete($id);
OCP\JSON::success();
Example #22
0
 /**
  * get the current settings
  *
  * @return array
  */
 public function get()
 {
     $settings = array(array('id' => 'various', 'showHidden' => (int) $this->settings->getUserValue($this->userId, $this->appName, 'various_showHidden'), 'startOfWeek' => (int) $this->settings->getUserValue($this->userId, $this->appName, 'various_startOfWeek'), 'userID' => $this->userId, 'categories' => \OC_Calendar_App::getCategoryOptions()));
     return $settings;
 }
Example #23
0
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
// Create default calendar ...
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1);
if (count($calendars) == 0) {
    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');
OCP\Util::emitHook('OC_Calendar', 'getSources', array('sources' => &$eventSources));
$categories = OC_Calendar_App::getCategoryOptions();
//Fix currentview for fullcalendar
if (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview") {
    OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "agendaWeek");
}
if (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview") {
    OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "month");
}
if (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "listview") {
    OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "list");
}
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') {
<?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);
Example #25
0
 /**
  * @brief returns the vcategories object of the user
  * @return (object) $vcategories
  */
 public static function getVCategories()
 {
     if (is_null(self::$categories)) {
         $categories = \OC::$server->getTagManager()->load('event');
         if ($categories->isEmpty('event')) {
             self::scanCategories();
         }
         self::$categories = \OC::$server->getTagManager()->load('event', self::getDefaultCategories());
     }
     return self::$categories;
 }
Example #26
0
 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;
     }
 }
Example #27
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;
 }
Example #28
0
    }
} else {
    $repeat['repeat'] = 'doesnotrepeat';
}
$calendar_options = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
$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();
$repeat_year_options = OC_Calendar_App::getYearOptions();
$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions();
$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth();
$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions();
$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions();
$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions();
$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
if ($permissions & OCP\Share::PERMISSION_UPDATE) {
    $tmpl = new OCP\Template('calendar', 'part.editevent');
} elseif ($permissions & OCP\Share::PERMISSION_READ) {
    $tmpl = new OCP\Template('calendar', 'part.showevent');
}
$tmpl->assign('eventid', $id);
$tmpl->assign('permissions', $permissions);
$tmpl->assign('lastmodified', $lastmodified);
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('repeat_options', $repeat_options);
$tmpl->assign('repeat_month_options', $repeat_month_options);
$tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
$tmpl->assign('repeat_end_options', $repeat_end_options);
$tmpl->assign('repeat_year_options', $repeat_year_options);
$tmpl->assign('repeat_byyearday_options', $repeat_byyearday_options);
Example #29
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;
 }
Example #30
0
OCP\JSON::callCheck();
$id = strip_tags($_GET['id']);
$idtype = strip_tags($_GET['idtype']);
switch ($idtype) {
    case 'calendar':
    case 'event':
        break;
    default:
        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) {
    case 'user':
    case 'group':
    case 'public':
        break;
    default:
        OCP\JSON::error(array('message' => 'unexspected parameter'));
        exit;
}
if ($sharetype == 'user' && !OCP\User::userExists($sharewith)) {