本文整理汇总了PHP中CUserCounter::Increment方法的典型用法代码示例。如果您正苦于以下问题:PHP CUserCounter::Increment方法的具体用法?PHP CUserCounter::Increment怎么用?PHP CUserCounter::Increment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUserCounter
的用法示例。
在下文中一共展示了CUserCounter::Increment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delegateTask
public static function delegateTask($taskId, $fromUserId, $toUserId)
{
global $DB;
$taskId = (int) $taskId;
$fromUserId = (int) $fromUserId;
$toUserId = (int) $toUserId;
if (!$taskId || !$fromUserId || !$toUserId) {
return false;
}
$originalUserId = 0;
//check ORIGINAL_USER_ID
$iterator = $DB->Query('SELECT ORIGINAL_USER_ID' . ' FROM b_bp_task_user' . ' WHERE TASK_ID = ' . $taskId . ' AND USER_ID = ' . $fromUserId);
$row = $iterator->fetch();
if (!empty($row['ORIGINAL_USER_ID'])) {
$originalUserId = $row['ORIGINAL_USER_ID'];
}
// check USER_ID (USER_ID must be unique for task)
$iterator = $DB->Query('SELECT USER_ID' . ' FROM b_bp_task_user' . ' WHERE TASK_ID = ' . $taskId . ' AND USER_ID = ' . $toUserId);
$row = $iterator->fetch();
if (!empty($row['USER_ID'])) {
return false;
}
$DB->Query("UPDATE b_bp_task_user SET USER_ID = " . $toUserId . (!$originalUserId ? ', ORIGINAL_USER_ID = ' . $fromUserId : '') . " WHERE TASK_ID = " . $taskId . " AND USER_ID = " . $fromUserId, true);
CUserCounter::Decrement($fromUserId, 'bp_tasks', '**');
CUserCounter::Increment($toUserId, 'bp_tasks', '**');
self::onTaskChange($taskId, array('USERS' => array($toUserId), 'USERS_REMOVED' => array($fromUserId)), CBPTaskChangedStatus::Delegate);
return true;
}
示例2: Update
public static function Update($id, $arFields)
{
global $DB;
$id = intval($id);
if ($id <= 0) {
throw new Exception("id");
}
self::ParseFields($arFields, $id);
$strUpdate = $DB->PrepareUpdate("b_bp_task", $arFields);
$strSql = "UPDATE b_bp_task SET " . "\t" . $strUpdate . ", " . "\tMODIFIED = " . $DB->CurrentTimeFunction() . " " . "WHERE ID = " . intval($id) . " ";
$DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (is_set($arFields, "USERS")) {
$DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " ");
CUserCounter::ClearByTag($id, 'bp_tasks', '**');
$ar = array();
foreach ($arFields["USERS"] as $userId) {
$userId = intval($userId);
if (in_array($userId, $ar)) {
continue;
}
$DB->Query("INSERT INTO b_bp_task_user (USER_ID, TASK_ID) " . "VALUES (" . intval($userId) . ", " . intval($id) . ") ");
CUserCounter::Increment($userId, 'bp_tasks', '**');
$ar[] = $userId;
}
}
$events = GetModuleEvents("bizproc", "OnTaskUpdate");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($id, $arFields));
}
return $id;
}
示例3: Update
public static function Update($id, $arFields)
{
global $DB;
$id = intval($id);
if ($id <= 0) {
throw new Exception("id");
}
self::ParseFields($arFields, $id);
$strUpdate = $DB->PrepareUpdate("b_bp_task", $arFields);
$strSql = "UPDATE b_bp_task SET " . "\t" . $strUpdate . ", " . "\tMODIFIED = " . $DB->CurrentTimeFunction() . " " . "WHERE ID = " . intval($id) . " ";
$DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$removedUsers = array();
if (is_set($arFields, "USERS")) {
$dbResUser = $DB->Query("SELECT USER_ID FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " ");
while ($arResUser = $dbResUser->Fetch()) {
CUserCounter::Decrement($arResUser["USER_ID"], 'bp_tasks', '**');
$removedUsers[] = $arResUser["USER_ID"];
}
$DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " ");
$ar = array();
foreach ($arFields["USERS"] as $userId) {
$userId = intval($userId);
if (in_array($userId, $ar)) {
continue;
}
$DB->Query("INSERT INTO b_bp_task_user (USER_ID, TASK_ID, ORIGINAL_USER_ID) " . "VALUES (" . intval($userId) . ", " . intval($id) . ", " . intval($userId) . ") ");
CUserCounter::Increment($userId, 'bp_tasks', '**');
$ar[] = $userId;
}
}
$userStatuses = array();
if (isset($arFields['STATUS']) && $arFields['STATUS'] > CBPTaskStatus::Running) {
$dbResUser = $DB->Query("SELECT USER_ID FROM b_bp_task_user WHERE TASK_ID = " . $id . " AND STATUS = " . CBPTaskUserStatus::Waiting);
while ($arResUser = $dbResUser->Fetch()) {
CUserCounter::Decrement($arResUser["USER_ID"], 'bp_tasks', '**');
if ($arFields['STATUS'] == CBPTaskStatus::Timeout) {
$userStatuses[$arResUser["USER_ID"]] = CBPTaskUserStatus::No;
} else {
$removedUsers[] = $arResUser["USER_ID"];
}
}
if ($arFields['STATUS'] == CBPTaskStatus::Timeout) {
$DB->Query("UPDATE b_bp_task_user SET STATUS = " . CBPTaskUserStatus::No . ", DATE_UPDATE = " . $DB->CurrentTimeFunction() . " WHERE TASK_ID = " . $id . " AND STATUS = " . CBPTaskUserStatus::Waiting);
} else {
$DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . $id . " AND STATUS = " . CBPTaskUserStatus::Waiting);
}
}
foreach (GetModuleEvents("bizproc", "OnTaskUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($id, $arFields));
}
if ($removedUsers) {
$arFields['USERS_REMOVED'] = $removedUsers;
}
if ($userStatuses) {
$arFields['USERS_STATUSES'] = $userStatuses;
}
self::onTaskChange($id, $arFields, CBPTaskChangedStatus::Update);
return $id;
}
示例4: Increment
public static function Increment($code, $site_id = SITE_ID, $sendPull = true, $increment = 1)
{
return CUserCounter::Increment(CUserCounter::SYSTEM_USER_ID, $code, $site_id, $sendPull, $increment);
}
示例5: processUsersCounters
private static function processUsersCounters($counterId, $operation, $arUsers, $delta)
{
if (!is_array($arUsers)) {
CTaskAssert::logError('[0x9418f293] ');
return;
}
$arUsers = array_unique($arUsers);
if ($operation === self::OP_DECREMENT) {
foreach ($arUsers as $userId) {
$userId = (int) $userId;
if ($userId < 1) {
CTaskAssert::logError('[0x8886cc18] ');
continue;
}
//$x = '[USER_ID= ' . $userId . '] ' . $counterId . '--';
//soundex($x);
CUserCounter::Decrement($userId, $counterId, '**', false, $delta);
}
} elseif ($operation === self::OP_INCREMENT) {
foreach ($arUsers as $userId) {
$userId = (int) $userId;
if ($userId < 1) {
CTaskAssert::logError('[0x01f722e7] ');
continue;
}
//$x = '[USER_ID= ' . $userId . '] ' . $counterId . '+=' . $delta;
//soundex($x);
CUserCounter::Increment((int) $userId, $counterId, '**', false, $delta);
}
} else {
CTaskAssert::logError('[0x0a5999d4] Invalid operation: ' . $operation);
}
}