Ejemplo n.º 1
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();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @NoAdminRequired
  */
 public function editCalendar()
 {
     $calendarid = (int) $this->params('id');
     $pName = (string) $this->params('name');
     $pActive = (int) $this->params('active');
     $pColor = (string) $this->params('color');
     if (trim($pName) === '') {
         $params = ['status' => 'error', 'message' => 'empty'];
         $response = new JSONResponse($params);
         return $response;
     }
     $calendars = CalendarCalendar::allCalendars($this->userId);
     foreach ($calendars as $cal) {
         if ($cal['userid'] !== $this->userId) {
             continue;
         }
         if ($cal['displayname'] === $pName && (int) $cal['id'] !== $calendarid) {
             $params = ['status' => 'error', 'message' => 'namenotavailable'];
             $response = new JSONResponse($params);
             return $response;
         }
     }
     try {
         CalendarCalendar::editCalendar($calendarid, strip_tags($pName), null, null, null, $pColor, null);
         CalendarCalendar::setCalendarActive($calendarid, $pActive);
     } catch (Exception $e) {
         $params = ['status' => 'error', 'message' => $e->getMessage()];
         $response = new JSONResponse($params);
         return $response;
     }
     $calendar = CalendarCalendar::find($calendarid);
     $isShareApiActive = \OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes');
     $shared = false;
     if ($calendar['userid'] !== $this->userId) {
         $sharedCalendar = $this->shareConnector->getItemSharedWithBySourceCalendar($calendarid);
         if ($sharedCalendar && $sharedCalendar['permissions'] & $this->shareConnector->getUpdateAccess()) {
             $shared = true;
         }
     }
     $params = ['status' => 'success', 'eventSource' => CalendarCalendar::getEventSourceInfo($calendar), 'calid' => $calendarid];
     $response = new JSONResponse($params);
     return $response;
 }
Ejemplo n.º 3
0
 /**
  * @NoAdminRequired
  */
 public function editCalendar()
 {
     $calendarid = (int) $this->params('id');
     $pName = (string) $this->params('name');
     $pActive = (int) $this->params('active');
     $pColor = (string) $this->params('color');
     if (trim($pName) === '') {
         $params = ['status' => 'error', 'message' => 'empty'];
         $response = new JSONResponse($params);
         return $response;
     }
     $calendars = CalendarCalendar::allCalendars($this->userId);
     foreach ($calendars as $cal) {
         if ($cal['userid'] !== $this->userId) {
             continue;
         }
         if ($cal['displayname'] === $pName && (int) $cal['id'] !== $calendarid) {
             $params = ['status' => 'error', 'message' => 'namenotavailable'];
             $response = new JSONResponse($params);
             return $response;
         }
     }
     try {
         CalendarCalendar::editCalendar($calendarid, strip_tags($pName), null, null, null, $pColor, null);
         CalendarCalendar::setCalendarActive($calendarid, $pActive);
     } catch (Exception $e) {
         $params = ['status' => 'error', 'message' => $e->getMessage()];
         $response = new JSONResponse($params);
         return $response;
     }
     $calendar = CalendarCalendar::find($calendarid);
     $isShareApiActive = \OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes');
     $shared = false;
     if ($calendar['userid'] !== $this->userId) {
         $sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $calendarid);
         if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_UPDATE) {
             $shared = true;
         }
     }
     $paramsList = ['calendar' => $calendar, 'shared' => $shared, 'appname' => $this->appName, 'isShareApi' => $isShareApiActive];
     $calendarRow = new TemplateResponse($this->appName, 'part.choosecalendar.rowfields', $paramsList, '');
     $params = ['status' => 'success', 'eventSource' => CalendarCalendar::getEventSourceInfo($calendar), 'calid' => $calendarid, 'countEvents' => false, 'page' => $calendarRow->render()];
     $response = new JSONResponse($params);
     return $response;
 }
Ejemplo n.º 4
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;
     }
 }
Ejemplo n.º 5
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;
         }
     }
 }
Ejemplo n.º 6
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;
     }
 }
Ejemplo n.º 7
0
 public function getCalendarPermissions()
 {
     $this->iCalPermissions = Calendar::find($this->iCalId);
 }
Ejemplo n.º 8
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;
 }
Ejemplo n.º 9
0
 /**
  * @NoAdminRequired
  */
 public function getEditFormEvent()
 {
     $id = $this->params('id');
     $choosenDate = $this->params('choosendate');
     $data = CalendarApp::getEventObject($id, false, false);
     $editInfo = $this->getVobjectData($id, $choosenDate, $data);
     if ($editInfo['permissions'] !== $this->shareConnector->getAllAccess()) {
         $aCalendar = CalendarCalendar::find($data['calendarid']);
         $calendar_options[0]['id'] = $data['calendarid'];
         $calendar_options[0]['permissions'] = $editInfo['permissions'];
         $calendar_options[0]['displayname'] = $aCalendar['displayname'];
         $calendar_options[0]['calendarcolor'] = $aCalendar['calendarcolor'];
     } else {
         $calendarsAll = CalendarCalendar::allCalendars($this->userId);
         $calendar_options = array();
         foreach ($calendarsAll as $calendar) {
             $isAktiv = (int) $calendar['active'];
             if ($this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calendar['id']) !== '') {
                 $isAktiv = (int) $this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calendar['id']);
             }
             if (!array_key_exists('active', $calendar)) {
                 $isAktiv = 1;
             }
             if ((int) $isAktiv === 1) {
                 $calendar_options[] = $calendar;
             }
         }
     }
     $category_options = CalendarApp::getCategoryOptions();
     $access_class_options = CalendarApp::getAccessClassOptions();
     $repeat_options = CalendarApp::getRepeatOptions();
     $repeat_end_options = CalendarApp::getEndOptions();
     $repeat_month_options = CalendarApp::getMonthOptions();
     $repeat_year_options = CalendarApp::getYearOptions();
     $repeat_weekly_options = CalendarApp::getWeeklyOptions();
     $repeat_weekofmonth_options = CalendarApp::getWeekofMonth();
     $repeat_byyearday_options = CalendarApp::getByYearDayOptions();
     $repeat_bymonth_options = CalendarApp::getByMonthOptions();
     $repeat_byweekno_options = CalendarApp::getByWeekNoOptions();
     $repeat_bymonthday_options = CalendarApp::getByMonthDayOptions();
     //NEW
     $repeat_weeklyshort_options = CalendarApp::getWeeklyOptionsShort();
     $repeat_advancedoptions = CalendarApp::getAdvancedRepeatOptions();
     $repeat_monthshort_options = CalendarApp::getByMonthShortOptions();
     //NEW Reminder
     $reminder_advanced_options = CalendarApp::getAdvancedReminderOptions();
     $reminder_time_options = CalendarApp::getReminderTimeOptions();
     $start = new \DateTime($editInfo['dtstart'], new \DateTimeZone('UTC'));
     $tWeekDay = Object::getWeeklyOptionsCheck($start->format('D'));
     $transWeekDay[$tWeekDay] = $tWeekDay;
     if ((string) $editInfo['rrule']['repeat'] !== 'doesnotrepeat') {
         $paramsRepeat = ['logicCheckWeekDay' => $tWeekDay, 'rRadio0' => isset($editInfo['rrule']['rRadio0']) ? $editInfo['rrule']['rRadio0'] : 'checked="checked"', 'rClass0' => isset($editInfo['rrule']['rClass0']) ? $editInfo['rrule']['rClass0'] : '', 'rRadio1' => isset($editInfo['rrule']['rRadio1']) ? $editInfo['rrule']['rRadio1'] : '', 'rClass1' => isset($editInfo['rrule']['rClass1']) ? $editInfo['rrule']['rClass1'] : 'class="ui-isDisabled"', 'checkedMonth' => isset($editInfo['rrule']['checkedMonth']) ? $editInfo['rrule']['checkedMonth'] : '', 'bdayClass' => isset($editInfo['rrule']['bdayClass']) ? $editInfo['rrule']['bdayClass'] : 'class="ui-isDisabled"', 'repeat_rules' => isset($editInfo['rrule']['repeat_rules']) ? $editInfo['rrule']['repeat_rules'] : '', 'advancedrepeat' => isset($editInfo['rrule']['rAdvanced']) ? $editInfo['rrule']['rAdvanced'] : 'DAILY', 'repeat_weekdaysSingle' => $transWeekDay, 'repeat_weekdays' => isset($editInfo['rrule']['weekdays']) ? $editInfo['rrule']['weekdays'] : array(), 'repeat_bymonthday' => isset($editInfo['rrule']['bymonthday']) ? $editInfo['rrule']['bymonthday'] : array(), 'repeat_bymonth' => isset($editInfo['rrule']['bymonth']) ? $editInfo['rrule']['bymonth'] : array(), 'repeat_weekofmonth' => isset($editInfo['rrule']['weekofmonth']) ? $editInfo['rrule']['weekofmonth'] : '1', 'repeat_interval' => isset($editInfo['rrule']['interval']) ? $editInfo['rrule']['interval'] : '1', 'repeat_end' => isset($editInfo['rrule']['end']) ? $editInfo['rrule']['end'] : 'never', 'repeat_count' => isset($editInfo['rrule']['count']) ? $editInfo['rrule']['count'] : '10', 'repeat_date' => isset($editInfo['rrule']['date']) ? $editInfo['rrule']['date'] : ''];
     } else {
         $tDayOfMonth[$start->format('j')] = $start->format('j');
         $tMonth[$start->format('n')] = $start->format('n');
         $first_of_month = $start->format('Y-m-1');
         $day_of_first = date('N', $start->format('U'));
         $day_of_month = $start->format('j');
         $weekNum = floor(($day_of_first + $day_of_month - 1) / 7) + 1;
         if ($weekNum >= 1 && $weekNum <= 4) {
             $weekNum = '+' . $weekNum;
         } else {
             $weekNum = '-1';
         }
         $paramsRepeat = ['logicCheckWeekDay' => $tWeekDay, 'rRadio0' => 'checked="checked"', 'rClass0' => '', 'rRadio1' => '', 'rClass1' => 'class="ui-isDisabled"', 'checkedMonth' => '', 'bdayClass' => 'class="ui-isDisabled"', 'repeat_rules' => '', 'advancedrepeat' => 'DAILY', 'repeat_weekdaysSingle' => $transWeekDay, 'repeat_weekdays' => $transWeekDay, 'repeat_bymonthday' => $tDayOfMonth, 'repeat_bymonth' => $tMonth, 'repeat_weekofmonth' => $weekNum, 'repeat_interval' => 1, 'repeat_end' => 'never', 'repeat_count' => '10', 'repeat_date' => ''];
     }
     $params = ['eventid' => $id, 'appname' => $this->appName, 'permissions' => $editInfo['permissions'], 'lastmodified' => $editInfo['lastmodified'], 'calendar_options' => $calendar_options, 'access_class_options' => $access_class_options, 'repeat_options' => $repeat_options, 'repeat_month_options' => $repeat_month_options, 'repeat_weekly_options' => $repeat_weekly_options, 'repeat_end_options' => $repeat_end_options, 'repeat_year_options' => $repeat_year_options, 'repeat_byyearday_options' => $repeat_byyearday_options, 'repeat_bymonth_options' => $repeat_bymonth_options, 'repeat_byweekno_options' => $repeat_byweekno_options, 'repeat_bymonthday_options' => $repeat_bymonthday_options, 'repeat_weekofmonth_options' => $repeat_weekofmonth_options, 'repeat_advancedoptions' => $repeat_advancedoptions, 'repeat_weeklyshort_options' => $repeat_weeklyshort_options, 'repeat_monthshort_options' => $repeat_monthshort_options, 'reminder_options' => $editInfo['reminder_options'], 'reminder_advanced_options' => $reminder_advanced_options, 'reminder_time_options' => $reminder_time_options, 'reminder_advanced' => 'DISPLAY', 'reminder_rules' => array_key_exists('triggerRequest', $editInfo['alarm']) ? $editInfo['alarm']['triggerRequest'] : '', 'reminder' => $editInfo['alarm']['action'], 'remindertimeselect' => array_key_exists('reminder_time_select', $editInfo['alarm']) ? $editInfo['alarm']['reminder_time_select'] : '', 'remindertimeinput' => array_key_exists('reminder_time_input', $editInfo['alarm']) ? $editInfo['alarm']['reminder_time_input'] : '', 'reminderemailinput' => array_key_exists('email', $editInfo['alarm']) ? $editInfo['alarm']['email'] : '', 'reminderdate' => array_key_exists('reminderdate', $editInfo['alarm']) ? $editInfo['alarm']['reminderdate'] : '', 'remindertime' => array_key_exists('remindertime', $editInfo['alarm']) ? $editInfo['alarm']['remindertime'] : '', 'title' => $editInfo['summary'], 'accessclass' => $editInfo['accessclass'], 'location' => $editInfo['location'], 'categories' => $editInfo['categories'], 'calendar' => $data['calendarid'], 'allday' => $editInfo['allday'], 'startdate' => $editInfo['startdate'], 'starttime' => $editInfo['starttime'], 'enddate' => $editInfo['enddate'], 'endtime' => $editInfo['endtime'], 'description' => $editInfo['description'], 'link' => $editInfo['link'], 'addSingleDeleteButton' => $editInfo['addSingleDeleteButton'], 'choosendate' => $choosenDate, 'isShareApi' => $this->appConfig->getValue('core', 'shareapi_enabled', 'yes'), 'repeat' => $editInfo['rrule']['repeat'], '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'), 'sharetypeevent' => $this->shareConnector->getConstShareEvent(), 'sharetypeeventprefix' => $this->shareConnector->getConstSharePrefixEvent()];
     $params = array_merge($params, $paramsRepeat);
     if ($editInfo['permissions'] & $this->shareConnector->getUpdateAccess()) {
         $response = new TemplateResponse($this->appName, 'part.editevent', $params, '');
     } elseif ($editInfo['permissions'] & $this->shareConnector->getReadAccess()) {
         //$response = new TemplateResponse('calendar', 'part.showevent',$params, '');
     }
     return $response;
 }
Ejemplo n.º 10
0
 /**
  * @NoAdminRequired
  */
 public function editTask()
 {
     //relatedto,hiddenfield, read_worker,$_POST,mytaskcal, mytaskmode
     $id = $this->params('tid');
     $hiddenPostField = $this->params('hiddenfield');
     $myTaskCal = $this->params('mytaskcal');
     $myTaskMode = $this->params('mytaskmode');
     $data = TasksApp::getEventObject($id, false, false);
     $object = VObject::parse($data['calendardata']);
     $calId = Object::getCalendarid($id);
     $orgId = $data['org_objid'];
     //Search for Main Task
     $mainTaskId = '';
     if ($data['relatedto'] !== '') {
         $mainTaskId = TasksApp::getEventIdbyUID($data['relatedto']);
     }
     //Search for Sub Tasks
     $subTaskIds = '';
     if ($data['relatedto'] === '') {
         $subTaskIds = TasksApp::getSubTasks($data['eventuid']);
     }
     if (isset($hiddenPostField) && $hiddenPostField === 'edititTask' && $id > 0) {
         $cid = $this->params('read_worker');
         $postRequestAll = $this->getParams();
         TasksApp::updateVCalendarFromRequest($postRequestAll, $object);
         TasksApp::edit($id, $object->serialize(), $orgId);
         if ($mainTaskId === '') {
             $mainTaskId = $id;
         }
         if ($calId !== intval($cid)) {
             Object::moveToCalendar($id, intval($cid));
             if ($subTaskIds !== '') {
                 $tempIds = explode(',', $subTaskIds);
                 foreach ($tempIds as $subIds) {
                     Object::moveToCalendar($subIds, intval($cid));
                 }
             }
         }
         $vcalendar1 = TasksApp::getVCalendar($id, true, true);
         $vtodo = $vcalendar1->VTODO;
         $aTask = TasksApp::getEventObject($id, true, true);
         $aCalendar = CalendarCalendar::find($aTask['calendarid']);
         $user_timezone = CalendarApp::getTimezone();
         $task_info = TasksApp::arrayForJSON($id, $vtodo, $user_timezone, $aCalendar, $aTask);
         $task_info['olduid'] = $data['eventuid'];
         $task_info['oldcalendarid'] = $data['calendarid'];
         $response = new JSONResponse();
         $response->setData($task_info);
         return $response;
     }
     $vtodo = $object->VTODO;
     $object = Object::cleanByAccessClass($id, $object);
     $accessclass = $vtodo->getAsString('CLASS');
     if (empty($accessclass)) {
         $accessclass = 'PUBLIC';
     }
     $permissions = TasksApp::getPermissions($id, TasksApp::TODO, $accessclass);
     $link = strtr($vtodo->getAsString('URL'), array('\\,' => ',', '\\;' => ';'));
     $TaskDate = '';
     $TaskTime = '';
     if ($vtodo->DUE) {
         $dateDueType = $vtodo->DUE->getValueType();
         if ($dateDueType === 'DATE') {
             $TaskDate = $vtodo->DUE->getDateTime()->format('d.m.Y');
             $TaskTime = '';
         }
         if ($dateDueType === 'DATE-TIME') {
             $TaskDate = $vtodo->DUE->getDateTime()->format('d.m.Y');
             $TaskTime = $vtodo->DUE->getDateTime()->format('H:i');
         }
     }
     $TaskStartDate = '';
     $TaskStartTime = '';
     if ($vtodo->DTSTART) {
         $dateStartType = $vtodo->DTSTART->getValueType();
         if ($dateStartType === 'DATE') {
             $TaskStartDate = $vtodo->DTSTART->getDateTime()->format('d.m.Y');
             $TaskStartTime = '';
         }
         if ($dateStartType === 'DATE-TIME') {
             $TaskStartDate = $vtodo->DTSTART->getDateTime()->format('d.m.Y');
             $TaskStartTime = $vtodo->DTSTART->getDateTime()->format('H:i');
         }
     }
     $priority = $vtodo->getAsString('PRIORITY');
     $calendarsArrayTmp = CalendarCalendar::allCalendars($this->userId, true);
     //Filter Importent Values
     $calendar_options = array();
     $checkArray = array();
     $checkShareArray = array();
     $bShareCalId = '';
     foreach ($calendarsArrayTmp as $calendar) {
         $isAktiv = $calendar['active'];
         if ($this->configInfo->getUserValue($this->userId, CalendarApp::$appname, 'calendar_' . $calendar['id']) != '') {
             $isAktiv = $this->configInfo->getUserValue($this->userId, CalendarApp::$appname, 'calendar_' . $calendar['id']);
         }
         if (!array_key_exists('active', $calendar)) {
             $isAktiv = 1;
         }
         if ((int) $isAktiv === 1 && $calendar['userid'] !== $this->userId || $mainTaskId !== '') {
             $sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $calendar['id']);
             if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_UPDATE && $mainTaskId === '') {
                 array_push($calendar_options, $calendar);
                 $checkShareArray[$calendar['id']] = $sharedCalendar['permissions'];
             }
         }
         if ($isAktiv === 1 && $calendar['userid'] === $this->userId) {
             array_push($calendar_options, $calendar);
             $checkShareArray[$calendar['id']] = \OCP\PERMISSION_ALL;
         }
     }
     if (!array_key_exists($calId, $checkShareArray)) {
         $bShareCalId = 'hide';
     }
     $priorityOptionsArray = TasksApp::getPriorityOptionsFilterd();
     $priorityOptions = TasksApp::generateSelectFieldArray('priority', (string) $vtodo->priority, $priorityOptionsArray, false);
     $access_class_options = CalendarApp::getAccessClassOptions();
     //NEW Reminder
     $reminder_options = CalendarApp::getReminderOptions();
     $reminder_advanced_options = CalendarApp::getAdvancedReminderOptions();
     $reminder_time_options = CalendarApp::getReminderTimeOptions();
     //reminder
     $vtodosharees = array();
     $sharedwithByVtodo = \OCP\Share::getItemShared(CalendarApp::SHARETODO, CalendarApp::SHARETODOPREFIX . $id);
     if (is_array($sharedwithByVtodo)) {
         foreach ($sharedwithByVtodo as $share) {
             if ($share['share_type'] == \OCP\Share::SHARE_TYPE_USER || $share['share_type'] == \OCP\Share::SHARE_TYPE_GROUP) {
                 $vtodosharees[] = $share;
             }
         }
     }
     $percentCompleted = '0';
     if ($vtodo->{'PERCENT-COMPLETE'}) {
         $percentCompleted = $vtodo->getAsString('PERCENT-COMPLETE');
     }
     $aAlarm = $this->setAlarmTask($vtodo, $reminder_options);
     $params = ['id' => $id, 'calId' => $calId, 'orgId' => $orgId, 'permissions' => $permissions, 'priorityOptions' => $priorityOptions, 'access_class_options' => $access_class_options, 'calendar_options' => $calendar_options, 'calendar' => $calId, 'mymode' => $myTaskMode, 'mycal' => $myTaskCal, 'bShareCalId' => $bShareCalId, 'subtaskids' => $subTaskIds, 'cal_permissions' => $checkShareArray, 'accessclass' => $accessclass, 'reminder_options' => $reminder_options, 'reminder_rules' => array_key_exists('triggerRequest', $aAlarm) ? $aAlarm['triggerRequest'] : '', 'reminder' => $aAlarm['action'], 'reminder_time_options' => $reminder_time_options, 'reminder_advanced_options' => $reminder_advanced_options, 'reminder_advanced' => 'DISPLAY', 'remindertimeselect' => array_key_exists('reminder_time_select', $aAlarm) ? $aAlarm['reminder_time_select'] : '', 'remindertimeinput' => array_key_exists('reminder_time_input', $aAlarm) ? $aAlarm['reminder_time_input'] : '', 'reminderemailinput' => array_key_exists('email', $aAlarm) ? $aAlarm['email'] : '', 'reminderdate' => array_key_exists('reminderdate', $aAlarm) ? $aAlarm['reminderdate'] : '', 'remindertime' => array_key_exists('remindertime', $aAlarm) ? $aAlarm['remindertime'] : '', 'link' => $link, 'priority' => $priority, 'TaskDate' => $TaskDate, 'TaskTime' => $TaskTime, 'TaskStartDate' => $TaskStartDate, 'TaskStartTime' => $TaskStartTime, 'vtodosharees' => $vtodosharees, 'percentCompleted' => $percentCompleted, 'sharetodo' => CalendarApp::SHARETODO, 'sharetodoprefix' => CalendarApp::SHARETODOPREFIX, 'vtodo' => $vtodo];
     $response = new TemplateResponse($this->appName, 'event.edit', $params, '');
     return $response;
 }
Ejemplo n.º 11
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;
 }
Ejemplo n.º 12
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;
 }
Ejemplo n.º 13
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);
     }
 }