本文整理汇总了PHP中CForumFiles::GetList方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumFiles::GetList方法的具体用法?PHP CForumFiles::GetList怎么用?PHP CForumFiles::GetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumFiles
的用法示例。
在下文中一共展示了CForumFiles::GetList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnPrepareComments
function OnPrepareComments()
{
$arResult =& $this->component->arResult;
$arParams =& $this->component->arParams;
$arMessages =& $arResult['MESSAGES'];
$arResult['FILES'] = array();
if (!empty($arMessages)) {
$res = array_keys($arMessages);
$arFilter = array("FORUM_ID" => $arParams["FORUM_ID"], "TOPIC_ID" => $arResult["FORUM_TOPIC_ID"], "APPROVED_AND_MINE" => $GLOBALS["USER"]->GetId(), ">MESSAGE_ID" => intVal(min($res)) - 1, "<MESSAGE_ID" => intVal(max($res)) + 1);
if ($arResult["USER"]["RIGHTS"]["MODERATE"] == "Y") {
unset($arFilter["APPROVED_AND_MINE"]);
}
$db_files = CForumFiles::GetList(array("MESSAGE_ID" => "ASC"), $arFilter);
if ($db_files && ($res = $db_files->Fetch())) {
do {
$res["SRC"] = CFile::GetFileSRC($res);
if ($arMessages[$res["MESSAGE_ID"]]["~ATTACH_IMG"] == $res["FILE_ID"]) {
// attach for custom
$arMessages[$res["MESSAGE_ID"]]["~ATTACH_FILE"] = $res;
$arMessages[$res["MESSAGE_ID"]]["ATTACH_IMG"] = CFile::ShowFile($res["FILE_ID"], 0, $this->imageSize, $this->imageSize, true, "border=0", false);
$arMessages[$res["MESSAGE_ID"]]["ATTACH_FILE"] = $arMessages[$res["MESSAGE_ID"]]["ATTACH_IMG"];
}
$arMessages[$res["MESSAGE_ID"]]["FILES"][$res["FILE_ID"]] = $res;
$arResult['FILES'][$res["FILE_ID"]] = $res;
} while ($res = $db_files->Fetch());
}
}
}
示例2: AddComment_Photo_Forum
public static function AddComment_Photo_Forum($arFields, $FORUM_ID, $arLog)
{
if (!CModule::IncludeModule("forum")) {
return false;
}
if (!CModule::IncludeModule("iblock")) {
return false;
}
$ufFileID = array();
$ufDocID = array();
$arElement = false;
$arFilteredText = array();
$arFilter = array("ID" => $arLog["SOURCE_ID"]);
$arSelectedFields = array("IBLOCK_ID", "ID", "NAME", "TAGS", "CODE", "IBLOCK_SECTION_ID", "DETAIL_PAGE_URL", "CREATED_BY", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PROPERTY_FORUM_TOPIC_ID", "PROPERTY_FORUM_MESSAGE_CNT");
$db_res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelectedFields);
if ($db_res && ($res = $db_res->GetNext())) {
$arElement = $res;
}
if ($arElement) {
// check iblock properties
CSocNetLogTools::AddComment_Review_CheckIBlock_Forum($arElement);
$dbMessage = CForumMessage::GetList(array(), array("PARAM2" => $arElement["ID"]));
if (!($arMessage = $dbMessage->Fetch())) {
// Add Topic
$TOPIC_ID = CSocNetLogTools::AddComment_Review_CreateRoot_Forum($arElement, $FORUM_ID);
$bNewTopic = true;
} else {
$TOPIC_ID = $arMessage["TOPIC_ID"];
}
if (intval($TOPIC_ID) > 0) {
if (COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
$arFields["TEXT_MESSAGE"] = $arFilteredText["TEXT_MESSAGE"] = CFilterUnquotableWords::Filter($arFields["TEXT_MESSAGE"]);
$arFilteredText["MESSAGE"] = CFilterUnquotableWords::Filter($arFields["MESSAGE"]);
}
// Add comment
$messageID = false;
$arFieldsMessage = array("POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "USE_SMILES" => "Y", "PARAM2" => $arElement["ID"], "APPROVED" => "Y");
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsMessage["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
}
}
}
$messageID = ForumAddMessage("REPLY", $FORUM_ID, $TOPIC_ID, 0, $arFieldsMessage, $sError, $sNote);
if (!$messageID) {
$strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
} else {
// get UF DOC value and FILE_ID there
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
CSocNetLogTools::AddComment_Review_UpdateElement_Forum($arElement, $TOPIC_ID, $bNewTopic);
}
} else {
$strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
}
} else {
$strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
}
return array_merge($arFilteredText, array("SOURCE_ID" => $messageID, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $messageID, "ERROR" => $strError, "NOTES" => "", "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID), "IM_MESSAGE" => $messageID ? $arFields["TEXT_MESSAGE"] : false));
}
示例3: __deprecated_Add
/**
* WARNING! This method is transitional and can be changed without
* any notifications! Don't use it.
*
* @deprecated
*/
public static function __deprecated_Add($commentText, $forumTopicId, $forumId, $nameTemplate, $arTask, $permissions, $commentId, $givenUserId, $imageWidth, $imageHeight, $arSmiles, $arForum, $messagesPerPage, $arUserGroupArray, $backPage, $strMsgAddComment, $strMsgEditComment, $strMsgNewTask, $componentName, &$outForumTopicId, &$arErrorCodes, &$outStrUrl, $arFieldsAdditional)
{
global $DB;
if (is_array($arTask)) {
if (!array_key_exists('~TITLE', $arTask)) {
$arTmpTask = $arTask;
foreach ($arTmpTask as $key => $value) {
if (substr($key, 0, 1) !== '~') {
$arTask['~' . $key] = $arTmpTask[$key];
}
}
}
}
$MID = 0;
$TID = 0;
if ($forumTopicId > 0 && CForumTopic::GetByID($forumTopicId) === false) {
$forumTopicId = false;
}
if ($forumTopicId <= 0) {
$arUserStart = array("ID" => intVal($arTask["CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
if ($arUserStart["ID"] > 0) {
$res = array();
$db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arTask["CREATED_BY"]));
if ($db_res && ($res = $db_res->Fetch())) {
$res["FORUM_USER_ID"] = intVal($res["ID"]);
$res["ID"] = $res["USER_ID"];
} else {
$db_res = CUser::GetByID($arTask["CREATED_BY"]);
if ($db_res && ($res = $db_res->Fetch())) {
$res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
$res["USER_PROFILE"] = "N";
}
}
if (!empty($res)) {
$arUserStart = $res;
$sName = $res["SHOW_NAME"] == "Y" ? trim(CUser::FormatName($nameTemplate, $res)) : "";
$arUserStart["NAME"] = empty($sName) ? trim($res["LOGIN"]) : $sName;
}
}
$arUserStart["NAME"] = empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"];
$DB->StartTransaction();
$arFields = array("TITLE" => $arTask["~TITLE"], "FORUM_ID" => $forumId, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "APPROVED" => "Y", "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions, "NAME_TEMPLATE" => $nameTemplate, 'XML_ID' => 'TASK_' . $arTask['ID']);
$TID = CForumTopic::Add($arFields);
if (intVal($TID) <= 0) {
$arErrorCodes[] = array('code' => 'topic is not created');
} else {
$arFields = array("FORUM_TOPIC_ID" => $TID);
$task = new CTasks();
$task->Update($arTask["ID"], $arFields);
}
if (!empty($arErrorCodes)) {
$DB->Rollback();
return false;
} else {
$DB->Commit();
}
}
$arFieldsG = array("POST_MESSAGE" => $commentText, "AUTHOR_NAME" => '', "AUTHOR_EMAIL" => $GLOBALS['USER']->GetEmail(), "USE_SMILES" => NULL, "PARAM2" => $arTask['ID'], "TITLE" => $arTask["~TITLE"], "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions);
// UF_* forwarding
if (is_array($arFieldsAdditional)) {
foreach ($arFieldsAdditional as $field => $value) {
if (strlen($field) && substr($field, 0, 3) == 'UF_') {
$arFieldsG[$field] = $value;
$GLOBALS[$field] = $value;
// strange behaviour required for ForumMessageAdd() to handle UF_* properly
}
}
}
if (!empty($_FILES["REVIEW_ATTACH_IMG"])) {
$arFieldsG["ATTACH_IMG"] = $_FILES["REVIEW_ATTACH_IMG"];
} else {
$arFiles = array();
if (!empty($_REQUEST["FILES"])) {
foreach ($_REQUEST["FILES"] as $key) {
$arFiles[$key] = array("FILE_ID" => $key);
if (!in_array($key, $_REQUEST["FILES_TO_UPLOAD"])) {
$arFiles[$key]["del"] = "Y";
}
}
}
if (!empty($_FILES)) {
$res = array();
foreach ($_FILES as $key => $val) {
if (substr($key, 0, strLen("FILE_NEW")) == "FILE_NEW" && !empty($val["name"])) {
$arFiles[] = $_FILES[$key];
}
}
}
if (!empty($arFiles)) {
$arFieldsG["FILES"] = $arFiles;
}
}
$TOPIC_ID = $forumTopicId > 0 ? $forumTopicId : $TID;
$MESSAGE_ID = 0;
//.........这里部分代码省略.........
示例4: array
// group
if ($arTask["GROUP_ID"]) {
$arGroup = CSocNetGroup::GetByID($arTask["GROUP_ID"]);
$arTask["GROUP_NAME"] = $arGroup["NAME"];
}
if ($arTask["FILES"]) {
$rsFiles = CFile::GetList(array(), array("@ID" => implode(",", $arTask["FILES"])));
$arTask["FILES"] = array();
while ($file = $rsFiles->GetNext()) {
$arTask["FILES"][] = $file;
}
}
// comments files
$arTask["FORUM_FILES"] = array();
if ($arTask["FORUM_TOPIC_ID"]) {
$rsFiles = CForumFiles::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $arTask["FORUM_TOPIC_ID"]));
while ($arFile = $rsFiles->GetNext()) {
$arTask["FORUM_FILES"][] = $arFile;
}
}
// templates
$rsTemplates = CTaskTemplates::GetList(array("ID" => "DESC"), array("CREATED_BY" => $loggedInUserId, 'BASE_TEMPLATE_ID' => false, '!TPARAM_TYPE' => CTaskTemplates::TYPE_FOR_NEW_USER), array('NAV_PARAMS' => array('nTopCount' => 10)), array(), array('ID', 'TITLE', 'TASK_ID', 'REPLICATE_PARAMS'));
$arResult["TEMPLATES"] = array();
while ($arTemplate = $rsTemplates->GetNext()) {
$arResult["TEMPLATES"][] = $arTemplate;
// try to found linked
if ($arTask['FORKED_BY_TEMPLATE_ID'] > 0 && $arTemplate['ID'] == $arTask['FORKED_BY_TEMPLATE_ID']) {
$arLinkedTemplate = $arTemplate;
} elseif ($arTemplate['TASK_ID'] > 0 && $arTemplate['TASK_ID'] == $arParams["TASK_ID"]) {
$arLinkedTemplate = $arTemplate;
}
示例5: ForumAddPageParams
$res["URL"]["EDIT"] = ForumAddPageParams(CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_TOPIC_NEW"], array("FID" => $arParams["FID"])), array("TID" => $arParams["TID"], "MID" => $res["ID"], "MESSAGE_TYPE" => "EDIT")) . "&" . bitrix_sessid_get();
/************** Panels/*********************************************/
/************** For custom templates *******************************/
$res["profile_view"] = $res["URL"]["AUTHOR"];
$res["MESSAGE_ANCHOR"] = $res["URL"]["MESSAGE"];
$res["message_link"] = $res["URL"]["MESSAGE"];
$res["email"] = $res["URL"]["AUTHOR_EMAIL"];
$res["icq"] = $res["URL"]["AUTHOR_ICQ"];
$res["pm_edit"] = $res["URL"]["AUTHOR_PM"];
/************** For custom templates/*******************************/
$arResult["MESSAGE_LIST"][$res["ID"]] = $res;
}
/************** Attach files ***************************************/
if (!empty($arResult["MESSAGE_LIST"])) {
$arFilter = array("@FILE_MESSAGE_ID" => array_keys($arResult["MESSAGE_LIST"]));
$db_files = CForumFiles::GetList(array("MESSAGE_ID" => "ASC"), $arFilter);
if ($db_files && ($res = $db_files->Fetch())) {
do {
$res["SRC"] = CFile::GetFileSRC($res);
if ($arResult["MESSAGE_LIST"][$res["MESSAGE_ID"]]["~ATTACH_IMG"] == $res["FILE_ID"]) {
// attach for custom
$arResult["MESSAGE_LIST"][$res["MESSAGE_ID"]]["~ATTACH_FILE"] = $res;
$arResult["MESSAGE_LIST"][$res["MESSAGE_ID"]]["ATTACH_IMG"] = CFile::ShowFile($res["FILE_ID"], 0, $arParams["IMAGE_SIZE"], $arParams["IMAGE_SIZE"], true, "border=0", false);
$arResult["MESSAGE_LIST"][$res["MESSAGE_ID"]]["ATTACH_FILE"] = $arResult["MESSAGE_LIST"][$res["MESSAGE_ID"]]["ATTACH_IMG"];
}
$arResult["MESSAGE_LIST"][$res["MESSAGE_ID"]]["FILES"][$res["FILE_ID"]] = $res;
$arResult["FILES"][$res["FILE_ID"]] = $res;
} while ($res = $db_files->Fetch());
}
/************** Message info ***************************************/
$parser->arFiles = $arResult["FILES"];
示例6: AddComment_Wiki
static function AddComment_Wiki($arFields)
{
if (!CModule::IncludeModule('iblock')) {
return false;
}
if (!CModule::IncludeModule('socialnetwork')) {
return false;
}
$ufFileID = array();
$ufDocID = array();
$dbResult = CSocNetLog::GetList(array('ID' => 'DESC'), array('TMP_ID' => $arFields['LOG_ID']), false, false, array('ID', 'SOURCE_ID', 'PARAMS', 'URL'));
$bFound = false;
if ($arLog = $dbResult->Fetch()) {
if (strlen($arLog['PARAMS']) > 0) {
$arFieldsParams = explode('&', $arLog['PARAMS']);
if (is_array($arFieldsParams) && count($arFieldsParams) > 0) {
foreach ($arFieldsParams as $tmp) {
list($key, $value) = explode('=', $tmp);
if ($key == 'forum_id') {
$FORUM_ID = intval($value);
break;
}
}
}
}
if ($FORUM_ID > 0 && intval($arLog['SOURCE_ID']) > 0) {
$bFound = true;
}
}
if ($bFound) {
$arElement = false;
$arFilter = array('ID' => $arLog['SOURCE_ID']);
$arSelectedFields = array('IBLOCK_ID', 'ID', 'NAME', 'TAGS', 'CODE', 'IBLOCK_SECTION_ID', 'DETAIL_PAGE_URL', 'CREATED_BY', 'PREVIEW_PICTURE', 'PREVIEW_TEXT', 'PROPERTY_FORUM_TOPIC_ID', 'PROPERTY_FORUM_MESSAGE_CNT');
$db_res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelectedFields);
if ($db_res && ($res = $db_res->GetNext())) {
$arElement = $res;
}
if ($arElement) {
// check iblock properties
CSocNetLogTools::AddComment_Review_CheckIBlock($arElement);
$dbMessage = CForumMessage::GetList(array(), array('PARAM2' => $arElement['ID']));
if (!($arMessage = $dbMessage->Fetch())) {
// Add Topic and Root Message
$TOPIC_ID = CSocNetLogTools::AddComment_Review_CreateRoot($arElement, $FORUM_ID, false);
$bNewTopic = true;
} else {
$TOPIC_ID = $arMessage['TOPIC_ID'];
}
if (intval($TOPIC_ID) > 0) {
// Add comment
$messageID = false;
$arFieldsMessage = array('POST_MESSAGE' => $arFields['TEXT_MESSAGE'], 'USE_SMILES' => 'Y', 'PARAM2' => $arElement['ID'], 'APPROVED' => 'Y');
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsMessage["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
}
}
}
$messageID = ForumAddMessage('REPLY', $FORUM_ID, $TOPIC_ID, 0, $arFieldsMessage, $sError, $sNote);
if (!$messageID) {
$strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
} else {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
CSocNetLogTools::AddComment_Review_UpdateElement($arElement, $TOPIC_ID, $bNewTopic);
$userID = $GLOBALS["USER"]->GetID();
if (CModule::IncludeModule("im") && intval($arElement["CREATED_BY"]) > 0 && $arElement["CREATED_BY"] != $userID) {
$rsUnFollower = CSocNetLogFollow::GetList(array("USER_ID" => $arElement["CREATED_BY"], "CODE" => "L" . $arLog["ID"], "TYPE" => "N"), array("USER_ID"));
$arUnFollower = $rsUnFollower->Fetch();
if (!$arUnFollower) {
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $arElement["CREATED_BY"], "FROM_USER_ID" => $userID, "LOG_ID" => $arLog["ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "wiki", "NOTIFY_EVENT" => "comment");
$arParams["TITLE"] = str_replace(array("\r\n", "\n"), " ", $arElement["NAME"]);
$arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
$arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
$arTmp = CSocNetLogTools::ProcessPath(array("ELEMENT_URL" => $arLog["URL"]), $arElement["CREATED_BY"]);
$serverName = $arTmp["SERVER_NAME"];
$url = $arTmp["URLS"]["ELEMENT_URL"];
$arMessageFields["NOTIFY_TAG"] = "WIKI|COMMENT|" . $arElement['ID'];
$arMessageFields["NOTIFY_MESSAGE"] = GetMessage("WIKI_SONET_FROM_LOG_IM_COMMENT", array("#title#" => strlen($url) > 0 ? "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>" : htmlspecialcharsbx($arParams["TITLE"])));
$arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("WIKI_SONET_FROM_LOG_IM_COMMENT", array("#title#" => htmlspecialcharsbx($arParams["TITLE"]))) . (strlen($url) > 0 ? " (" . $serverName . $url . ")" : "") . "#BR##BR#" . $arFields["TEXT_MESSAGE"];
CIMNotify::Add($arMessageFields);
}
}
}
} else {
$strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
}
} else {
$strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
}
} else {
$strError = GetMessage('SONET_ADD_COMMENT_SOURCE_ERROR');
//.........这里部分代码省略.........
示例7: __deprecated_Add
/**
* WARNING! This method is transitional and can be changed without
* any notifications! Don't use it.
*
* @deprecated
*/
public static function __deprecated_Add($commentText, $forumTopicId, $forumId, $nameTemplate, $arTask, $permissions, $commentId, $givenUserId, $imageWidth, $imageHeight, $arSmiles, $arForum, $messagesPerPage, $arUserGroupArray, $backPage, $strMsgAddComment, $strMsgEditComment, $strMsgNewTask, $componentName, &$outForumTopicId, &$arErrorCodes, &$outStrUrl, $arFieldsAdditional = array())
{
global $DB;
if (is_array($arTask)) {
if (!array_key_exists('~TITLE', $arTask)) {
$arTmpTask = $arTask;
foreach ($arTmpTask as $key => $value) {
if (substr($key, 0, 1) !== '~') {
$arTask['~' . $key] = $arTmpTask[$key];
}
}
}
}
$MID = 0;
$TID = 0;
if ($forumTopicId > 0 && CForumTopic::GetByID($forumTopicId) === false) {
$forumTopicId = false;
}
if ($forumTopicId <= 0) {
$arUserStart = array("ID" => intVal($arTask["CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
if ($arUserStart["ID"] > 0) {
$res = array();
$db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arTask["CREATED_BY"]));
if ($db_res && ($res = $db_res->Fetch())) {
$res["FORUM_USER_ID"] = intVal($res["ID"]);
$res["ID"] = $res["USER_ID"];
} else {
$db_res = CUser::GetByID($arTask["CREATED_BY"]);
if ($db_res && ($res = $db_res->Fetch())) {
$res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
$res["USER_PROFILE"] = "N";
}
}
if (!empty($res)) {
$arUserStart = $res;
$sName = $res["SHOW_NAME"] == "Y" ? trim(CUser::FormatName($nameTemplate, $res)) : "";
$arUserStart["NAME"] = empty($sName) ? trim($res["LOGIN"]) : $sName;
}
}
$arUserStart["NAME"] = empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"];
$DB->StartTransaction();
$arFields = array("TITLE" => $arTask["~TITLE"], "FORUM_ID" => $forumId, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "APPROVED" => "Y", "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions, "NAME_TEMPLATE" => $nameTemplate, 'XML_ID' => 'TASK_' . $arTask['ID']);
$TID = CForumTopic::Add($arFields);
if (intVal($TID) <= 0) {
$arErrorCodes[] = array('code' => 'topic is not created');
} else {
$arFields = array("FORUM_TOPIC_ID" => $TID);
$task = new CTasks();
$task->Update($arTask["ID"], $arFields);
}
if (!empty($arErrorCodes)) {
$DB->Rollback();
return false;
} else {
$DB->Commit();
}
}
$arFieldsG = array("POST_MESSAGE" => $commentText, "AUTHOR_NAME" => '', "AUTHOR_EMAIL" => $GLOBALS['USER']->GetEmail(), "USE_SMILES" => NULL, "PARAM2" => $arTask['ID'], "TITLE" => $arTask["~TITLE"], "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions);
// UF_* forwarding
if (is_array($arFieldsAdditional)) {
foreach ($arFieldsAdditional as $field => $value) {
if (strlen($field) && substr($field, 0, 3) == 'UF_') {
$arFieldsG[$field] = $value;
$GLOBALS[$field] = $value;
// strange behaviour required for ForumMessageAdd() to handle UF_* properly
}
}
}
if (!empty($_FILES["REVIEW_ATTACH_IMG"])) {
$arFieldsG["ATTACH_IMG"] = $_FILES["REVIEW_ATTACH_IMG"];
} else {
$arFiles = array();
if (!empty($_REQUEST["FILES"])) {
foreach ($_REQUEST["FILES"] as $key) {
$arFiles[$key] = array("FILE_ID" => $key);
if (!in_array($key, $_REQUEST["FILES_TO_UPLOAD"])) {
$arFiles[$key]["del"] = "Y";
}
}
}
if (!empty($_FILES)) {
$res = array();
foreach ($_FILES as $key => $val) {
if (substr($key, 0, strLen("FILE_NEW")) == "FILE_NEW" && !empty($val["name"])) {
$arFiles[] = $_FILES[$key];
}
}
}
if (!empty($arFiles)) {
$arFieldsG["FILES"] = $arFiles;
}
}
$TOPIC_ID = $forumTopicId > 0 ? $forumTopicId : $TID;
$MESSAGE_ID = 0;
//.........这里部分代码省略.........
示例8: UpdateCrmActivityComment
public static function UpdateCrmActivityComment($arFields)
{
if (!isset($arFields["SOURCE_ID"]) || intval($arFields["SOURCE_ID"]) <= 0) {
return false;
}
$ufFileID = array();
$ufDocID = array();
$dbResult = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array('ID', 'ENTITY_ID'));
if ($arLog = $dbResult->Fetch()) {
$dbCrmActivity = CCrmActivity::GetList(array(), array('ID' => $arLog['ENTITY_ID'], 'CHECK_PERMISSIONS' => 'N'));
if (($arCrmActivity = $dbCrmActivity->Fetch()) && $arCrmActivity['TYPE_ID'] == CCrmActivityType::Task && CModule::IncludeModule("forum")) {
$messageId = intval($arFields["SOURCE_ID"]);
if ($arForumMessage = CForumMessage::GetByID($messageId)) {
$arFieldsMessage = array("POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "USE_SMILES" => "Y", "APPROVED" => "Y", "SONET_PERMS" => array("bCanFull" => true));
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsMessage["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsMessage["FILES"][$file_id] = array("FILE_ID" => $file_id);
}
if (!empty($arFieldsMessage["FILES"])) {
$arFileParams = array("FORUM_ID" => $arForumMessage["FORUM_ID"], "TOPIC_ID" => $arForumMessage["TOPIC_ID"]);
if (CForumFiles::CheckFields($arFieldsMessage["FILES"], $arFileParams, "NOT_CHECK_DB")) {
CForumFiles::Add(array_keys($arFieldsMessage["FILES"]), $arFileParams);
}
}
}
}
$messageID = ForumAddMessage("EDIT", $arForumMessage["FORUM_ID"], $arForumMessage["TOPIC_ID"], $messageId, $arFieldsMessage, $sError, $sNote);
unset($GLOBALS["UF_FORUM_MESSAGE_DOC"]);
// get UF DOC value and FILE_ID there
if ($messageID > 0) {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
}
} else {
$sError = GetMessage("CRM_SL_UPDATE_COMMENT_SOURCE_ERROR");
}
return array("ERROR" => $sError, "NOTES" => $sNote, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID));
}
}
return array("NO_SOURCE" => "Y");
}
示例9: AddCommentMessage
public static function AddCommentMessage($arFields, $FORUM_ID, $arLog)
{
global $USER, $DB;
$dbRes = CTimeManEntry::GetList(array(), array('ID' => $arLog['SOURCE_ID']));
$arEntry = $dbRes->Fetch();
if ($arEntry && CModule::IncludeModule("forum")) {
$ufFileID = array();
$ufDocID = array();
if (!($userName = trim($USER->GetFormattedName(false)))) {
$userName = $USER->GetLogin();
}
if ($arEntry["FORUM_TOPIC_ID"] <= 0) {
$t = ConvertTimeStamp(time(), "FULL");
$arTopicFields = array("TITLE" => $arEntry["DATE_START"], "USER_START_ID" => $arFields["USER_ID"], "STATE" => "Y", "FORUM_ID" => $FORUM_ID, "USER_START_NAME" => $userName, "START_DATE" => $t, "POSTS" => 0, "VIEWS" => 0, "APPROVED" => "Y", "LAST_POSTER_NAME" => $userName, "LAST_POST_DATE" => $t, "LAST_MESSAGE_ID" => 0, "XML_ID" => "TIMEMAN_ENTRY_" . $arLog["SOURCE_ID"]);
$TOPIC_ID = CForumTopic::Add($arTopicFields);
if ($TOPIC_ID > 0) {
CTimeManEntry::Update($arLog['SOURCE_ID'], array("FORUM_TOPIC_ID" => $TOPIC_ID));
}
} else {
$TOPIC_ID = $arEntry["FORUM_TOPIC_ID"];
}
if ($TOPIC_ID) {
$arFieldsP = array("AUTHOR_ID" => $arFields["USER_ID"], "AUTHOR_NAME" => $userName, "POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "POST_DATE" => date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL")), time() - 1), "FORUM_ID" => $FORUM_ID, "TOPIC_ID" => $TOPIC_ID, "APPROVED" => "Y", "PARAM2" => $arLog["SOURCE_ID"]);
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsP["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsP["FILES"][] = array("FILE_ID" => $file_id);
}
}
}
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("FORUM_MESSAGE", $arFieldsP);
$mess_id = CForumMessage::Add($arFieldsP);
// get UF DOC value and FILE_ID there
if ($mess_id > 0) {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $mess_id));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $mess_id, LANGUAGE_ID);
}
if (IsModuleInstalled("im")) {
CTimeManNotify::AddCommentToIM(array("USER_ID" => $arFieldsP["AUTHOR_ID"], "ENTRY_ID" => $arEntry["ID"], "LOG_ID" => $arLog["ID"], "MESSAGE" => $arFields["TEXT_MESSAGE"]));
}
}
return array("SOURCE_ID" => $mess_id, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID));
}
return false;
}
示例10: SocnetLogMessageAdd
public static function SocnetLogMessageAdd($arParams, $arMessageFields, $action = "")
{
static $parser = null;
if ($parser == null) {
$parser = new forumTextParser();
}
$arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "LIST" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "SMILES" => "N", "UPLOAD" => "Y", "NL2BR" => "N", "TABLE" => "N", "ALIGN" => "N");
// $arParams["LOG_ID"], $arParams["LANG"] ....
$arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $arParams["ENTITY_ID"], "EVENT_ID" => "forum", "=LOG_DATE" => !!$arMessageFields["DATE_CREATE"] ? $arMessageFields["DATE_CREATE"] : $GLOBALS["DB"]->CurrentTimeFunction(), "LOG_UPDATE" => !!$arMessageFields["POST_DATE"] ? $arMessageFields["POST_DATE"] : null, "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $arMessageFields["AUTHOR_NAME"], CForumEmail::GetLangMessage("FORUM_MAIL_SOCNET_TITLE_TOPIC", $arParams["LANG"])), "TITLE" => $arMessageFields["TITLE"], "MESSAGE" => $parser->convert($arMessageFields["POST_MESSAGE"], $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($arMessageFields["POST_MESSAGE"]), "URL" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("UID" => $arMessageFields["AUTHOR_ID"], "FID" => $arMessageFields["FORUM_ID"], "TID" => $arMessageFields["TOPIC_ID"], "TITLE_SEO" => $arMessageFields["TOPIC_ID"], "MID" => $arMessageFields["ID"])), "PARAMS" => serialize(array("PATH_TO_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("TID" => $arMessageFields["TOPIC_ID"])))), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arMessageFields["ID"], "RATING_TYPE_ID" => "FORUM_TOPIC", "RATING_ENTITY_ID" => $arMessageFields["TOPIC_ID"]);
if ($arMessageFields["AUTHOR_ID"] > 0) {
$arFieldsForSocnet["USER_ID"] = $arMessageFields["AUTHOR_ID"];
}
$db_res = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $arMessageFields["ID"]));
$ufFileID = array();
while ($res = $db_res->Fetch()) {
$ufFileID[] = $res["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $arMessageFields["ID"], LANGUAGE_ID);
$logID = $arParams["LOG_ID"];
if ($logID <= 0) {
if (!empty($ufFileID)) {
$arFieldsForSocnet["UF_SONET_LOG_FILE"] = $ufFileID;
}
if ($ufDocID) {
$arFieldsForSocnet["UF_SONET_LOG_DOC"] = $ufDocID;
}
$logID = CSocNetLog::Add($arFieldsForSocnet, false);
if (intval($logID) > 0) {
CSocNetLog::Update($logID, array("TMP_ID" => $logID));
CSocNetLogRights::SetForSonet($logID, $arFieldsForSocnet["ENTITY_TYPE"], $arFieldsForSocnet["ENTITY_ID"], "forum", "view", true);
if ($action == "SEND_EVENT") {
CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
}
}
}
if ($logID > 0 && $action == "ADD_COMMENT") {
if (!empty($ufFileID)) {
$arFieldsForSocnet["UF_SONET_COM_FILE"] = $ufFileID;
}
if ($ufDocID) {
$arFieldsForSocnet["UF_SONET_COM_DOC"] = $ufDocID;
}
$arFieldsForSocnet["LOG_ID"] = $logID;
$arFieldsForSocnet["RATING_TYPE_ID"] = "FORUM_POST";
$arFieldsForSocnet["RATING_ENTITY_ID"] = $arMessageFields["ID"];
$commentID = CSocNetLogComments::Add($arFieldsForSocnet);
CSocNetLog::CounterIncrement($commentID, false, false, "LC");
return $commentID;
}
return $logID;
}
示例11: AddComment_Tasks
function AddComment_Tasks($arFields)
{
global $DB;
if (!CModule::IncludeModule("forum")) {
return false;
}
if (!CModule::IncludeModule("tasks")) {
return false;
}
$ufFileID = array();
$ufDocID = array();
$dbResult = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "SITE_ID"));
if ($arLog = $dbResult->Fetch()) {
$rsTask = CTasks::GetById($arLog["SOURCE_ID"]);
if ($arTask = $rsTask->Fetch()) {
// read shared cross-site FORUM_ID
$forumID = COption::GetOptionString("tasks", "task_forum_id", 0, $siteId = '');
if ($forumID) {
if (!$arTask["FORUM_TOPIC_ID"]) {
$arUserStart = array("ID" => intVal($arTask["CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
if ($arUserStart["ID"] > 0) {
$res = array();
$db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arTask["CREATED_BY"]));
if ($db_res && ($res = $db_res->Fetch())) {
$res["FORUM_USER_ID"] = intVal($res["ID"]);
$res["ID"] = $res["USER_ID"];
} else {
$db_res = CUser::GetByID($arTask["CREATED_BY"]);
if ($db_res && ($res = $db_res->Fetch())) {
$res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
$res["USER_PROFILE"] = "N";
}
}
if (!empty($res)) {
$arUserStart = $res;
$sName = $res["SHOW_NAME"] == "Y" ? trim($res["NAME"] . " " . $res["LAST_NAME"]) : "";
$arUserStart["NAME"] = empty($sName) ? trim($res["LOGIN"]) : $sName;
}
}
$arUserStart["NAME"] = empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"];
$DB->StartTransaction();
$arTopicFields = array("TITLE" => $arTask["TITLE"], "FORUM_ID" => $forumID, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "PERMISSION_EXTERNAL" => 'E', "PERMISSION" => 'E', "APPROVED" => "Y", 'XML_ID' => 'TASK_' . $arTask['ID']);
$TID = CForumTopic::Add($arTopicFields);
if (intVal($TID) > 0) {
$arFieldsFirstMessage = array("POST_MESSAGE" => $arTopicFields['XML_ID'], "AUTHOR_ID" => $arTopicFields["USER_START_ID"], "AUTHOR_NAME" => $arTopicFields["USER_START_NAME"], "FORUM_ID" => $arTopicFields["FORUM_ID"], "TOPIC_ID" => $TID, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => 'TK', "PARAM2" => $arTask['ID'], "PERMISSION_EXTERNAL" => 'E', "PERMISSION" => 'E');
CForumMessage::Add($arFieldsFirstMessage, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
$arTask["FORUM_TOPIC_ID"] = $TID;
$arTaskFields = array("FORUM_TOPIC_ID" => $TID);
$task = new CTasks();
$task->Update($arTask["ID"], $arTaskFields);
}
if (!$arTask["FORUM_TOPIC_ID"]) {
$DB->Rollback();
} else {
$DB->Commit();
}
} else {
// override forumId by fact forum, attached to the task
if ($arTopic = CForumTopic::getByID($arTask['FORUM_TOPIC_ID'])) {
$forumID = $arTopic['FORUM_ID'];
}
}
if ($forumID && $arTask["FORUM_TOPIC_ID"]) {
$userID = $GLOBALS["USER"]->GetID();
$arLogSites = array();
$rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
while ($arLogSite = $rsLogSite->Fetch()) {
$arLogSites[] = $arLogSite["LID"];
}
$bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin($arLogSites);
if ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "tasks", "view", $bCurrentUserIsAdmin)) {
$strPermission = "I";
}
} else {
if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "tasks", "view", $bCurrentUserIsAdmin)) {
$strPermission = "I";
}
}
$arFieldsMessage = array("POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "USE_SMILES" => "Y", "PERMISSION_EXTERNAL" => "Q", "PERMISSION" => $strPermission, "APPROVED" => "Y");
$MESSAGE_TYPE = 'REPLY';
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsMessage["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
}
}
}
$messageID = ForumAddMessage($MESSAGE_TYPE, $forumID, $arTask["FORUM_TOPIC_ID"], 0, $arFieldsMessage, $sError, $sNote);
// get UF DOC value and FILE_ID there
if ($messageID > 0) {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
//.........这里部分代码省略.........
示例12: ForumMoveMessage
function ForumMoveMessage($FID, $TID, $Message, $NewTID = 0, $arFields, &$strErrorMessage, &$strOKMessage, $iFileSize = false)
{
global $USER, $DB;
$arError = array();
$arOK = array();
$NewFID = 0;
$arForum = array();
$arTopic = array();
$arNewForum = array();
$arNewTopic = array();
$arCurrUser = array();
$SendSubscribe = false;
//************************* Input params **************************************************************************
$TID = IntVal($TID);
$FID = IntVal($FID);
$NewTID = IntVal($NewTID);
$Message = ForumDataToArray($Message);
if (empty($Message)) {
$arError[] = GetMessage("FMM_NO_MESSAGE");
}
if ($TID <= 0) {
$arError[] = GetMessage("FMM_NO_TOPIC_SOURCE0");
} else {
$arTopic = CForumTopic::GetByID($TID);
if ($arTopic) {
$FID = IntVal($arTopic["FORUM_ID"]);
$arForum = CForumNew::GetByID($FID);
} else {
$arError[] = GetMessage("FMM_NO_TOPIC_SOURCE1");
}
}
if ($NewTID <= 0 && strLen(trim($arFields["TITLE"])) <= 0) {
$arError[] = GetMessage("FMM_NO_TOPIC_RECIPIENT0");
} elseif ($NewTID > 0) {
if ($NewTID == $TID) {
$arError[] = GetMessage("FMM_NO_TOPIC_EQUAL");
}
$arNewTopic = CForumTopic::GetByID($NewTID);
if (!$arNewTopic) {
$arError[] = GetMessage("FMM_NO_TOPIC_RECIPIENT1");
} elseif ($arNewTopic["STATE"] == "L") {
$arError[] = GetMessage("FMM_TOPIC_IS_LINK");
} else {
$NewFID = $arNewTopic["FORUM_ID"];
$arNewForum = CForumNew::GetByID($NewFID);
}
}
//*************************/Input params **************************************************************************
//*************************!Proverka prav pol'zovatelya na forume-istochnike i forume-poluchatele*********************
// Tak kak realizovan mehanizm peremeweniya tem s forumov, gde tekuwij pol'zovatel' yavlyaetsya moderatorom na forumy,
// gde on moderatorov ne yavlyaetsya, to v dannom sluchae budet ispol'zovan tot zhe samyj shablon dejstvij. Isklyucheniem
// yavlyaetsya to, chto esli pol'zovatel' na forume-poluchatele ne obladaet pravami moderirovaniya, tema budet neaktivna.
//*************************!Proverka prav pol'zovatelya*************************************************************
$arCurrUser["Perms"]["FID"] = ForumCurrUserPermissions($FID);
$arCurrUser["Perms"]["NewFID"] = ForumCurrUserPermissions($NewFID);
if ($arCurrUser["Perms"]["FID"] < "Q") {
$arError[] = GetMessage("FMM_NO_MODERATE");
}
//************************* Actions *******************************************************************************
$DB->StartTransaction();
if (count($arError) <= 0) {
// Create topic
if ($NewTID <= 0) {
$arFields["APPROVED"] = $arNewForum["MODERATION"] == "Y" ? "N" : "Y";
if ($arCurrUser["Perms"]["NewFID"] >= "Q") {
$arFields["APPROVED"] = "Y";
}
$arRes = array("NAME" => GetMessage("FR_GUEST"));
$ShowName = GetMessage("FR_GUEST");
$db_res = CForumMessage::GetList(array("ID" => "ASC"), array("@ID" => implode(",", $Message), "TOPIC_ID" => $TID));
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") {
//.........这里部分代码省略.........
示例13: array
$res["AUTHOR_URL"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("user_id" => $res["AUTHOR_ID"]));
}
$res["POST_TIMESTAMP"] = MakeTimeStamp($res["POST_DATE"], CSite::GetDateFormat());
$arTopics[$res['TOPIC_ID']]['MESSAGE'] = array('ID' => $res["ID"], '~POST_MESSAGE_TEXT' => $res["~POST_MESSAGE_TEXT"], 'POST_MESSAGE_TEXT' => $res["~POST_MESSAGE_TEXT"], 'NEW_TOPIC' => $res["NEW_TOPIC"], 'POST_DATE' => CForumFormat::DateFormat($arParams["DATE_TIME_FORMAT"], $res["POST_TIMESTAMP"]), 'USE_SMILES' => $res["USE_SMILES"], 'POST_TIMESTAMP' => $res["POST_TIMESTAMP"], 'AUTHOR_NAME' => $res["AUTHOR_NAME"], 'AUTHOR_ID' => $res["AUTHOR_ID"], 'AUTHOR_URL' => str_replace('#UID#', $res["AUTHOR_ID"], $res["AUTHOR_URL"]), 'AUTHOR_AVATAR_ID' => $res["AVATAR"] > 0 ? $res["AVATAR"] : $res["PERSONAL_PHOTO"]);
if ($arParams["CACHE_TAG"] == "Y" && $arParams["CACHE_TIME"] > 0 && defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->RegisterTag('forum_topic_' . $res['TOPIC_ID']);
}
}
if (!empty($ids)) {
$parser = new forumTextParser(LANGUAGE_ID);
$parser->imageWidth = $parser->imageHeight = array_key_exists("IMAGE_SIZE", $arParams) ? $arParams["IMAGE_SIZE"] : 200;
$parser->userPath = $arParams["URL_TEMPLATES_PROFILE_VIEW"];
$parser->userNameTemplate = $arParams["NAME_TEMPLATE"];
$files = array();
$props = array();
$db_files = CForumFiles::GetList(array("MESSAGE_ID" => "ASC"), array("@MESSAGE_ID" => $ids));
while ($res = $db_files->Fetch()) {
$files[$res["MESSAGE_ID"]] = $files[$res["MESSAGE_ID"]] ?: array();
$files[$res["MESSAGE_ID"]][$res["FILE_ID"]] = $res;
}
if (!empty($arParams["USER_FIELDS"])) {
$db_props = CForumMessage::GetList(array("ID" => "ASC"), array("@ID" => $ids), false, 0, array("SELECT" => $arParams["USER_FIELDS"]));
while ($res = $db_props->Fetch()) {
$props[$res["ID"]] = array_intersect_key($res, array_flip($arParams["USER_FIELDS"]));
}
}
$arAllow = array("HTML" => $arParams["ALLOW_HTML"], "ANCHOR" => $arParams["ALLOW_ANCHOR"], "BIU" => $arParams["ALLOW_BIU"], "IMG" => $arParams["ALLOW_IMG"], "VIDEO" => $arParams["ALLOW_VIDEO"], "LIST" => $arParams["ALLOW_LIST"], "QUOTE" => $arParams["ALLOW_QUOTE"], "CODE" => $arParams["ALLOW_CODE"], "FONT" => $arParams["ALLOW_FONT"], "SMILES" => $arParams["ALLOW_SMILES"], "NL2BR" => $arParams["ALLOW_NL2BR"], "TABLE" => $arParams["ALLOW_TABLE"], "UPLOAD" => $arParams["ALLOW_UPLOAD"], "ALIGN" => $arParams["ALLOW_ALIGN"]);
foreach ($arTopics as &$topic) {
$topic['MESSAGE']["POST_MESSAGE_TEXT"] = $parser->convert($topic['MESSAGE']["~POST_MESSAGE_TEXT"], array_merge($arAllow, array("SMILES" => $topic["MESSAGE"]["USE_SMILES"] == "Y" ? $arParams["ALLOW_SMILES"] : "N", "USERFIELDS" => $props[$topic["MESSAGE"]["ID"]])), "html", $files[$topic["MESSAGE"]["ID"]]);
if ($arParams['TOPIC_POST_MESSAGE_LENGTH'] > 0) {
$symbols_len = strlen(strip_tags($topic['MESSAGE']["POST_MESSAGE_TEXT"]));
示例14: isset
$arResult["~REVIEW_AUTHOR"] = $_POST["REVIEW_AUTHOR"];
}
$arResult["~REVIEW_EMAIL"] = $_POST["REVIEW_EMAIL"];
$arResult["~REVIEW_TEXT"] = $_POST["REVIEW_TEXT"];
$arResult["~REVIEW_USE_SMILES"] = $_POST["REVIEW_USE_SMILES"] == "Y" ? "Y" : "N";
}
$arResult["REVIEW_AUTHOR"] = isset($arResult["~REVIEW_AUTHOR"]) ? htmlspecialcharsEx($arResult["~REVIEW_AUTHOR"]) : "";
$arResult["REVIEW_EMAIL"] = isset($arResult["~REVIEW_EMAIL"]) ? htmlspecialcharsEx($arResult["~REVIEW_EMAIL"]) : "";
$arResult["REVIEW_TEXT"] = isset($arResult["~REVIEW_TEXT"]) ? htmlspecialcharsEx($arResult["~REVIEW_TEXT"]) : "";
$arResult["REVIEW_USE_SMILES"] = $arResult["~REVIEW_USE_SMILES"];
$arResult["REVIEW_FILES"] = array();
foreach ($_REQUEST["FILES"] as $key => $val) {
if (intVal($val) <= 0) {
continue;
}
$resForumFile = CForumFiles::GetList(array(), array('FILE_ID' => $val));
if ($resForumFile && ($arForumFile = $resForumFile->Fetch())) {
$bFileAccessible = false;
// Workaround for just uploaded files
if ($arForumFile['MESSAGE_ID'] == 0 && $arForumFile['TOPIC_ID'] == 0) {
$bFileAccessible = true;
} else {
$arTmp['MESSAGE'] = CForumMessage::GetByIDEx($arForumFile['MESSAGE_ID'], array('GET_FORUM_INFO' => 'N', 'GET_TOPIC_INFO' => 'Y'));
if (isset($arTmp['MESSAGE']['TOPIC_INFO']['ID']) && CTasks::CanCurrentUserViewTopic($arTmp['MESSAGE']['TOPIC_INFO']['ID'])) {
$bFileAccessible = true;
}
}
if ($bFileAccessible) {
$arResult['REVIEW_FILES'][$val] = CFile::GetFileArray($val);
}
}
示例15: CheckFields
function CheckFields(&$arFields, &$arParams, $ACTION = "ADD", $extParams = array())
{
$aMsg = array();
$arFiles = !is_array($arFields) ? array($arFields) : $arFields;
$arParams = !is_array($arParams) ? array($arParams) : $arParams;
$arParams["FORUM_ID"] = intVal($arParams["FORUM_ID"]);
if (isset($arParams["TOPIC_ID"])) {
$arParams["TOPIC_ID"] = intVal($arParams["TOPIC_ID"]);
}
$arParams["MESSAGE_ID"] = intVal($arParams["MESSAGE_ID"]);
$arParams["USER_ID"] = intVal($arParams["USER_ID"]);
if (empty($arFiles)) {
return true;
} elseif (!empty($arFiles["name"])) {
$arFiles = array($arFiles);
}
$ACTION = $ACTION == "UPDATE" || "NOT_CHECK_DB" ? $ACTION : "ADD";
if ($arParams["FORUM_ID"] <= 0) {
$aMsg[] = array("id" => 'bad_forum', "text" => GetMessage("F_ERR_EMPTY_FORUM_ID"));
} else {
// Y - Image files F - Files of specified type A - All files
$arForum = !!$extParams["FORUM"] ? $extParams["FORUM"] : CForumNew::GetByID($arParams["FORUM_ID"]);
if (empty($arForum)) {
$aMsg[] = array("id" => 'bad_forum', "text" => GetMessage("F_ERR_FORUM_IS_LOST"));
} elseif (!in_array($arForum["ALLOW_UPLOAD"], array("Y", "F", "A"))) {
$aMsg[] = array("id" => 'bad_forum_permission', "text" => GetMessage("F_ERR_UPOAD_IS_DENIED"));
}
}
if (empty($aMsg)) {
$arFilesExists = array();
$iFileSize = intVal(COption::GetOptionString("forum", "file_max_size", 5242880));
foreach ($arFiles as $key => $val) {
$res = "";
if (strLen($val["name"]) <= 0 && intVal($val["FILE_ID"]) <= 0) {
unset($arFiles[$key]);
continue;
} elseif (strLen($val["name"]) > 0) {
if ($arForum["ALLOW_UPLOAD"] == "Y") {
$res = CFile::CheckImageFile($val, $iFileSize, 0, 0);
} elseif ($arForum["ALLOW_UPLOAD"] == "F") {
$res = CFile::CheckFile($val, $iFileSize, false, $arForum["ALLOW_UPLOAD_EXT"]);
} else {
$res = CFile::CheckFile($val, $iFileSize, false, false);
}
if (strLen($res) > 0) {
$aMsg[] = array("id" => 'attach_error', "text" => $res);
}
}
if (intVal($val["FILE_ID"]) > 0) {
$arFiles[$key]["old_file"] = $val["FILE_ID"];
$arFilesExists[$val["FILE_ID"]] = $val;
continue;
}
}
if ($ACTION != "NOT_CHECK_DB" && !empty($arFilesExists)) {
$arFilter = array("FILE_FORUM_ID" => $arParams["FORUM_ID"]);
if (isset($arParams["TOPIC_ID"])) {
$arFilter["FILE_TOPIC_ID"] = $arParams["TOPIC_ID"];
}
if (isset($arParams["MESSAGE_ID"])) {
$arFilter["FILE_MESSAGE_ID"] = $arParams["MESSAGE_ID"];
}
$arFilter["@FILE_ID"] = array_keys($arFilesExists);
$db_res = CForumFiles::GetList(array("FILE_ID" => "ASC"), $arFilter);
if ($db_res && ($res = $db_res->Fetch())) {
do {
unset($arFilesExists[$res["FILE_ID"]]);
} while ($res = $db_res->Fetch());
}
if (!empty($arFilesExists)) {
$aMsg[] = array("id" => 'attach_error', "text" => str_replace("#FILE_ID#", implode(", ", array_keys($arFilesExists)), GetMessage("F_ERR_UPOAD_FILES_IS_LOST")));
}
}
}
if (!empty($aMsg)) {
$e = new CAdminException($aMsg);
$GLOBALS["APPLICATION"]->ThrowException($e);
return false;
}
$arFields = $arFiles;
return true;
}