コード例 #1
0
ファイル: im_notify.php プロジェクト: DarneoStudio/bitrix
 public static function DeleteBySubTag($notifySubTag, $authorId = false)
 {
     global $DB;
     if (strlen($notifySubTag) <= 0) {
         return false;
     }
     $sqlUser = "";
     $sqlUser2 = "";
     if ($authorId !== false) {
         $sqlUser = "******" . intval($authorId);
         $sqlUser2 = " AND AUTHOR_ID = " . intval($authorId);
     }
     $dbRes = $DB->Query("SELECT M.ID, M.NOTIFY_TYPE, R.USER_ID, R.STATUS FROM b_im_relation R, b_im_message M WHERE M.CHAT_ID = R.CHAT_ID AND M.NOTIFY_SUB_TAG = '" . $DB->ForSQL($notifySubTag) . "'" . $sqlUser, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $arUsers = array();
     $messages = array();
     while ($row = $dbRes->Fetch()) {
         $messages[$row['ID']] = $row['NOTIFY_TYPE'];
         $count = $row['STATUS'] < IM_STATUS_READ ? 1 : 0;
         if (isset($arUsers[$row['USER_ID']])) {
             $arUsers[$row['USER_ID']] += $count;
         } else {
             $arUsers[$row['USER_ID']] = $count;
         }
     }
     $pullActive = false;
     if (CModule::IncludeModule("pull")) {
         $pullActive = true;
     }
     $arUsersSend = array();
     foreach ($arUsers as $userId => $count) {
         CIMMessenger::SpeedFileDelete($userId, IM_SPEED_NOTIFY);
         if ($count > 0) {
             $arUsersSend[] = $userId;
             //CUserCounter::Decrement($userId, 'im_notify_v2', '**', false);
         }
         if ($pullActive) {
             CPushManager::DeleteFromQueueBySubTag($userId, $notifySubTag);
         }
     }
     if ($pullActive) {
         CPullStack::AddByUsers(array_keys($arUsers), array('module_id' => 'im', 'command' => 'massDeleteMessage', 'params' => array('MESSAGE' => $messages)));
     }
     if (count($messages) > 0) {
         $messageParameters = IM\MessageParamTable::getList(array('select' => array('ID'), 'filter' => array('=MESSAGE_ID' => array_keys($messages))));
         while ($ar = $messageParameters->fetch()) {
             IM\MessageParamTable::delete($ar['ID']);
         }
         $strSql = "DELETE FROM b_im_message WHERE NOTIFY_SUB_TAG = '" . $DB->ForSQL($notifySubTag) . "'" . $sqlUser2;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     CIMMessenger::SendBadges($arUsersSend);
     return true;
 }
コード例 #2
0
ファイル: im_message_param.php プロジェクト: Satariall/izurit
 public static function Set($messageId, $params = array())
 {
     global $DB;
     $messageId = intval($messageId);
     if (!(is_array($params) || is_null($params)) || $messageId <= 0) {
         return false;
     }
     if (is_null($params) || count($params) <= 0) {
         $messageParameters = IM\MessageParamTable::getList(array('select' => array('ID'), 'filter' => array('=MESSAGE_ID' => $messageId)));
         while ($parameterInfo = $messageParameters->fetch()) {
             IM\MessageParamTable::delete($parameterInfo['ID']);
         }
         return true;
     }
     $default = self::GetDefault();
     $arToDelete = array();
     foreach ($params as $key => $val) {
         if (isset($default[$key]) && $default[$key] == $val) {
             $arToDelete[$key] = array("=MESSAGE_ID" => $messageId, "=PARAM_NAME" => $key);
         }
     }
     $arToInsert = array();
     foreach ($params as $k1 => $v1) {
         $name = substr(trim($k1), 0, 100);
         if (strlen($name)) {
             if (!is_array($v1)) {
                 $v1 = array($v1);
             }
             if (empty($v1)) {
                 $arToDelete[$name] = array("=MESSAGE_ID" => $messageId, "=PARAM_NAME" => $name);
             } else {
                 foreach ($v1 as $v2) {
                     $value = substr(trim($v2), 0, 100);
                     if (strlen($value)) {
                         $key = md5($name) . md5($value);
                         $arToInsert[$key] = array("MESSAGE_ID" => $messageId, "PARAM_NAME" => $name, "PARAM_VALUE" => $value);
                     }
                 }
             }
         }
     }
     if (!empty($arToInsert)) {
         $messageParameters = IM\MessageParamTable::getList(array('select' => array('ID', 'PARAM_NAME', 'PARAM_VALUE'), 'filter' => array('=MESSAGE_ID' => $messageId)));
         while ($ar = $messageParameters->fetch()) {
             $key = md5($ar["PARAM_NAME"]) . md5($ar["PARAM_VALUE"]);
             if (array_key_exists($key, $arToInsert)) {
                 unset($arToInsert[$key]);
             } else {
                 if (isset($params[$ar["PARAM_NAME"]])) {
                     IM\MessageParamTable::delete($ar['ID']);
                 }
             }
         }
     }
     foreach ($arToInsert as $parameterInfo) {
         IM\MessageParamTable::add($parameterInfo);
     }
     foreach ($arToDelete as $filter) {
         $messageParameters = IM\MessageParamTable::getList(array('select' => array('ID'), 'filter' => $filter));
         while ($parameterInfo = $messageParameters->fetch()) {
             IM\MessageParamTable::delete($parameterInfo['ID']);
         }
     }
 }
コード例 #3
0
 public static function GetMessageIdByParam($paramName, $paramValue)
 {
     $arResult = array();
     if (strlen($paramName) <= 0 || strlen($paramValue) <= 0) {
         return $arResult;
     }
     $messageParameters = IM\MessageParamTable::getList(array('select' => array('MESSAGE_ID'), 'filter' => array('=PARAM_NAME' => $paramName, '=PARAM_VALUE' => $paramValue)));
     while ($ar = $messageParameters->fetch()) {
         $arResult[] = $ar["MESSAGE_ID"];
     }
     return $arResult;
 }