Example #1
0
 public static function GetNotifySchema()
 {
     if (is_null(self::$arNotifySchema)) {
         self::$arNotifySchema = array();
         foreach (GetModuleEvents("im", "OnGetNotifySchema", true) as $arEvent) {
             $ar = ExecuteModuleEventEx($arEvent);
             if (is_array($ar)) {
                 foreach ($ar as $moduleId => $arNotifyType) {
                     self::$arNotifySchema[$moduleId]['NAME'] = isset($arNotifyType['NOTIFY']) && isset($arNotifyType['NAME']) ? $arNotifyType['NAME'] : '';
                     $arNotify = $arNotifyType;
                     if (isset($arNotifyType['NOTIFY'])) {
                         $arNotify = $arNotifyType['NOTIFY'];
                     }
                     foreach ($arNotify as $notifyEvent => $arConfig) {
                         if (!isset($arConfig['PUSH']) || $arConfig['PUSH'] == 'NONE') {
                             $arConfig['DISABLED'][] = IM_NOTIFY_FEATURE_PUSH;
                         }
                         $arConfig['SITE'] = !isset($arConfig['SITE']) || $arConfig['SITE'] == 'Y' ? true : false;
                         $arConfig['MAIL'] = !isset($arConfig['MAIL']) || $arConfig['MAIL'] == 'Y' ? true : false;
                         $arConfig['XMPP'] = !isset($arConfig['XMPP']) || $arConfig['XMPP'] == 'Y' ? true : false;
                         $arConfig['PUSH'] = isset($arConfig['PUSH']) && $arConfig['PUSH'] == 'Y' ? true : false;
                         $arDisabled['SITE'] = isset($arConfig['DISABLED']) && in_array(IM_NOTIFY_FEATURE_SITE, $arConfig['DISABLED']) ? true : false;
                         $arDisabled['MAIL'] = isset($arConfig['DISABLED']) && in_array(IM_NOTIFY_FEATURE_MAIL, $arConfig['DISABLED']) ? true : false;
                         $arDisabled['XMPP'] = isset($arConfig['DISABLED']) && in_array(IM_NOTIFY_FEATURE_XMPP, $arConfig['DISABLED']) ? true : false;
                         $arDisabled['PUSH'] = isset($arConfig['DISABLED']) && in_array(IM_NOTIFY_FEATURE_PUSH, $arConfig['DISABLED']) ? true : false;
                         $arConfig['DISABLED'] = $arDisabled;
                         $arConfig['LIFETIME'] = intval($arConfig['LIFETIME']);
                         self::$arNotifySchema[$moduleId]['NOTIFY'][$notifyEvent] = $arConfig;
                     }
                 }
             }
         }
     }
     return self::$arNotifySchema;
 }
Example #2
0
 public static function GetNotifySchema()
 {
     if (is_null(self::$arNotifySchema)) {
         self::$arNotifySchema = array();
         foreach (GetModuleEvents("im", "OnGetNotifySchema", true) as $arEvent) {
             $ar = ExecuteModuleEventEx($arEvent);
             if (is_array($ar)) {
                 foreach ($ar as $moduleId => $arNotifyType) {
                     self::$arNotifySchema[$moduleId]['NAME'] = isset($arNotifyType['NOTIFY']) && isset($arNotifyType['NAME']) ? $arNotifyType['NAME'] : '';
                     $arNotify = $arNotifyType;
                     if (isset($arNotifyType['NOTIFY'])) {
                         $arNotify = $arNotifyType['NOTIFY'];
                     }
                     foreach ($arNotify as $notifyEvent => $arConfig) {
                         $arConfig['SITE'] = true;
                         $arConfig['MAIL'] = true;
                         $arConfig['XMPP'] = true;
                         self::$arNotifySchema[$moduleId]['NOTIFY'][$notifyEvent] = $arConfig;
                     }
                 }
             }
         }
     }
     return self::$arNotifySchema;
 }
 public static function GetNotifySchema()
 {
     if (is_null(self::$arNotifySchema)) {
         self::$arNotifySchema = array();
         foreach (GetModuleEvents("im", "OnGetNotifySchema", true) as $arEvent) {
             $ar = ExecuteModuleEventEx($arEvent);
             if (is_array($ar)) {
                 foreach ($ar as $moduleId => $arNotifyType) {
                     foreach ($arNotifyType as $notifyEvent => $arConfig) {
                         $arConfig['ID'] = $notifyEvent;
                         self::$arNotifySchema[$moduleId][$notifyEvent] = $arConfig;
                     }
                 }
             }
         }
     }
     return self::$arNotifySchema;
 }
Example #4
0
 public static function GetSimpleNotifyBlocked($byModule = false)
 {
     $arNotifyBlocked = array();
     $arSettings = self::Get();
     if ($arSettings[self::SETTINGS]['notifyScheme'] == 'expert') {
         foreach ($arSettings[self::NOTIFY] as $key => $value) {
             if ($value === false) {
                 list($clientId, $moduleId, $notifyId) = explode('|', $key, 3);
                 if ($clientId == self::CLIENT_SITE) {
                     if (CIMNotifySchema::CheckDisableFeature($moduleId, $notifyId, $clientId)) {
                         continue;
                     }
                     if ($byModule) {
                         $arNotifyBlocked[$moduleId][$notifyId] = false;
                     } else {
                         $arNotifyBlocked[$moduleId . '|' . $notifyId] = false;
                     }
                 }
             }
         }
     } else {
         foreach ($arSettings[self::NOTIFY] as $key => $value) {
             if ($value === false) {
                 list($clientId, $moduleId, $notifyId) = explode('|', $key, 3);
                 if (in_array($clientId, array('push', 'important', 'disabled'))) {
                     continue;
                 }
                 if ($clientId == self::CLIENT_SITE) {
                     if (CIMNotifySchema::CheckDisableFeature($moduleId, $notifyId, $clientId)) {
                         continue;
                     }
                     if ($byModule) {
                         $arNotifyBlocked[$moduleId][$notifyId] = false;
                     } else {
                         $arNotifyBlocked[$moduleId . '|' . $notifyId] = false;
                     }
                 }
             }
         }
     }
     return $arNotifyBlocked;
 }
Example #5
0
 public static function MailNotifyAgent()
 {
     global $DB;
     $defSiteID = CSite::GetDefSite();
     $arMark = array();
     $arGroupNotify = array();
     $arGroupNotifyUser = array();
     $arUnsendNotify = CIMNotify::GetUnsendNotify();
     foreach ($arUnsendNotify as $id => $arNotify) {
         if (!isset($arMark[$arNotify["CHAT_ID"]]) || $arMark[$arNotify["CHAT_ID"]] < $arNotify["ID"]) {
             $arMark[$arNotify["CHAT_ID"]] = $arNotify["ID"];
         }
         if ($arNotify['TO_USER_ACTIVE'] != 'Y') {
             unset($arUnsendNotify[$id]);
             continue;
         }
         if (isset($arNotify["NOTIFY_MODULE"]) && isset($arNotify["NOTIFY_EVENT"]) && !CIMNotifySchema::CheckEnableFeature($arNotify["NOTIFY_MODULE"], $arNotify["NOTIFY_EVENT"], IM_FEATURE_MAIL)) {
             unset($arUnsendNotify[$id]);
             continue;
         }
         $siteID = $arNotify["TO_USER_LID"];
         if ($siteID == false || StrLen($siteID) <= 0) {
             $siteID = $defSiteID;
             if ($siteID == false || StrLen($siteID) <= 0) {
                 unset($arUnsendNotify[$id]);
                 continue;
             }
         }
         if (strlen($arNotify["MESSAGE_OUT"]) <= 0) {
             $arNotify["MESSAGE_OUT"] = $arNotify["MESSAGE"];
         }
         if (!(isset($arNotify["EMAIL_TEMPLATE"]) && strlen($arNotify["EMAIL_TEMPLATE"]) > 0)) {
             $arNotify["EMAIL_TEMPLATE"] = "IM_NEW_NOTIFY";
         }
         $arNotify["USER"] = htmlspecialcharsback(CUser::FormatName(CSite::GetNameFormat(false), array("NAME" => $arNotify["TO_USER_NAME"], "LAST_NAME" => $arNotify["TO_USER_LAST_NAME"], "SECOND_NAME" => $arNotify["TO_USER_SECOND_NAME"], "LOGIN" => $arNotify["TO_USER_LOGIN"]), true));
         $arNotify["FROM_USER"] = htmlspecialcharsback(CUser::FormatName(CSite::GetNameFormat(false), array("NAME" => $arNotify["FROM_USER_NAME"], "LAST_NAME" => $arNotify["FROM_USER_LAST_NAME"], "SECOND_NAME" => $arNotify["FROM_USER_SECOND_NAME"], "LOGIN" => $arNotify["FROM_USER_LOGIN"]), true));
         $arNotify['NOTIFY_TAG_MD5'] = md5($arNotify['NOTIFY_TAG']);
         if ($arNotify["EMAIL_TEMPLATE"] == "IM_NEW_NOTIFY" && $arNotify['NOTIFY_TAG'] != '') {
             if (isset($arGroupNotify[$arNotify['NOTIFY_TAG_MD5']])) {
                 $arGroupNotifyUser[$arNotify['NOTIFY_TAG_MD5']][$arNotify["FROM_USER_ID"]] = $arNotify["FROM_USER"];
                 unset($arUnsendNotify[$id]);
             } else {
                 $arGroupNotifyUser[$arNotify['NOTIFY_TAG_MD5']][$arNotify["FROM_USER_ID"]] = $arNotify["FROM_USER"];
                 $arGroupNotify[$arNotify['NOTIFY_TAG_MD5']] = true;
             }
         }
         $arUnsendNotify[$id] = $arNotify;
     }
     foreach ($arMark as $chatId => $lastSendId) {
         CIMNotify::SetLastSendId($chatId, $lastSendId);
     }
     $CTP = new CTextParser();
     foreach ($arUnsendNotify as $id => $arNotify) {
         $arFields = array("MESSAGE_ID" => $arNotify["ID"], "USER" => $arNotify["USER"], "USER_ID" => $arNotify["TO_USER_ID"], "USER_LOGIN" => $arNotify["TO_USER_LOGIN"], "USER_NAME" => $arNotify["TO_USER_NAME"], "USER_LAST_NAME" => $arNotify["TO_USER_LAST_NAME"], "USER_SECOND_NAME" => $arNotify["TO_USER_SECOND_NAME"], "DATE_CREATE" => $arNotify["DATE_CREATE"], "FROM_USER_ID" => $arNotify["FROM_USER_ID"], "FROM_USER_LOGIN" => $arNotify["FROM_USER_LOGIN"], "FROM_USER" => $arNotify["FROM_USER"], "SENDER_ID" => $arNotify["FROM_USER_ID"], "SENDER_LOGIN" => $arNotify["FROM_USER_LOGIN"], "SENDER_NAME" => $arNotify["FROM_USER_NAME"], "SENDER_LAST_NAME" => $arNotify["FROM_USER_LAST_NAME"], "SENDER_SECOND_NAME" => $arNotify["FROM_USER_SECOND_NAME"], "EMAIL_TO" => $arNotify["TO_USER_EMAIL"], "TITLE" => trim($arNotify["NOTIFY_TITLE"]), "MESSAGE" => CTextParser::convert4mail(str_replace("#BR#", "\n", strip_tags($arNotify["MESSAGE_OUT"]))), "MESSAGE_50" => $CTP->html_cut(str_replace(array("<br>", "<br/>", "<br />", "#BR#"), array(" ", " ", " ", " "), nl2br(CTextParser::convert4mail(strip_tags($arNotify["MESSAGE_OUT"])))), 50));
         if (strlen($arFields['TITLE']) > 0) {
             $arFields["MESSAGE_50"] = $arFields['TITLE'];
         } else {
             $arFields["TITLE"] = $arFields['MESSAGE_50'];
         }
         if (isset($arGroupNotifyUser[$arNotify['NOTIFY_TAG_MD5']]) && count($arGroupNotifyUser[$arNotify['NOTIFY_TAG_MD5']]) > 1) {
             $arNotify["EMAIL_TEMPLATE"] = "IM_NEW_NOTIFY_GROUP";
             $arFields['FROM_USERS'] = implode(', ', $arGroupNotifyUser[$arNotify['NOTIFY_TAG_MD5']]);
             unset($arFields['FROM_USER']);
         }
         $event = new CEvent();
         $event->Send($arNotify["EMAIL_TEMPLATE"], $siteID, $arFields, "N");
     }
     return "CIMMail::MailNotifyAgent();";
 }
Example #6
0
 public static function GetNotifyNames()
 {
     $arNames = array();
     $arNotify = CIMNotifySchema::GetNotifySchema();
     foreach ($arNotify as $moduleId => $notifyTypes) {
         $arNames[$moduleId]['NAME'] = $notifyTypes['NAME'];
         if (strlen($notifyTypes['NAME']) <= 0) {
             $info = CModule::CreateModuleObject($moduleId);
             $arNames[$moduleId]['NAME'] = $info->MODULE_NAME;
         }
         foreach ($notifyTypes['NOTIFY'] as $notifyId => $notify) {
             $arNames[$moduleId]['NOTIFY'][$notifyId] = $notify['NAME'];
         }
     }
     return $arNames;
 }