Exemple #1
0
 public static function mailserviceAdd($arParams)
 {
     global $USER;
     if (!$USER->CanDoOperation('bitrix24_config')) {
         throw new Exception(GetMessage('ACCESS_DENIED'));
     }
     $arFields = array('SITE_ID' => SITE_ID, 'ACTIVE' => $arParams['ACTIVE'] ?: 'Y', 'NAME' => $arParams['NAME'], 'SERVER' => $arParams['SERVER'], 'PORT' => $arParams['PORT'], 'ENCRYPTION' => $arParams['ENCRYPTION'], 'LINK' => $arParams['LINK'], 'ICON' => CRestUtil::saveFile($arParams['ICON']) ?: $arParams['ICON'], 'SORT' => $arParams['SORT'] ?: 100);
     $result = Bitrix\Mail\MailServicesTable::add($arFields);
     if (!$result->isSuccess()) {
         throw new Exception(join('; ', $result->getErrorMessages()));
     }
     return $result->getId();
 }
Exemple #2
0
 function InstallDB($arParams = array())
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     // Database tables creation
     if (!$DB->Query("SELECT 'x' FROM b_mail_mailbox WHERE 1=0", true)) {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mail/install/db/" . strtolower($DB->type) . "/install.sql");
     }
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     } else {
         RegisterModule("mail");
         if (CModule::IncludeModule("mail")) {
             $result = Bitrix\Mail\MailServicesTable::getList(array('filter' => array('ACTIVE' => 'Y')));
             if ($result->fetch() === false) {
                 $mailServices = array('gmail' => array('SERVER' => 'imap.gmail.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'https://mail.google.com/'), 'icloud' => array('SERVER' => 'imap.mail.me.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'https://www.icloud.com/#mail'), 'outlook.com' => array('SERVER' => 'imap-mail.outlook.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'https://www.outlook.com/owa'), 'office365' => array('SERVER' => 'outlook.office365.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://mail.office365.com/'), 'yahoo' => array('SERVER' => 'imap.mail.yahoo.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://mail.yahoo.com/'), 'aol' => array('SERVER' => 'imap.aol.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://mail.aol.com/'), 'yandex' => array('SERVER' => 'imap.yandex.ru', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'https://mail.yandex.ru/'), 'mail.ru' => array('SERVER' => 'imap.mail.ru', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://e.mail.ru/'), 'ukr.net' => array('SERVER' => 'imap.ukr.net', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://freemail.ukr.net/'), 'exchange' => array(), 'other' => array());
                 $mailServicesByLang = array('ru' => array(100 => 'gmail', 200 => 'outlook.com', 300 => 'icloud', 400 => 'office365', 500 => 'exchange', 600 => 'yahoo', 700 => 'aol', 800 => 'yandex', 900 => 'mail.ru', 1000 => 'ukr.net', 1100 => 'other'), 'ua' => array(100 => 'gmail', 200 => 'outlook.com', 300 => 'icloud', 400 => 'office365', 500 => 'exchange', 600 => 'yahoo', 700 => 'aol', 800 => 'yandex', 900 => 'mail.ru', 1000 => 'ukr.net', 1100 => 'other'), 'en' => array(100 => 'gmail', 200 => 'outlook.com', 300 => 'icloud', 400 => 'office365', 500 => 'exchange', 600 => 'yahoo', 700 => 'aol', 800 => 'other'), 'de' => array(100 => 'gmail', 200 => 'outlook.com', 300 => 'icloud', 400 => 'office365', 500 => 'exchange', 600 => 'yahoo', 700 => 'aol', 800 => 'other'));
                 $result = \Bitrix\Main\SiteTable::getList();
                 while (($site = $result->fetch()) !== false) {
                     if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite($site['LID'])) {
                         continue;
                     }
                     $mailServicesList = isset($mailServicesByLang[$site['LANGUAGE_ID']]) ? $mailServicesByLang[$site['LANGUAGE_ID']] : $mailServicesByLang['en'];
                     foreach ($mailServicesList as $serviceSort => $serviceName) {
                         $serviceSettings = $mailServices[$serviceName];
                         $serviceSettings['SITE_ID'] = $site['LID'];
                         $serviceSettings['ACTIVE'] = 'Y';
                         $serviceSettings['SERVICE_TYPE'] = 'imap';
                         $serviceSettings['NAME'] = $serviceName;
                         $serviceSettings['SORT'] = $serviceSort;
                         Bitrix\Mail\MailServicesTable::add($serviceSettings);
                     }
                 }
             }
         }
         RegisterModuleDependences('rest', 'OnRestServiceBuildDescription', 'mail', 'CMailRestService', 'OnRestServiceBuildDescription');
         RegisterModuleDependences('main', 'OnAfterUserUpdate', 'mail', 'CMail', 'onUserUpdate');
         RegisterModuleDependences('main', 'OnAfterUserDelete', 'mail', 'CMail', 'onUserDelete');
         CAgent::AddAgent("CMailbox::CleanUp();", "mail", "N", 60 * 60 * 24);
         return true;
     }
 }
    $str_LINK = $ms['LINK'];
    $str_ICON = $ms['ICON'];
    $str_TOKEN = $ms['TOKEN'];
    $str_SORT = $ms['SORT'];
} else {
    $ID = 0;
}
if ($REQUEST_METHOD == "POST" && (strlen($save) > 0 || strlen($apply) > 0) && $MOD_RIGHT == "W" && check_bitrix_sessid()) {
    $ICON['old_file'] = $str_ICON;
    $ICON['del'] = $remove_icon;
    $arFields = array('SITE_ID' => $SITE_ID, 'ACTIVE' => $ACTIVE ?: 'N', 'NAME' => $NAME, 'SERVER' => $SERVER, 'PORT' => $PORT ?: null, 'ENCRYPTION' => $TYPE == 'imap' ? $bCanUseTLS ? $ENCRYPTION : 'N' : ($ENCRYPTION == 'N' ? 'N' : 'Y'), 'LINK' => $LINK, 'ICON' => $ICON, 'TOKEN' => $TOKEN, 'SORT' => $SORT);
    if ($ID > 0) {
        $result = Bitrix\Mail\MailServicesTable::update($ID, $arFields);
    } else {
        $arFields['SERVICE_TYPE'] = $TYPE;
        $result = Bitrix\Mail\MailServicesTable::add($arFields);
        $ID = $result->isSuccess() ? $result->getId() : 0;
    }
    if (!$result->isSuccess()) {
        $message = new CAdminMessage(array('MESSAGE' => GetMessage("MAIL_MSERVICE_EDT_ERROR"), 'DETAILS' => join('<br>', $result->getErrorMessages())));
    } else {
        if (strlen($save) > 0) {
            LocalRedirect("mail_mailservice_admin.php?lang=" . LANG);
        } else {
            LocalRedirect($APPLICATION->GetCurPage() . "?lang=" . LANG . "&ID=" . $ID);
        }
    }
}
if ($message) {
    $DB->InitTableVarsForEdit("b_mail_mailservices", "", "str_");
    $str_ICON = null;