Beispiel #1
0
 public static function getMailServices()
 {
     static $services;
     if (is_null($services)) {
         $dbServices = \Bitrix\Mail\MailServicesTable::getList(array('filter' => array('ACTIVE' => 'Y', '=SITE_ID' => SITE_ID), 'order' => array('SORT' => 'ASC', 'NAME' => 'ASC')));
         $services = array();
         while (($service = $dbServices->fetch()) !== false) {
             $services[$service['ID']] = array('id' => $service['ID'], 'type' => $service['SERVICE_TYPE'], 'name' => $service['NAME'], 'link' => $service['LINK'], 'icon' => \Bitrix\Mail\MailServicesTable::getIconSrc($service['NAME'], $service['ICON']), 'server' => $service['SERVER'], 'port' => $service['PORT'], 'encryption' => $service['ENCRYPTION'], 'token' => $service['TOKEN'], 'flags' => $service['FLAGS'], 'sort' => $service['SORT']);
         }
     }
     return $services;
 }
Beispiel #2
0
 public static function notifyMailDomain($type, $sid, $user_id, $cnt = 0)
 {
     $user_id = intval($user_id);
     $cnt = intval($cnt);
     if (!CModule::includeModule('mail')) {
         return '';
     }
     $arAdmin = CUser::getList($by, $order, array('ID' => $user_id, 'GROUPS_ID' => 1, 'ACTIVE' => 'Y'), array('FIELDS' => array('ID', 'EMAIL')))->fetch();
     if (empty($arAdmin)) {
         return '';
     }
     if ($cnt == 0) {
         return 'CIntranetUtils::notifyMailDomain("' . $type . '", "' . $sid . '", ' . $user_id . ', ' . ++$cnt . ');';
     }
     includeModuleLangFile(__FILE__);
     if (isModuleInstalled('bitrix24')) {
         $learnmoreLink = getMessage('INTR_MAIL_DOMAIN_LEARNMOREB24_LINK');
         $supportLink = getMessage('INTR_MAIL_DOMAIN_SUPPORTB24_LINK');
     } else {
         $learnmoreLink = getMessage('INTR_MAIL_DOMAIN_LEARNMORE_LINK');
         $supportLink = getMessage('INTR_MAIL_DOMAIN_SUPPORT_LINK');
     }
     if (in_array($type, array('nocomplete', 'nomailbox'))) {
         $sid = intval($sid);
         $service = \Bitrix\Mail\MailServicesTable::getList(array('filter' => array('=ID' => $sid)))->fetch();
         if (empty($service) || $service['ACTIVE'] != 'Y' || !in_array($service['SERVICE_TYPE'], array('domain', 'crdomain'))) {
             return '';
         }
         if ($service['SERVICE_TYPE'] == 'domain') {
             $result = CMailDomain2::getDomainStatus($service['TOKEN'], $service['SERVER'], $error);
             $stage = empty($result['stage']) ? null : $result['stage'];
         } else {
             $crResponse = CControllerClient::executeEvent('OnMailControllerCheckMemberDomain', array('DOMAIN' => $service['SERVER']));
             $stage = empty($crResponse['result']['stage']) ? null : $crResponse['result']['stage'];
         }
         if ($type == 'nocomplete') {
             if (in_array($stage, array('owner-check', 'mx-check'))) {
                 CEvent::send('INTRANET_MAILDOMAIN_NOCOMPLETE', array($service['SITE_ID']), array('EMAIL_TO' => $arAdmin['EMAIL'], 'LEARNMORE_LINK' => $learnmoreLink, 'SUPPORT_LINK' => $supportLink));
                 if ($cnt == 1) {
                     global $pPERIOD;
                     $pPERIOD = 3600 * 24 * 4;
                     return 'CIntranetUtils::notifyMailDomain("nocomplete", ' . $sid . ', ' . $user_id . ', ' . ++$cnt . ');';
                 }
             }
         } else {
             if ($stage == 'added') {
                 $dbMailboxes = CMailbox::getList(array(), array('ACTIVE' => 'Y', '!USER_ID' => 0, 'SERVICE_ID' => $sid));
                 $adminMailbox = false;
                 $userMailboxes = false;
                 while ($arMailbox = $dbMailboxes->fetch()) {
                     if ($arMailbox['USER_ID'] == $user_id) {
                         $adminMailbox = true;
                     } else {
                         $userMailboxes = true;
                         break;
                     }
                 }
                 if (!$userMailboxes) {
                     $eventType = $adminMailbox ? 'INTRANET_MAILDOMAIN_NOMAILBOX2' : 'INTRANET_MAILDOMAIN_NOMAILBOX';
                     CEvent::send($eventType, array($service['SITE_ID']), array('EMAIL_TO' => $arAdmin['EMAIL'], 'LEARNMORE_LINK' => $learnmoreLink, 'SUPPORT_LINK' => $supportLink));
                     if ($cnt == 1) {
                         global $pPERIOD;
                         $pPERIOD = 3600 * 24 * 21;
                         return 'CIntranetUtils::notifyMailDomain("nomailbox", ' . $sid . ', ' . $user_id . ', ' . ++$cnt . ');';
                     }
                 }
             }
         }
     } else {
         if ($type == 'noreg') {
             $dbServices = \Bitrix\Mail\MailServicesTable::getList(array('filter' => array('ACTIVE' => 'Y', 'SERVICE_TYPE' => 'crdomain')));
             while ($service = $dbServices->fetch()) {
                 if ($service['FLAGS'] & CMail::F_DOMAIN_REG) {
                     return '';
                 }
             }
             $r = CEvent::send('INTRANET_MAILDOMAIN_NOREG', array($sid), array('EMAIL_TO' => $arAdmin['EMAIL'], 'LEARNMORE_LINK' => $learnmoreLink, 'SUPPORT_LINK' => $supportLink));
         }
     }
     return '';
 }
Beispiel #3
0
} elseif (!CModule::IncludeModule('intranet')) {
    echo GetMessage("BX24_INVITE_DIALOG_INTRANET_MODULE");
} else {
    $SITE_ID = CSite::GetDefSite();
    $rsSite = CSite::GetList($by = "sort", $order = "asc", array("ID" => $SITE_ID));
    $arSite = $rsSite->GetNext();
    $SITE_DIR = $arSite["DIR"];
    $ID_INVITED = $ID_ADDED = 0;
    $arMailServices = array();
    $bDomainUsersExist = false;
    $bCreateDomainsExist = false;
    $bConnectDomainsExist = false;
    $bMailInstalled = false;
    if (CModule::IncludeModule("mail")) {
        $bMailInstalled = true;
        $dbService = \Bitrix\Mail\MailServicesTable::getList(array('filter' => array('ACTIVE' => 'Y', '=SITE_ID' => $SITE_ID), 'order' => array('SORT' => 'ASC', 'NAME' => 'ASC')));
        while ($arService = $dbService->fetch()) {
            $arMailServices[$arService['ID']] = array('id' => $arService['ID'], 'type' => $arService['SERVICE_TYPE'], 'name' => $arService['NAME'], 'link' => $arService['LINK'], 'icon' => \Bitrix\Mail\MailServicesTable::getIconSrc($arService['NAME'], $arService['ICON']), 'server' => $arService['SERVER'], 'port' => $arService['PORT'], 'encryption' => $arService['ENCRYPTION'], 'token' => $arService['TOKEN']);
            if ($arService['SERVICE_TYPE'] == 'controller') {
                $crDomains = CControllerClient::ExecuteEvent('OnMailControllerGetDomains', array());
                if (!empty($crDomains['result']) && is_array($crDomains['result'])) {
                    $arMailServices[$arService['ID']]['domains'] = $crDomains['result'];
                    $bCreateDomainsExist = true;
                }
                $arMailServices[$arService['ID']]['users'] = array();
                $crUsers = CControllerClient::ExecuteEvent('OnMailControllerGetUsers', array());
                if (!empty($crUsers['result']) && is_array($crUsers['result'])) {
                    foreach ($crUsers['result'] as $email) {
                        list($login, $domain) = explode('@', $email, 2);
                        if (empty($arMailServices[$arService['ID']]['users'][$domain])) {
                            $arMailServices[$arService['ID']]['users'][$domain] = array();