本文整理汇总了PHP中CUserCounter::Decrement方法的典型用法代码示例。如果您正苦于以下问题:PHP CUserCounter::Decrement方法的具体用法?PHP CUserCounter::Decrement怎么用?PHP CUserCounter::Decrement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUserCounter
的用法示例。
在下文中一共展示了CUserCounter::Decrement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DeleteByWorkflow
public static function DeleteByWorkflow($workflowId)
{
global $DB;
$workflowId = trim($workflowId);
if (strlen($workflowId) <= 0)
throw new Exception("workflowId");
$dbRes = $DB->Query(
"SELECT ID ".
"FROM b_bp_task ".
"WHERE WORKFLOW_ID = '".$DB->ForSql($workflowId)."' "
);
while ($arRes = $dbRes->Fetch())
{
$taskId = intval($arRes["ID"]);
$dbResUser = $DB->Query("SELECT USER_ID FROM b_bp_task_user WHERE TASK_ID = ".$taskId." ");
while ($arResUser = $dbResUser->Fetch())
CUserCounter::Decrement($arResUser["USER_ID"], 'bp_tasks', '**');
$DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = ".$taskId." ", true);
foreach (GetModuleEvents("bizproc", "OnTaskDelete", true) as $arEvent)
ExecuteModuleEventEx($arEvent, array($taskId));
}
$DB->Query(
"DELETE FROM b_bp_task ".
"WHERE WORKFLOW_ID = '".$DB->ForSql($workflowId)."' ",
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")) {
$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', '**');
}
$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) " . "VALUES (" . intval($userId) . ", " . intval($id) . ") ");
CUserCounter::Increment($userId, 'bp_tasks', '**');
$ar[] = $userId;
}
}
foreach (GetModuleEvents("bizproc", "OnTaskUpdate", true) as $arEvent) {
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: MarkCompleted
public function MarkCompleted($id, $userId)
{
global $DB;
$id = intval($id);
if ($id <= 0) {
throw new Exception("id");
}
$userId = intval($userId);
if ($userId <= 0) {
throw new Exception("userId");
}
$DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " AND USER_ID = " . intval($userId) . " ", true);
$dbRes = $DB->Query("SELECT COUNT(ID) as CNT FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " ");
$arRes = $dbRes->Fetch();
if (intval($arRes["CNT"]) <= 0) {
$DB->Query("DELETE FROM b_bp_task WHERE ID = " . intval($id) . " ", true);
}
CUserCounter::Decrement($userId, 'bp_tasks', '**');
$events = GetModuleEvents("bizproc", "OnTaskMarkCompleted");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($id, $userId));
}
}
示例5: DeleteByWorkflow
public static function DeleteByWorkflow($workflowId)
{
global $DB;
$workflowId = trim($workflowId);
if (strlen($workflowId) <= 0) {
throw new Exception("workflowId");
}
$dbRes = $DB->Query("SELECT ID " . "FROM b_bp_task " . "WHERE WORKFLOW_ID = '" . $DB->ForSql($workflowId) . "' ");
while ($arRes = $dbRes->Fetch()) {
$taskId = intval($arRes["ID"]);
$removedUsers = array();
$dbResUser = $DB->Query("SELECT USER_ID, STATUS FROM b_bp_task_user WHERE TASK_ID = " . $taskId . " ");
while ($arResUser = $dbResUser->Fetch()) {
if ($arResUser['STATUS'] == CBPTaskUserStatus::Waiting) {
CUserCounter::Decrement($arResUser["USER_ID"], 'bp_tasks', '**');
}
$removedUsers[] = $arResUser['USER_ID'];
}
$DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . $taskId . " ", true);
self::onTaskChange($taskId, array('USERS_REMOVED' => $removedUsers), CBPTaskChangedStatus::Delete);
foreach (GetModuleEvents("bizproc", "OnTaskDelete", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($taskId));
}
}
$DB->Query("DELETE FROM b_bp_task " . "WHERE WORKFLOW_ID = '" . $DB->ForSql($workflowId) . "' ", true);
}
示例6: Decrement
public static function Decrement($code, $site_id = SITE_ID, $sendPull = true, $decrement = 1)
{
return CUserCounter::Decrement(CUserCounter::SYSTEM_USER_ID, $code, $site_id, $sendPull, $decrement);
}
示例7: 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);
}
}