示例#1
0
 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;
 }
示例#2
0
 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()) {
         $DB->Query("DELETE FROM b_bp_task_user " . "WHERE TASK_ID = " . intval($arRes["ID"]) . " ", true);
         CUserCounter::ClearByTag($arRes["ID"], 'bp_tasks', '**');
         $events = GetModuleEvents("bizproc", "OnTaskDelete");
         while ($arEvent = $events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array(intval($arRes["ID"])));
         }
     }
     $DB->Query("DELETE FROM b_bp_task " . "WHERE WORKFLOW_ID = '" . $DB->ForSql($workflowId) . "' ", true);
 }
示例#3
0
 public static function ClearByTag($tag, $code, $site_id = SITE_ID, $sendPull = true)
 {
     return CUserCounter::ClearByTag($tag, $code, $site_id, $sendPull);
 }