Exemple #1
0
 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));
     }
 }