本文整理汇总了PHP中CForumFiles::UpdateByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumFiles::UpdateByID方法的具体用法?PHP CForumFiles::UpdateByID怎么用?PHP CForumFiles::UpdateByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumFiles
的用法示例。
在下文中一共展示了CForumFiles::UpdateByID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnAfterCommentAdd
function OnAfterCommentAdd($entityType, $entityID, $params = array())
{
$arPost = array();
$arParams =& $this->component->arParams;
$arResult =& $this->component->arResult;
if (!!$this->OnCommentAdd($entityType, $entityID, $arPost) && !!$arPost["FILES"]) {
CForumFiles::UpdateByID(array_keys($arPost["FILES"]), array("FORUM_ID" => $arParams["FORUM_ID"], "TOPIC_ID" => $params["TOPIC_ID"], "MESSAGE_ID" => $params["MESSAGE_ID"]));
}
}
示例2: Update
function Update($ID, $arFields, $skip_counts = false, $strUploadDir = false)
{
global $DB;
$ID = intVal($ID);
$strSql = "";
$strUploadDir = $strUploadDir === false ? "forum" : $strUploadDir;
if ($ID <= 0 || !CForumMessage::CheckFields("UPDATE", $arFields, $ID) || empty($arFields)) {
return false;
}
// if (!$skip_counts || IsModuleInstalled("search") || is_array($arFields["ATTACH_IMG"]) || is_array($arFields["FILES"]))
// {
$arMessage_prev = CForumMessage::GetByID($ID, array("FILTER" => "N"));
// }
if (is_set($arFields, "POST_MESSAGE") || is_set($arFields, "FORUM_ID")) {
$arFields["POST_MESSAGE_HTML"] = '';
$arFields["POST_MESSAGE_FILTER"] = '';
}
$arr = array("AUTHOR_NAME" => $arMessage_prev["AUTHOR_NAME"], "AUTHOR_EMAIL" => $arMessage_prev["AUTHOR_EMAIL"], "EDITOR_NAME" => $arMessage_prev["EDITOR_NAME"], "EDITOR_EMAIL" => $arMessage_prev["EDITOR_EMAIL"], "EDIT_REASON" => $arMessage_prev["EDIT_REASON"]);
$bUpdateHTML = false;
foreach ($arr as $key => $val) {
if (is_set($arFields, $key) && $val != $arFields[$key]) {
$bUpdateHTML = true;
break;
}
}
if ($bUpdateHTML) {
$arFields["HTML"] = '';
}
if (is_set($arFields, "POST_DATE") && strLen(trim($arFields["POST_DATE"])) <= 0) {
$strSql = ", POST_DATE=" . $DB->GetNowFunction();
unset($arFields["POST_DATE"]);
}
if (!is_set($arFields, "EDIT_DATE")) {
$strSql .= ", EDIT_DATE=" . $DB->GetNowFunction();
} else {
if (strLen(trim($arFields["EDIT_DATE"])) <= 0) {
$strSql .= ", EDIT_DATE=" . $DB->GetNowFunction();
unset($arFields["EDIT_DATE"]);
}
}
/***************** Event onBeforeMessageUpdate *********************/
foreach (GetModuleEvents("forum", "onBeforeMessageUpdate", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields, &$strUploadDir)) === false) {
return false;
}
}
/***************** /Event ******************************************/
/***************** Attach ******************************************/
$arFiles = array();
if (is_array($arFields["ATTACH_IMG"])) {
$arFields["FILES"] = array($arFields["ATTACH_IMG"]);
}
unset($arFields["ATTACH_IMG"]);
if (is_array($arFields["FILES"]) && !empty($arFields["FILES"])) {
$res = array("FORUM_ID" => $arMessage_prev["FORUM_ID"], "TOPIC_ID" => $arMessage_prev["TOPIC_ID"], "MESSAGE_ID" => $ID, "USER_ID" => $arFields["EDITOR_ID"], "upload_dir" => $strUploadDir);
$arFiles = CForumFiles::Save($arFields["FILES"], $res, false);
$db_res = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $ID));
if ($db_res && ($res = $db_res->Fetch())) {
do {
$arFiles[$res["FILE_ID"]] = $res;
} while ($db_res && ($res = $db_res->Fetch()));
}
if (!empty($arFiles)) {
$arFiles = array_keys($arFiles);
sort($arFiles);
$arFields["ATTACH_IMG"] = $arFiles[0];
} else {
$arFields["ATTACH_IMG"] = 0;
}
unset($arFields["FILES"]);
}
/***************** Attach/******************************************/
if (empty($arFields) && empty($strSql)) {
return false;
}
$strUpdate = $DB->PrepareUpdate("b_forum_message", $arFields, $strUploadDir);
$strSql = "UPDATE b_forum_message SET " . $strUpdate . $strSql . " WHERE ID = " . $ID;
$DB->QueryBind($strSql, array("POST_MESSAGE" => $arFields["POST_MESSAGE"], "POST_MESSAGE_HTML" => $arFields["POST_MESSAGE_HTML"], "POST_MESSAGE_FILTER" => $arFields["POST_MESSAGE_FILTER"], "EDIT_REASON" => $arFields["EDIT_REASON"], "HTML" => $arFields["HTML"]));
/***************** Attach ******************************************/
if (!empty($arFiles)) {
$res = array("FORUM_ID" => is_set($arFields, "FORUM_ID") ? $arFields["FORUM_ID"] : $arMessage_prev["FORUM_ID"], "TOPIC_ID" => is_set($arFields, "TOPIC_ID") ? $arFields["TOPIC_ID"] : $arMessage_prev["TOPIC_ID"], "MESSAGE_ID" => $ID);
CForumFiles::UpdateByID($arFiles, $res);
}
/***************** Attach/******************************************/
/***************** Quota *******************************************/
$_SESSION["SESS_RECOUNT_DB"] = "Y";
$GLOBALS["USER_FIELD_MANAGER"]->Update("FORUM_MESSAGE", $ID, $arFields);
/***************** Event onAfterMessageUpdate **********************/
foreach (GetModuleEvents("forum", "onAfterMessageUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields, $arMessage_prev));
}
/***************** /Event ******************************************/
unset($GLOBALS["FORUM_CACHE"]["MESSAGE"][$ID]);
unset($GLOBALS["FORUM_CACHE"]["MESSAGE_FILTER"][$ID]);
if (!$skip_counts || IsModuleInstalled("search")) {
$arMessage = CForumMessage::GetByIDEx($ID, array("GET_TOPIC_INFO" => "Y", "GET_FORUM_INFO" => "Y", "FILTER" => "Y"));
if (!$skip_counts) {
// author
if ($arMessage["AUTHOR_ID"] != $arMessage_prev["AUTHOR_ID"]) {
CForumUser::SetStat($arMessage_prev["AUTHOR_ID"], array("MESSAGE" => $arMessage_prev, "ACTION" => "DECREMENT"));
//.........这里部分代码省略.........
示例3: Update
function Update($ID, $arFields, $skip_counts = False)
{
global $DB;
$ID = intVal($ID);
$arFields1 = array();
$arFieldsForFilter = array();
$bNeedFilter = false;
if ($ID <= 0 || !CForumTopic::CheckFields("UPDATE", $arFields)) {
return false;
}
/***************** Event onBeforeTopicUpdate **************************/
$events = GetModuleEvents("forum", "onBeforeTopicUpdate");
while ($arEvent = $events->Fetch()) {
if (ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields)) === false) {
return false;
}
}
/***************** /Event ******************************************/
if (empty($arFields)) {
return false;
}
foreach ($arFields as $key => $value) {
if (substr($key, 0, 1) == "=") {
$arFields1[substr($key, 1)] = $value;
unset($arFields[$key]);
}
}
if (!$skip_counts && is_set($arFields, "FORUM_ID") || COption::GetOptionString("forum", "FILTER", "Y") == "Y" || (is_set($arFields, "TITLE") || is_set($arFields, "TAGS")) && IsModuleInstalled("search")) {
$arTopic_prev = CForumTopic::GetByID($ID, array("NoFilter" => true));
}
// Fields "HTML".
if (COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
$arFieldsForFilter = array("TITLE" => is_set($arFields, "TITLE") ? $arFields["TITLE"] : $arTopic_prev["TITLE"], "TAGS" => is_set($arFields, "TAGS") ? $arFields["TAGS"] : $arTopic_prev["TAGS"], "DESCRIPTION" => is_set($arFields, "DESCRIPTION") ? $arFields["DESCRIPTION"] : $arTopic_prev["DESCRIPTION"], "LAST_POSTER_NAME" => is_set($arFields, "LAST_POSTER_NAME") ? $arFields["LAST_POSTER_NAME"] : $arTopic_prev["LAST_POSTER_NAME"], "ABS_LAST_POSTER_NAME" => is_set($arFields, "ABS_LAST_POSTER_NAME") ? $arFields["ABS_LAST_POSTER_NAME"] : $arTopic_prev["ABS_LAST_POSTER_NAME"], "USER_START_NAME" => is_set($arFields, "USER_START_NAME") ? $arFields["USER_START_NAME"] : $arTopic_prev["USER_START_NAME"]);
$bNeedFilter = false;
foreach ($arFieldsForFilter as $key => $val) {
if (is_set($arFields, $key)) {
$bNeedFilter = true;
break;
}
}
if ($bNeedFilter) {
foreach ($arFieldsForFilter as $key => $val) {
$res = CFilterUnquotableWords::Filter($val);
if (empty($res) && !empty($val)) {
$res = "*";
}
$arFieldsForFilter[$key] = $res;
}
$arFields["HTML"] = serialize($arFieldsForFilter);
}
}
$strUpdate = $DB->PrepareUpdate("b_forum_topic", $arFields);
foreach ($arFields1 as $key => $value) {
if (strLen($strUpdate) > 0) {
$strUpdate .= ", ";
}
$strUpdate .= $key . "=" . $value . " ";
}
if (!empty($strUpdate)) {
$strSql = "UPDATE b_forum_topic SET " . $strUpdate . " WHERE ID = " . $ID;
$DB->QueryBind($strSql, array("HTML" => $arFields["HTML"]), false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
}
$res = array_merge($arFields1, $arFields);
if (count($res) == 1 && !empty($res["VIEWS"])) {
if (intVal($res["VIEWS"]) <= 0) {
$GLOBALS["FORUM_CACHE"]["TOPIC"][$ID]["VIEWS"]++;
$GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$ID]["VIEWS"]++;
} else {
$GLOBALS["FORUM_CACHE"]["TOPIC"][$ID]["VIEWS"] = intVal($res["VIEWS"]);
$GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$ID]["VIEWS"] = intVal($res["VIEWS"]);
}
} else {
unset($GLOBALS["FORUM_CACHE"]["FORUM"][$arTopic_prev["FORUM_ID"]]);
unset($GLOBALS["FORUM_CACHE"]["TOPIC"][$ID]);
unset($GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$ID]);
if (intVal($arFields1["FORUM_ID"]) > 0) {
unset($GLOBALS["FORUM_CACHE"]["FORUM"][intVal($arFields1["FORUM_ID"])]);
}
if (intVal($arFields["FORUM_ID"]) > 0) {
unset($GLOBALS["FORUM_CACHE"]["FORUM"][intVal($arFields["FORUM_ID"])]);
}
}
if (count($res) == 1 && !empty($res["VIEWS"])) {
return $ID;
}
if (is_set($arFields, "FORUM_ID") && intVal($arFields["FORUM_ID"]) != intVal($arTopic_prev["FORUM_ID"])) {
$arFiles = array();
$db_res = CForumFiles::GetList(array(), array("TOPIC_ID" => $ID));
if ($db_res && ($res = $db_res->Fetch())) {
do {
$arFiles[] = $res["ID"];
} while ($res = $db_res->Fetch());
}
CForumFiles::UpdateByID($arFiles, array("FORUM_ID" => $arFields["FORUM_ID"]));
}
/***************** Event onAfterTopicUpdate ************************/
$events = GetModuleEvents("forum", "onAfterTopicUpdate");
if ($events->nSelectedCount > 0) {
$arTopicFields = CForumTopic::GetByID($ID, array("NoFilter" => true));
}
//.........这里部分代码省略.........
示例4: Add
function Add($arFields, $strUploadDir = false, $arParams = array())
{
global $DB;
$strUploadDir = ($strUploadDir === false ? "forum/upload" : $strUploadDir);
if (!CForumMessage::CheckFields("ADD", $arFields))
return false;
$arForum = CForumNew::GetByID($arFields["FORUM_ID"]);
$arParams["SKIP_STATISTIC"] = ($arParams["SKIP_STATISTIC"] == "Y" ? "Y" : "N");
$arParams["SKIP_INDEXING"] = ($arParams["SKIP_INDEXING"] == "Y" || $arForum["INDEXATION"] != "Y" ? "Y" : "N");
$POST_MESSAGE = $arFields["POST_MESSAGE"];
$parser = new forumTextParser(LANGUAGE_ID);
$allow = forumTextParser::GetFeatures($arForum);
$allow['SMILES'] = (($arFields["USE_SMILES"] != "Y") ? 'N' : $allow['SMILES']);
if (COption::GetOptionString("forum", "FILTER", "Y") == "Y")
{
$POST_MESSAGE = CFilterUnquotableWords::Filter($POST_MESSAGE);
$arFields["POST_MESSAGE_FILTER"] = (empty($POST_MESSAGE) ? "*" : $POST_MESSAGE);
}
/***************** Attach ******************************************/
$arFiles = array();
if (is_array($arFields["ATTACH_IMG"]))
$arFields["FILES"] = array($arFields["ATTACH_IMG"]);
unset($arFields["ATTACH_IMG"]);
if (is_array($arFields["FILES"]) && !empty($arFields["FILES"]))
{
$res = array("FORUM_ID" => $arFields["FORUM_ID"], "USER_ID" => $arFields["AUTHOR_ID"], "upload_dir" => $strUploadDir);
$arFiles = CForumFiles::Save($arFields["FILES"], $res, false);
if (!empty($arFiles))
{
$arFiles = array_keys($arFiles);
sort($arFiles);
$arFields["ATTACH_IMG"] = $arFiles[0];
$arFields["ATTACHED_FILES"] = $arFiles;
}
unset($arFields["FILES"]);
}
/***************** Attach/******************************************/
if (COption::GetOptionString("forum", "MESSAGE_HTML", "N") == "Y")
$POST_MESSAGE = $parser->convert($POST_MESSAGE, $allow, "html", $arFiles);
$arFields["POST_MESSAGE_HTML"] = $POST_MESSAGE;
/***************** Event onBeforeMessageAdd ************************/
foreach(GetModuleEvents("forum", "onBeforeMessageAdd", true) as $arEvent)
{
if (ExecuteModuleEventEx($arEvent, array(&$arFields, &$strUploadDir)) === false)
return false;
}
/***************** /Event ******************************************/
if (empty($arFields))
return false;
$arInsert = $DB->PrepareInsert("b_forum_message", $arFields, $strUploadDir);
$strDatePostField = "";
$strDatePostValue = "";
if (!is_set($arFields, "POST_DATE"))
{
$strDatePostField = ", POST_DATE";
$strDatePostValue = ", ".$DB->GetNowFunction()."";
}
$strSql = "INSERT INTO b_forum_message(".$arInsert[0].$strDatePostField.") VALUES(".$arInsert[1].$strDatePostValue.")";
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
$ID = intVal($DB->LastID());
/***************** Attach ******************************************/
if (!empty($arFiles))
CForumFiles::UpdateByID($arFiles, array("FORUM_ID" => $arFields["FORUM_ID"],
"TOPIC_ID" => $arFields["TOPIC_ID"], "MESSAGE_ID" => $ID));
/***************** Attach/******************************************/
/***************** Quota *******************************************/
$_SESSION["SESS_RECOUNT_DB"] = "Y";
$GLOBALS["USER_FIELD_MANAGER"]->Update("FORUM_MESSAGE", $ID, $arFields);
if ($arParams["SKIP_STATISTIC"] == "Y" && $arParams["SKIP_INDEXING"] == "Y")
return $ID;
$arMessage = CForumMessage::GetByIDEx($ID, array("GET_FORUM_INFO" => "N", "GET_TOPIC_INFO" => "Y", "FILTER" => "Y"));
if ($arParams["SKIP_STATISTIC"] != "Y")
{
if (intVal($arMessage["AUTHOR_ID"]) > 0)
{
CForumUser::SetStat($arMessage["AUTHOR_ID"], array("MESSAGE" => $arMessage));
}
CForumTopic::SetStat($arMessage["TOPIC_ID"], array("MESSAGE" => $arMessage));
CForumNew::SetStat($arMessage["FORUM_ID"], array("MESSAGE" => $arMessage));
}
/***************** Events onAfterMessageAdd ************************/
foreach(GetModuleEvents("forum", "onAfterMessageAdd", true) as $arEvent)
ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage, $arMessage["TOPIC_INFO"], $arMessage["FORUM_INFO"], $arFields));
/***************** /Events *****************************************/
if ($arMessage["APPROVED"] == "Y")
{
if ($arParams["SKIP_INDEXING"] != "Y" && CModule::IncludeModule("search"))
{
$arMessage["POST_MESSAGE"] = (COption::GetOptionString("forum", "FILTER", "Y") == "Y" ?
$arMessage["POST_MESSAGE_FILTER"] : $arMessage["POST_MESSAGE"]);
$arParams = array(
"PERMISSION" => array(),
//.........这里部分代码省略.........
示例5: ForumMoveMessage
//.........这里部分代码省略.........
if ($db_res && ($res = $db_res->Fetch())) {
$arRes["NAME"] = $res["AUTHOR_NAME"];
$arRes["ID"] = $res["AUTHOR_ID"];
}
$arFieldsTopic = array("TITLE" => $arFields["TITLE"], "TITLE_SEO" => $arFields["TITLE_SEO"], "DESCRIPTION" => $arFields["DESCRIPTION"], "ICON" => $arFields["ICON"], "TAGS" => $arFields["TAGS"], "FORUM_ID" => $FID, "USER_START_ID" => $arRes["ID"], "USER_START_NAME" => $arRes["NAME"], "LAST_POSTER_NAME" => $arRes["NAME"], "LAST_POSTER_ID" => $arRes["ID"], "APPROVED" => $arFields["APPROVED"]);
$NewTID = CForumTopic::Add($arFieldsTopic);
if (IntVal($NewTID) <= 0) {
$arError[] = GetMessage("FMM_NO_TOPIC_NOT_CREATED");
} else {
$arNewTopic = CForumTopic::GetByID($NewTID);
if ($arNewTopic) {
$NewFID = $FID;
$arNewForum = $arForum;
$SendSubscribe = true;
} else {
$arError[] = GetMessage("FMM_NO_TOPIC_NOT_CREATED");
}
}
}
}
if (count($arError) <= 0) {
// Move message
$db_res = CForumMessage::GetList(array(), array("@ID" => implode(",", $Message), "TOPIC_ID" => $TID));
if ($db_res && ($res = $db_res->Fetch())) {
do {
// echo "NewFID: ".$NewFID." -- FID:".$FID."<br/>";
$arMessage = array();
if ($NewFID != $FID) {
$arMessage["APPROVED"] = $arNewForum["MODERATION"] == "Y" ? "N" : "Y";
if ($arCurrUser["Perms"]["NewFID"] >= "Q") {
$arMessage["APPROVED"] = "Y";
}
$arMessage["FORUM_ID"] = $NewFID;
$arMessage["POST_MESSAGE_HTML"] = "";
}
if ($NewTID != $TID) {
$arMessage["NEW_TOPIC"] = "N";
$arMessage["TOPIC_ID"] = $NewTID;
}
if (count($arMessage) > 0) {
$MID = CForumMessage::Update($res["ID"], $arMessage, true);
$res_log = $SendSubscribe == true ? GetMessage("F_MESSAGE_WAS_MOVED_TO_NEW") : GetMessage("F_MESSAGE_WAS_MOVED");
$res_log = str_replace(array("#ID#", "#TOPIC_TITLE#", "#TOPIC_ID#", "#NEW_TOPIC_TITLE#", "#NEW_TOPIC_ID#"), array($MID, $arTopic["TITLE"], $arTopic["ID"], $arNewTopic['TITLE'], $arNewTopic['ID']), $res_log);
$res["TITLE"] = $arNewTopic['TITLE'];
$res["TOPIC_ID"] = $arNewTopic['ID'];
$res["beforeTITLE"] = $arTopic["TITLE"];
$res["DESCRIPTION"] = $res_log;
CForumEventLog::Log("message", "move", $MID, serialize($res));
$db_res2 = CForumFiles::GetList(array(), array("FILE_MESSAGE_ID" => $res["ID"]));
if ($db_res2 && ($res2 = $db_res2->Fetch())) {
$arFiles = array();
do {
$arFiles[] = $res2["FILE_ID"];
} while ($res2 = $db_res2->Fetch());
CForumFiles::UpdateByID($arFiles, $arMessage);
}
if (IntVal($MID) <= 0) {
$arError[] = str_replace("##", $res["ID"], GetMessage("FMM_NO_MESSAGE_MOVE"));
break;
}
}
} while ($res = $db_res->Fetch());
}
}
if (count($arError) <= 0) {
$db_res = CForumMessage::GetList(array(), array("TOPIC_ID" => $TID), false, 1);
if (!($db_res && ($res = $db_res->Fetch()))) {
CForumTopic::Delete($TID);
} else {
CForumTopic::SetStat($TID);
}
$db_res = CForumMessage::GetList(array(), array("TOPIC_ID" => $NewTID), false, 1);
if (!($db_res && ($res = $db_res->Fetch()))) {
CForumTopic::Delete($NewTID);
} else {
CForumTopic::SetStat($NewTID);
}
CForumNew::SetStat($FID);
if ($NewFID != $FID) {
CForumNew::SetStat($NewFID);
}
}
if (count($arError) <= 0) {
$DB->Commit();
} else {
$DB->Rollback();
}
if (count($arError) > 0) {
$strErrorMessage .= implode(". \n", $arError) . ". \n";
} else {
$strOKMessage .= GetMessage("FMM_YES_MESSAGE_MOVE");
if ($SendSubscribe) {
foreach ($Message as $MID) {
CForumMessage::SendMailMessage($MID, array(), false, "NEW_FORUM_MESSAGE");
}
}
return true;
}
return false;
}