Exemplo n.º 1
0
 /**
  * @NoAdminRequired
  */
 public function deleteEvent()
 {
     $id = $this->params('id');
     Object::delete($id);
     $response = new JSONResponse();
     return $response;
 }
Exemplo n.º 2
0
 /**
  * Extracts all matching contacts with email address and name
  *
  * @param string $term
  * @return array
  */
 public function addBirthdays($userid, $calId)
 {
     if (!$this->contactsManager->isEnabled()) {
         return array();
     }
     $addrBooks = $this->contactsManager->getAddressBooks();
     $aContacts = array();
     foreach ($addrBooks as $key => $addrBook) {
         if (is_integer($key)) {
             $bContacts = \OCA\ContactsPlus\VCard::all($key);
             $aContacts = array_merge($aContacts, $bContacts);
         }
     }
     $sDateFormat = $this->configInfo->getUserValue($this->userId, $this->appName, 'dateformat', 'd-m-Y');
     if ($sDateFormat === 'd-m-Y') {
         $sDateFormat = 'd.m.Y';
     }
     $aResult = array();
     foreach ($aContacts as $contact) {
         $vcard = \Sabre\VObject\Reader::read($contact['carddata']);
         if (isset($vcard->BDAY)) {
             $Birthday = new \DateTime((string) $vcard->BDAY);
             $checkForm = $Birthday->format('d-m-Y');
             $temp = explode('-', $checkForm);
             $getAge = $this->getAge($temp[2], $temp[1], $temp[0]);
             $title = $contact['fullname'];
             $birthdayOutput = $Birthday->format($sDateFormat);
             $aktYear = $Birthday->format('d-m');
             $aktYear = $aktYear . date('-Y');
             $start = new \DateTime($aktYear);
             $end = new \DateTime($aktYear . ' +1 day');
             $vcalendar = new VObject('VCALENDAR');
             $vcalendar->add('PRODID', 'ownCloud Calendar');
             $vcalendar->add('VERSION', '2.0');
             $vevent = new VObject('VEVENT');
             $vcalendar->add($vevent);
             $vevent->setDateTime('CREATED', 'now');
             $vevent->add('DTSTART');
             $vevent->DTSTART->setDateTime($start);
             $vevent->add('DTEND');
             $vevent->DTEND->setDateTime($end);
             $vevent->DTSTART['VALUE'] = 'date';
             $vevent->DTEND['VALUE'] = 'date';
             $vevent->{'RRULE'} = 'FREQ=YEARLY;INTERVAL=1';
             $vevent->{'TRANSP'} = 'TRANSPARENT';
             $vevent->{'SUMMARY'} = (string) $title . ' (' . $getAge . ')';
             $description = (string) $this->l10n->t("Happy Birthday! Born on: ") . $birthdayOutput;
             $vevent->setString('DESCRIPTION', $description);
             $vevent->{'UID'} = substr(md5(rand() . time()), 0, 10);
             $insertid = Object::add($calId, $vcalendar->serialize());
             if ($this->isDuplicate($insertid)) {
                 Object::delete($insertid);
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * @NoAdminRequired
  */
 public function deleteTask()
 {
     $id = $this->params('id');
     $task = CalendarApp::getEventObject($id);
     //Search for Sub Tasks
     $subTaskIds = '';
     if ($task['relatedto'] === '') {
         $subTaskIds = TasksApp::getSubTasks($task['eventuid']);
         if ($subTaskIds !== '') {
             $tempIds = explode(',', $subTaskIds);
             foreach ($tempIds as $subIds) {
                 Object::delete($subIds);
             }
         }
     }
     Object::delete($id);
     $params = ['id' => $id];
     $response = new JSONResponse();
     $response->setData($params);
     return $response;
 }