コード例 #1
0
                     $arSonetFields = array_intersect_key($arSonetFields, array_flip(array("TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "PARAMS")));
                     CSocNetLog::Update($arRes["ID"], $arSonetFields);
                     CSocNetLogRights::SetForSonet($arRes["ID"], $arParams["MODE"] == "GROUP" ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, $arParams["MODE"] == "GROUP" ? $arParams["SOCNET_GROUP_ID"] : $arParams["USER_ID"], "forum", "view");
                 } else {
                     $dbRes = CSocNetLogComments::GetList(array(), array("EVENT_ID" => "forum", "SOURCE_ID" => $MID1), false, false, array("ID"));
                     if ($arRes = $dbRes->Fetch()) {
                         // message/comment
                         $arSonetFields = array_intersect_key($arSonetFields, array_flip(array("MESSAGE", "TEXT_MESSAGE", "PARAMS")));
                         CSocNetLogComments::Update($arRes["ID"], $arSonetFields);
                     }
                 }
             }
             $url = ForumAddPageParams(CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $arParams["FID"], "TID" => $arParams["TID"], "MID" => intVal($arParams["MID"]), "UID" => $arParams["USER_ID"], "GID" => $arParams["SOCNET_GROUP_ID"])), array("result" => $arNote["code"]));
             LocalRedirect($url);
         } elseif (intVal($arFieldsG["PARAM2"]) > 0 && $arFieldsG["PARAM1"] == "VT") {
             CVote::Delete($arFieldsG["PARAM2"]);
         }
     }
     if (!empty($strErrorMessage)) {
         $arError[] = array("id" => $arParams["MESSAGE_TYPE"], "text" => $strErrorMessage);
     }
 } elseif ($arResult["VIEW"] == "Y") {
     $bVarsFromForm = true;
     $arFields = array("FORUM_ID" => intVal($arParams["FID"]), "TOPIC_ID" => intVal($arParams["TID"]), "MESSAGE_ID" => intVal($arParams["MID"]), "USER_ID" => intVal($GLOBALS["USER"]->GetID()));
     $arFiles = array();
     $arFilesExists = array();
     $res = array();
     foreach ($_FILES as $key => $val) {
         if (substr($key, 0, strLen("FILE_NEW")) == "FILE_NEW" && !empty($val["name"])) {
             $arFiles[] = $_FILES[$key];
         }
コード例 #2
0
ファイル: include.php プロジェクト: k-kalashnikov/geekcon_new
function VoteVoteEditFromArray($CHANNEL_ID, $VOTE_ID = false, $arFields = array(), $params = array())
{
    $CHANNEL_ID = intVal($CHANNEL_ID);
    if ($CHANNEL_ID <= 0 || empty($arFields)) {
        return false;
    } elseif (CVote::UserGroupPermission($CHANNEL_ID) <= 0) {
        return false;
    }
    $aMsg = array();
    $params = is_array($params) ? $params : array();
    $params["UNIQUE_TYPE"] = is_set($params, "UNIQUE_TYPE") ? intVal($params["UNIQUE_TYPE"]) : 20;
    $params["DELAY"] = is_set($params, "DELAY") ? intVal($params["DELAY"]) : 10;
    $params["DELAY_TYPE"] = is_set($params, "DELAY_TYPE") && in_array($params['DELAY_TYPE'], array("S", "M", "H", "D")) ? $params["DELAY_TYPE"] : "D";
    $arVote = array();
    $arQuestions = array();
    $arFieldsQuestions = array();
    $arFieldsVote = array("CHANNEL_ID" => $CHANNEL_ID, "AUTHOR_ID" => $GLOBALS["USER"]->GetID(), "UNIQUE_TYPE" => $params["UNIQUE_TYPE"], "DELAY" => $params["DELAY"], "DESCRIPTION_TYPE" => $params["DELAY_TYPE"]);
    if (!empty($arFields["DATE_START"])) {
        $arFieldsVote["DATE_START"] = $arFields["DATE_START"];
    }
    if (!empty($arFields["DATE_END"])) {
        $arFieldsVote["DATE_END"] = $arFields["DATE_END"];
    }
    if (!empty($arFields["TITLE"])) {
        $arFieldsVote["TITLE"] = $arFields["TITLE"];
    }
    if (isset($arFields["ACTIVE"])) {
        $arFieldsVote["ACTIVE"] = $arFields["ACTIVE"];
    }
    if (isset($arFields["NOTIFY"])) {
        $arFieldsVote["NOTIFY"] = $arFields["NOTIFY"];
    }
    if (isset($arFields["URL"])) {
        $arFieldsVote["URL"] = $arFields["URL"];
    }
    /************** Fatal errors ***************************************/
    if (!CVote::CheckFields("UPDATE", $arFieldsVote)) {
        $e = $GLOBALS['APPLICATION']->GetException();
        $aMsg[] = array("id" => "VOTE_ID", "text" => $e->GetString());
    } elseif (intval($VOTE_ID) > 0) {
        $db_res = CVote::GetByID($VOTE_ID);
        if (!($db_res && ($res = $db_res->Fetch()))) {
            $aMsg[] = array("id" => "VOTE_ID", "text" => GetMessage("VOTE_VOTE_NOT_FOUND", array("#ID#", $VOTE_ID)));
        } elseif ($res["CHANNEL_ID"] != $CHANNEL_ID) {
            $aMsg[] = array("id" => "CHANNEL_ID", "text" => GetMessage("VOTE_CHANNEL_ID_ERR"));
        } else {
            $arVote = $res;
            $db_res = CVoteQuestion::GetList($arVote["ID"], $by = "s_id", $order = "asc", array(), $is_filtered);
            if ($db_res && ($res = $db_res->Fetch())) {
                do {
                    $arQuestions[$res["ID"]] = $res + array("ANSWERS" => array());
                } while ($res = $db_res->Fetch());
            }
            $db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"), array("VOTE_ID" => $arVote["ID"]));
            if ($db_res && ($res = $db_res->Fetch())) {
                do {
                    $arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res;
                } while ($res = $db_res->Fetch());
            }
        }
    }
    if (!empty($aMsg)) {
        $e = new CAdminException(array_reverse($aMsg));
        $GLOBALS["APPLICATION"]->ThrowException($e);
        return false;
    }
    /************** Fatal errors/***************************************/
    if (!empty($arFieldsVote["TITLE"]) && !empty($arVote["TITLE"])) {
        $q = reset($arQuestions);
        if ($arVote["TITLE"] == substr($q["QUESTION"], 0, strlen($arVote["TITLE"]))) {
            unset($arFieldsVote["TITLE"]);
        }
    }
    /************** Check Data *****************************************/
    // Questions
    $arFields["QUESTIONS"] = is_array($arFields["QUESTIONS"]) ? $arFields["QUESTIONS"] : array();
    $iQuestions = 0;
    foreach ($arFields["QUESTIONS"] as $key => $arQuestion) {
        if ($arQuestion["DEL"] != "Y") {
            $arQuestion["ID"] = intval($arQuestion["ID"]);
            $arQuestion = array("ID" => $arQuestion["ID"] > 0 && is_set($arQuestions, $arQuestion["ID"]) ? $arQuestion["ID"] : false, "QUESTION" => trim($arQuestion["QUESTION"]), "ANSWERS" => is_array($arQuestion["ANSWERS"]) ? $arQuestion["ANSWERS"] : array());
            $arAnswers = $arQuestion["ID"] > 0 ? $arQuestions[$arQuestion["ID"]]["ANSWERS"] : array();
            foreach ($arQuestion["ANSWERS"] as $keya => $arAnswer) {
                $arAnswer["ID"] = intVal($arAnswer["ID"]);
                $arAnswer["MESSAGE"] = trim($arAnswer["MESSAGE"]);
                if (!empty($arAnswer["MESSAGE"]) && $arAnswer["DEL"] != "Y") {
                    $arQuestion["ANSWERS"][$keya] = array("MESSAGE" => $arAnswer["MESSAGE"], "FIELD_TYPE" => $arAnswer["FIELD_TYPE"]);
                    if ($arAnswer["ID"] > 0 && is_set($arAnswers, $arAnswer["ID"])) {
                        $arQuestion["ANSWERS"][$keya]["ID"] = $arAnswer["ID"];
                        unset($arAnswers[$arAnswer["ID"]]);
                    }
                }
            }
        }
        if ($arQuestion["DEL"] == "Y" || empty($arQuestion["QUESTION"]) || empty($arQuestion["ANSWERS"])) {
            if ($arQuestion["DEL"] != "Y" && !(empty($arQuestion["QUESTION"]) && empty($arQuestion["ANSWERS"]))) {
                $aMsg[] = array("id" => "QUESTION_" . $key, "text" => empty($arQuestion["QUESTION"]) ? GetMessage("VOTE_QUESTION_EMPTY", array("#NUMBER#" => $key)) : GetMessage("VOTE_ANSWERS_EMPTY", array("#QUESTION#" => $arQuestion["QUESTION"])));
            }
            continue;
        }
        if ($arQuestion["ID"] > 0) {
            unset($arQuestions[$arQuestion["ID"]]);
            foreach ($arAnswers as $arAnswer) {
                $arQuestion["ANSWERS"][] = $arAnswer + array("DEL" => "Y");
            }
        }
        $iQuestions++;
        $arFieldsQuestions[$key] = $arQuestion;
    }
    foreach ($arQuestions as $arQuestion) {
        $arFieldsQuestions[] = $arQuestion + array("DEL" => "Y");
    }
    if (!empty($aMsg)) {
        $e = new CAdminException(array_reverse($aMsg));
        $GLOBALS["APPLICATION"]->ThrowException($e);
        return false;
    } elseif (empty($arFieldsQuestions) && $VOTE_ID <= 0) {
        return true;
    } elseif ($params["bOnlyCheck"] == "Y") {
        return true;
    }
    /************** Check Data/*****************************************/
    /************** Main actions with return ***************************/
    if (empty($arFieldsVote["TITLE"])) {
        $q = reset($arFieldsQuestions);
        $arFieldsVote["TITLE"] = null;
        do {
            if ($q["DEL"] != "Y") {
                $arFieldsVote["TITLE"] = $q["QUESTION"];
                break;
            }
        } while ($q = next($arFieldsQuestions));
        reset($arFieldsQuestions);
    }
    if (empty($arVote)) {
        $arFieldsVote["UNIQUE_TYPE"] = $params["UNIQUE_TYPE"];
        $arFieldsVote["DELAY"] = $params["DELAY"];
        $arFieldsVote["DELAY_TYPE"] = $params["DELAY_TYPE"];
        $arVote["ID"] = intval(CVote::Add($arFieldsVote));
    } else {
        CVote::Update($VOTE_ID, $arFieldsVote);
    }
    if ($iQuestions > 0 && $arVote["ID"] > 0) {
        $iQuestions = 0;
        foreach ($arFieldsQuestions as $arQuestion) {
            if ($arQuestion["DEL"] == "Y") {
                CVoteQuestion::Delete($arQuestion["ID"]);
                continue;
            } elseif ($arQuestion["ID"] > 0) {
                $arQuestion["C_SORT"] = ($iQuestions + 1) * 10;
                CVoteQuestion::Update($arQuestion["ID"], $arQuestion);
            } else {
                $arQuestion["C_SORT"] = ($iQuestions + 1) * 10;
                $arQuestion["VOTE_ID"] = $arVote["ID"];
                $arQuestion["ID"] = intVal(CVoteQuestion::Add($arQuestion));
                if ($arQuestion["ID"] <= 0) {
                    continue;
                }
            }
            $iQuestions++;
            $iAnswers = 0;
            foreach ($arQuestion["ANSWERS"] as $arAnswer) {
                if ($arAnswer["DEL"] == "Y") {
                    CVoteAnswer::Delete($arAnswer["ID"]);
                    continue;
                }
                if ($arAnswer["ID"] > 0) {
                    $arAnswer["C_SORT"] = $iAnswers * 10;
                    CVoteAnswer::Update($arAnswer["ID"], $arAnswer);
                } else {
                    $arAnswer["QUESTION_ID"] = $arQuestion["ID"];
                    $arAnswer["C_SORT"] = ($iAnswers + 1) * 10;
                    $arAnswer["ID"] = intVal(CVoteAnswer::Add($arAnswer));
                    if ($arAnswer["ID"] <= 0) {
                        continue;
                    }
                }
                $iAnswers++;
            }
            if ($iAnswers <= 0) {
                CVoteQuestion::Delete($arQuestion["ID"]);
                $iQuestions--;
            }
        }
    }
    if (intVal($arVote["ID"]) <= 0) {
        return false;
    } elseif ($iQuestions <= 0) {
        CVote::Delete($arVote["ID"]);
        return 0;
    }
    return $arVote["ID"];
    /************** Actions/********************************************/
    /*	$arFields = array(
    		"ID" => 345, 
    		"TITLE" => "test", 
    		"...", 
    		"QUESTIONS" => array(
    			array(
    				"ID" => 348, 
    				"QUESTION" => "test", 
    				"ANSWERS" => array(
    					array(
    						"ID" => 340, 
    						"MESSAGE" => "test"), 
    					array(
    						"ID" => 0, 
    						"MESSAGE" => "test"), 
    					array(
    						"ID" => 350,
    						"DEL" => "Y",  
    						"MESSAGE" => "test")
    					)
    				), 
    			array(
    				"ID" => 351, 
    				"DEL" => "Y", 
    				"QUESTION" => "test", 
    				"ANSWERS" => array(
    					array(
    						"ID" => 0, 
    						"MESSAGE" => "test"), 
    					array(
    						"ID" => 478,
    						"DEL" => "Y",  
    						"MESSAGE" => "test")
    					)
    				), 
    			array(
    				"ID" => 0, 
    				"QUESTION" => "test", 
    				"ANSWERS" => array(
    					array(
    						"ID" => 0, 
    						"MESSAGE" => "test"), 
    					)
    				), 
    			)
    		);
    */
}
コード例 #3
0
ファイル: channel.php プロジェクト: rasuldev/torino
 public static function Delete($ID)
 {
     global $DB;
     $err_mess = CAllVoteChannel::err_mess() . "<br>Function: Delete<br>Line: ";
     $ID = intval($ID);
     if ($ID <= 0) {
         return true;
     }
     /***************** Event onBeforeVoteChannelDelete ******************/
     foreach (GetModuleEvents("vote", "onBeforeVoteChannelDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     // drop votes
     $z = $DB->Query("SELECT ID FROM b_vote WHERE CHANNEL_ID='{$ID}'", false, $err_mess . __LINE__);
     while ($zr = $z->Fetch()) {
         CVote::Delete($zr["ID"]);
     }
     $DB->Query("DELETE FROM b_vote_channel_2_group WHERE CHANNEL_ID=" . $ID, false, $err_mess . __LINE__);
     $DB->Query("DELETE FROM b_vote_channel_2_site WHERE CHANNEL_ID=" . $ID, false, $err_mess . __LINE__);
     $res = $DB->Query("DELETE FROM b_vote_channel WHERE ID=" . $ID, false, $err_mess . __LINE__);
     /***************** Event onAfterVoteChannelDelete ******************/
     foreach (GetModuleEvents("vote", "onAfterVoteChannelDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     /***************** /Event ******************************************/
     return $res;
 }
コード例 #4
0
ファイル: message.php プロジェクト: mrdeadmouse/u136006
 function Delete($ID)
 {
     global $DB;
     $ID = intVal($ID);
     $arMessage = array();
     if ($ID > 0) {
         $arMessage = CForumMessage::GetByID($ID, array("FILTER" => "N"));
     }
     if (empty($arMessage)) {
         return false;
     }
     /***************** Event onBeforeMessageAdd ************************/
     foreach (GetModuleEvents("forum", "onBeforeMessageDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     $AUTHOR_ID = intVal($arMessage["AUTHOR_ID"]);
     $TOPIC_ID = intVal($arMessage["TOPIC_ID"]);
     $FORUM_ID = intVal($arMessage["FORUM_ID"]);
     $DB->StartTransaction();
     // delete votes
     if ($arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0 && IsModuleInstalled("vote")) {
         CModule::IncludeModule("vote");
         CVote::Delete($arMessage["PARAM2"]);
     }
     // delete files
     CForumFiles::Delete(array("MESSAGE_ID" => $ID), array("DELETE_MESSAGE_FILE" => "Y"));
     // delete message
     $DB->Query("DELETE FROM b_forum_message WHERE ID=" . $ID);
     // after delete
     $db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID), false, 1);
     $res = false;
     if (!($db_res && ($res = $db_res->Fetch()))) {
         CForumTopic::Delete($TOPIC_ID);
     } else {
         // if deleted message was first
         if ($arMessage["NEW_TOPIC"] == "Y") {
             $DB->Update('b_forum_message', array('NEW_TOPIC' => '"Y"'), "WHERE ID=" . $res["ID"]);
         }
         CForumTopic::SetStat($TOPIC_ID);
     }
     $DB->Commit();
     $GLOBALS["USER_FIELD_MANAGER"]->Delete("FORUM_MESSAGE", $ID);
     if ($AUTHOR_ID > 0) {
         CForumUser::SetStat($AUTHOR_ID);
     }
     CForumNew::SetStat($FORUM_ID);
     /***************** Event onBeforeMessageAdd ************************/
     foreach (GetModuleEvents("forum", "onAfterMessageDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arMessage));
     }
     /***************** /Event ******************************************/
     if (CModule::IncludeModule("search")) {
         CSearch::DeleteIndex("forum", $ID);
         if (is_array($res) && !empty($res)) {
             CForumMessage::Reindex($res["ID"], $res);
         }
     }
     return true;
 }
コード例 #5
0
ファイル: forum_new.php プロジェクト: DarneoStudio/bitrix
 function Delete($ID)
 {
     global $DB;
     $ID = intVal($ID);
     $bCanDelete = true;
     /***************** Event OnBeforeForumDelete ***********************/
     foreach (GetModuleEvents("forum", "OnBeforeForumDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID)) === false) {
             $bCanDelete = false;
             break;
         }
     }
     /***************** /Event ******************************************/
     if (!$bCanDelete) {
         return false;
     }
     /***************** Event OnForumDelete *****************************/
     foreach (GetModuleEvents("forum", "OnForumDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$ID));
     }
     /***************** /Event ******************************************/
     /***************** Cleaning cache **********************************/
     unset($GLOBALS["FORUM_CACHE"]["FORUM"][$ID]);
     if (CACHED_b_forum !== false) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum");
     }
     if (CACHED_b_forum_perms !== false) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum_perms");
     }
     if (CACHED_b_forum2site !== false) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum2site");
     }
     /***************** Cleaning cache/**********************************/
     /***************** Search module ***********************************/
     set_time_limit(0);
     if (CModule::IncludeModule("search")) {
         CSearch::DeleteIndex("forum", false, $ID);
     }
     CForumFiles::Delete(array("FORUM_ID" => $ID), array("DELETE_FORUM_FILE" => "Y"));
     $DB->StartTransaction();
     // Update USER statistic
     $arProcAuth = array();
     $db_res = CForumMessage::GetList(array(), array("FORUM_ID" => $ID, "!AUTHOR_ID" => 0));
     while ($res = $db_res->Fetch()) {
         $res["AUTHOR_ID"] = intVal($res["AUTHOR_ID"]);
         if (!in_array($res["AUTHOR_ID"], $arProcAuth)) {
             $arProcAuth[] = intVal($res["AUTHOR_ID"]);
         }
     }
     if (IsModuleInstalled("vote")) {
         $db_res = CForumMessage::GetList(array(), array("FORUM_ID" => $ID, "PARAM1" => "VT", "!PARAM2" => 0));
         if ($db_res && ($res = $db_res->Fetch())) {
             CModule::IncludeModule("vote");
             do {
                 CVote::Delete($res["PARAM2"]);
             } while ($res = $db_res->Fetch());
         }
     }
     if (!$DB->Query("DELETE FROM b_forum_subscribe WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum_message WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum_topic WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum_perms WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum2site WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum WHERE ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     // Update USER statistic
     foreach ($arProcAuth as $i => $procAuth) {
         CForumUser::SetStat($procAuth);
     }
     $DB->Commit();
     /***************** Event OnAfterForumDelete ************************/
     foreach (GetModuleEvents("forum", "OnAfterForumDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     /***************** /Event ******************************************/
     return true;
 }
コード例 #6
0
ファイル: topic.php プロジェクト: k-kalashnikov/geekcon_new
 function Delete($ID)
 {
     global $DB;
     $ID = intVal($ID);
     $arTopic = CForumTopic::GetByID($ID);
     if (empty($arTopic)) {
         return false;
     }
     /***************** Event onBeforeTopicDelete ***********************/
     $events = GetModuleEvents("forum", "onBeforeTopicDelete");
     while ($arEvent = $events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID, $arTopic)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     $arAuthor = array();
     $arVotes = array();
     $db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $ID));
     while ($res = $db_res->Fetch()) {
         if (intVal($res["AUTHOR_ID"]) > 0) {
             $arAuthor[intVal($res["AUTHOR_ID"])] = $res["AUTHOR_ID"];
         }
         if ($res["PARAM1"] == "VT" && intVal($res["PARAM2"]) > 0) {
             $arVotes[] = intVal($res["PARAM2"]);
         }
     }
     if (!empty($arVotes) && IsModuleInstalled("vote") && CModule::IncludeModule("vote")) {
         foreach ($arVotes as $res) {
             CVote::Delete($res);
         }
     }
     //		$DB->StartTransaction();
     CForumFiles::Delete(array("TOPIC_ID" => $ID), array("DELETE_TOPIC_FILE" => "Y"));
     $DB->Query("DELETE FROM b_forum_subscribe WHERE TOPIC_ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_message WHERE TOPIC_ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_user_topic WHERE TOPIC_ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_topic WHERE ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_topic WHERE TOPIC_ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_stat WHERE TOPIC_ID = " . $ID . "");
     //		$DB->Commit();
     unset($GLOBALS["FORUM_CACHE"]["TOPIC"][$ID]);
     unset($GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$ID]);
     foreach ($arAuthor as $key) {
         CForumUser::SetStat($key);
     }
     CForumNew::SetStat($arTopic["FORUM_ID"]);
     if (IsModuleInstalled("search") && CModule::IncludeModule("search")) {
         CSearch::DeleteIndex("forum", false, $arTopic["FORUM_ID"], $ID);
     }
     /***************** Event onAfterTopicDelete ************************/
     $events = GetModuleEvents("forum", "onAfterTopicDelete");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array(&$ID, $arTopic));
     }
     /***************** /Event ******************************************/
     return true;
 }
コード例 #7
0
ファイル: vote_list.php プロジェクト: DarneoStudio/bitrix
    if ($_REQUEST['action_target'] == 'selected') {
        $arID = array();
        $rsData = CVote::GetList($by, $order, $arFilter, $is_filtered);
        while ($arRes = $rsData->Fetch()) {
            $arID[] = $arRes['ID'];
        }
    }
    $arID = is_array($arID) ? $arID : array($arID);
    foreach ($arID as $ID) {
        $ID = intVal($ID);
        if ($ID <= 0) {
            continue;
        }
        switch ($_REQUEST['action']) {
            case "delete":
                CVote::Delete($ID);
                break;
            case "activate":
            case "deactivate":
                if (!CVote::Update($ID, array("ACTIVE" => $_REQUEST['action'] == "activate" ? "Y" : "N"))) {
                    if ($ex = $GLOBALS['APPLICATION']->GetException()) {
                        $lAdmin->AddGroupError($ex->GetString(), $ID);
                    } else {
                        $lAdmin->AddGroupError(GetMessage("VOTE_SAVE_ERROR"), $ID);
                    }
                }
                break;
        }
    }
}
/********************************************************************
コード例 #8
0
ファイル: message.php プロジェクト: ASDAFF/bxApiDocs
	/**
	 * <p>Удаляет сообщение с кодом <i>ID</i>.</p> <p><b>Примечание</b>. Метод использует внутреннюю транзакцию. Если у вас используется <b>MySQL</b> и <b>InnoDB</b>, и ранее была открыта транзакция, то ее необходимо закрыть до подключения метода.</p>
	 *
	 *
	 *
	 *
	 * @param int $ID  Код сообщения, которое необходимо удалить.
	 *
	 *
	 *
	 * @return bool 
	 *
	 *
	 * <h4>See Also</h4> 
	 * <ul><li>Перед удалением сообщения следует проверить возможность
	 * удаления методом <a
	 * href="http://dev.1c-bitrix.ru/api_help/forum/developer/cforummessage/canuserdeletemessage.php">CForumMessage::CanUserDeleteMessage</a>
	 * </li></ul>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/forum/developer/cforummessage/delete.php
	 * @author Bitrix
	 */
	public static function Delete($ID)
	{
		global $DB;
		$ID = intVal($ID);
		$arMessage = array();
		if ($ID > 0)
			$arMessage = CForumMessage::GetByID($ID, array("FILTER" => "N"));
		if (empty($arMessage))
			return false;
/***************** Event onBeforeMessageAdd ************************/
		$events = GetModuleEvents("forum", "onBeforeMessageDelete");
		while ($arEvent = $events->Fetch())
		{
			if (ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage)) === false)
				return false;
		}
/***************** /Event ******************************************/
		$AUTHOR_ID = intVal($arMessage["AUTHOR_ID"]);
		$TOPIC_ID = intVal($arMessage["TOPIC_ID"]);
		$FORUM_ID = intVal($arMessage["FORUM_ID"]);

		$DB->StartTransaction();
		// delete votes
		if ($arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0 && IsModuleInstalled("vote")):
			CModule::IncludeModule("vote");
			CVote::Delete($arMessage["PARAM2"]);
		endif;
		// delete files
		CForumFiles::Delete(array("MESSAGE_ID" => $ID), array("DELETE_MESSAGE_FILE" => "Y"));
		// delete message
		$DB->Query("DELETE FROM b_forum_message WHERE ID=".$ID);
		// after delete
		$db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID), false, 1);
		$res = false;
		if (!($db_res && $res = $db_res->Fetch())):
			CForumTopic::Delete($TOPIC_ID);
		else:
			// if deleted message was first
			if ($arMessage["NEW_TOPIC"] == "Y"):
				$DB->Query("UPDATE b_forum_message SET NEW_TOPIC='Y' WHERE ID=".$res["ID"]);
			endif;
			CForumTopic::SetStat($TOPIC_ID);
		endif;
		$DB->Commit();

		$GLOBALS["USER_FIELD_MANAGER"]->Delete("FORUM_MESSAGE", $ID);

		if ($AUTHOR_ID > 0):
			CForumUser::SetStat($AUTHOR_ID);
		endif;
		CForumNew::SetStat($FORUM_ID);
/***************** Event onBeforeMessageAdd ************************/
		$events = GetModuleEvents("forum", "onAfterMessageDelete");
		while ($arEvent = $events->Fetch())
			ExecuteModuleEventEx($arEvent, array($ID, $arMessage));
/***************** /Event ******************************************/
		if (CModule::IncludeModule("search"))
		{
			CSearch::DeleteIndex("forum", $ID);
		}
		return true;
	}
コード例 #9
0
ファイル: channel.php プロジェクト: ASDAFF/bxApiDocs
	public static function Delete($ID)
	{
		global $DB, $CACHE_MANAGER;
		$err_mess = (CAllVoteChannel::err_mess())."<br>Function: Delete<br>Line: ";
		$ID = intval($ID);
		if ($ID <= 0):
			return true;
		endif;
		/***************** Event onBeforeVoteChannelDelete ******************/
		$events = GetModuleEvents("vote", "onBeforeVoteChannelDelete");
		while ($arEvent = $events->Fetch()) {
			if (ExecuteModuleEventEx($arEvent, array(&$ID)) === false)
				return false; }
		/***************** /Event ******************************************/

		// drop votes
		$strSql = "SELECT ID FROM b_vote WHERE CHANNEL_ID='$ID'";
		$z = $DB->Query($strSql, false, $err_mess.__LINE__);
		while ($zr = $z->Fetch()) CVote::Delete($zr["ID"]);
		
		$DB->Query("DELETE FROM b_vote_channel_2_group WHERE CHANNEL_ID=".$ID, false, $err_mess.__LINE__);
		$DB->Query("DELETE FROM b_vote_channel_2_site WHERE CHANNEL_ID=".$ID, false, $err_mess.__LINE__);
		$res = $DB->Query("DELETE FROM b_vote_channel WHERE ID=".$ID, false, $err_mess.__LINE__);
		/***************** Event onAfterVoteChannelDelete ******************/
		$events = GetModuleEvents("vote", "onAfterVoteChannelDelete");
		while ($arEvent = $events->Fetch())
			ExecuteModuleEventEx($arEvent, array($ID));
		/***************** /Event ******************************************/
		return $res;
	}