/** * @see Accessible\Handler::execute */ public function execute($params) { if (TineSessionRepository::getTineSession()->isLoggedIn()) { $liteRequestProcessor = new LiteRequestProcessor(); $liteRequestProcessor->executeRequest('Logoff', (object) array()); } Dispatcher::processRequest('Core.ShowFeedback', (object) array('typeMsg' => ShowFeedback::MSG_SUCCESS, 'message' => 'Saída realizada com sucesso.', 'destinationText' => 'Acessar a página de login', 'destinationUrl' => (object) array('action' => 'Login.Main'))); }
/** * Pushes uploaded file into Tine shadows. * * @param array $upFileObj Associative array of uploaded $_FILE entry. * @return stdClass Ordinary Tine upload status. */ private function uploadFile(array $upFileObj) { if (empty($upFileObj['tmp_name']) || $upFileObj['error'] !== 0) { return null; // this file upload slot was not used } return json_decode(MessageUtils::uploadTempFile(TineSessionRepository::getTineSession(), file_get_contents($upFileObj['tmp_name']), $upFileObj['name'], $upFileObj['type'])); }
/** * @see Accessible\Handler::execute */ public function execute($params) { $liteRequestProcessor = new LiteRequestProcessor(); $response = $liteRequestProcessor->executeRequest('SearchFolders', (object) array('recursive' => true)); $folders = $this->flatFolderTree($response, $params); TineSessionRepository::getTineSession()->setAttribute('folders', $folders); $this->showTemplate('OpenFolderTemplate', (object) array('folders' => $folders, 'folderName' => $params->folderName, 'lnkRefreshFolder' => $this->makeUrl('Mail.Main', array('folderName' => $params->folderName, 'folderId' => $params->folderId, 'page' => $params->page)), 'lnkRefreshMessage' => $this->makeUrl('Mail.OpenMessage', array('folderName' => $params->folderName, 'folderId' => $params->folderId, 'page' => $params->page, 'messageId' => isset($params->messageIds) ? $params->messageIds : '')), 'isMsgBeingMoved' => isset($params->isMsgBeingMoved) ? true : false)); }
/** * Processes raw HTTP requests. Used only in ../index.php page. * * @param array $httpRequest Should always be $_REQUEST object. */ public static function processRawHttpRequest(array $httpRequestParams) { $request = isset($httpRequestParams['r']) ? $httpRequestParams['r'] : null; $params = self::getParamsFromHttpRequest($httpRequestParams); $isLoggedIn = TineSessionRepository::getTineSession()->isLoggedIn(); if ($isLoggedIn && $request === null) { $request = self::MAIL_REQUEST; } if ($request === null) { $request = self::LOGIN_REQUEST; } self::processRequest($request, (object) $params); }
public function execute($params) { $folders = TineSessionRepository::getTineSession()->getAttribute('folders'); $isTrashFolder = FALSE; foreach ($folders as $fol) { if ($fol->id === $params->folderId) { $isTrashFolder = $fol->globalName === self::TRASH_FOLDER; break; } } $liteRequestProcessor = new LiteRequestProcessor(); $message = $liteRequestProcessor->executeRequest('DeleteMessages', (object) array('messages' => $params->messageIds, 'forever' => $isTrashFolder ? '1' : '0')); $outMsg = $this->getFormattedFeedbackMsg($params->messageIds, $isTrashFolder); Dispatcher::processRequest('Core.ShowFeedback', (object) array('typeMsg' => ShowFeedback::MSG_SUCCESS, 'message' => $outMsg, 'destinationText' => 'Voltar para ' . $params->folderName, 'destinationUrl' => (object) array('action' => 'Mail.Main', 'params' => array('folderId' => $params->folderId)))); }
/** * Instantiates the appropriate request handler (an object of a subclass of LiteRequest) * and initializes it with the current Tine Session and the informed params. * * * @param $requestName The * request name, as defined by Lite. It must be the same name * of the class that is responsible to execute it. * @param $params The * params to be associated to the request. * */ public function prepareLiteRequestHandler($requestName, $params = array()) { $handlerClassName = self::LITE_REQUEST_NAMESPACE . ucfirst($requestName); // uppercase first letter $tineSession = TineSessionRepository::getTineSession(); try { $handlerClass = @new ReflectionClass($handlerClassName); } catch (ReflectionException $re) { throw new LiteException('Invalid Lite Request: ' . $requestName, 0, 400); } $functionHandler = $handlerClass->newInstance(); $functionHandler->init($this, $tineSession, $params); TineSessionRepository::storeTineSession($tineSession); // store tineSession back in case any of its attributes changed. // TODO: this is probably not necessary for most calls, as session attributes // usually only change during login. return $functionHandler; }
/** * Get folder from Folder ID * * @param int $folderId * @return array of current folder */ private function getFolder($folderId) { $folders = TineSessionRepository::getTineSession()->getAttribute('folders'); if ($folderId === null || $folders === null) { $liteRequestProcessor = new LiteRequestProcessor(); $response = $liteRequestProcessor->executeRequest('SearchFolders', (object) array()); $curFolder = (object) array('id' => $response[0]->id, 'localName' => $response[0]->localName, 'globalName' => $response[0]->globalName, 'totalMails' => $response[0]->totalMails, 'unreadMails' => $response[0]->unreadMails); if (!isset($folders)) { $folders[] = (object) array('id' => $curFolder->id, 'title' => 'Esta pasta contém ' . $curFolder->totalMails . ' emails' . ' e ' . $curFolder->unreadMails . ' emails não lido', 'localName' => $curFolder->localName, 'globalName' => $curFolder->globalName, 'totalMails' => $curFolder->totalMails, 'unreadMails' => $curFolder->unreadMails); TineSessionRepository::getTineSession()->setAttribute('folders', $folders); } } else { $liteRequestProcessor = new LiteRequestProcessor(); $response = $liteRequestProcessor->executeRequest('UpdateMessageCache', (object) array('folderId' => $folderId)); foreach ($folders as $tmp) { if ($tmp->id === $folderId) { $curFolder = (object) array('id' => $folderId, 'localName' => $tmp->localName, 'globalName' => $tmp->globalName, 'totalMails' => $response->totalMails, 'unreadMails' => $response->unreadMails); break; } } } return $curFolder; }
/** * Formats "Cc" address field, if needed. * * @param stdClass $params Request parameters. * @param stdClass $msg Message object, if replied or forwarded. * @return string The return Cc addresses formatted. */ private function formatCcAddresses($params, $msg = null) { $userEmail = TineSessionRepository::getTineSession()->getAttribute('Expressomail.email'); if (($key = array_search($userEmail, $msg->to)) !== false) { unset($msg->to[$key]); } if (isset($params->replyAll) && $msg !== null) { return implode(', ', array_merge($msg->to, $msg->cc)); } return ''; }
/** * Returns an ordered listing of events according to the provided events * date range and to the currently selected user calendar. * * @param string $calendarId Current calendar to be used * @param StdClass $currDateRange Formatted date range with month and year values * to use as the event date range * @return StdClass Event listing content (->listing) and a boolean (->hasEvents) * indicating whether or not there are calendar events */ private function getEventListing($calendarId, $currDateRange) { // Setting properly the correct timezone based on login user timezone $timeZone = TineSessionRepository::getTineSession()->getAttribute('Tinebase.timeZone'); $lrp = new LiteRequestProcessor(); $preparedEventDateRange = EventUtils::prepareEventsDateRange($currDateRange); $message = $lrp->executeRequest('SearchEvents', (object) array('from' => $preparedEventDateRange->from, 'until' => $preparedEventDateRange->until, 'timeZone' => $timeZone, 'calendarId' => $calendarId)); // Sorts the event list comparing each event start time (->from) usort($message->events, function ($e1, $e2) { return strcmp($e1->from, $e2->from); }); return (object) array('hasEvents' => count($message->events) > 0, 'listing' => (object) $message->events); }
/** * Dumps the current tineSession associated to this request * with a new one provided by TineSessionRepository * * @return TineSession The new TineSession * */ public function resetTineSession() { $this->tineSession = TineSessionRepository::resetTineSession(); }
/** * Format information, about the attendees of a calendar event, to be viewed. The current user * logged in, if he is one of the attendees, so he must be the first exhibited attendee. The * remaining attendees will be group by, in the following order, that have the confirmation * type: ACCEPTED, TENTATIVE, NEEDS-ACTION and DECLINED. * * @param array $attendees An array of attendees objects * @return array An array of formatted information about attendees in wich element contains * the name (->name) of the attendee, it's current confirmation (->userConfirm), * the icon css class of the current confirmation type (->userConfirmIcon) and * the organization and region about attendee's role */ private function formatAttendeesInformation($attendees) { // Email of current logged in user, because we'll search for it in attendees list $currUserEmail = TineSessionRepository::getTineSession()->getAttribute('Expressomail.email'); // Array which indexes are confirmation types, each one containing an empty list of attendees $result = EventUtils::prepareListOfConfirmationTypesToGroupAttendees(); $currUserAttendee = null; $userHasNotFounded = true; foreach ($attendees as $attendee) { // Formatting the description for the current attendee event confirmation type $attendee->confirmStatus = EventUtils::getConfirmationDescription($attendee->confirmation); // Verifying if the logged in user is also an attendee of the event. if ($userHasNotFounded && $attendee->email === $currUserEmail) { $currUserAttendee = $attendee; $userHasNotFounded = false; } else { $result[$attendee->confirmation][] = $attendee; } } // Checking whether the logged in user is a attendee of the current event if (!$userHasNotFounded && !is_null($currUserAttendee)) { array_unshift($result, array($currUserAttendee)); // First one to be displayed } return EventUtils::sortAttendeesByName($result); }