コード例 #1
0
ファイル: utils.php プロジェクト: mrdeadmouse/u136006
 public static function checkMailDomain($service_id, $user_id, $cnt = 1)
 {
     $service_id = intval($service_id);
     $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', 'TIME_ZONE_OFFSET')))->fetch();
     if (empty($arAdmin)) {
         return '';
     }
     $service = \Bitrix\Mail\MailServicesTable::getList(array('filter' => array('=ID' => $service_id)))->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']);
         $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 (!in_array($stage, array('none', 'owner-check', 'mx-check', 'added'))) {
         return false;
     } else {
         if (in_array($stage, array('none', 'added'))) {
             if ($stage == 'added') {
                 if (CModule::includeModule('im')) {
                     includeModuleLangFile(__FILE__);
                     $siteUrl = sprintf('http%s://%s%s', CMain::isHTTPS() ? 's' : '', $_SERVER['SERVER_NAME'], in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT']);
                     CIMNotify::add(array('TO_USER_ID' => $user_id, 'FROM_USER_ID' => 0, 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM, 'NOTIFY_MODULE' => 'intranet', 'NOTIFY_MESSAGE' => str_replace(array('#DOMAIN#', '#SERVER#'), array(htmlspecialcharsbx($service['SERVER']), $siteUrl), getMessage('INTR_MAIL_DOMAINREADY_NOTICE'))));
                 }
                 $timeout = new DateTime(intval($arAdmin['TIME_ZONE_OFFSET']) . ' seconds +7 days');
                 if ($timeout->format('N') > 5) {
                     $timeout->modify('next monday');
                 }
                 CAgent::addAgent('CIntranetUtils::notifyMailDomain("nomailbox", ' . $service_id . ', ' . $user_id . ');', 'intranet', 'N', $timeout->getTimestamp() - intval($arAdmin['TIME_ZONE_OFFSET']) - time());
             }
             return '';
         } else {
             if ($cnt > 100) {
                 return '';
             }
             global $pPERIOD;
             $pPERIOD = $pPERIOD * $cnt;
             if ($pPERIOD > 3600 * 4) {
                 $pPERIOD = 3600 * 4;
             }
             return 'CIntranetUtils::checkMailDomain(' . $service_id . ', ' . $user_id . ', ' . ++$cnt . ');';
         }
     }
 }
コード例 #2
0
ファイル: driver.php プロジェクト: DarneoStudio/bitrix
 /**
  * Send notify by module "IM".
  *
  * @param int $toUserId Target user id.
  * @param array $dataNotify Specific data.
  * @return bool
  * @throws \Bitrix\Main\LoaderException
  */
 public function sendNotify($toUserId, array $dataNotify)
 {
     if (!(ModuleManager::isModuleInstalled('im') && Loader::includeModule('im'))) {
         return false;
     }
     $dataNotify['NOTIFY_MODULE'] = self::INTERNAL_MODULE_ID;
     $dataNotify['TO_USER_ID'] = $toUserId;
     switch ($dataNotify['NOTIFY_TYPE']) {
         case 'IM_NOTIFY_FROM':
             $dataNotify['NOTIFY_TYPE'] = IM_NOTIFY_FROM;
             break;
         case 'IM_NOTIFY_CONFIRM':
             $dataNotify['NOTIFY_TYPE'] = IM_NOTIFY_CONFIRM;
             break;
         default:
             $dataNotify['NOTIFY_TYPE'] = IM_NOTIFY_FROM;
     }
     return (bool) \CIMNotify::add($dataNotify);
 }