/**
  * @see ExpressoLite\Backend\Request\LiteRequest::execute
  */
 public function execute()
 {
     $msgIds = explode(',', $this->param('ids'));
     // comma-separated into array
     $asRead = $this->param('asRead') === '1';
     return MessageUtils::addOrClearFlag($this->tineSession, $msgIds, "\\Seen", $asRead);
 }
 /**
  * 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 ExpressoLite\Backend\Request\LiteRequest::execute
  */
 public function execute()
 {
     $fileType = isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : 'text/plain';
     if (isset($_SERVER['HTTP_X_FILE_NAME']) && isset($_SERVER['HTTP_X_FILE_TYPE'])) {
         return MessageUtils::uploadTempFile($this->tineSession, file_get_contents('php://input'), $_SERVER['HTTP_X_FILE_NAME'], $fileType);
     } else {
         return $this->httpError(400, 'Nenhum arquivo a ser carregado.');
     }
 }
 /**
  * @see ExpressoLite\Backend\Request\LiteRequest::execute
  */
 public function execute()
 {
     $msgIds = explode(',', $this->param('messages'));
     $forever = $this->isParamSet('forever') && $this->param('forever') === '1';
     if ($forever) {
         return MessageUtils::addOrClearFlag($this->tineSession, $msgIds, "\\Deleted", true);
     } else {
         return MessageUtils::moveMessages($this->tineSession, $msgIds, '_trash_');
     }
 }
 /**
  * @see ExpressoLite\Backend\Request\LiteRequest::execute
  */
 public function execute()
 {
     $response = $this->jsonRpc('Addressbook.getContact', (object) array('id' => $this->param('id')));
     $tineContact = $response->result;
     if ($tineContact->jpegphoto != 'images/empty_photo_blank.png') {
         $mugshot = MessageUtils::getContactPicture($this->tineSession, $tineContact->id, strtotime($tineContact->creation_time), 90, 113);
     } else {
         $mugshot = '';
     }
     return (object) array('id' => $tineContact->id, 'name' => $tineContact->n_fn, 'email' => $tineContact->email, 'phone' => $tineContact->tel_work, 'mobile' => $tineContact->tel_cell, 'mugshot' => $mugshot, 'otherFields' => $tineContact);
 }
 /**
  * @see ExpressoLite\Backend\Request\LiteRequest::execute
  */
 public function execute()
 {
     $subject = $this->param('subject');
     $body = $this->param('body');
     $to = $this->toArrayOfEmails($this->param('to'));
     $cc = $this->toArrayOfEmails($this->param('cc'));
     $bcc = $this->toArrayOfEmails($this->param('bcc'));
     $isImportant = $this->param('isImportant') == '1';
     $replyToId = $this->emptyAsNull($this->param('replyToId'));
     $forwardFromId = $this->emptyAsNull($this->param('forwardFromId'));
     $origDraftId = $this->emptyAsNull($this->param('origDraftId'));
     $wantConfirm = $this->isParamSet('wantConfirm') ? $this->param('wantConfirm') == '1' : false;
     $attachs = $this->param('attachs');
     if ($attachs != '') {
         $attachs = json_decode($attachs);
     } else {
         $attachs = array();
     }
     $response = $this->jsonRpc('Expressomail.saveMessage', (object) array('recordData' => MessageUtils::buildMessageForSaving($this->tineSession, $subject, $body, $to, $cc, $bcc, $isImportant, $replyToId, $forwardFromId, $origDraftId, $attachs, $wantConfirm)));
     return $response->result;
 }
 /**
  * @see ExpressoLite\Backend\Request\LiteRequest::execute
  */
 public function execute()
 {
     $draftFolderId = $this->param('draftFolderId');
     $subject = $this->param('subject');
     $body = $this->param('body');
     $to = $this->toArrayOfEmails($this->param('to'));
     $cc = $this->toArrayOfEmails($this->param('cc'));
     $bcc = $this->toArrayOfEmails($this->param('bcc'));
     $isImportant = $this->param('isImportant') == '1';
     $replyToId = $this->emptyAsNull($this->param('replyToId'));
     $forwardFromId = $this->emptyAsNull($this->param('forwardFromId'));
     $origDraftId = $this->emptyAsNull($this->param('origDraftId'));
     $attachs = $this->param('attachs') != '' ? json_decode($this->param('attachs')) : array();
     // array of tempFile objects
     $recordData = MessageUtils::buildMessageForSaving($this->tineSession, $subject, $body, $to, $cc, $bcc, $isImportant, $replyToId, $forwardFromId, $origDraftId, $attachs);
     $this->jsonRpc('Expressomail.saveMessageInFolder', (object) array('folderName' => 'INBOX/Drafts', 'recordData' => $recordData));
     $draftMsg = $this->processor->executeRequest('searchHeadlines', array('folderIds' => $draftFolderId, 'start' => 0, 'limit' => 1));
     // newest draft
     $result = MessageUtils::addOrClearFlag($this->tineSession, array($draftMsg[0]->id), "\\Seen", true);
     // because Tine saves new draft as unread
     return $result;
 }
 /**
  * @see ExpressoLite\Backend\Request\LiteRequest::execute
  */
 public function execute()
 {
     $msgIds = explode(',', $this->param('messages'));
     $folder = $this->param('folder');
     return MessageUtils::moveMessages($this->tineSession, $msgIds, $folder);
 }
 /**
  * @see ExpressoLite\Backend\Request\LiteRequest::execute
  */
 public function execute()
 {
     $asHighlighted = $this->param('asHighlighted') === '1';
     $msgIds = explode(',', $this->param('ids'));
     return MessageUtils::addOrClearFlag($this->tineSession, $msgIds, "\\Flagged", $asHighlighted);
 }