Ejemplo n.º 1
0
 public function updateCollectionACL(&$uri, &$params, &$criteria, $original)
 {
     if (Config::module('useCaldav', 'expressoCalendar')) {
         $permision = Controller::read(array('concept' => 'calendarToPermission', 'id' => $params['id']));
         $calendar = Controller::read(array('concept' => 'calendar', 'id' => $permision['calendar']));
         if ($permision['user'] !== '0') {
             $user = Controller::read(array('concept' => 'user', 'id' => $permision['user']));
             $xmUser = '******' . Config::service('CalDAV', 'url') . '/' . $user['uid'] . '/</D:href>';
         } else {
             $xmUser = '******';
         }
         $xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n               <D:acl xmlns:D=\"DAV:\">\n             <D:ace>\n               <D:principal>\n                " . $xmUser . "\n               </D:principal>\n               <D:grant>\n                " . self::acltToXML($params['acl']) . "\n               </D:grant>\n             </D:ace>\n            </D:acl>";
         ob_start();
         require_once ROOTPATH . '/plugins/davicalCliente/caldav-client-v2.php';
         $cal = new CalDAVClient(Config::service('CalDAV', 'url') . '/' . $calendar['location'] . '/', Config::me('uid'), Config::me('password'));
         $cal->DoXMLRequest('ACL', $xml);
         self::setReadCurrentUserPrivilege(Config::service('CalDAV', 'url') . '/' . substr($calendar['location'], 0, strpos($calendar['location'], '/') + 1));
         ob_end_clean();
     }
 }
Ejemplo n.º 2
0
 public function analize($data, $params = false)
 {
     $vcalendar = new icalCreatorVcalendar();
     $vcalendar->parse(trim($data));
     $vcalendar->sort();
     $return = array();
     $method = $vcalendar->getProperty('method', FALSE, FALSE);
     while ($component = $vcalendar->getComponent()) {
         $interation = array();
         $uid = $component->getProperty('uid', false, false);
         //Resgata o uid do componente
         switch (strtoupper($component->objName)) {
             case 'VEVENT':
                 switch ($method) {
                     case 'PUBLISH':
                         $interation = array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds');
                         break;
                     case 'REQUEST':
                         $schedulable = self::_getSchedulable($uid);
                         if ($schedulable) {
                             //Caso o evento exista
                             $isOrganizer = false;
                             $isParticipant = false;
                             foreach ($schedulable['participants'] as $value) {
                                 if ($value['user']['id'] == $params['owner']) {
                                     $isParticipant = true;
                                     if ($value['isOrganizer']) {
                                         $isOrganizer = true;
                                     }
                                     if (!self::_existInMyCalendars($schedulable['id'], $params['owner']) || $value['status'] == STATUS_UNANSWERED || $value['status'] == STATUS_DECLINED) {
                                         $interation = ICAL_ACTION_UPDATE;
                                         $interation = strrpos($value['acl'], ATTENDEE_ACL_PARTICIPATION_REQUIRED) ? ICAL_ACTION_IMPORT_REQUIRED : array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds');
                                         break;
                                     } else {
                                         if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) {
                                             //Organizador esta requisitando que você atualize o evento
                                             $interation = $isOrganizer ? ICAL_ACTION_ORGANIZER_UPDATE : ICAL_ACTION_UPDATE;
                                         } else {
                                             $interation = $isOrganizer ? ICAL_ACTION_ORGANIZER_NONE : ICAL_ACTION_NONE;
                                         }
                                     }
                                 }
                             }
                             if (!$isParticipant) {
                                 if (self::_existInMyCalendars($schedulable['id'], $params['owner'])) {
                                     $interation = self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] ? ICAL_ACTION_UPDATE : ICAL_ACTION_NONE;
                                 } else {
                                     $interation = self::_checkParticipantByPermissions($schedulable);
                                 }
                             }
                         } else {
                             $interation = array('action' => ICAL_ACTION_IMPORT_REQUIRED, 'type' => 'calendarIds');
                         }
                         if ($interation != ICAL_ACTION_NONE && $interation != ICAL_ACTION_ORGANIZER_NONE && $interation != ICAL_ACTION_ORGANIZER_UPDATE && $interation != ICAL_ACTION_NONE && $interation != ICAL_ACTION_UPDATE && !is_array($interation)) {
                             if ($params['owner'] != Config::me("uidNumber")) {
                                 $sig = Controller::find(array('concept' => 'calendarSignature'), array('calendar'), array('filter' => array('AND', array('=', 'user', $params['owner']), array('=', 'isOwner', '1'))));
                                 $calendars = array();
                                 foreach ($sig as $val) {
                                     $calendars[] = $val['calendar'];
                                 }
                                 $calendarsPermission = Controller::find(array('concept' => 'calendarToPermission'), array('calendar'), array('filter' => array('AND', array('=', 'user', Config::me("uidNumber")), array('IN', 'calendar', $calendars))));
                                 foreach ($calendarsPermission as $val) {
                                     $ids[] = $val['calendar'];
                                 }
                                 $interation = array('action' => ICAL_ACTION_IMPORT_FROM_PERMISSION, 'calendar' => $ids);
                             }
                         }
                         break;
                     case 'REFRESH':
                         break;
                     case 'CANCEL':
                         $interation = ICAL_ACTION_DELETE;
                         break;
                     case 'ADD':
                         break;
                     case 'REPLY':
                         if ($schedulable = self::_getSchedulable($uid)) {
                             while ($property = $component->getProperty('attendee', FALSE, TRUE)) {
                                 if ($attendee = self::_getParticipantByMail(str_replace('MAILTO:', '', $property['value']), $schedulable['participants'], true)) {
                                     $interation = constant('STATUS_' . strtoupper($property['params']['PARTSTAT'])) == $attendee['status'] ? ICAL_ACTION_NONE : ICAL_ACTION_REPLY;
                                 }
                             }
                         } else {
                             $interation = ICAL_NOT_FOUND;
                         }
                         break;
                     case 'COUNTER':
                         $interation = ICAL_ACTION_SUGGESTION;
                         break;
                     case 'DECLINECOUNTER':
                         $interation = ICAL_ACTION_NONE;
                         break;
                     default:
                         $schedulable = self::_getSchedulable($uid);
                         if ($schedulable && (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence'])) {
                             //Caso o evento exista
                             $interation = ICAL_ACTION_UPDATE;
                         } else {
                             if ($schedulable) {
                                 $interation = ICAL_ACTION_NONE;
                             } else {
                                 // Importar evento
                                 $interation = array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds');
                             }
                         }
                         break;
                 }
                 $return[$uid] = $interation;
                 break;
             case 'VTODO':
                 switch ($method) {
                     case 'PUBLISH':
                         $interation = array('action' => ICAL_ACTION_IMPORT, 'type' => 'groupIds');
                         break;
                     case 'REQUEST':
                         $schedulable = self::_getSchedulable($uid);
                         if ($schedulable) {
                             //Caso o evento exista
                             $isOrganizer = false;
                             $isParticipant = false;
                             foreach ($schedulable['participants'] as $value) {
                                 if ($value['user']['id'] == $params['owner']) {
                                     $isParticipant = true;
                                     if ($value['isOrganizer']) {
                                         $isOrganizer = true;
                                     }
                                     if (!self::_existInMyCalendars($schedulable['id'], $params['owner'])) {
                                         $interation = array('action' => ICAL_ACTION_IMPORT, 'type' => 'groupIds');
                                         break;
                                     }
                                 } else {
                                     ///Atualiza o Caldadav mesmo que o expresso não prescisse de atualização, pois os calendarios do caldav são independentes um de cada usuario diferente do expresso que so tem 1 evento e é compartilhado entre os usuarios
                                     if (Config::module('useCaldav', 'expressoCalendar')) {
                                         //Ignorar Put dos eventos ja vindos do caldav
                                         require_once ROOTPATH . '/modules/calendar/interceptors/DAViCalAdapter.php';
                                         $calendars = self::schedulable2calendarToObject($schedulable['id'], isset($params['owner']) ? $params['owner'] : false);
                                         //Busca os calendarios do usuario logado que contenham o evento
                                         if (is_array($calendars)) {
                                             foreach ($calendars as $calendar) {
                                                 DAViCalAdapter::putIcal($data, array('uid' => $schedulable['uid'], 'location' => $calendar['calendar_location']));
                                             }
                                         }
                                     }
                                     if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) {
                                         //Organizador esta requisitando que você atualize o evento
                                         $interation = $isOrganizer ? ICAL_ACTION_ORGANIZER_UPDATE : ICAL_ACTION_UPDATE;
                                     } else {
                                         $interation = $isOrganizer ? ICAL_ACTION_ORGANIZER_NONE : ICAL_ACTION_NONE;
                                     }
                                 }
                             }
                             if (!$isParticipant) {
                                 $interation = self::_checkParticipantByPermissions($schedulable);
                             }
                         } else {
                             $interation = array('action' => ICAL_ACTION_IMPORT, 'type' => 'groupIds');
                         }
                         break;
                     case 'REFRESH':
                         break;
                     case 'CANCEL':
                         $interation = ICAL_ACTION_DELETE;
                         break;
                     case 'ADD':
                         break;
                     case 'REPLY':
                         $interation = ICAL_ACTION_REPLY;
                         break;
                     case 'COUNTER':
                         $interation = ICAL_ACTION_SUGGESTION;
                         break;
                     case 'DECLINECOUNTER':
                         $interation = ICAL_ACTION_NONE;
                         break;
                     default:
                         $schedulable = self::_getSchedulable($uid);
                         if ($schedulable && (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence'])) {
                             //Caso o evento exista
                             $interation = ICAL_ACTION_UPDATE;
                         } else {
                             if ($schedulable) {
                                 $interation = ICAL_ACTION_NONE;
                             } else {
                                 // Importar evento
                                 $interation = array('action' => ICAL_ACTION_IMPORT, 'type' => 'groupIds');
                             }
                         }
                         break;
                 }
                 $return[$uid] = $interation;
                 break;
             case 'VTIMEZONE':
                 break;
         }
     }
     return $return;
 }
Ejemplo n.º 3
0
 public function davcalUpdateCollection(&$uri, &$params, &$criteria, $original)
 {
     if (Config::module('useCaldav', 'expressoCalendar')) {
         require_once ROOTPATH . '/modules/calendar/interceptors/DAViCalAdapter.php';
         if (isset($params['location'])) {
             $calendar = Controller::read($uri);
             if ($calendar['location'] !== $params['location']) {
                 DAViCalAdapter::mvcalendar($calendar['location'], $params['location']);
             }
         }
     }
 }