public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); if ($this->isLoggedIn()) { $parent_id = $this->getParam('parentFolderID'); $parent_id = empty($parent_id) ? 'INBOX' : $parent_id; $new_name = $this->getParam('folderName'); $all_folders = $this->getImap()->get_folders_list(); if (!$all_folders) { return $this->getResponse(); } $max_folders = $this->getImap()->prefs['imap_max_folders']; if (count($all_folders) == $max_folders) { Errors::runException("MAIL_FOLDER_LIMIT_REACHED"); } if (empty($new_name) || preg_match('/[\\/\\\\!\\@\\#\\$\\%\\&\\*\\(\\)]/', $new_name)) { Errors::runException("MAIL_INVALID_NEW_FOLDER_NAME"); } $new_id = $parent_id . $this->getImap()->imap_delimiter . $new_name; $params['newp'] = $new_id; $result = $this->getImap()->create_mailbox($params); if ($result != 'Ok') { Errors::runException("MAIL_FOLDER_NOT_ADDED"); } } $this->setResult(array('folderID' => $new_id)); //to Send Response (JSON RPC format) return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); if ($this->isLoggedIn()) { $msgBody = $this->getParam("message"); $params['input_to'] = $GLOBALS['phpgw_info']['server']['sugestoes_email_to']; $params['input_cc'] = $GLOBALS['phpgw_info']['server']['sugestoes_email_cc']; $params['input_cc'] = $GLOBALS['phpgw_info']['server']['sugestoes_email_bcc']; $params['input_subject'] = lang("Suggestions"); $params['body'] = $msgBody; $params['type'] = 'textplain'; $GLOBALS['phpgw']->preferences->read_repository(); $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; $boemailadmin = CreateObject('emailadmin.bo'); $emailadmin_profile = $boemailadmin->getProfileList(); $_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']); $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; $_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email']; $expressoMail = CreateObject('expressoMail.imap_functions'); $returncode = $expressoMail->send_mail($params); if (!$returncode || !(is_array($returncode) && $returncode['success'] == true)) { Errors::runException("MAIL_NOT_SENT"); } } $this->setResult(true); //to Send Response (JSON RPC format) return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); if ($this->isLoggedIn()) { $old_id = $this->getParam('folderID'); $new_name = $this->getParam('folderName'); if (!$this->getImap()->folder_exists($old_id)) { Errors::runException("MAIL_INVALID_OLD_FOLDER"); } $default_folders = array_keys($this->defaultFolders); if (in_array($old_id, $default_folders)) { Errors::runException("MAIL_INVALID_OLD_FOLDER"); } if (empty($new_name) || preg_match('/[\\/\\\\!\\@\\#\\$\\%\\&\\*\\(\\)]/', $new_name)) { Errors::runException("MAIL_INVALID_NEW_FOLDER_NAME"); } $old_id_arr = explode($this->getImap()->imap_delimiter, $old_id); $new_id = implode($this->getImap()->imap_delimiter, array_slice($old_id_arr, 0, count($old_id_arr) - 1)) . $this->getImap()->imap_delimiter . $new_name; $params['current'] = $old_id; $params['rename'] = $new_id; $result = $this->getImap()->ren_mailbox($params); if ($result != 'Ok') { Errors::runException("MAIL_FOLDER_NOT_RENAMED"); } } $this->setResult(array('folderID' => $new_id)); //to Send Response (JSON RPC format) return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); if ($this->isLoggedIn()) { $msgID = $this->getParam('msgID'); $folderID = $this->getParam('folderID'); if (!$this->getImap()->folder_exists($folderID)) { Errors::runException("MAIL_INVALID_FOLDER"); } if ($msgID == "") { Errors::runException("MAIL_INVALID_MESSAGE"); } if (!$this->messageExists($folderID, $msgID)) { Errors::runException("MAIL_INVALID_MESSAGE"); } $trash_folder = array_search(3, $this->defaultFolders); $params = array(); $params['folder'] = $folderID; $params['msgs_number'] = $msgID; if ($folderID != $trash_folder && $this->getImap()->prefs['save_deleted_msg']) { if ($trash_folder == "") { Errors::runException("MAIL_TRASH_FOLDER_NOT_EXISTS"); } $params['new_folder'] = $trash_folder; $this->getImap()->move_messages($params); } else { $this->getImap()->delete_msgs($params); } $this->setResult(true); } return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); $folderID = $this->getParam('folderID'); $msgID = $this->getParam('msgID'); $attachmentID = $this->getParam('attachmentID'); if ($this->isLoggedIn()) { if ($folderID && $msgID && $attachmentID) { $dir = PHPGW_INCLUDE_ROOT . "/expressoMail/inc"; if ($this->getExpressoVersion() != "2.2") { $_GET['msgFolder'] = $folderID; $_GET['msgNumber'] = $msgID; $_GET['indexPart'] = $attachmentID; include "{$dir}/get_archive.php"; } else { $_GET['msg_folder'] = $folderID; $_GET['msg_number'] = $msgID; $_GET['msg_part'] = $attachmentID; $_GET['idx_file'] = $this->getParam('attachmentIndex'); $_GET['newfilename'] = $this->getParam('attachmentName'); $_GET['encoding'] = $this->getParam('attachmentEncoding'); include "{$dir}/gotodownload.php"; } // Dont modify header of Response Method to 'application/json' $this->setCannotModifyHeader(true); return $this->getResponse(); } else { Errors::runException("MAIL_ATTACHMENT_NOT_FOUND"); } } }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); if ($this->isLoggedIn()) { // parametros recuperados conforme draft $msgForwardTo = $this->getParam("msgForwardTo"); $originalMsgID = $this->getParam("originalMsgID"); $originalUserAction = $this->getParam("originalUserAction"); $params['input_subject'] = $this->getParam("msgSubject"); $params['input_to'] = $this->getParam("msgTo"); $params['input_cc'] = $this->getParam("msgCcTo"); $params['input_cco'] = $this->getParam("msgBccTo"); $params['input_replyto'] = $this->getParam("msgReplyTo"); $params['body'] = $this->getParam("msgBody"); $params['type'] = $this->getParam("msgType") ? $this->getParam("msgType") : "plain"; $params['folder'] = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'] == "-1" ? "null" : $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']; if (count($_FILES)) { $files = array(); $totalSize = 0; foreach ($_FILES as $name => $file) { $files[$name] = array('name' => $file['name'], 'type' => $file['type'], 'source' => base64_encode(file_get_contents($file['tmp_name'], $file['size'])), 'size' => $file['size'], 'error' => $file['error']); $totalSize += $file['size']; } $uploadMaxFileSize = str_replace("M", "", $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size']) * 1024 * 1024; if ($totalSize > $uploadMaxFileSize) { Errors::runException("MAIL_NOT_SENT_LIMIT_EXCEEDED", $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size']); } if ($this->getExpressoVersion() != "2.2") { require_once __DIR__ . '/../../../prototype/api/controller.php'; Controller::addFallbackHandler(0, function ($e) { throw $e; }); $result = array(); $attachments_ids = array(); foreach ($files as $key => $value) { $value['disposition'] = isset($value['disposition']) ? $value['disposition'] : 'attachment'; try { $attachment = Controller::put(array('concept' => "mailAttachment"), $value); $attachments_ids[] = $attachment[0]['id']; } catch (Exception $e) { Errors::runException($e->getMessage()); } } $params['attDisposition1'] = 'attachment'; $params['attachments'] = json_encode($attachments_ids); } } $returncode = $this->getImap()->send_mail($params); if (!$returncode || !(is_array($returncode) && $returncode['success'] == true)) { Errors::runException("MAIL_NOT_SENT"); } } $this->setResult(true); //to Send Response (JSON RPC format) return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); if ($sessionid = $GLOBALS['phpgw']->session->create($this->getParam('user'), $this->getParam('password'))) { $result = array('auth' => $sessionid . ":" . $GLOBALS['phpgw']->session->kp3, 'profile' => array($this->getUserProfile())); $this->setResult($result); } else { Errors::runException($GLOBALS['phpgw']->session->cd_reason); } return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); if ($this->isLoggedIn()) { $params['clean_folder'] = 'imapDefaultTrashFolder'; if (!$this->getImap()->empty_folder($params)) { Errors::runException("MAIL_TRASH_NOT_CLEANED"); } } $this->setResult(true); //to Send Response (JSON RPC format) return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); if ($this->isLoggedIn()) { if ($this->getParams()) { $search = trim($this->getParam('search')); $search = $search ? mb_convert_encoding($search, "ISO_8859-1", "UTF8") : ""; if ($this->getParam('contactType') == 1) { if ($search != "") { $query_contact = "(A.alias ilike '%{$search}%' or A.names_ordered ilike '%{$search}%' or C.connection_value ilike '%{$search}%') and"; } elseif ($this->getParam('contactID') > 0) { $query_contact = 'A.id_contact=' . $this->getParam('contactID') . ' and'; } } elseif ($this->getParam('contactType') == 2) { if ($this->getMinArgumentSearch() <= strlen($search)) { return $this->getGlobalContacts($search, $this->getParam('contactID')); } else { Errors::runException("CATALOG_MIN_ARGUMENT_SEARCH", $this->getMinArgumentSearch()); } } } $query = 'select B.id_typeof_contact_connection, A.photo, A.id_contact, A.alias, A.given_names, A.family_names, A.names_ordered, A.birthdate, A.notes, C.connection_value from phpgw_cc_contact A, ' . 'phpgw_cc_contact_conns B, phpgw_cc_connections C where A.id_contact = B.id_contact and B.id_connection = C.id_connection ' . ' and ' . $query_contact . ' A.id_owner=' . $this->getUserId() . ' group by ' . ' B.id_typeof_contact_connection, A.photo, A.id_contact, A.alias, A.given_names, A.family_names,A.names_ordered,A.birthdate, A.notes,C.connection_value order by lower(A.names_ordered)'; if (!$this->getDb()->query($query)) { return false; } $contacts = array(); while ($this->getDb()->next_record()) { $row = $this->getDb()->row(); $id = $row['id_contact']; $contactType = $row['id_typeof_contact_connection'] == 2 ? 'contactPhones' : 'contactMails'; if ($contacts[$id] != null) { $contacts[$id][$contactType][] = $row['connection_value']; } else { $contacts[$id] = array('contactID' => $row['id_contact'], $contactType => array($row['connection_value']), 'contactAlias' => $row['alias'] != null ? mb_convert_encoding($row['alias'], "UTF8", "ISO_8859-1") : "", 'contactFirstName' => $row['given_names'] != null ? mb_convert_encoding($row['given_names'], "UTF8", "ISO_8859-1") : "", 'contactLastName' => $row['family_names'] != null ? mb_convert_encoding($row['family_names'], "UTF8", "ISO_8859-1") : "", 'contactFullName' => $row['names_ordered'] != null ? mb_convert_encoding($row['names_ordered'], "UTF8", "ISO_8859-1") : "", 'contactBirthDate' => $row['birthdate'] != null ? $row['birthdate'] : "", 'contactNotes' => $row['notes'] != null ? mb_convert_encoding($row['notes'], "UTF8", "ISO_8859-1") : "", 'contactHasImagePicture' => $row['photo'] != null ? 1 : 0); } } $result = array('contacts' => array_values($contacts)); $this->setResult($result); } //to Send Response (JSON RPC format) return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); if ($this->isLoggedIn()) { $params['del_past'] = $folder_id = $this->getParam('folderID'); if (!$this->getImap()->folder_exists($folder_id)) { Errors::runException("MAIL_INVALID_FOLDER"); } $default_folders = array_keys($this->defaultFolders); if (in_array($folder_id, $default_folders)) { Errors::runException("MAIL_CANNOT_DEL_DEFAULT_FOLDER"); } $personal_folders = $this->getImap()->get_folders_list(array('noSharedFolders' => true, 'folderType' => 'personal')); if (!$personal_folders) { return $this->getResponse(); } foreach ($personal_folders as $personal_folder) { if ($personal_folder['folder_id'] == $folder_id && $personal_folder['folder_hasChildren']) { Errors::runException("MAIL_FOLDER_NOT_EMPTY"); } } if ($this->getImap()->get_num_msgs(array('folder' => $folder_id)) > 0) { Errors::runException("MAIL_FOLDER_NOT_EMPTY"); } // TODO: verificar o que ocorre com o objeto imap nas validações acima. Por algum motivo, recriando o objeto, o método delete_mailbox funciona, mas sem recriar, não funciona. $this->imap = null; $result = $this->getImap()->delete_mailbox($params); if ($result != 'Ok') { Errors::runException("MAIL_FOLDER_NOT_DELETED"); } } $this->setResult(true); //to Send Response (JSON RPC format) return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); $imap_msgs = null; $all_msgs = array(); if ($this->isLoggedIn()) { $max_email_per_page = intval($this->getParam('resultsPerPage') ? $this->getParam('resultsPerPage') : $this->getImap()->prefs['max_email_per_page']); if ($this->getParam('folderID') && $this->getParam('msgID') > 0) { $msg = $this->getMessage(); if (!$msg) { Errors::runException("MAIL_MESSAGE_NOT_FOUND", $this->getParam('folderID')); } else { $result = array('messages' => array($msg)); $this->setResult($result); return $this->getResponse(); } } elseif ($this->getParam('search') != "") { $imap = $this->getImap(); $condition = array(); $imap_folders = $imap->get_folders_list(); if ($this->getExpressoVersion() == "2.2") { foreach ($imap_folders as $i => $imap_folder) { if (is_int($i)) { $folder = mb_convert_encoding($imap_folder['folder_id'], 'UTF8', 'ISO-8859-1'); $condition[] = "{$folder}##ALL <=>" . $this->getParam('search') . "##"; } } $params = array('condition' => implode(",", $condition), 'page' => $this->getParam('page') ? intval($this->getParam('page')) - 1 : 0, 'sort_type' => "SORTDATE"); $this->getImap()->prefs['preview_msg_subject'] = "1"; $imap_msgs = $this->getImap()->search_msg($params); if (!$imap_msgs) { return $this->getResponse(); } if ($imap_msgs['num_msgs'] > 0) { foreach ($imap_msgs['data'] as $imap_msg) { $msg = array(); $msg['msgID'] = $imap_msg['uid']; $msg['folderID'] = $imap_msg['boxname']; $msg['msgDate'] = $imap_msg['udate'] . " 00:00"; $msg['msgSubject'] = mb_convert_encoding($imap_msg['subject'], "UTF8", "ISO_8859-1"); $msg['msgSize'] = $imap_msg['size']; $msg['msgFrom'] = array('fullName' => mb_convert_encoding($imap_msg['from'], "UTF8", "ISO_8859-1"), 'mailAddress' => ""); $msg['msgFlagged'] = strpos($imap_msg['flag'], "F") !== false ? "1" : "0"; $msg['msgSeen'] = strpos($imap_msg['flag'], "U") !== false ? "0" : "1"; $msg['msgHasAttachments'] = strpos($imap_msg['flag'], "T") !== false ? "1" : "0"; $msg['msgForwarded'] = strpos($imap_msg['flag'], "A") !== false && strpos($imap_msg['flag'], "X") !== false ? "1" : "0"; $msg['msgAnswered'] = $msg['msgForwarded'] != "1" && strpos($imap_msg['flag'], "A") !== false ? "1" : "0"; $msg['msgDraft'] = $msg['msgForwarded'] != "1" && strpos($imap_msg['flag'], "X") !== false ? "1" : "0"; //$msg['msgTo'] = array(); //$msg['ContentType'] = ""; //$msg['msgBodyResume'] = ""; $all_msgs[] = $msg; } } } else { // TODO: Implementar a pesquisa de mensagens para versão 2.4 } } else { $current_page = intval($this->getParam('page') ? $this->getParam('page') : 1); $msg_range_begin = $max_email_per_page * ($current_page - 1) + 1; $msg_range_end = $msg_range_begin + ($max_email_per_page - 1); $this->getImap()->prefs['preview_msg_subject'] = "1"; $imap_msgs = $this->getImap()->get_range_msgs2(array("folder" => $this->getParam('folderID'), "msg_range_begin" => $msg_range_begin, "msg_range_end" => $msg_range_end, "search_box_type" => "ALL", "sort_box_reverse" => "1", "sort_box_type" => "SORTARRIVAL")); if (!$imap_msgs) { return $this->getResponse(); } foreach ($imap_msgs as $i => $imap_msg) { if (!is_int($i)) { continue; } $msg = array(); $msg['msgID'] = $imap_msg['msg_number']; $msg['folderID'] = $imap_msgs['folder']; $msg['msgDate'] = gmdate('d/m/Y H:i', $imap_msg['timestamp']); $msg['msgFrom']['fullName'] = mb_convert_encoding($imap_msg['from']['name'], "UTF8", "ISO_8859-1"); $msg['msgFrom']['mailAddress'] = $imap_msg['from']['email']; $msg['msgTo'] = array(); if ($this->getExpressoVersion() != "2.2") { foreach ($imap_msg['to'] as $to) { $msg['msgTo'][] = array('fullName' => mb_convert_encoding($to['name'], "UTF8", "ISO_8859-1"), 'mailAddress' => $to['email']); } } else { $msg['msgTo'][] = array('fullName' => mb_convert_encoding($to['name'], "UTF8", "ISO_8859-1"), 'mailAddress' => $imap_msg['to']['email']); } $msg['msgReplyTo'][0] = $this->formatMailObject($imap_msg['reply_toaddress']); $msg['msgSubject'] = mb_convert_encoding($imap_msg['subject'], "UTF8", "ISO_8859-1"); if ($this->getExpressoVersion() != "2.2") { $msg['msgHasAttachments'] = $imap_msg['attachment'] ? "1" : "0"; } else { $msg['msgHasAttachments'] = $imap_msg['attachment']['number_attachments'] ? "1" : "0"; } $msg['msgFlagged'] = $imap_msg['Flagged'] == "F" ? "1" : "0"; $msg['msgForwarded'] = $imap_msg['Forwarded'] == "F" ? "1" : "0"; $msg['msgAnswered'] = $imap_msg['Answered'] == "A" ? "1" : "0"; $msg['msgDraft'] = $imap_msg['Draft'] == "X" ? "1" : "0"; $msg['msgSeen'] = $imap_msg['Unseen'] == "U" ? "0" : "1"; $msg['ContentType'] = $imap_msg['ContentType']; $msg['msgSize'] = $imap_msg['Size']; $msg['msgBodyResume'] = $imap_msg['msg_sample']['body']; if ($this->getExpressoVersion() != "2.2") { $msg['msgBodyResume'] = base64_decode($msg['msgBodyResume']); } $msg['msgBodyResume'] = substr($msg['msgBodyResume'], 2); $msg['msgBodyResume'] = str_replace("\r\n", "", $msg['msgBodyResume']); $msg['msgBodyResume'] = str_replace(chr(160), " ", $msg['msgBodyResume']); $msg['msgBodyResume'] = preg_replace('/\\s\\s+/', '', $msg['msgBodyResume']); $msg['msgBodyResume'] = mb_convert_encoding($msg['msgBodyResume'], "UTF8", "ISO_8859-1"); $all_msgs[] = $msg; } } } $num_msgs = 0; $num_pages = 1; $num_msgs = intval($imap_msgs['num_msgs']); if ($num_msgs > $max_email_per_page) { $num_pages = $num_msgs / $max_email_per_page; if ($num_pages > intval($num_pages)) { $num_pages = intval($num_pages) + 1; } } $result = array('messages' => $all_msgs, 'numMessages' => $num_msgs, 'numPages' => $num_pages, 'timeZone' => $imap_msgs['offsetToGMT'] ? $imap_msgs['offsetToGMT'] : "", 'totalUnseen' => $imap_msgs['tot_unseen'] ? $imap_msgs['tot_unseen'] : ""); $this->setResult($result); // to Send Response (JSON RPC format) return $this->getResponse(); }
public function post($request) { // to Receive POST Params (use $this->params) parent::post($request); $user_id = $this->getUserId(); $tz_offset = $this->getTimezoneOffset(); if ($this->isLoggedIn()) { $date_start = $this->getParam('dateStart'); $date_end = $this->getParam('dateEnd'); // check the dates parameters formats (ex: 31/12/2012 23:59:59, but the time is optional) $regex_date = '/^(0[1-9]|[12][0-9]|3[01])\\/(0[1-9]|1[0-2])\\/([12][0-9]{3})( ([01][0-9]|2[0-3])(:[0-5][0-9]){2})?$/'; if (!preg_match($regex_date, $date_start)) { Errors::runException("CALENDAR_INVALID_START_DATE"); } if (!preg_match($regex_date, $date_end)) { Errors::runException("CALENDAR_INVALID_END_DATE"); } // get the start timestamp UNIX from the parameter $start_arr = explode(' ', $date_start); $start_date_arr = explode('/', $start_arr[0]); $start_time_arr = !empty($start_arr[1]) ? explode(':', $start_arr[1]) : array('00', '00', '00'); $rangeStart = mktime($start_time_arr[0], $start_time_arr[1], $start_time_arr[2], $start_date_arr[1], $start_date_arr[0], $start_date_arr[2]) - $tz_offset; // get the end timestamp UNIX from the parameter $end_arr = explode(' ', $date_end); $end_date_arr = explode('/', $end_arr[0]); $end_time_arr = !empty($end_arr[1]) ? explode(':', $end_arr[1]) : array('23', '59', '59'); $rangeEnd = mktime($end_time_arr[0], $end_time_arr[1], $end_time_arr[2], $end_date_arr[1], $end_date_arr[0], $end_date_arr[2]) - $tz_offset; $rangeStart = $rangeStart * 1000; $rangeEnd = $rangeEnd * 1000; $concept = "schedulable"; $id = false; $criteria = array(); $criteria['order'] = "startTime"; $criteria['deepness'] = 2; $criteria['timezones'] = array(); $criteria['timezones'][1] = 'America/Sao_Paulo'; $criteria['timezones'][3] = 'America/Sao_Paulo'; $criteria['filter'] = array(); $criteria['filter'][0] = "AND"; $criteria['filter'][1] = array(); $criteria['filter'][1][0] = "OR"; $criteria['filter'][1][1] = array(); $criteria['filter'][1][1][0] = "AND"; $criteria['filter'][1][1][1] = array(); $criteria['filter'][1][1][1][0] = ">="; $criteria['filter'][1][1][1][1] = "rangeEnd"; $criteria['filter'][1][1][1][2] = $rangeStart; //START $criteria['filter'][1][1][2] = array(); $criteria['filter'][1][1][2][0] = "=<"; $criteria['filter'][1][1][2][1] = "rangeEnd"; $criteria['filter'][1][1][2][2] = $rangeEnd; //END $criteria['filter'][1][2] = array(); $criteria['filter'][1][2][0] = "AND"; $criteria['filter'][1][2][1] = array(); $criteria['filter'][1][2][1][0] = ">="; $criteria['filter'][1][2][1][1] = "rangeStart"; $criteria['filter'][1][2][1][2] = $rangeStart; //START $criteria['filter'][1][2][2] = array(); $criteria['filter'][1][2][2][0] = "=<"; $criteria['filter'][1][2][2][1] = "rangeStart"; $criteria['filter'][1][2][2][2] = $rangeEnd; //END $criteria['filter'][1][3] = array(); $criteria['filter'][1][3][0] = "AND"; $criteria['filter'][1][3][1] = array(); $criteria['filter'][1][3][1][0] = "<="; $criteria['filter'][1][3][1][1] = "rangeStart"; $criteria['filter'][1][3][1][2] = $rangeStart; //START $criteria['filter'][1][3][2] = array(); $criteria['filter'][1][3][2][0] = ">="; $criteria['filter'][1][3][2][1] = "rangeEnd"; $criteria['filter'][1][3][2][2] = $rangeEnd; //END $criteria['filter'][2] = array("IN", "calendar", array(1)); $properties = $criteria && isset($criteria['properties']) ? $criteria['properties'] : false; $service = $criteria && isset($criteria['service']) ? $criteria['service'] : false; $res = Controller::call('find', Controller::URI($concept), false, $criteria); $arrEvents = array(); foreach ($res as $event) { $timeZone = new DateTimeZone($event['timezone']); $timeStart = new DateTime('@' . (int) ($event['startTime'] / 1000), $timeZone); $timeEnd = new DateTime('@' . (int) ($event['endTime'] / 1000), $timeZone); $timeStart->setTimezone($timeZone); $timeEnd->setTimezone($timeZone); $newEvent = array(); $newEvent['eventID'] = "" . $event['id']; $newEvent['eventName'] = "" . $event['summary']; $newEvent['eventDescription'] = "" . $event['description']; $newEvent['eventLocation'] = "" . $event['location']; $newEvent['eventStartDate'] = "" . $timeStart->format('d/m/Y H:i:s'); $newEvent['eventEndDate'] = "" . $timeEnd->format('d/m/Y H:i:s'); //$newEvent['eventTimeZone'] = "" . $event['timezone']; $newEvent['eventAllDay'] = "" . $event['allDay']; $arrEvents[] = $newEvent; } $result = array('events' => $arrEvents); $this->setResult($result); } //to Send Response (JSON RPC format) return $this->getResponse(); }
protected function isLoggedIn() { if ($this->getParam('auth') != null) { list($sessionid, $kp3) = explode(":", $this->getParam('auth')); if (!$GLOBALS['phpgw']->session->verify() && $GLOBALS['phpgw']->session->verify($sessionid, $kp3)) { return $sessionid; } else { Errors::runException("LOGIN_AUTH_INVALID"); } } elseif ($sessionid = $GLOBALS['_COOKIE']['sessionid']) { if ($GLOBALS['phpgw']->session->verify($sessionid)) { return $sessionid; } else { Errors::runException("LOGIN_NOT_LOGGED_IN"); } } else { Errors::runException("LOGIN_NOT_LOGGED_IN"); } }