Ejemplo n.º 1
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.º 2
0
 /**
  * @NoAdminRequired
  */
 public function touchCalendar()
 {
     $id = (int) $this->params('eventid');
     $data = CalendarApp::getEventObject($id, false, false);
     $vcalendar = VObject::parse($data['calendardata']);
     $vevent = $vcalendar->VEVENT;
     $vevent->setDateTime('LAST-MODIFIED', 'now');
     $vevent->setDateTime('DTSTAMP', 'now');
     Object::edit($id, $vcalendar->serialize());
     $params = ['status' => 'success'];
     $response = new JSONResponse($params);
     return $response;
 }
Ejemplo n.º 3
0
 /**
  * @NoAdminRequired
  */
 public function addSubscriberEvent()
 {
     $eventId = $this->params('eventId');
     $pEmails = $this->params('emails');
     $ExistAttendees = $this->params('attendees');
     $emails = array_map('trim', explode(",", $pEmails));
     if (is_array($ExistAttendees)) {
         $testEmailArray = array();
         foreach ($ExistAttendees as $val) {
             $testEmailArray[$val] = 1;
         }
     }
     $data = CalendarApp::getEventObject($eventId, false, false);
     $vcalendar = VObject::parse($data['calendardata']);
     $vevent = $vcalendar->VEVENT;
     $vevent->setDateTime('LAST-MODIFIED', 'now');
     $vevent->setDateTime('DTSTAMP', 'now');
     if (!$vevent->ORGANIZER) {
         $vevent->add('ORGANIZER', 'mailto:' . $this->configInfo->getUserValue($this->userId, 'settings', 'email'));
     }
     $sendEmails = array();
     foreach ($emails as $email) {
         if (!$testEmailArray[$email]) {
             $vevent->add('ATTENDEE', 'mailto:' . $email);
             $sendEmails[] = $email;
         }
     }
     Object::edit($eventId, $vcalendar->serialize());
     $summary = $data['summary'];
     $dtstart = $data['startdate'];
     $dtend = $data['enddate'];
     if (count($sendEmails) > 0) {
         CalendarApp::sendEmails($eventId, $summary, $dtstart, $dtend, $sendEmails);
         $msg = 'sent';
     } else {
         $msg = 'notsent';
     }
     $params = ['message' => $msg];
     $response = new JSONResponse();
     $response->setData($params);
     return $response;
 }