Exemplo n.º 1
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 = CalendarCalendar::extractUserID($this->getOwner());
     $calendar = CalendarApp::getCalendar($this->calendarInfo['id'], false, false);
     if ($uid === \OCP\USER::getUser() && (bool) $calendar['issubscribe'] === true) {
         $readprincipal = 'principals/' . \OCP\USER::getUser();
         $writeprincipal = '';
     }
     if ($uid !== \OCP\USER::getUser()) {
         $sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $this->calendarInfo['id']);
         if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_READ) {
             $readprincipal = 'principals/' . \OCP\USER::getUser();
             $writeprincipal = '';
         }
         if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_UPDATE) {
             $readprincipal = 'principals/' . \OCP\USER::getUser();
             $writeprincipal = 'principals/' . \OCP\USER::getUser();
         }
     }
     $acl = 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), array('privilege' => '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true));
     if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) {
         $acl[] = ['privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true];
         $acl[] = ['privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true];
     }
     return $acl;
 }
Exemplo n.º 2
0
 public function __construct()
 {
     $timeNow = time();
     //test
     $checkOffset = new \DateTime(date('d.m.Y', $timeNow), new \DateTimeZone(self::$tz));
     $calcSumWin = $checkOffset->getOffset();
     $this->nowTime = strtotime(date('d.m.Y H:i', $timeNow)) + $calcSumWin;
     if (\OC::$server->getSession()->get('public_link_token')) {
         $linkItem = \OCP\Share::getShareByToken(\OC::$server->getSession()->get('public_link_token', false));
         if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
             if ($linkItem['item_type'] === App::SHARECALENDAR) {
                 $sPrefix = App::SHARECALENDARPREFIX;
             }
             if ($linkItem['item_type'] === App::SHAREEVENT) {
                 $sPrefix = App::SHAREEVENTPREFIX;
             }
             if ($linkItem['item_type'] === App::SHARETODO) {
                 $sPrefix = App::SHARETODOPREFIX;
             }
             $itemSource = App::validateItemSource($linkItem['item_source'], $sPrefix);
             $rootLinkItem = Calendar::find($itemSource);
             $this->aCalendars[] = $rootLinkItem;
         }
     } else {
         if (\OCP\User::isLoggedIn()) {
             $this->aCalendars = Calendar::allCalendars(\OCP\User::getUser());
             $this->checkAlarm();
         }
     }
 }
Exemplo n.º 3
0
 /**
  * @brief Get a unique name of the item for the specified user
  * @param string Item
  * @param string|false User the item is being shared with
  * @param array|null List of similar item names already existing as shared items
  * @return string Target name
  *
  * This function needs to verify that the user does not already have an item with this name.
  * If it does generate a new name e.g. name_#
  */
 public function generateTarget($itemSource, $shareWith, $exclude = null)
 {
     $itemSource = App::validateItemSource($itemSource, App::SHARECALENDARPREFIX);
     $calendar = App::getCalendar($itemSource);
     $user_calendars = array();
     foreach (\OCA\CalendarPlus\Calendar::allCalendars($shareWith) as $user_calendar) {
         $user_calendars[] = $user_calendar['displayname'];
     }
     $name = $calendar['userid'] . "'s " . $calendar['displayname'];
     $suffix = '';
     while (in_array($name . $suffix, $user_calendars)) {
         $suffix++;
     }
     return $name . $suffix;
 }
Exemplo n.º 4
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 = CalendarCalendar::extractUserID($this->getOwner());
     if ($uid != \OCP\USER::getUser()) {
         $object = VObject::parse($this->objectData['calendardata']);
         $sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $this->calendarInfo['id']);
         $sharedAccessClassPermissions = Object::getAccessClassPermissions($object);
         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();
         } else {
             $writeprincipal = '';
         }
     }
     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));
 }
Exemplo n.º 5
0
 /**
  * @brief returns the owner of an object
  * @param integer $id
  * @return string
  */
 public static function getowner($id)
 {
     $event = self::find($id);
     $cal = Calendar::find($event['calendarid']);
     //\OCP\Util::writeLog(App::$appname,'OWNER'.$event['calendarid'].' of '.$event['summary'], \OCP\Util::DEBUG);
     if ($cal === false || is_array($cal) === false) {
         return null;
     }
     if (array_key_exists('userid', $cal)) {
         return $cal['userid'];
     } else {
         return null;
     }
 }
Exemplo n.º 6
0
 /**
  * @NoAdminRequired
  */
 public function importEventsPerDrop()
 {
     $pCalid = $this->params('calid');
     $pAddCal = $this->params('addCal');
     $pAddCalCol = $this->params('addCalCol');
     $data = $this->params('data');
     $data = explode(',', $data);
     $data = end($data);
     $data = base64_decode($data);
     $import = new Import($data);
     $import->setUserID($this->userId);
     $import->setTimeZone(CalendarApp::$tz);
     $import->disableProgressCache();
     if (!$import->isValid()) {
         $params = ['status' => 'error', 'error' => 'notvalid'];
         $response = new JSONResponse($params);
         return $response;
     }
     if ($pCalid == 'newCal' && $pAddCal != '') {
         $calendars = CalendarCalendar::allCalendars($this->userId);
         foreach ($calendars as $calendar) {
             if ($calendar['displayname'] == $pAddCal) {
                 $id = $calendar['id'];
                 $newcal = false;
                 break;
             }
             $newcal = true;
         }
         if ($newcal) {
             $id = CalendarCalendar::addCalendar($this->userId, strip_tags($pAddCal), 'VEVENT,VTODO,VJOURNAL', null, 0, strip_tags($pAddCalCol));
             CalendarCalendar::setCalendarActive($id, 1);
         }
     } else {
         $id = $pCalid;
         $calendar = CalendarApp::getCalendar($id);
         if ($calendar['userid'] != $this->userId) {
             $params = ['status' => 'error', 'error' => 'missingcalendarrights'];
             $response = new JSONResponse($params);
             return $response;
         }
     }
     $import->setOverwrite(false);
     $import->setCalendarID($id);
     $import->import();
     $count = $import->getCount();
     if ($count == 0) {
         CalendarCalendar::deleteCalendar($id);
         $params = ['status' => 'error', 'message' => $this->l10n->t('The file contained either no events or all events are already saved in your calendar.')];
         $response = new JSONResponse($params);
         return $response;
     } else {
         $newcalendarname = strip_tags($pAddCal);
         if ($pAddCal != '') {
             $params = ['status' => 'success', 'message' => $count . ' ' . $this->l10n->t('events has been saved in the new calendar') . ' ' . $newcalendarname, 'eventSource' => CalendarCalendar::getEventSourceInfo(CalendarCalendar::find($id))];
             $response = new JSONResponse($params);
             return $response;
         } else {
             $params = ['status' => 'success', 'message' => $count . ' ' . $this->l10n->t('events has been saved in the calendar') . ' ' . $calendar['displayname'], 'eventSource' => ''];
             $response = new JSONResponse($params);
             return $response;
         }
     }
 }
Exemplo n.º 7
0
 /**
  * 
  * @param string $query
  * @return \OCP\Search\Result
  */
 function search($query)
 {
     $today = date('Y-m-d', time());
     $allowedCommands = array('#ra' => 1, '#dt' => 1);
     $calendars = Calendar::allCalendars(\OCP\USER::getUser(), true);
     $activeCalendars = '';
     $config = \OC::$server->getConfig();
     foreach ($calendars as $calendar) {
         $isAktiv = $calendar['active'];
         if ($config->getUserValue(\OCP\USER::getUser(), CalendarApp::$appname, 'calendar_' . $calendar['id']) != '') {
             $isAktiv = $config->getUserValue(\OCP\USER::getUser(), CalendarApp::$appname, 'calendar_' . $calendar['id']);
         }
         if (!array_key_exists('active', $calendar)) {
             $isAktiv = 1;
         }
         if ($isAktiv == 1 && (int) $calendar['issubscribe'] === 0) {
             $activeCalendars[] = $calendar;
         }
     }
     if (count($activeCalendars) == 0 || !\OCP\App::isEnabled(CalendarApp::$appname)) {
         //return false;
     }
     $results = array();
     $searchquery = array();
     if (substr_count($query, ' ') > 0) {
         $searchquery = explode(' ', $query);
     } else {
         $searchquery[] = $query;
     }
     $user_timezone = CalendarApp::getTimezone();
     $l = \OC::$server->getL10N(TasksApp::$appname);
     $isDate = false;
     if (strlen($query) >= 5 && self::validateDate($query)) {
         $isDate = true;
         //\OCP\Util::writeLog('calendar','VALID DATE FOUND', \OCP\Util::DEBUG);
     }
     //foreach($calendars as $calendar) {
     $objects = TasksApp::all($activeCalendars);
     foreach ($objects as $object) {
         if ($object['objecttype'] != 'VTODO') {
             continue;
         }
         $searchAdvanced = false;
         if ($isDate == true && strlen($query) >= 5) {
             $tempQuery = strtotime($query);
             $checkDate = date('Y-m-d', $tempQuery);
             if (substr_count($object['startdate'], $checkDate) > 0 || substr_count($object['enddate'], $checkDate) > 0) {
                 $searchAdvanced = true;
             }
         }
         if (array_key_exists($query, $allowedCommands) && $allowedCommands[$query]) {
             if ($query == '#dt') {
                 $search = $object['startdate'];
                 if (substr_count($search, $today) > 0) {
                     $searchAdvanced = true;
                 }
             }
             if ($query == '#ra') {
                 if ($object['isalarm'] == 1) {
                     $searchAdvanced = true;
                 }
             }
         }
         if (substr_count(strtolower($object['summary']), strtolower($query)) > 0 || $searchAdvanced == true) {
             $calendardata = VObject::parse($object['calendardata']);
             $vtodo = $calendardata->VTODO;
             if (Object::getowner($object['id']) !== \OCP\USER::getUser()) {
                 if (isset($vtodo->CLASS) && $vtodo->CLASS->getValue() === 'CONFIDENTIAL') {
                     continue;
                 }
                 if (isset($vtodo->CLASS) && ($vtodo->CLASS->getValue() === 'PRIVATE' || $vtodo->CLASS->getValue() === '')) {
                     continue;
                 }
             }
             if ($vtodo->DUE) {
                 $dtstart = $vtodo->DUE;
                 $start_dt = $dtstart->getDateTime();
                 $start_dt->setTimezone(new \DateTimeZone($user_timezone));
                 if ($dtstart->getValueType() == 'DATE') {
                     $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
                 } else {
                     $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i');
                 }
             }
             if ($vtodo->DTSTART) {
                 $dtstart1 = $vtodo->DTSTART;
                 $start_dt = $dtstart1->getDateTime();
                 $start_dt->setTimezone(new \DateTimeZone($user_timezone));
                 if ($dtstart1->getValueType() == 'DATE') {
                     $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
                 } else {
                     $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i');
                 }
             }
             $link = \OC::$server->getURLGenerator()->linkToRoute(TasksApp::$appname . '.page.index') . '#' . urlencode($object['id']);
             $returnData['id'] = $object['id'];
             $returnData['description'] = $object['summary'] . ' ' . $info;
             $returnData['link'] = $link;
             $results[] = new Result($returnData);
         }
     }
     //}
     return $results;
 }
Exemplo n.º 8
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     if (\OC::$server->getAppManager()->isEnabledForUser('contactsplus')) {
         $appinfo = \OCP\App::getAppVersion('contactsplus');
         if (version_compare($appinfo, '1.0.6', '>=')) {
             $calId = $this->calendarController->checkBirthdayCalendarByUri('bdaycpltocal_' . $this->userId);
         }
     }
     $calendars = CalendarCalendar::allCalendars($this->userId, false, false, false);
     if (count($calendars) == 0) {
         CalendarCalendar::addDefaultCalendars($this->userId);
         $calendars = CalendarCalendar::allCalendars($this->userId, true);
     }
     if ($this->configInfo->getUserValue($this->userId, $this->appName, 'currentview', 'month') == "onedayview") {
         $this->configInfo->setUserValue($this->userId, $this->appName, 'currentview', "agendaDay");
     }
     if ($this->configInfo->getUserValue($this->userId, $this->appName, 'currentview', 'month') == "oneweekview") {
         $this->configInfo->setUserValue($this->userId, $this->appName, 'currentview', "agendaWeek");
     }
     if ($this->configInfo->getUserValue($this->userId, $this->appName, 'currentview', 'month') == "onemonthview") {
         $this->configInfo->setUserValue($this->userId, $this->appName, 'currentview', "month");
     }
     if ($this->configInfo->getUserValue($this->userId, $this->appName, 'currentview', 'month') == "listview") {
         $this->configInfo->setUserValue($this->userId, $this->appName, 'currentview', "list");
     }
     if ($this->configInfo->getUserValue($this->userId, $this->appName, 'currentview', 'month') == "fourweeksview") {
         $this->configInfo->setUserValue($this->userId, $this->appName, 'currentview', "fourweeks");
     }
     \OCP\Util::addStyle($this->appName, '3rdparty/colorPicker');
     \OCP\Util::addscript($this->appName, '3rdparty/jquery.colorPicker');
     \OCP\Util::addScript($this->appName, '3rdparty/fullcalendar');
     \OCP\Util::addStyle($this->appName, '3rdparty/fullcalendar');
     \OCP\Util::addStyle($this->appName, '3rdparty/jquery.timepicker');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/animation');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/fontello');
     \OCP\Util::addScript($this->appName, 'jquery.scrollTo.min');
     //\OCP\Util::addScript($this->appName,'timepicker');
     \OCP\Util::addScript($this->appName, '3rdparty/datepair');
     \OCP\Util::addScript($this->appName, '3rdparty/jquery.datepair');
     \OCP\Util::addScript($this->appName, '3rdparty/jquery.timepicker');
     \OCP\Util::addScript($this->appName, "3rdparty/jquery.webui-popover");
     \OCP\Util::addScript($this->appName, "3rdparty/chosen.jquery.min");
     \OCP\Util::addStyle($this->appName, "3rdparty/chosen");
     \OCP\Util::addScript($this->appName, '3rdparty/tag-it');
     \OCP\Util::addStyle($this->appName, '3rdparty/jquery.tagit');
     \OCP\Util::addStyle($this->appName, '3rdparty/jquery.webui-popover');
     if ($this->configInfo->getUserValue($this->userId, $this->appName, 'timezone') == null || $this->configInfo->getUserValue($this->userId, $this->appName, 'timezonedetection') == 'true') {
         \OCP\Util::addScript($this->appName, '3rdparty/jstz-1.0.4.min');
         \OCP\Util::addScript($this->appName, 'geo');
     }
     \OCP\Util::addScript($this->appName, '3rdparty/printThis');
     \OCP\Util::addScript($this->appName, 'app');
     \OCP\Util::addScript($this->appName, 'loaderimport');
     \OCP\Util::addStyle($this->appName, 'style');
     \OCP\Util::addStyle($this->appName, "mobile");
     \OCP\Util::addScript($this->appName, 'jquery.multi-autocomplete');
     \OCP\Util::addScript('core', 'tags');
     \OCP\Util::addScript($this->appName, 'on-event');
     $leftNavAktiv = $this->configInfo->getUserValue($this->userId, $this->appName, 'calendarnav');
     $rightNavAktiv = $this->configInfo->getUserValue($this->userId, $this->appName, 'tasknav');
     $pCalendar = $calendars;
     $pHiddenCal = 'class="isHiddenCal"';
     $pButtonCalAktive = '';
     if ($leftNavAktiv === 'true') {
         $pHiddenCal = '';
         $pButtonCalAktive = 'button-info';
     }
     $pButtonTaskAktive = '';
     $pTaskOutput = '';
     $pRightnavAktiv = $rightNavAktiv;
     $pIsHidden = 'class="isHiddenTask"';
     if ($rightNavAktiv === 'true' && \OC::$server->getAppManager()->isEnabledForUser('tasksplus')) {
         $allowedCals = [];
         foreach ($calendars as $calInfo) {
             $isAktiv = (int) $calInfo['active'];
             if ($this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calInfo['id']) !== '') {
                 $isAktiv = (int) $this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calInfo['id']);
             }
             if ($isAktiv === 1) {
                 $allowedCals[] = $calInfo;
             }
         }
         $cDataTimeLine = new \OCA\TasksPlus\Timeline();
         $cDataTimeLine->setCalendars($allowedCals);
         $taskOutPutbyTime = $cDataTimeLine->generateAddonCalendarTodo();
         $paramsList = ['taskOutPutbyTime' => $taskOutPutbyTime];
         $list = new TemplateResponse('tasksplus', 'calendars.tasks.list', $paramsList, '');
         $pButtonTaskAktive = 'button-info';
         $pTaskOutput = $list->render();
         $pIsHidden = '';
     }
     $params = ['calendars' => $pCalendar, 'leftnavAktiv' => $leftNavAktiv, 'isHiddenCal' => $pHiddenCal, 'buttonCalAktive' => $pButtonCalAktive, 'isHidden' => $pIsHidden, 'buttonTaskAktive' => $pButtonTaskAktive, 'taskOutput' => $pTaskOutput, 'rightnavAktiv' => $pRightnavAktiv, 'mailNotificationEnabled' => \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_mail_notification', 'yes'), 'allowShareWithLink' => \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes'), 'mailPublicNotificationEnabled' => \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_public_notification', 'no')];
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedImageDomain('*');
     $response = new TemplateResponse($this->appName, 'calendar', $params);
     $response->setContentSecurityPolicy($csp);
     return $response;
 }
 /**
  * @NoAdminRequired
  */
 public function reScanCal()
 {
     $calendars = CalendarCalendar::allCalendars($this->userId);
     foreach ($calendars as $calendar) {
         $this->repeatController->cleanCalendar($calendar['id']);
         $this->repeatController->generateCalendar($calendar['id']);
     }
     $params = ['status' => 'success', 'data' => ['message' => (string) $this->l10n->t('Success')]];
     $response = new JSONResponse($params);
     return $response;
 }
Exemplo n.º 10
0
    /**
     * @NoAdminRequired
     */
    public function rebuildLeftNavigation()
    {
        $leftNavAktiv = $this->configInfo->getUserValue($this->userId, $this->appName, 'calendarnav');
        //make it as template
        if ($leftNavAktiv === 'true') {
            $calendars = CalendarCalendar::allCalendars($this->userId, false);
            //$mySharees=Object::getCalendarSharees();
            $activeCal = $this->configInfo->getUserValue($this->userId, $this->appName, 'choosencalendar');
            $outputAbo = '';
            $output = '<div id="leftcontentInner">
							<div class="view navigation-left button-group" style="float:none;">
							<button class="button viewaction" data-action="agendaDay" data-view="true" data-weekends="true">' . $this->l10n->t('Day') . '</button>
							<button class="button viewaction" data-action="agendaThreeDays" data-view="true" data-weekends="true">' . $this->l10n->t('3-Days') . '</button>	
							<button class="button viewaction" data-action="agendaWorkWeek" data-view="true" data-weekends="false">' . $this->l10n->t('W-Week') . '</button>			
							<button class="button viewaction" data-action="agendaWeek" data-view="true" data-weekends="true">' . $this->l10n->t('Week') . '</button>
						  <button class="button viewaction" data-action="month" data-view="true" data-weekends="true">' . $this->l10n->t('Month') . '</button>
						   <button class="button viewaction" data-action="list" data-view="true" data-weekends="true"><i class="ioc ioc-th-list" title="' . $this->l10n->t('List') . '"></i></button>
						   	<button class="button viewaction" data-action="year" data-view="true" data-weekends="true">' . $this->l10n->t('Year') . '</button>
						   
						   <br />
						   <button class="button" data-action="prev" data-view="false" data-weekends="false"><i class="ioc ioc-angle-left"></i></button>		
						  <button class="button"  data-action="next" data-view="false" data-weekends="false"><i class="ioc ioc-angle-right"></i></button>	
				
			  </div>	
				<div id="datepickerNav"></div>
					<h3><i class="ioc ioc-calendar"></i>&nbsp;' . $this->l10n->t('Calendar') . '</h3>
								<ul id="calendarList">';
            $bShareApi = \OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes');
            foreach ($calendars as $calInfo) {
                $rightsOutput = '';
                $share = '';
                $checkBox = '';
                $isActiveUserCal = '';
                $addCheckClass = '';
                $sharedescr = '';
                if ($activeCal === $calInfo['id']) {
                    $isActiveUserCal = 'isActiveCal';
                    $addCheckClass = 'isActiveUserCal';
                }
                /*
                						  if((is_array($mySharees) && array_key_exists($calInfo['id'], $mySharees))) {
                						 	$sharedescr=$mySharees[$calInfo['id']];	
                						 	$share='<i class="ioc ioc-share toolTip" title="<b>'. $this->l10n->t('Shared with').'</b><br>'.$sharedescr.'"></i> '; 	
                						 }*/
                $shareLink = '';
                if ($calInfo['permissions'] & \OCP\PERMISSION_SHARE && $bShareApi === 'yes') {
                    $shareLink = '<a href="#" class="share icon-share" 
							  	data-item-type="' . CalendarApp::SHARECALENDAR . '" 
							    data-item="' . CalendarApp::SHARECALENDARPREFIX . $calInfo['id'] . '" 
							    data-link="true"
							    data-title="' . $calInfo['displayname'] . '"
								data-possible-permissions="' . $calInfo['permissions'] . '"
								title="' . (string) $this->l10n->t('Share Calendar') . '"
								style="float:right;"
								>
								</a>';
                }
                $displayName = '<span class="descr toolTip"  title="' . $calInfo['displayname'] . '">' . $calInfo['displayname'] . '</span>' . $shareLink;
                $checked = $calInfo['active'] ? ' checked="checked"' : '';
                $notice = '';
                $shareInfo = '';
                if ($calInfo['userid'] !== $this->userId) {
                    if ($shareLink === '') {
                        if (\OCP\Share::getItemSharedWithByLink(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $calInfo['id'], $calInfo['userid'])) {
                            $notice = '<b>Notice</b><br>This calendar is also shared by Link for public!<br>';
                        }
                        $rightsOutput = CalendarCalendar::permissionReader($calInfo['permissions']);
                        $shareInfo = '<i style="float:right;" class="toolTip ioc ioc-info" title="' . $notice . (string) $this->l10n->t('by') . ' ' . $calInfo['userid'] . '<br />(' . $rightsOutput . ')"></i>';
                    }
                    $calShare = $calInfo['active'];
                    if ($this->configInfo->getUserValue($this->userId, 'calendar', 'calendar_' . $calInfo['id']) !== '') {
                        $calShare = $this->configInfo->getUserValue($this->userId, 'calendar', 'calendar_' . $calInfo['id']);
                    }
                    $checked = $calShare ? ' checked="checked"' : '';
                    $displayName = '<span class="descr toolTip" title="' . $calInfo['displayname'] . '">' . $calInfo['displayname'] . '</span>' . $shareLink . $shareInfo;
                    // $checkBox='';
                }
                $checkBox = '<input class="activeCalendarNav regular-checkbox" data-id="' . $calInfo['id'] . '" style="float:left;" id="edit_active_' . $calInfo['id'] . '" type="checkbox" ' . $checked . ' /><label style="float:left;margin-right:5px;" class="toolTip" title="' . $this->l10n->t('show / hide calendar') . '" for="edit_active_' . $calInfo['id'] . '"></label>';
                if ((bool) $calInfo['issubscribe'] === false) {
                    $output .= '<li data-id="' . $calInfo['id'] . '" class="calListen ' . $isActiveUserCal . '">' . $checkBox . '<div class="colCal toolTip iCalendar ' . $addCheckClass . '" title="' . $this->l10n->t('choose calendar as default') . '" style="cursor:pointer;background:' . $calInfo['calendarcolor'] . '">&nbsp;</div> ' . $displayName . '</li>';
                } else {
                    if ($calInfo['userid'] === $this->userId) {
                        $refreshImage = '<i title="refresh"  class="refreshSubscription ioc ioc-refresh" style="cursor:pointer;float:right;position:absolute;right:18px;">&nbsp;</i>';
                    }
                    $outputAbo .= '<li data-id="' . $calInfo['id'] . '" class="calListen ' . $isActiveUserCal . '">' . $checkBox . '<div class="colCal" style="cursor:pointer;background:' . $calInfo['calendarcolor'] . '">&nbsp;</div> ' . $displayName . $refreshImage . '</li>';
                }
            }
            if ($outputAbo !== '') {
                $outputAbo = '<br style="clear:both;"><br /><h3><i class="ioc ioc-rss-alt"></i>&nbsp;' . $this->l10n->t('Subscription') . '</h3><ul>' . $outputAbo . '</ul>';
            }
            $output .= '</ul>' . $outputAbo . '<br />
				   <br style="clear:both;"><br />
				   <h3 data-id="lCategory" style=" cursor:pointer; line-height:24px;" ><label id="showCategory"><i style="font-size:22px;" class="ioc ioc-angle-down ioc-rotate-270"></i>&nbsp;<i class="ioc ioc-tags"></i>&nbsp;' . $this->l10n->t('Tags') . '</label> 
				   	 	
				   
				   </h3>
					 <ul id="categoryCalendarList">
					 </ul>
					  </div>
					     ';
            return $output;
        } else {
            return '';
        }
    }
Exemplo n.º 11
0
 public function getCalendarPermissions()
 {
     $this->iCalPermissions = Calendar::find($this->iCalId);
 }
Exemplo n.º 12
0
 /**
  * @PublicPage
  * @NoCSRFRequired
  */
 public function getShowEvent()
 {
     $id = $this->params('id');
     $choosenDate = $this->params('choosendate');
     if (\OCP\User::isLoggedIn()) {
         $sDateFormat = $this->configInfo->getUserValue($this->userId, $this->appName, 'dateformat', 'd-m-Y');
         $sTimeFormat = $this->configInfo->getUserValue($this->userId, $this->appName, 'timeformat', '24');
         if ($sTimeFormat == 24) {
             $sTimeFormatRead = 'H:i';
         } else {
             $sTimeFormatRead = 'g:i a';
         }
         if ($sDateFormat === 'd-m-Y') {
             $sDateFormat = 'd.m.Y';
         }
     } else {
         if ($this->session->get('public_dateformat') != '') {
             $sDateFormat = $this->session->get('public_dateformat');
         } else {
             $sDateFormat = 'd.m.Y';
         }
         if ($this->session->get('public_timeformat') != '') {
             $sTimeFormatRead = $this->session->get('public_timeformat');
         } else {
             $sTimeFormatRead = 'H:i';
         }
     }
     $data = CalendarApp::getEventObject($id, false, false);
     if (!$data) {
         exit;
     }
     $object = VObject::parse($data['calendardata']);
     //FIXME Working with objectparser
     $vevent = $object->VEVENT;
     $object = Object::cleanByAccessClass($id, $object);
     $accessclass = $vevent->getAsString('CLASS');
     $permissions = CalendarApp::getPermissions($id, CalendarApp::EVENT, $accessclass);
     $dtstart = $vevent->DTSTART;
     if (isset($choosenDate) && $choosenDate !== '') {
         $choosenDate = $choosenDate;
     } else {
         $choosenDate = $dtstart->getDateTime()->format('Ymd');
     }
     $showdate = $dtstart->getDateTime()->format('Y-m-d H:i:s');
     $organzier = '';
     if ($vevent->ORGANIZER) {
         $organizerVal = $vevent->getAsString('ORGANIZER');
         $temp = explode('mailto:', $organizerVal);
         $organzier = $temp[1];
     }
     $attendees = '';
     if ($vevent->ATTENDEE) {
         $attendees = array();
         foreach ($vevent->ATTENDEE as $key => $param) {
             $temp1 = explode('mailto:', $param);
             $attendees[$key] = $temp1[1];
         }
     }
     $dtend = Object::getDTEndFromVEvent($vevent);
     $dtstartType = (string) $vevent->DTSTART->getValueType();
     $datetimedescr = '';
     if ($dtstartType === 'DATE') {
         $startdate = $dtstart->getDateTime()->format('d-m-Y');
         $starttime = '';
         $enddate = $dtend->getDateTime()->modify('-1 day')->format('d-m-Y');
         $endtime = '';
         $choosenDate = $choosenDate + 3600 * 24;
         $allday = true;
         if ($startdate === $enddate) {
             $datetimedescr = (string) $this->l10n->t('On') . ' ' . $dtstart->getDateTime()->format($sDateFormat);
         } else {
             $datetimedescr = (string) $this->l10n->t('From') . ' ' . $dtstart->getDateTime()->format($sDateFormat) . ' ' . (string) $this->l10n->t('To') . ' ' . $dtend->getDateTime()->modify('-1 day')->format($sDateFormat);
         }
     }
     if ($dtstartType === 'DATE-TIME') {
         $tz = CalendarApp::getTimezone();
         $start_dt = new \DateTime($data['startdate'], new \DateTimeZone('UTC'));
         $end_dt = new \DateTime($data['enddate'], new \DateTimeZone('UTC'));
         $start_dt->setTimezone(new \DateTimeZone($tz));
         $end_dt->setTimezone(new \DateTimeZone($tz));
         $startdate = $start_dt->format('d-m-Y');
         $starttime = $start_dt->format($sTimeFormatRead);
         $enddate = $end_dt->format('d-m-Y');
         $endtime = $end_dt->format($sTimeFormatRead);
         if ($startdate === $enddate) {
             $datetimedescr = (string) $this->l10n->t('On') . ' ' . $start_dt->format($sDateFormat) . ' ' . (string) $this->l10n->t('From') . ' ' . $starttime . ' ' . (string) $this->l10n->t('To') . ' ' . $endtime;
         } else {
             $datetimedescr = (string) $this->l10n->t('From') . ' ' . $start_dt->format($sDateFormat) . ' ' . $starttime . ' ' . (string) $this->l10n->t('To') . ' ' . $end_dt->format($sDateFormat) . ' ' . $endtime;
         }
         $allday = false;
     }
     $summary = strtr($vevent->getAsString('SUMMARY'), array('\\,' => ',', '\\;' => ';'));
     $location = strtr($vevent->getAsString('LOCATION'), array('\\,' => ',', '\\;' => ';'));
     $categories = $vevent->getAsArray('CATEGORIES');
     $description = strtr($vevent->getAsString('DESCRIPTION'), array('\\,' => ',', '\\;' => ';'));
     $link = strtr($vevent->getAsString('URL'), array('\\,' => ',', '\\;' => ';'));
     $categoriesOut = '';
     if (is_array($categories)) {
         foreach ($categories as $category) {
             $bgColor = CalendarApp::genColorCodeFromText(trim($category), 80);
             $categoriesOut[] = array('name' => $category, 'bgcolor' => $bgColor, 'color' => CalendarApp::generateTextColor($bgColor));
         }
     }
     $last_modified = $vevent->__get('LAST-MODIFIED');
     if ($last_modified) {
         $lastmodified = $last_modified->getDateTime()->format('U');
     } else {
         $lastmodified = 0;
     }
     $addSingleDeleteButton = false;
     $repeatInfo = array();
     $repeat['repeat'] = '';
     if ((int) $data['repeating'] === 1) {
         $addSingleDeleteButton = true;
         $rrule = explode(';', $vevent->getAsString('RRULE'));
         $rrulearr = array();
         $repeat['repeat_rules'] = '';
         foreach ($rrule as $rule) {
             list($attr, $val) = explode('=', $rule);
             if ((string) $attr !== 'COUNT' && (string) $attr !== 'UNTIL') {
                 if ($repeat['repeat_rules'] === '') {
                     $repeat['repeat_rules'] = $attr . '=' . $val;
                 } else {
                     $repeat['repeat_rules'] .= ';' . $attr . '=' . $val;
                 }
             }
             if ((string) $attr === 'COUNT' || (string) $attr === 'UNTIL') {
                 $rrulearr[$attr] = $val;
             }
         }
         if (array_key_exists('COUNT', $rrulearr)) {
             $repeat['end'] = 'count';
             $repeat['count'] = $rrulearr['COUNT'];
         } elseif (array_key_exists('UNTIL', $rrulearr)) {
             $repeat['end'] = 'date';
             $endbydate_day = substr($rrulearr['UNTIL'], 6, 2);
             $endbydate_month = substr($rrulearr['UNTIL'], 4, 2);
             $endbydate_year = substr($rrulearr['UNTIL'], 0, 4);
             $rEnd_dt = new \DateTime($endbydate_day . '-' . $endbydate_month . '-' . $endbydate_year, new \DateTimeZone('UTC'));
             $repeat['date'] = $rEnd_dt->format($sDateFormat);
             //Switch it
         } else {
             $repeat['end'] = 'never';
         }
         $repeat_end_options = CalendarApp::getEndOptions();
         if ($repeat['end'] === 'count') {
             $repeatInfo['end'] = $this->l10n->t('after') . ' ' . $repeat['count'] . ' ' . $this->l10n->t('Events');
         }
         if ($repeat['end'] === 'date') {
             $repeatInfo['end'] = $repeat['date'];
         }
         if ($repeat['end'] === 'never') {
             $repeatInfo['end'] = $repeat_end_options[$repeat['end']];
         }
     } else {
         $repeat['repeat'] = 'doesnotrepeat';
     }
     if ($permissions !== $this->shareConnector->getAllAccess()) {
         $calendar_options[0]['id'] = $data['calendarid'];
     } else {
         $calendar_options = CalendarCalendar::allCalendars($this->userId);
     }
     $checkCatCache = '';
     if (\OCP\User::isLoggedIn()) {
         $category_options = CalendarApp::loadTags();
         foreach ($category_options['tagslist'] as $catInfo) {
             $checkCatCache[$catInfo['name']] = $catInfo['bgcolor'];
         }
     }
     $access_class_options = CalendarApp::getAccessClassOptions();
     $aOExdate = '';
     if ($vevent->EXDATE) {
         $timezone = CalendarApp::getTimezone();
         foreach ($vevent->EXDATE as $param) {
             $param = new \DateTime($param);
             $aOExdate[$param->format('U')] = $param->format($sDateFormat);
         }
     }
     //NEW Reminder
     $reminder_options = CalendarApp::getReminderOptions();
     $reminder_time_options = CalendarApp::getReminderTimeOptions();
     //reminder
     $sAlarm = '';
     $count = '';
     if ($vevent->VALARM) {
         $valarm = '';
         $sAlarm = '';
         $counter = 0;
         foreach ($vevent->getComponents() as $param) {
             if ($param->name === 'VALARM') {
                 $attr = $param->children();
                 foreach ($attr as $attrInfo) {
                     $valarm[$counter][$attrInfo->name] = $attrInfo->getValue();
                 }
                 $counter++;
             }
         }
         foreach ($valarm as $vInfo) {
             if ($vInfo['ACTION'] === 'DISPLAY' && strstr($vInfo['TRIGGER'], 'P')) {
                 if (substr_count($vInfo['TRIGGER'], 'PT') === 1 && !stristr($vInfo['TRIGGER'], 'TRIGGER')) {
                     $sAlarm[] = 'TRIGGER:' . $vInfo['TRIGGER'];
                 }
                 if (substr_count($vInfo['TRIGGER'], 'PT') === 1 && stristr($vInfo['TRIGGER'], 'TRIGGER')) {
                     $sAlarm[] = $vInfo['TRIGGER'];
                 }
                 if (substr_count($vInfo['TRIGGER'], '-P') === 1 && substr_count($vInfo['TRIGGER'], 'PT') === 0) {
                     $temp = explode('-P', (string) $vInfo['TRIGGER']);
                     $sAlarm[] = 'TRIGGER:-PT' . $temp[1];
                 }
                 if (substr_count($vInfo['TRIGGER'], '+P') === 1 && substr_count($vInfo['TRIGGER'], 'PT') === 0) {
                     $temp = explode('+P', $vInfo['TRIGGER']);
                     $sAlarm[] = 'TRIGGER:+PT' . $temp[1];
                 }
             }
             if ($vInfo['ACTION'] === 'DISPLAY' && !strstr($vInfo['TRIGGER'], 'P')) {
                 if (!strstr($vInfo['TRIGGER'], 'DATE-TIME')) {
                     $sAlarm[] = 'TRIGGER;VALUE=DATE-TIME:' . $vInfo['TRIGGER'];
                 } else {
                     $sAlarm[] = $vInfo['TRIGGER'];
                 }
             }
         }
     }
     if ($permissions & $this->shareConnector->getReadAccess()) {
         $bShareOnlyEvent = 0;
         if (Object::checkShareEventMode($id)) {
             $bShareOnlyEvent = 1;
         }
         $pCategoriesCol = '';
         $pCategories = '';
         if (is_array($categoriesOut) && count($categoriesOut) > 0) {
             $pCategoriesCol = $checkCatCache;
             $pCategories = $categoriesOut;
         }
         $pRepeatInfo = '';
         if ($repeat['repeat'] !== 'doesnotrepeat') {
             $pRepeatInfo = $repeatInfo;
         }
         $aCalendar = CalendarApp::getCalendar($data['calendarid'], false, false);
         $isBirthday = false;
         if ($aCalendar['uri'] === 'bdaycpltocal_' . $aCalendar['userid']) {
             $isBirthday = true;
         }
         $params = ['bShareOnlyEvent' => $bShareOnlyEvent, 'eventid' => $id, 'appname' => $this->appName, 'permissions' => $permissions, 'lastmodified' => $lastmodified, 'exDate' => $aOExdate, 'isBirthday' => $isBirthday, 'calendar_options' => $calendar_options, 'access_class_options' => $access_class_options, 'sReminderTrigger' => $sAlarm, 'cValarm' => $count, 'isShareApi' => $this->appConfig->getValue('core', 'shareapi_enabled', 'yes'), 'mailNotificationEnabled' => $this->appConfig->getValue('core', 'shareapi_allow_mail_notification', 'yes'), 'allowShareWithLink' => $this->appConfig->getValue('core', 'shareapi_allow_links', 'yes'), 'mailPublicNotificationEnabled' => $this->appConfig->getValue('core', 'shareapi_allow_public_notification', 'no'), 'title' => $summary, 'accessclass' => $accessclass, 'location' => $location, 'categoriesCol' => $pCategoriesCol, 'categories' => $pCategories, 'aCalendar' => $aCalendar, 'allday' => $allday, 'startdate' => $startdate, 'starttime' => $starttime, 'enddate' => $enddate, 'endtime' => $endtime, 'datetimedescr' => $datetimedescr, 'description' => $description, 'link' => $link, 'organzier' => $organzier, 'attendees' => $attendees, 'addSingleDeleteButton' => $addSingleDeleteButton, 'choosendate' => $choosenDate, 'showdate' => $showdate, 'repeat' => $repeat['repeat'], 'repeat_rules' => isset($repeat['repeat_rules']) ? $repeat['repeat_rules'] : '', 'repeatInfo' => $pRepeatInfo, 'sharetypeevent' => $this->shareConnector->getConstShareEvent(), 'sharetypeeventprefix' => $this->shareConnector->getConstSharePrefixEvent()];
         $response = new TemplateResponse($this->appName, 'part.showevent', $params, '');
         return $response;
     }
 }
Exemplo n.º 13
0
 /**
  * @NoAdminRequired
  */
 public function getDefaultValuesTasks()
 {
     $calendars = CalendarCalendar::allCalendars($this->userId);
     $myCalendars = array();
     foreach ($calendars as $calendar) {
         if (!array_key_exists('active', $calendar)) {
             $calendar['active'] = 1;
         }
         if ($calendar['active'] == 1) {
             //$calendarInfo[$calendar['id']]=array('bgcolor'=>$calendar['calendarcolor'],'color'=>OCA\CalendarPlus\Calendar::generateTextColor($calendar['calendarcolor']));
             $myCalendars[$calendar['id']] = array('id' => $calendar['id'], 'name' => $calendar['displayname'], 'uri' => $calendar['uri']);
         }
     }
     $checkCat = CalendarApp::loadTags();
     $checkCatTagsList = '';
     $checkCatCategory = '';
     foreach ($checkCat['categories'] as $category) {
         $checkCatCategory[] = $category;
     }
     foreach ($checkCat['tagslist'] as $tag) {
         $checkCatTagsList[$tag['name']] = array('id' => $tag['id'], 'name' => $tag['name'], 'color' => $tag['color'], 'bgcolor' => $tag['bgcolor']);
     }
     $params = ['mycalendars' => $myCalendars, 'categories' => $checkCatCategory, 'tags' => $checkCatTagsList];
     $response = new JSONResponse();
     $response->setData($params);
     return $response;
 }
Exemplo n.º 14
0
 /**
  * @NoAdminRequired
  */
 public function setCompletedTask()
 {
     $id = $this->params('id');
     $checked = $this->params('checked');
     $vcalendar = CalendarApp::getVCalendar($id);
     $vtodo = $vcalendar->VTODO;
     TasksApp::setComplete($vtodo, $checked ? 100 : 0, null);
     Object::edit($id, $vcalendar->serialize());
     $user_timezone = CalendarApp::getTimezone();
     $aTask = TasksApp::getEventObject($id, true, true);
     $aCalendar = CalendarCalendar::find($aTask['calendarid']);
     $task_info[] = TasksApp::arrayForJSON($id, $vtodo, $user_timezone, $aCalendar, $aTask);
     $subTaskIds = '';
     if ($aTask['relatedto'] === '') {
         $subTaskIds = TasksApp::getSubTasks($aTask['eventuid']);
         if ($subTaskIds !== '') {
             $tempIds = explode(',', $subTaskIds);
             foreach ($tempIds as $subIds) {
                 $vcalendar = TasksApp::getVCalendar($subIds, true, true);
                 $vtodo = $vcalendar->VTODO;
                 TasksApp::setComplete($vtodo, $checked ? 100 : 0, null);
                 TasksApp::edit($subIds, $vcalendar->serialize());
                 $task_info[] = TasksApp::arrayForJSON($subIds, $vtodo, $user_timezone, $aCalendar, $aTask);
             }
         }
     }
     $params = ['status' => 'success', 'data' => $task_info];
     $response = new JSONResponse($params);
     return $response;
 }
Exemplo n.º 15
0
 /**
  * @brief Get the permissions for a calendar / an event
  * @param (int) $id - id of the calendar / event
  * @param (string) $type - type of the id (calendar/event)
  * @return (int) $permissions - CRUDS permissions
  * @param (string) $accessclass - access class (rfc5545, section 3.8.1.3)
  * @see \OCP\Share
  */
 public static function getPermissions($id, $type, $accessclass = '')
 {
     $permissions_all = \OCP\PERMISSION_ALL;
     if ($type === self::CALENDAR) {
         $calendar = self::getCalendar($id, false, false);
         if ($calendar['userid'] === \OCP\USER::getUser()) {
             return $permissions_all;
         } else {
             $sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $id);
             if ($sharedCalendar) {
                 return $sharedCalendar['permissions'];
             }
         }
     } elseif ($type == self::TODO) {
         if (Object::getowner($id) === \OCP\USER::getUser()) {
             return $permissions_all;
         } else {
             $object = Object::find($id);
             $cal = Calendar::find($object['calendarid']);
             if (\OCP\USER::isLoggedIn()) {
                 $sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $object['calendarid']);
                 $sharedEvent = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARETODO, CalendarApp::SHARETODOPREFIX . $id);
                 $calendar_permissions = 0;
                 $event_permissions = 0;
                 if ($sharedCalendar) {
                     $calendar_permissions = $sharedCalendar['permissions'];
                 }
                 if ($sharedEvent) {
                     $event_permissions = $sharedEvent['permissions'];
                 }
             }
             if (!\OCP\USER::isLoggedIn()) {
                 $sharedByLinkCalendar = \OCP\Share::getItemSharedWithByLink(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $object['calendarid'], $cal['userid']);
                 if ($sharedByLinkCalendar) {
                     $calendar_permissions = $sharedByLinkCalendar['permissions'];
                     $event_permissions = 0;
                 }
             }
             if ($accessclass === 'PRIVATE') {
                 return 0;
             } elseif ($accessclass === 'CONFIDENTIAL') {
                 return \OCP\PERMISSION_READ;
             } else {
                 return max($calendar_permissions, $event_permissions);
             }
         }
     }
     return 0;
 }
Exemplo n.º 16
0
 /**
  * @PublicPage
  * @NoCSRFRequired
  */
 public function getGuestSettingsCalendar()
 {
     $token = $this->params('t');
     if (isset($token)) {
         $linkItem = \OCP\Share::getShareByToken($token, false);
         if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
             // seems to be a valid share
             if ($linkItem['item_type'] === CalendarApp::SHARECALENDAR) {
                 $sPrefix = CalendarApp::SHARECALENDARPREFIX;
             }
             if ($linkItem['item_type'] === CalendarApp::SHAREEVENT) {
                 $sPrefix = CalendarApp::SHAREEVENTPREFIX;
             }
             $itemSource = CalendarApp::validateItemSource($linkItem['item_source'], $sPrefix);
             $shareOwner = $linkItem['uid_owner'];
             $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
             if (isset($rootLinkItem['uid_owner'])) {
                 \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
                 $calendar = CalendarCalendar::find($itemSource);
                 if (!array_key_exists('active', $calendar)) {
                     $calendar['active'] = 1;
                 }
                 if ($calendar['active'] == 1) {
                     $eventSources[] = CalendarCalendar::getEventSourceInfo($calendar, true);
                     $eventSources[0]['url'] = \OC::$server->getURLGenerator()->linkToRoute($this->appName . '.public.getEventsPublic') . '?t=' . $token;
                     $calendarInfo[$calendar['id']] = array('bgcolor' => $calendar['calendarcolor'], 'color' => CalendarCalendar::generateTextColor($calendar['calendarcolor']));
                     $myRefreshChecker[$calendar['id']] = $calendar['ctag'];
                 }
             }
         }
         $defaultView = 'month';
         if ($this->session->get('public_currentView') != '') {
             $defaultView = (string) $this->session->get('public_currentView');
         }
         $params = ['status' => 'success', 'defaultView' => $defaultView, 'agendatime' => 'HH:mm { - HH:mm}', 'defaulttime' => 'HH:mm', 'firstDay' => '1', 'calendarId' => $calendar['id'], 'eventSources' => $eventSources, 'calendarcolors' => $calendarInfo, 'myRefreshChecker' => $myRefreshChecker];
         $response = new JSONResponse($params);
         return $response;
     }
 }
Exemplo n.º 17
0
 /**
  * scan events for categories.
  * @param $events VEVENTs to scan. null to check all events for the current user.
  */
 public static function scanCategories($events = null)
 {
     if (is_null($events)) {
         $calendars = CalendarCalendar::allCalendars(\OCP\USER::getUser());
         if (count($calendars) > 0) {
             $events = array();
             foreach ($calendars as $calendar) {
                 if ($calendar['userid'] === \OCP\User::getUser()) {
                     $calendar_events = Object::all($calendar['id']);
                     $events = $events + $calendar_events;
                 }
             }
         }
     }
     if (is_array($events) && count($events) > 0) {
         $vcategories = \OC::$server->getTagManager()->load('event');
         $getName = function ($tag) {
             return $tag['name'];
         };
         $tags = array_map($getName, $vcategories->getTags());
         $vcategories->delete($tags);
         foreach ($events as $event) {
             $vobject = VObject::parse($event['calendardata']);
             if (!is_null($vobject)) {
                 $object = null;
                 if (isset($calendar->VEVENT)) {
                     $object = $calendar->VEVENT;
                 } else {
                     if (isset($calendar->VTODO)) {
                         $object = $calendar->VTODO;
                     } else {
                         if (isset($calendar->VJOURNAL)) {
                             $object = $calendar->VJOURNAL;
                         }
                     }
                 }
                 if ($object && isset($object->CATEGORIES)) {
                     $vcategories->addMultiple($object->CATEGORIES->getParts(), true, $event['id']);
                 }
             }
         }
     }
 }
Exemplo n.º 18
0
 /**
  * @brief Get the permissions for a calendar / an event
  * @param (int) $id - id of the calendar / event
  * @param (string) $type - type of the id (calendar/event)
  * @return (int) $permissions - CRUDS permissions
  * @param (string) $accessclass - access class (rfc5545, section 3.8.1.3)
  * @see \OCP\Share
  */
 public static function getPermissions($id, $type, $accessclass = '')
 {
     $permissions_all = \OCP\PERMISSION_ALL;
     if ($type == self::CALENDAR) {
         $calendar = self::getCalendar($id, false, false);
         if ($calendar['userid'] == \OCP\USER::getUser()) {
             if (isset($calendar['issubscribe'])) {
                 $permissions_all = \OCP\PERMISSION_READ;
             }
             return $permissions_all;
         } else {
             $sharedCalendar = \OCP\Share::getItemSharedWithBySource(self::SHARECALENDAR, App::SHARECALENDARPREFIX . $id);
             if ($sharedCalendar) {
                 return $sharedCalendar['permissions'];
             }
         }
     } elseif ($type == self::EVENT) {
         $object = Object::find($id);
         $cal = Calendar::find($object['calendarid']);
         if ($cal['userid'] == \OCP\USER::getUser()) {
             if ($cal['issubscribe']) {
                 $permissions_all = \OCP\PERMISSION_READ;
             }
             return $permissions_all;
         } else {
             if (\OCP\USER::isLoggedIn()) {
                 $sharedCalendar = \OCP\Share::getItemSharedWithBySource(self::SHARECALENDAR, self::SHARECALENDARPREFIX . $object['calendarid']);
                 $sharedEvent = \OCP\Share::getItemSharedWithBySource(self::SHAREEVENT, self::SHAREEVENTPREFIX . $id);
                 $calendar_permissions = 0;
                 $event_permissions = 0;
                 if ($sharedCalendar) {
                     $calendar_permissions = $sharedCalendar['permissions'];
                 }
                 if ($sharedEvent) {
                     $event_permissions = $sharedEvent['permissions'];
                 }
             }
             if (!\OCP\USER::isLoggedIn()) {
                 //\OCP\Util::writeLog('calendar', __METHOD__ . ' id: ' . $id . ', NOT LOGGED IN: ', \OCP\Util::DEBUG);
                 $sharedByLinkCalendar = \OCP\Share::getItemSharedWithByLink(self::SHARECALENDAR, self::SHARECALENDARPREFIX . $object['calendarid'], $cal['userid']);
                 if ($sharedByLinkCalendar) {
                     $calendar_permissions = $sharedByLinkCalendar['permissions'];
                     $event_permissions = 0;
                 }
             }
             if ($accessclass === 'PRIVATE') {
                 return 0;
             } elseif ($accessclass === 'CONFIDENTIAL') {
                 return \OCP\PERMISSION_READ;
             } else {
                 return max($calendar_permissions, $event_permissions);
             }
         }
     }
     return 0;
 }
Exemplo n.º 19
0
 /**
  * @NoAdminRequired
  */
 public function rebuildLeftNavigation()
 {
     $leftNavAktiv = $this->configInfo->getUserValue($this->userId, $this->appName, 'calendarnav');
     //make it as template
     //if ($leftNavAktiv === 'true') {
     $calendars = CalendarCalendar::allCalendars($this->userId, false);
     $bShareApi = \OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes');
     $activeCal = (int) $this->configInfo->getUserValue($this->userId, $this->appName, 'choosencalendar');
     $bActiveCalFound = false;
     $aCalendars = array();
     foreach ($calendars as $calInfo) {
         if ($activeCal === (int) $calInfo['id']) {
             $bActiveCalFound = true;
         }
         $calInfo['bShare'] = false;
         if ($calInfo['permissions'] & $this->shareConnector->getShareAccess() && $bShareApi === 'yes') {
             $calInfo['bShare'] = true;
         }
         $calInfo['shareInfo'] = '';
         if ($calInfo['bShare'] === false) {
             $calInfo['shareInfoLink'] = false;
             if ($this->shareConnector->getItemSharedWithByLinkCalendar($calInfo['id'], $calInfo['userid'])) {
                 $calInfo['shareInfoLink'] = true;
             }
             $calInfo['shareInfo'] = CalendarCalendar::permissionReader($calInfo['permissions']);
         }
         $calInfo['download'] = \OC::$server->getURLGenerator()->linkToRoute($this->appName . '.export.exportEvents') . '?calid=' . $calInfo['id'];
         $calInfo['isActive'] = (int) $calInfo['active'];
         $calInfo['bRefresh'] = true;
         $calInfo['bAction'] = true;
         if ($calInfo['userid'] !== $this->userId) {
             $calInfo['isActive'] = (int) $calInfo['active'];
             if ($this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calInfo['id']) !== '') {
                 $calInfo['isActive'] = (int) $this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calInfo['id']);
             }
             $calInfo['bRefresh'] = false;
             $calInfo['bAction'] = false;
         }
         if ((bool) $calInfo['issubscribe'] === false) {
             $aCalendars['cal'][] = $calInfo;
         } else {
             $calInfo['birthday'] = false;
             if ($calInfo['id'] === 'bdaycpltocal_' . $this->userId) {
                 $calInfo['birthday'] = true;
             }
             $aCalendars['abo'][] = $calInfo;
         }
     }
     if ($this->configInfo->getUserValue($this->userId, $this->appName, 'userconfig')) {
         $userConfig = json_decode($this->configInfo->getUserValue($this->userId, $this->appName, 'userconfig'));
     } else {
         //Guest Config Public Page
         $userConfig = '{"agendaDay":"true","agendaThreeDays":"false","agendaWorkWeek":"false","agendaWeek":"true","month":"true","year":"false","list":"false"}';
         $userConfig = json_decode($userConfig);
     }
     if ($bActiveCalFound === false) {
         $activeCal = $aCalendars['cal'][0]['id'];
         $this->configInfo->setUserValue($this->userId, $this->appName, 'choosencalendar', $activeCal);
     }
     $params = ['calendars' => $aCalendars, 'activeCal' => $activeCal, 'shareType' => $this->shareConnector->getConstShareCalendar(), 'shareTypePrefix' => $this->shareConnector->getConstSharePrefixCalendar(), 'timezone' => $this->configInfo->getUserValue($this->userId, $this->appName, 'timezone', ''), 'timezones' => \DateTimeZone::listIdentifiers(), 'timeformat' => $this->configInfo->getUserValue($this->userId, $this->appName, 'timeformat', '24'), 'dateformat' => $this->configInfo->getUserValue($this->userId, $this->appName, 'dateformat', 'd-m-Y'), 'timezonedetection' => $this->configInfo->getUserValue($this->userId, $this->appName, 'timezonedetection'), 'firstday' => $this->configInfo->getUserValue($this->userId, $this->appName, 'firstday', 'mo'), 'userConfig' => $userConfig, 'appname' => $this->appName];
     $response = new TemplateResponse($this->appName, 'navigationleft', $params, '');
     return $response;
 }
Exemplo n.º 20
0
 /**
  * Deletes an existing calendar object.
  *
  * @param string $calendarId
  * @param string $objectUri
  * @return void
  */
 public function deleteCalendarObject($calendarId, $objectUri)
 {
     $calendar = CalendarCalendar::find($calendarId);
     $bAccess = true;
     if ($calendar['userid'] !== \OCP\User::getUser()) {
         $sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $calendarId);
         if (!$sharedCalendar || !($sharedCalendar['permissions'] & \OCP\PERMISSION_UPDATE)) {
             $bAccess = false;
             \OCP\Util::writeLog('calendarplus', 'CALDAV -> DELETE Permission denied! Calendar ' . $calendar['displayname'], \OCP\Util::DEBUG);
         }
     }
     if ($bAccess === true) {
         Object::deleteFromDAVData($calendarId, $objectUri);
     }
 }