예제 #1
0
 /**
  * @return array
  */
 public function AjaxAccountResetPassword()
 {
     $mResult = false;
     $oAccount = $this->getDefaultAccountFromParam();
     $sUrlHash = $this->getParamValue('UrlHash', '');
     $oTenant = null;
     if ($oAccount->Domain->IdTenant > 0) {
         $oTenant = $this->oApiTenants->getTenantById($oAccount->Domain->IdTenant);
     } else {
         $oTenant = $this->oApiTenants->getDefaultGlobalTenant();
     }
     if ($oTenant) {
         $oNotificationAccount = $this->oApiUsers->GetAccountByEmail($oTenant->InviteNotificationEmailAccount);
         if ($oNotificationAccount) {
             $sPasswordResetUrl = rtrim(\api_Utils::GetAppUrl(), '/');
             $sPasswordResetHash = \md5(\time() . \rand(1000, 9999) . \CApi::$sSalt);
             $oAccount->User->PasswordResetHash = $sPasswordResetHash;
             $this->oApiUsers->updateAccount($oAccount);
             $sSubject = \CApi::ClientI18N('ACCOUNT_PASSWORD_RESET/SUBJECT', $oAccount, array('SITE_NAME' => $oAccount->Domain->SiteName));
             $sBody = \CApi::ClientI18N('ACCOUNT_PASSWORD_RESET/BODY', $oAccount, array('SITE_NAME' => $oAccount->Domain->SiteName, 'PASSWORD_RESET_URL' => $sPasswordResetUrl . '/?reset-pass='******'#' . $sUrlHash, 'EMAIL' => $oAccount->Email));
             $oMessage = \MailSo\Mime\Message::NewInstance();
             $oMessage->RegenerateMessageId();
             $oMessage->DoesNotCreateEmptyTextPart();
             $sXMailer = \CApi::GetConf('webmail.xmailer-value', '');
             if (0 < strlen($sXMailer)) {
                 $oMessage->SetXMailer($sXMailer);
             }
             $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oTenant->InviteNotificationEmailAccount))->SetSubject($sSubject)->AddText($sBody, true);
             $oToEmails = \MailSo\Mime\EmailCollection::NewInstance($oAccount->Email);
             if ($oToEmails && $oToEmails->Count()) {
                 $oMessage->SetTo($oToEmails);
             }
             if ($oMessage) {
                 try {
                     $mResult = $this->oApiMail->sendMessage($oNotificationAccount, $oMessage);
                 } catch (\CApiManagerException $oException) {
                     throw $oException;
                 }
             }
         }
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult);
 }
예제 #2
0
 public function CreatePublicLink($oAccount, $sType, $sPath, $sName, $sSize, $bIsFolder)
 {
     $sID = implode('|', array($oAccount->IdAccount, $sType, $sPath, $sName));
     $mResult = false;
     $oMin = $this->GetMinManager();
     $mMin = $oMin->GetMinByID($sID);
     if (!empty($mMin['__hash__'])) {
         $mResult = $mMin['__hash__'];
     } else {
         $mResult = $oMin->CreateMin($sID, array('Account' => $oAccount->IdAccount, 'Type' => $sType, 'Path' => $sPath, 'Name' => $sName, 'Size' => $sSize, 'IsFolder' => $bIsFolder));
     }
     $bServerUseUrlRewrite = \CApi::GetConf('labs.server-use-url-rewrite', false);
     $sUrl = $bIsFolder ? '?files-pub=' : ($bServerUseUrlRewrite ? 'share/' : '?/Min/Share/');
     return \api_Utils::GetAppUrl() . $sUrl . $mResult;
 }