/** * @return array */ public function AjaxMessageSave() { $mResult = false; $oAccount = $this->getAccountFromParam(); $sDraftFolder = $this->getParamValue('DraftFolder', ''); $sDraftUid = $this->getParamValue('DraftUid', ''); $sFetcherID = $this->getParamValue('FetcherID', ''); $sIdIdentity = $this->getParamValue('IdentityID', ''); if (0 === strlen($sDraftFolder)) { throw new \ProjectSeven\Exceptions\ClientException(\ProjectSeven\Notifications::InvalidInputParameter); } $oFetcher = null; if (!empty($sFetcherID) && is_numeric($sFetcherID) && 0 < (int) $sFetcherID) { $iFetcherID = (int) $sFetcherID; $oApiFetchers = $this->ApiFetchers(); $aFetchers = $oApiFetchers->GetFetchers($oAccount); if (is_array($aFetchers) && 0 < count($aFetchers)) { foreach ($aFetchers as $oFetcherItem) { if ($oFetcherItem && $iFetcherID === $oFetcherItem->IdFetcher && $oAccount->IdUser === $oFetcherItem->IdUser) { $oFetcher = $oFetcherItem; break; } } } } $oIdentity = null; if (!empty($sIdIdentity) && is_numeric($sIdIdentity) && 0 < (int) $sIdIdentity) { $oIdentity = $this->oApiUsers->GetIdentity((int) $sIdIdentity); } $oMessage = $this->buildMessage($oAccount, $oFetcher, true, $oIdentity); if ($oMessage) { try { \CApi::Plugin()->RunHook('webmail.build-message-for-save', array(&$oMessage)); $mResult = $this->oApiMail->MessageSave($oAccount, $oMessage, $sDraftFolder, $sDraftUid); } catch (\CApiManagerException $oException) { $iCode = \ProjectSeven\Notifications::CanNotSaveMessage; throw new \ProjectSeven\Exceptions\ClientException($iCode, $oException); } } return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult); }