本文整理汇总了PHP中CPullStack::AddByChannel方法的典型用法代码示例。如果您正苦于以下问题:PHP CPullStack::AddByChannel方法的具体用法?PHP CPullStack::AddByChannel怎么用?PHP CPullStack::AddByChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPullStack
的用法示例。
在下文中一共展示了CPullStack::AddByChannel方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Delete
public static function Delete($channelId)
{
global $DB;
$arMessage = array('module_id' => 'pull', 'command' => 'channel_die', 'params' => '');
CPullStack::AddByChannel($channelId, $arMessage);
$strSql = "DELETE FROM b_pull_channel WHERE CHANNEL_ID = '" . $DB->ForSQL($channelId) . "'";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
return true;
}
示例2: AddToStack
public static function AddToStack($tag, $arMessage)
{
global $DB;
$result = false;
$strSql = "SELECT CHANNEL_ID FROM b_pull_watch WHERE TAG = '" . $DB->ForSQL($tag) . "'";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($arRes = $dbRes->Fetch()) {
$result = CPullStack::AddByChannel($arRes['CHANNEL_ID'], $arMessage);
if (!$result) {
break;
}
}
return !$result ? false : true;
}
示例3: IncrementWithSelect
public static function IncrementWithSelect($sub_select, $sendPull = true)
{
global $DB, $CACHE_MANAGER, $APPLICATION;
if (strlen($sub_select) > 0)
{
$pullInclude = $sendPull && self::CheckLiveMode();
$strSQL = "
INSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE, SENT) (".$sub_select.")
ON DUPLICATE KEY UPDATE CNT = CNT + VALUES(CNT), SENT = VALUES(SENT)
";
$DB->Query($strSQL, false, "FILE: ".__FILE__."<br> LINE: ".__LINE__);
self::$counters = false;
$CACHE_MANAGER->CleanDir("user_counter");
if ($pullInclude)
{
$db_lock = $DB->Query("SELECT GET_LOCK('".$APPLICATION->GetServerUniqID()."_pull', 0) as L");
$ar_lock = $db_lock->Fetch();
if($ar_lock["L"] > 0)
{
$arSites = Array();
$res = CSite::GetList(($b = ""), ($o = ""), Array("ACTIVE" => "Y"));
while($row = $res->Fetch())
$arSites[] = $row['ID'];
$strSQL = "
SELECT distinct pc.CHANNEL_ID, uc1.USER_ID, uc1.SITE_ID, uc1.CODE, uc1.CNT
FROM b_user_counter uc
INNER JOIN b_user_counter uc1 ON uc1.USER_ID = uc.USER_ID AND uc1.CODE = uc.CODE
INNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID
WHERE uc.SENT = '0'
";
$res = $DB->Query($strSQL, false, "FILE: ".__FILE__."<br> LINE: ".__LINE__);
$pullMessage = Array();
while($row = $res->Fetch())
{
if ($row['SITE_ID'] == '**')
{
foreach($arSites as $siteId)
{
if (isset($pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']]))
$pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] += intval($row['CNT']);
else
$pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] = intval($row['CNT']);
}
}
else
{
if (isset($pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']]))
$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] += intval($row['CNT']);
else
$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] = intval($row['CNT']);
}
}
$DB->Query("UPDATE b_user_counter SET SENT = '1' WHERE SENT = '0'");
$DB->Query("SELECT RELEASE_LOCK('".$APPLICATION->GetServerUniqID()."_pull')");
foreach ($pullMessage as $channelId => $arMessage)
{
CPullStack::AddByChannel($channelId, Array(
'module_id' => 'main',
'command' => 'user_counter',
'params' => $arMessage,
));
}
}
}
}
}
示例4: AddToStack
public static function AddToStack($tag, $arMessage)
{
global $DB;
$arPush = array();
if (isset($arMessage['push'])) {
$arPush = $arMessage['push'];
unset($arMessage['push']);
}
$channels = array();
$strSql = "\n\t\t\t\tSELECT pc.CHANNEL_ID, pc.USER_ID\n\t\t\t\tFROM b_pull_watch pw\n\t\t\t\tLEFT JOIN b_pull_channel pc ON pw.USER_ID = pc.USER_ID\n\t\t\t\tWHERE pw.TAG = '" . $DB->ForSQL($tag) . "'\n\t\t";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($arRes = $dbRes->Fetch()) {
$channels[$arRes['USER_ID']] = $arRes['CHANNEL_ID'];
}
$result = CPullStack::AddByChannel($channels, $arMessage);
if ($result && !empty($arPush) && (isset($arPush['advanced_params']) || isset($arPush['message']) && strlen($arPush['message']) > 0)) {
$CPushManager = new CPushManager();
$pushUsers = array();
foreach ($channels as $userId => $channelId) {
if (isset($arPush['skip_users']) && in_array($userId, $arPush['skip_users'])) {
continue;
}
$pushUsers[] = $userId;
}
$CPushManager->AddQueue(array('USER_ID' => $pushUsers, 'MESSAGE' => str_replace("\n", " ", $arPush['message']), 'PARAMS' => $arPush['params'], 'ADVANCED_PARAMS' => isset($arPush['advanced_params']) ? $arPush['advanced_params'] : array(), 'BADGE' => isset($arPush['badge']) ? intval($arPush['badge']) : '', 'SOUND' => isset($arPush['sound']) ? $arPush['sound'] : '', 'TAG' => isset($arPush['tag']) ? $arPush['tag'] : '', 'SUB_TAG' => isset($arPush['sub_tag']) ? $arPush['sub_tag'] : '', 'APP_ID' => isset($arPush['app_id']) ? $arPush['app_id'] : '', 'SEND_IMMEDIATELY' => isset($arPush['send_immediately']) && $arPush['send_immediately'] == 'Y' ? 'Y' : 'N'));
}
return true;
}
示例5: SendPullEvent
protected static function SendPullEvent($user_id, $code = "")
{
$user_id = intval($user_id);
if ($user_id <= 0)
return false;
if (self::CheckLiveMode())
{
global $DB;
$arSites = Array();
$res = CSite::GetList(($b = ""), ($o = ""), Array("ACTIVE" => "Y"));
while ($row = $res->Fetch())
$arSites[] = $row['ID'];
$strSQL = "
SELECT pc.CHANNEL_ID, uc.USER_ID, uc.SITE_ID, uc.CODE, uc.CNT
FROM b_user_counter uc
INNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID
WHERE uc.USER_ID = ".intval($user_id).(strlen($code) > 0? " AND uc.CODE = '".$DB->ForSQL($code)."'": "")."
";
$res = $DB->Query($strSQL, false, "FILE: ".__FILE__."<br> LINE: ".__LINE__);
$pullMessage = Array();
while ($row = $res->Fetch())
{
if ($row['SITE_ID'] == '**')
{
foreach ($arSites as $siteId)
{
if (isset($pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']]))
$pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] += intval($row['CNT']);
else
$pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] = intval($row['CNT']);
}
}
else
{
if (isset($pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']]))
$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] += intval($row['CNT']);
else
$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] = intval($row['CNT']);
}
}
foreach ($pullMessage as $channelId => $arMessage)
{
CPullStack::AddByChannel($channelId, Array(
'module_id' => 'main',
'command' => 'user_counter',
'params' => $arMessage,
));
}
}
}
示例6: DeleteByUser
public static function DeleteByUser($userId, $channelId = null, $channelType = '')
{
global $DB, $CACHE_MANAGER;
$userId = intval($userId);
if ($userId == 0 && $channelType == 'private')
{
$channelType = 'shared';
}
if (is_null($channelId))
{
$strSql = "SELECT CHANNEL_ID, CHANNEL_TYPE FROM b_pull_channel WHERE USER_ID = ".$userId." AND CHANNEL_TYPE = '".$DB->ForSQL($channelType)."'";
$res = $DB->Query($strSql);
if ($arRes = $res->Fetch())
{
$channelId = $arRes['CHANNEL_ID'];
$channelType = $arRes['CHANNEL_TYPE'];
}
}
if (strlen($channelType) <= 0)
$channelTypeSql = "(CHANNEL_TYPE = '' OR CHANNEL_TYPE IS NULL)";
else
$channelTypeSql = "CHANNEL_TYPE = '".$DB->ForSQL($channelType)."'";
$strSql = "DELETE FROM b_pull_channel WHERE USER_ID = ".$userId." AND ".$channelTypeSql;
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
$CACHE_MANAGER->Clean("b_pchc_".$userId."_".$channelType, "b_pull_channel");
$newChannelId = '';
$newChannelDesc = 'delete by user';
if ($channelType == 'shared')
{
$result = self::GetShared(false);
if ($result)
{
$newChannelId = Array('PREV_CHANNEL_ID' => $channelId, 'CHANNEL_ID' => $result['CHANNEL_ID'], 'CHANNEL_DIE' => $result['CHANNEL_DT']);
$newChannelDesc = 'replace by user';
}
}
$arMessage = Array(
'module_id' => 'pull',
'command' => 'channel_die',
'params' => Array(
'replace' => $newChannelId,
'from' => $newChannelDesc
)
);
CPullStack::AddByChannel($channelId, $arMessage);
return true;
}
示例7: AddToStack
public static function AddToStack($tag, $arMessage)
{
global $DB;
$arChannels = array();
$strSql = "\n\t\t\t\tSELECT pc.CHANNEL_ID\n\t\t\t\tFROM b_pull_watch pw\n\t\t\t\tLEFT JOIN b_pull_channel pc ON pw.USER_ID = pc.USER_ID\n\t\t\t\tWHERE pw.TAG = '" . $DB->ForSQL($tag) . "'\n\t\t";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($arRes = $dbRes->Fetch()) {
$arChannels[] = $arRes['CHANNEL_ID'];
}
$result = CPullStack::AddByChannel($arChannels, $arMessage);
if (!$result) {
return false;
}
return true;
}
示例8: DeleteByCode
public static function DeleteByCode($code)
{
global $DB, $APPLICATION, $CACHE_MANAGER;
if (strlen($code) <= 0) {
return false;
}
$pullMessage = array();
$bPullEnabled = false;
if (self::CheckLiveMode()) {
$db_lock = $DB->Query("SELECT GET_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull', 0) as L");
$ar_lock = $db_lock->Fetch();
if ($ar_lock["L"] > 0) {
$bPullEnabled = true;
$arSites = array();
$res = CSite::GetList($b = "", $o = "", array("ACTIVE" => "Y"));
while ($row = $res->Fetch()) {
$arSites[] = $row['ID'];
}
$strSQL = "\n\t\t\t\t\tSELECT distinct pc.CHANNEL_ID, uc.USER_ID, uc.SITE_ID, uc.CODE, uc.CNT\n\t\t\t\t\tFROM b_user_counter uc\n\t\t\t\t\tINNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID\n\t\t\t\t\tWHERE uc.CODE LIKE '**%'\n\t\t\t\t";
$res = $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
while ($row = $res->Fetch()) {
if ($row["CODE"] == $code) {
continue;
}
CUserCounter::addValueToPullMessage($row, $arSites, $pullMessage);
}
}
}
$DB->Query("DELETE FROM b_user_counter WHERE CODE = '" . $code . "'", false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
self::$counters = false;
$CACHE_MANAGER->CleanDir("user_counter");
if ($bPullEnabled) {
$DB->Query("SELECT RELEASE_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull')");
}
foreach ($pullMessage as $channelId => $arMessage) {
CPullStack::AddByChannel($channelId, array('module_id' => 'main', 'command' => 'user_counter', 'params' => $arMessage));
}
}
示例9: SendPullEvent
protected static function SendPullEvent($user_id, $code = "", $bMultiple = false)
{
$user_id = intval($user_id);
if ($user_id < 0) {
return false;
}
if (self::CheckLiveMode()) {
global $DB;
$arSites = array();
$res = CSite::GetList($b = "", $o = "", array("ACTIVE" => "Y"));
while ($row = $res->Fetch()) {
$arSites[] = $row['ID'];
}
$strSQL = "\n\t\t\t\tSELECT pc.CHANNEL_ID, pc.CHANNEL_TYPE, uc.USER_ID, uc.SITE_ID, uc.CODE, uc.CNT\n\t\t\t\tFROM b_user_counter uc\n\t\t\t\tINNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID\n\t\t\t\tWHERE uc.USER_ID = " . intval($user_id) . (strlen($code) > 0 ? $bMultiple ? " AND uc.CODE LIKE '" . $DB->ForSQL($code) . "%'" : " AND uc.CODE = '" . $DB->ForSQL($code) . "'" : "") . "\n\t\t\t";
$res = $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
$pullMessage = array();
while ($row = $res->Fetch()) {
$key = strlen($code) > 0 ? $code : $row['CODE'];
if (!($row['CHANNEL_TYPE'] == 'private' || $row['CHANNEL_TYPE'] == 'shared' && $row['USER_ID'] == 0)) {
continue;
}
if ($row['SITE_ID'] == self::ALL_SITES) {
foreach ($arSites as $siteId) {
if (isset($pullMessage[$row['CHANNEL_ID']][$siteId][$key])) {
$pullMessage[$row['CHANNEL_ID']][$siteId][$key] += intval($row['CNT']);
} else {
$pullMessage[$row['CHANNEL_ID']][$siteId][$key] = intval($row['CNT']);
}
}
} else {
if (isset($pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$key])) {
$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$key] += intval($row['CNT']);
} else {
$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$key] = intval($row['CNT']);
}
}
}
foreach ($pullMessage as $channelId => $arMessage) {
CPullStack::AddByChannel($channelId, array('module_id' => 'main', 'command' => 'user_counter', 'expiry' => 3600, 'params' => $arMessage));
}
}
}
示例10: DeleteByUser
public static function DeleteByUser($userId, $channelId = null)
{
global $DB, $CACHE_MANAGER;
$userId = intval($userId);
if (is_null($channelId))
{
$strSql = "SELECT CHANNEL_ID FROM b_pull_channel WHERE USER_ID = ".$userId;
$res = $DB->Query($strSql);
if ($arRes = $res->Fetch())
$channelId = $arRes['CHANNEL_ID'];
}
$strSql = "DELETE FROM b_pull_channel WHERE CHANNEL_ID = '".$DB->ForSql($channelId)."'";
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
$CACHE_MANAGER->Clean("b_pchc_".$userId, "b_pull_channel");
$arMessage = Array(
'module_id' => 'pull',
'command' => 'channel_die',
'params' => Array('from' => 'delete by user')
);
CPullStack::AddByChannel($channelId, $arMessage);
return true;
}
示例11: IncrementWithSelect
public static function IncrementWithSelect($sub_select, $sendPull = true, $arParams = array())
{
global $DB, $CACHE_MANAGER, $APPLICATION;
if (strlen($sub_select) > 0) {
$pullInclude = $sendPull && self::CheckLiveMode();
if (is_array($arParams) && isset($arParams["TAG_SET"])) {
$strSQL = "\n\t\t\t\t\tINSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE, SENT, TAG) (" . $sub_select . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE CNT = CNT + VALUES(CNT), SENT = VALUES(SENT), TAG = '" . $DB->ForSQL($arParams["TAG_SET"]) . "'\n\t\t\t\t";
} elseif (is_array($arParams) && isset($arParams["TAG_CHECK"])) {
$strSQL = "\n\t\t\t\t\tINSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE, SENT) (" . $sub_select . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE CNT = CASE\n\t\t\t\t\t\tWHEN\n\t\t\t\t\t\t\tTAG = '" . $DB->ForSQL($arParams["TAG_CHECK"]) . "'\n\t\t\t\t\t\tTHEN\n\t\t\t\t\t\t\tCNT\n\n\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\tCNT + VALUES(CNT)\n\t\t\t\t\t\tEND,\n\t\t\t\t\t\tSENT = CASE\n\t\t\t\t\t\tWHEN\n\t\t\t\t\t\t\tTAG = '" . $DB->ForSQL($arParams["TAG_CHECK"]) . "'\n\t\t\t\t\t\tTHEN\n\t\t\t\t\t\t\tSENT\n\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\tSENT = VALUES(SENT)\n\t\t\t\t\t\tEND\n\t\t\t\t";
} else {
$strSQL = "\n\t\t\t\t\tINSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE, SENT) (" . $sub_select . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE CNT = CNT + VALUES(CNT), SENT = VALUES(SENT)\n\t\t\t\t";
}
$DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
if (!is_array($arParams) || !isset($arParams["TAG_SET"])) {
self::$counters = false;
$CACHE_MANAGER->CleanDir("user_counter");
}
if ($pullInclude) {
$db_lock = $DB->Query("SELECT GET_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull', 0) as L");
$ar_lock = $db_lock->Fetch();
if ($ar_lock["L"] > 0) {
$arSites = array();
$res = CSite::GetList($b = "", $o = "", array("ACTIVE" => "Y"));
while ($row = $res->Fetch()) {
$arSites[] = $row['ID'];
}
$strSQL = "\n\t\t\t\t\t\tSELECT distinct pc.CHANNEL_ID, uc1.USER_ID, uc1.SITE_ID, uc1.CODE, uc1.CNT\n\t\t\t\t\t\tFROM b_user_counter uc\n\t\t\t\t\t\tINNER JOIN b_user_counter uc1 ON uc1.USER_ID = uc.USER_ID AND uc1.CODE = uc.CODE\n\t\t\t\t\t\tINNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID\n\t\t\t\t\t\tWHERE uc.SENT = '0'\n\t\t\t\t\t";
$res = $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
$pullMessage = array();
while ($row = $res->Fetch()) {
if ($row['SITE_ID'] == self::ALL_SITES) {
foreach ($arSites as $siteId) {
if (isset($pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']])) {
$pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] += intval($row['CNT']);
} else {
$pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] = intval($row['CNT']);
}
}
} else {
if (isset($pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']])) {
$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] += intval($row['CNT']);
} else {
$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] = intval($row['CNT']);
}
}
}
$DB->Query("UPDATE b_user_counter SET SENT = '1' WHERE SENT = '0'");
$DB->Query("SELECT RELEASE_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull')");
foreach ($pullMessage as $channelId => $arMessage) {
CPullStack::AddByChannel($channelId, array('module_id' => 'main', 'command' => 'user_counter', 'params' => $arMessage));
}
}
}
}
}
示例12: DeleteByUser
public static function DeleteByUser($userId, $channelId = null, $channelType = '')
{
global $DB, $CACHE_MANAGER;
$userId = intval($userId);
if ($userId == 0 && $channelType == 'private') {
$channelType = 'shared';
}
if (is_null($channelId)) {
$strSql = "SELECT CHANNEL_ID, CHANNEL_TYPE FROM b_pull_channel WHERE USER_ID = " . $userId . " AND CHANNEL_TYPE = '" . $DB->ForSQL($channelType) . "'";
$res = $DB->Query($strSql);
if ($arRes = $res->Fetch()) {
$channelId = $arRes['CHANNEL_ID'];
$channelType = $arRes['CHANNEL_TYPE'];
}
}
if (strlen($channelType) <= 0) {
$channelType = "(CHANNEL_TYPE = '' OR CHANNEL_TYPE IS NULL)";
} else {
$channelType = "CHANNEL_TYPE = '" . $DB->ForSQL($channelType) . "'";
}
$strSql = "DELETE FROM b_pull_channel WHERE USER_ID = " . $userId . " AND " . $channelType;
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$CACHE_MANAGER->Clean("b_pchc_" . $userId . "_" . $channelType, "b_pull_channel");
$arMessage = array('module_id' => 'pull', 'command' => 'channel_die', 'params' => array('from' => 'delete by user'));
CPullStack::AddByChannel($channelId, $arMessage);
return true;
}