/** * @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; }
/** * @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; }