当前位置: 首页>>代码示例>>PHP>>正文


PHP CForumMessage::CanUserAddMessage方法代码示例

本文整理汇总了PHP中CForumMessage::CanUserAddMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumMessage::CanUserAddMessage方法的具体用法?PHP CForumMessage::CanUserAddMessage怎么用?PHP CForumMessage::CanUserAddMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CForumMessage的用法示例。


在下文中一共展示了CForumMessage::CanUserAddMessage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetMessage

	ShowError(str_replace("#ELEMENT_ID#", $arParams["ELEMENT_ID"], GetMessage("F_ERR_EID_IS_NOT_EXIST")));
	return false;
elseif ($arResult["USER"]["PERMISSION"] <= "A"):
	return false;
endif;

/********************************************************************
				Default values
 ********************************************************************/
$arResult["FORUM_TOPIC_ID"] = intval($arResult["ELEMENT"]["PROPERTY_FORUM_TOPIC_ID_VALUE"]);

$arResult["USER"]["RIGHTS"] = array(
	"ADD_TOPIC" => CForumTopic::CanUserAddTopic($arParams["FORUM_ID"], $arResult["USER"]["GROUPS"], $arResult["USER"]["ID"], $arResult["FORUM"] ) ? "Y" : "N",
	"MODERATE" => CForumNew::CanUserModerateForum($arParams["FORUM_ID"], $arResult["USER"]["GROUPS"], $arResult["USER"]["ID"]) == true ? "Y" : "N",
	"EDIT" => CForumNew::CanUserEditForum($arParams["FORUM_ID"], $arResult["USER"]["GROUPS"], $arResult["USER"]["ID"]) ? "Y" : "N",
	"ADD_MESSAGE" => CForumMessage::CanUserAddMessage($arResult["FORUM_TOPIC_ID"], $arResult["USER"]["GROUPS"], $arResult["USER"]["ID"]) ? "Y" : "N");

if ($USER->IsAuthorized())
{
	$arResult["USER"]["SHOWED_NAME"] = $USER->GetLogin();
	if ($_SESSION["FORUM"]["SHOW_NAME"] == "Y")
	{
		$arResult["USER"]["SHOWED_NAME"] = CUser::FormatName(
			$arParams["NAME_TEMPLATE"],
			array(
				"NAME" => $USER->GetFirstName(),
				"LAST_NAME"	=> $USER->GetLastName(),
				"SECOND_NAME"	=> $USER->GetSecondName(),
				"LOGIN" 		=> $USER->GetLogin()),
			true,
			false
开发者ID:akniyev,项目名称:arteva.ru,代码行数:31,代码来源:component.php

示例2: ShowError

    ShowError($res);
    return false;
}
/********************************************************************
				/Main Data & Permissions
********************************************************************/
/********************************************************************
				Default params # 2
********************************************************************/
$arResult["MESSAGE_FIRST"] = array();
$arResult["MESSAGE_LIST"] = array();
$arResult["MESSAGE_VIEW"] = array();
$arResult["VIEW"] = "N";
$bVarsFromForm = false;
/************** Current User ***************************************/
$arResult["USER"] = array("INFO" => array(), "PERMISSION" => $arParams["PERMISSION"], "RIGHTS" => array("ADD_TOPIC" => CForumTopic::CanUserAddTopic($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID(), $arResult["FORUM"], $arParams["PERMISSION"]) ? "Y" : "N", "MODERATE" => CForumNew::CanUserModerateForum($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID(), $arParams["PERMISSION"]) == true ? "Y" : "N", "EDIT" => CForumNew::CanUserEditForum($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID(), $arParams["PERMISSION"]) ? "Y" : "N", "ADD_MESSAGE" => CForumMessage::CanUserAddMessage($arParams["TID"], $USER->GetUserGroupArray(), $USER->GetID(), $arParams["PERMISSION"]) ? "Y" : "N"), "SUBSCRIBE" => array(), "SHOW_NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
// to avoid forum module permissions extension for admin
if ($arParams["PERMISSION"] <= "E") {
    $arResult["USER"]["RIGHTS"] = array("ADD_TOPIC" => "N", "MODERATE" => "N", "EDIT" => "N", "ADD_MESSAGE" => "N");
}
if ($USER->IsAuthorized()) {
    $arResult["USER"]["INFO"] = CForumUser::GetByUSER_ID($USER->GetParam("USER_ID"));
    $arResult["USER"]["SHOW_NAME"] = $_SESSION["FORUM"]["SHOW_NAME"];
    $arResult["USER"]["RANK"] = CForumUser::GetUserRank($USER->GetParam("USER_ID"));
    $db_res = CForumSubscribe::GetList(array(), array("USER_ID" => $USER->GetID(), "FORUM_ID" => $arParams["FID"], "TOPIC_ID" => $arParams["TID"], "SITE_ID" => SITE_ID));
    if ($db_res && ($res = $db_res->Fetch())) {
        $arResult["USER"]["SUBSCRIBE"][$res["ID"]] = $res;
    }
}
/*******************************************************************/
$arResult["PANELS"] = array("MODERATE" => $arResult["USER"]["RIGHTS"]["MODERATE"], "DELETE" => $arResult["USER"]["RIGHTS"]["EDIT"], "SUPPORT" => IsModuleInstalled("support") && $APPLICATION->GetGroupRight("forum") >= "W" ? "Y" : "N", "EDIT" => $arResult["USER"]["RIGHTS"]["EDIT"], "STATISTIC" => IsModuleInstalled("statistic") && $APPLICATION->GetGroupRight("statistic") > "D" ? "Y" : "N", "MAIN" => $APPLICATION->GetGroupRight("main") > "D" ? "Y" : "N", "MAIL" => $APPLICATION->GetGroupRight("mail") > "R" ? "Y" : "N");
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:component.php

示例3: AddComment_News

 function AddComment_News($arFields)
 {
     if (!CModule::IncludeModule("forum")) {
         return false;
     }
     if (!CModule::IncludeModule("iblock")) {
         return false;
     }
     if (!CModule::IncludeModule("socialnetwork")) {
         return false;
     }
     $dbResult = CSocNetLog::GetList(array("ID" => "DESC"), array("TMP_ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "PARAMS"));
     $bFound = false;
     if ($arLog = $dbResult->Fetch()) {
         if (intval($arLog["SOURCE_ID"]) > 0) {
             $arFilter = array("ID" => $arLog["SOURCE_ID"]);
             $arSelectedFields = array("IBLOCK_ID", "ID", "CREATED_BY", "NAME", "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;
                 $val = COption::GetOptionString("intranet", "sonet_log_news_iblock_forum");
                 if (strlen($val) > 0) {
                     $arIBlockForum = unserialize($val);
                 } else {
                     $arIBlockForum = array();
                 }
                 if (array_key_exists($arElement["IBLOCK_ID"], $arIBlockForum)) {
                     $FORUM_ID = $arIBlockForum[$arElement["IBLOCK_ID"]];
                 }
                 if (intval($FORUM_ID) > 0) {
                     CSocNetLogTools::AddComment_Review_CheckIBlock($arElement);
                     $dbMessage = CForumMessage::GetList(array(), array("PARAM2" => $arElement["ID"]));
                     if (!($arMessage = $dbMessage->Fetch())) {
                         // Add Topic
                         $TOPIC_ID = CSocNetLogTools::AddComment_Review_CreateRoot($arElement, $FORUM_ID);
                         $bNewTopic = true;
                     } else {
                         $TOPIC_ID = $arMessage["TOPIC_ID"];
                     }
                     if (intval($TOPIC_ID) > 0) {
                         // Add comment
                         $messageID = false;
                         $bError = false;
                         if (CForumMessage::CanUserAddMessage($TOPIC_ID, $GLOBALS["USER"]->GetUserGroupArray(), $GLOBALS["USER"]->GetID(), false)) {
                             $bSHOW_NAME = true;
                             $res = CForumUser::GetByUSER_ID($GLOBALS["USER"]->GetID());
                             if ($res) {
                                 $bSHOW_NAME = $res["SHOW_NAME"] == "Y";
                             }
                             if ($bSHOW_NAME) {
                                 $AUTHOR_NAME = $GLOBALS["USER"]->GetFullName();
                             }
                             if (strlen(Trim($AUTHOR_NAME)) <= 0) {
                                 $AUTHOR_NAME = $GLOBALS["USER"]->GetLogin();
                             }
                             if (strlen($AUTHOR_NAME) <= 0) {
                                 $bError = true;
                             }
                         }
                         if (!$bError) {
                             $arFieldsMessage = array("POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "USE_SMILES" => "Y", "APPROVED" => "Y", "PARAM2" => $arElement["ID"], "AUTHOR_NAME" => $AUTHOR_NAME, "AUTHOR_ID" => IntVal($GLOBALS["USER"]->GetParam("USER_ID")), "FORUM_ID" => $FORUM_ID, "TOPIC_ID" => $TOPIC_ID, "NEW_TOPIC" => "N", "GUEST_ID" => $_SESSION["SESS_GUEST_ID"], "ADD_TO_LOG" => "N");
                             $AUTHOR_IP = ForumGetRealIP();
                             $AUTHOR_IP_tmp = $AUTHOR_IP;
                             $AUTHOR_REAL_IP = $_SERVER['REMOTE_ADDR'];
                             if (COption::GetOptionString("forum", "FORUM_GETHOSTBYADDR", "N") == "Y") {
                                 $AUTHOR_IP = @gethostbyaddr($AUTHOR_IP);
                                 if ($AUTHOR_IP_tmp == $AUTHOR_REAL_IP) {
                                     $AUTHOR_REAL_IP = $AUTHOR_IP;
                                 } else {
                                     $AUTHOR_REAL_IP = @gethostbyaddr($AUTHOR_REAL_IP);
                                 }
                             }
                             $arFieldsMessage["AUTHOR_IP"] = $AUTHOR_IP !== False ? $AUTHOR_IP : "<no address>";
                             $arFieldsMessage["AUTHOR_REAL_IP"] = $AUTHOR_REAL_IP !== False ? $AUTHOR_REAL_IP : "<no address>";
                             $messageID = CForumMessage::Add($arFieldsMessage, false);
                             if (intVal($messageID) <= 0) {
                                 $bError = true;
                             } else {
                                 if (CModule::IncludeModule("statistic")) {
                                     $arForum = CForumNew::GetByID($FORUM_ID);
                                     $F_EVENT1 = $arForum["EVENT1"];
                                     $F_EVENT2 = $arForum["EVENT2"];
                                     $F_EVENT3 = $arForum["EVENT3"];
                                     if (strlen($F_EVENT3) <= 0) {
                                         $arForumSite_tmp = CForumNew::GetSites($FORUM_ID);
                                         $F_EVENT3 = CForumNew::PreparePath2Message($arForumSite_tmp[SITE_ID], array("FORUM_ID" => $FORUM_ID, "TOPIC_ID" => $TOPIC_ID, "MESSAGE_ID" => $messageID));
                                     }
                                     CStatistic::Set_Event($F_EVENT1, $F_EVENT2, $F_EVENT3);
                                 }
                                 CForumMessage::SendMailMessage($messageID, array(), false, "NEW_FORUM_MESSAGE");
                                 CSocNetLogTools::AddComment_Review_UpdateElement($arElement, $TOPIC_ID, $bNewTopic);
                             }
                         }
                     }
                 }
             }
         }
     }
     if (intval($messageID) <= 0) {
         $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:include.php

示例4: ShowError

				/Main Params
 ********************************************************************/
if (empty($arResult["FORUM"])) {
    ShowError(str_replace("#FORUM_ID#", $arParams["FORUM_ID"], GetMessage("F_ERR_FID_IS_NOT_EXIST")));
    return false;
} elseif (empty($arResult["ELEMENT"])) {
    ShowError(str_replace("#ELEMENT_ID#", $arParams["ELEMENT_ID"], GetMessage("F_ERR_EID_IS_NOT_EXIST")));
    return false;
} elseif ($arResult["USER"]["PERMISSION"] <= "A") {
    return false;
}
/********************************************************************
				Default values
 ********************************************************************/
$arResult["FORUM_TOPIC_ID"] = intval($arResult["ELEMENT"]["PROPERTY_FORUM_TOPIC_ID_VALUE"]);
$arResult["USER"]["RIGHTS"] = array("ADD_TOPIC" => CForumTopic::CanUserAddTopic($arParams["FORUM_ID"], $arResult["USER"]["GROUPS"], $arResult["USER"]["ID"], $arResult["FORUM"]) ? "Y" : "N", "MODERATE" => CForumNew::CanUserModerateForum($arParams["FORUM_ID"], $arResult["USER"]["GROUPS"], $arResult["USER"]["ID"]) == true ? "Y" : "N", "EDIT" => CForumNew::CanUserEditForum($arParams["FORUM_ID"], $arResult["USER"]["GROUPS"], $arResult["USER"]["ID"]) ? "Y" : "N", "ADD_MESSAGE" => CForumMessage::CanUserAddMessage($arResult["FORUM_TOPIC_ID"], $arResult["USER"]["GROUPS"], $arResult["USER"]["ID"]) ? "Y" : "N");
if ($USER->IsAuthorized()) {
    $arResult["USER"]["SHOWED_NAME"] = $USER->GetLogin();
    if ($_SESSION["FORUM"]["SHOW_NAME"] == "Y") {
        $arResult["USER"]["SHOWED_NAME"] = CUser::FormatName($arParams["NAME_TEMPLATE"], array("NAME" => $USER->GetFirstName(), "LAST_NAME" => $USER->GetLastName(), "SECOND_NAME" => $USER->GetSecondName(), "LOGIN" => $USER->GetLogin()), true, false);
    }
}
$arResult["PANELS"] = array("MODERATE" => $arResult["USER"]["RIGHTS"]["MODERATE"], "DELETE" => $arResult["USER"]["RIGHTS"]["EDIT"]);
$arResult["SHOW_PANEL"] = in_array("Y", $arResult["PANELS"]) ? "Y" : "N";
// PARSER
$parser = new forumTextParser(LANGUAGE_ID);
$parser->image_params["width"] = $arParams["IMAGE_SIZE"];
$parser->image_params["height"] = $arParams["IMAGE_SIZE"];
$arResult["PARSER"] = $parser;
// FORUM
$arAllow = forumTextParser::GetFeatures($arResult["FORUM"]);
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:component.php

示例5: array

$arResult["TRANSLIT"] = LANGUAGE_ID == "ru" ? "Y" : "N";
$arResult["ForumPrintIconsList"] = "";
$arResult["ForumPrintSmilesList"] = "";
$arResult["TOPIC_FILTER"] = array();
$arResult["TOPIC"] = array();
$arResult["MESSAGE"] = array("AUTHOR_ID" => $USER->GetParam("USER_ID"), "USE_SMILES" => "Y", "AUTHOR_NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"], "AUTHOR_EMAIL" => "", "POST_MESSAGE" => "", "EDITOR_NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"], "EDITOR_EMAIL" => "quest@guest.com", "EDIT_REASON" => "", "FILES" => array());
$arResult["TOPIC"] = array("TITLE" => "", "TAGS" => "", "DESCRIPTION" => "", "ICON_ID" => "");
$arResult["QUESTIONS"] = array();
$arResult["~QUESTIONS"] = array();
$arResult['DATE_END'] = GetTime(time() + 30 * 86400);
/********************************************************************
				/Default params
********************************************************************/
$bShowForm = false;
if ($arParams["MESSAGE_TYPE"] == "REPLY" && $arParams["TID"] > 0) {
    $bShowForm = CForumMessage::CanUserAddMessage($arParams["TID"], $USER->GetUserGroupArray(), $USER->GetID());
} elseif ($arParams["MESSAGE_TYPE"] == "EDIT" && $arParams["MID"] > 0) {
    $bShowForm = CForumMessage::CanUserUpdateMessage($arParams["MID"], $USER->GetUserGroupArray(), intVal($USER->GetID()));
} elseif ($arParams["MESSAGE_TYPE"] == "NEW" && $arParams["FID"] > 0) {
    $bShowForm = CForumTopic::CanUserAddTopic($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID());
}
if (!$bShowForm) {
    return 0;
}
if ($arParams["SHOW_VOTE"] == "Y") {
    CModule::IncludeModule("vote");
    $permission = isset($arParams['PERMISSION']) && intval($arParams['PERMISSION'] > 0 || $arParams['PERMISSION'] === 0) ? intval($arParams['PERMISSION']) : CVoteChannel::GetGroupPermission($arParams["VOTE_CHANNEL_ID"]);
    if ($permission < 2) {
        $arParams["SHOW_VOTE"] = "N";
    }
    $res = array_intersect($USER->GetUserGroupArray(), $arParams["VOTE_GROUP_ID"]);
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:component.php

示例6: foreach

$arResult["TOPIC"]["iLAST_TOPIC_MESSAGE"] = "";
/************** Forum **********************************************/
foreach ($arResult["FORUM"] as $key => $val):
	$arResult["FORUM"]["~".$key] = $val;
	$arResult["FORUM"][$key] = htmlspecialcharsEx($val);
endforeach;
if ($arParams["SHOW_FIRST_POST"] == "N"):
	$arParams["SHOW_FIRST_POST"] = ($arResult["FORUM"]["ALLOW_TOPIC_TITLED"] == "Y" ? "Y" : "N");
endif;
/************** Current User ***************************************/
$arResult["USER"]["SHOW_NAME"] = $GLOBALS["FORUM_STATUS_NAME"]["guest"];
$arResult["USER"]["RIGHTS"] = array(
	"ADD_TOPIC" => CForumTopic::CanUserAddTopic($arParams["FID"], $arUserGroups, $USER->GetID(), $arResult["FORUM"]) ? "Y" : "N",
	"MODERATE" => (CForumNew::CanUserModerateForum($arParams["FID"], $arUserGroups, $USER->GetID()) == true ? "Y" : "N"),
	"EDIT" => CForumNew::CanUserEditForum($arParams["FID"], $arUserGroups, $USER->GetID()) ? "Y" : "N",
	"ADD_MESSAGE" => CForumMessage::CanUserAddMessage($arParams["TID"], $arUserGroups, $USER->GetID()) ? "Y" : "N");
if ($USER->IsAuthorized()):
	$arResult["USER"]["INFO"] = CForumUser::GetByUSER_ID($USER->GetParam("USER_ID"));
	$arResult["USER"]["SHOW_NAME"] = $_SESSION["FORUM"]["SHOW_NAME"];
	$arResult["USER"]["RANK"] = CForumUser::GetUserRank($USER->GetParam("USER_ID"), LANGUAGE_ID);
	$arFields = array("USER_ID" => $USER->GetID(), "FORUM_ID" => $arParams["FID"], "TOPIC_ID" => $arParams["TID"], "SITE_ID" => SITE_ID);
	$db_res = CForumSubscribe::GetList(array(), $arFields);
	if ($db_res && $res = $db_res->Fetch())
		$arResult["USER"]["SUBSCRIBE"][$res["ID"]] = $res;
	$arResult["USER"]["RIGHTS"]["EDIT_MESSAGE"] = ($arResult["USER"]["RIGHTS"]["EDIT"] != "Y" ? $arResult["USER"]["RIGHTS"]["ADD_MESSAGE"] : "N");
else:
	$arResult["USER"]["RIGHTS"]["EDIT_MESSAGE"] = "N";
endif;
$arResult["USER"]["RIGHTS"]["EDIT_OWN_POST"] = COption::GetOptionString("forum", "USER_EDIT_OWN_POST", "N");
/************** Edit panels info ***********************************/
$arResult["PANELS"] = array(
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:31,代码来源:component.php

示例7: foreach

    if (!is_array($val)) {
        $arResult["TOPIC"][$key] = $parser->wrap_long_words($arResult["TOPIC"][$key]);
    }
}
$arResult["TOPIC"]["iLAST_TOPIC_MESSAGE"] = "";
/************** Forum **********************************************/
foreach ($arResult["FORUM"] as $key => $val) {
    $arResult["FORUM"]["~" . $key] = $val;
    $arResult["FORUM"][$key] = htmlspecialcharsEx($val);
}
if ($arParams["SHOW_FIRST_POST"] == "N") {
    $arParams["SHOW_FIRST_POST"] = $arResult["FORUM"]["ALLOW_TOPIC_TITLED"] == "Y" ? "Y" : "N";
}
/************** Current User ***************************************/
$arResult["USER"]["SHOW_NAME"] = $GLOBALS["FORUM_STATUS_NAME"]["guest"];
$arResult["USER"]["RIGHTS"] = array("ADD_TOPIC" => CForumTopic::CanUserAddTopic($arParams["FID"], $arUserGroups, $USER->GetID(), $arResult["FORUM"]) ? "Y" : "N", "MODERATE" => CForumNew::CanUserModerateForum($arParams["FID"], $arUserGroups, $USER->GetID()) == true ? "Y" : "N", "EDIT" => CForumNew::CanUserEditForum($arParams["FID"], $arUserGroups, $USER->GetID()) ? "Y" : "N", "ADD_MESSAGE" => CForumMessage::CanUserAddMessage($arParams["TID"], $arUserGroups, $USER->GetID()) ? "Y" : "N");
if ($USER->IsAuthorized()) {
    $arResult["USER"]["INFO"] = CForumUser::GetByUSER_ID($USER->GetParam("USER_ID"));
    $arResult["USER"]["SHOW_NAME"] = $_SESSION["FORUM"]["SHOW_NAME"];
    $arResult["USER"]["RANK"] = CForumUser::GetUserRank($USER->GetParam("USER_ID"), LANGUAGE_ID);
    $arFields = array("USER_ID" => $USER->GetID(), "FORUM_ID" => $arParams["FID"], "TOPIC_ID" => $arParams["TID"], "SITE_ID" => SITE_ID);
    $db_res = CForumSubscribe::GetList(array(), $arFields);
    if ($db_res && ($res = $db_res->Fetch())) {
        $arResult["USER"]["SUBSCRIBE"][$res["ID"]] = $res;
    }
    $arResult["USER"]["RIGHTS"]["EDIT_MESSAGE"] = $arResult["USER"]["RIGHTS"]["EDIT"] != "Y" ? $arResult["USER"]["RIGHTS"]["ADD_MESSAGE"] : "N";
} else {
    $arResult["USER"]["RIGHTS"]["EDIT_MESSAGE"] = "N";
}
$arResult["USER"]["RIGHTS"]["EDIT_OWN_POST"] = COption::GetOptionString("forum", "USER_EDIT_OWN_POST", "N");
/************** Edit panels info ***********************************/
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例8: ForumAddMessage

function ForumAddMessage($MESSAGE_TYPE, $FID, $TID, $MID, $arFieldsG, &$strErrorMessage, &$strOKMessage, $iFileSize = false, $captcha_word = "", $captcha_sid = 0, $captcha_code = "")
{
    global $USER, $DB, $APPLICATION;
    $APPLICATION->ResetException();
    $aMsg = array();
    $bUpdateTopic = False;
    $bAddEditNote = $MESSAGE_TYPE == "EDIT";
    $arParams = array("PERMISSION" => false);
    $arUserGroups = $USER->GetUserGroupArray();
    // ************ External Permission *********************************
    if (!empty($arFieldsG["PERMISSION_EXTERNAL"])) {
        $arParams["PERMISSION"] = CForumNew::GetUserPermission($FID, $arUserGroups);
        $arParams["PERMISSION"] = $arParams["PERMISSION"] < "Q" ? $arFieldsG["PERMISSION_EXTERNAL"] : $arParams["PERMISSION"];
        unset($arFieldsG["PERMISSION_EXTERNAL"]);
    } elseif (!empty($arFieldsG["SONET_PERMS"])) {
        $arParams["PERMISSION"] = CForumNew::GetUserPermission($FID, $arUserGroups);
        if ($arParams["PERMISSION"] < "Q") {
            if ($arFieldsG["SONET_PERMS"]["bCanFull"] === true) {
                $arParams["PERMISSION"] = "Y";
            } elseif ($arFieldsG["SONET_PERMS"]["bCanNew"] === true) {
                $arParams["PERMISSION"] = "M";
            } elseif ($arFieldsG["SONET_PERMS"]["bCanWrite"] === true) {
                $arParams["PERMISSION"] = "I";
            } else {
                $arParams["PERMISSION"] = "A";
            }
        }
        unset($arFieldsG["SONET_PERMS"]);
    }
    $DB->StartTransaction();
    if (!in_array($MESSAGE_TYPE, array("NEW", "EDIT", "REPLY"))) {
        $aMsg[] = array("id" => "MESSAGE_TYPE", "text" => GetMessage("ADDMES_NO_TYPE") . ".");
    }
    $MID = intval($MID);
    $TID = intval($TID);
    $FID = intval($FID);
    $arFieldsG["EDIT_ADD_REASON"] = $arFieldsG["EDIT_ADD_REASON"] == "Y" ? "Y" : "N";
    if ($MID > 0) {
        $arMessage = CForumMessage::GetByID($MID, array("FILTER" => "N"));
        if ($arMessage) {
            $TID = IntVal($arMessage["TOPIC_ID"]);
            $FID = IntVal($arMessage["FORUM_ID"]);
        }
    }
    $arTopic = array();
    if ($TID > 0) {
        $arTopic = CForumTopic::GetByID($TID);
        if ($arTopic) {
            $FID = IntVal($arTopic["FORUM_ID"]);
        }
    }
    $arForum = CForumNew::GetByID($FID);
    //************************* Input params **************************************************************************
    if ($MESSAGE_TYPE == "NEW" && !CForumTopic::CanUserAddTopic($FID, $arUserGroups, $USER->GetID(), $arForum, $arParams["PERMISSION"])) {
        $aMsg[] = array("id" => "PERMISSION", "text" => GetMessage("ADDMESS_NO_PERMS2NEW") . ".");
    } elseif ($MESSAGE_TYPE == "EDIT" && !CForumMessage::CanUserUpdateMessage($MID, $arUserGroups, $USER->GetID(), $arParams["PERMISSION"])) {
        $aMsg[] = array("id" => "PERMISSION", "text" => GetMessage("ADDMESS_NO_PERMS2EDIT") . ".");
    } elseif ($MESSAGE_TYPE == "REPLY" && !CForumMessage::CanUserAddMessage($TID, $arUserGroups, $USER->GetID(), $arParams["PERMISSION"])) {
        $aMsg[] = array("id" => "PERMISSION", "text" => GetMessage("ADDMESS_NO_PERMS2REPLY") . ".");
    }
    if ($MESSAGE_TYPE == "NEW" || $MESSAGE_TYPE == "EDIT" && array_intersect_key($arFieldsG, array("TITLE" => "", "DESCRIPTION" => "", "ICON" => "", "TAGS" => "", "OWNER_ID" => "", "SOCNET_GROUP_ID" => "")) && CForumTopic::CanUserUpdateTopic($TID, $arUserGroups, $USER->GetID(), $arParams["PERMISSION"])) {
        $bUpdateTopic = True;
    }
    if ($MESSAGE_TYPE == "EDIT" && (ForumCurrUserPermissions($FID, $arParams) > "Q" && $arFieldsG["EDIT_ADD_REASON"] == "N")) {
        $bAddEditNote = false;
    }
    //*************************!CAPTCHA********************************************************************************
    if (!$USER->IsAuthorized() && $arForum["USE_CAPTCHA"] == "Y") {
        include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/captcha.php";
        $cpt = new CCaptcha();
        if (strlen($captcha_code) > 0) {
            $captchaPass = COption::GetOptionString("main", "captcha_password", "");
            if (!$cpt->CheckCodeCrypt($captcha_word, $captcha_code, $captchaPass)) {
                $aMsg[] = array("id" => "CAPTCHA", "text" => GetMessage("FORUM_POSTM_CAPTCHA") . ".");
            }
        } else {
            if (!$cpt->CheckCode($captcha_word, $captcha_sid)) {
                $aMsg[] = array("id" => "CAPTCHA", "text" => GetMessage("FORUM_POSTM_CAPTCHA") . ".");
            }
        }
    }
    //*************************!CAPTCHA********************************************************************************
    $arFieldsG["POST_MESSAGE"] = trim($arFieldsG["POST_MESSAGE"]);
    if (empty($arFieldsG["POST_MESSAGE"])) {
        $aMsg[] = array("id" => "POST_MESSAGE", "text" => GetMessage("ADDMESS_INPUT_MESSAGE") . ".");
    }
    if ($bUpdateTopic && is_set($arFieldsG, "TITLE")) {
        $arFieldsG["TITLE"] = trim($arFieldsG["TITLE"]);
        if (empty($arFieldsG["TITLE"])) {
            $aMsg[] = array("id" => "TITLE", "text" => GetMessage("ADDMESS_INPUT_TITLE") . ".");
        }
    }
    //*************************!QUOTA**********************************************************************************
    /*	if (empty($aMsg))
    	{
    		$quota = new CDiskQuota();
    		if ($MESSAGE_TYPE=="EDIT")
    		{
    			if (!$quota->checkDiskQuota(strLen($arFieldsG["POST_MESSAGE"]) - strLen($arMessage["POST_MESSAGE"])))
    			{
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:include.php

示例9: elseif

        }
    } elseif ($res["STATE"] == "L") {
        $arError[] = array("id" => "topic is topic-link", "text" => GetMessage("F_TID_IS_LINK"));
    } elseif ($res["APPROVED"] != "Y" && $arParams["PERMISSION"] < "Q") {
        $arError[] = array("id" => "topic is not approved", "text" => GetMessage("F_TID_IS_NOT_APPROVED"));
    } else {
        $arResult["TOPIC"] = $res;
    }
}
/************** Permission *****************************************/
if (empty($arError)) {
    if ($arParams["MESSAGE_TYPE"] == "NEW" && !CForumTopic::CanUserAddTopic($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID(), $arResult["FORUM"], $arParams["PERMISSION"])) {
        $arError[] = array("id" => "user cannot add topic", "text" => GetMessage("F_NO_NPERMS"));
    } elseif ($arParams["MESSAGE_TYPE"] == "EDIT" && !CForumMessage::CanUserUpdateMessage($arParams["MID"], $USER->GetUserGroupArray(), $USER->GetID(), $arParams["PERMISSION"])) {
        $arError[] = array("id" => "user cannot edit message", "text" => GetMessage("F_NO_EPERMS"));
    } elseif ($arParams["MESSAGE_TYPE"] == "REPLY" && !CForumMessage::CanUserAddMessage($arParams["TID"], $USER->GetUserGroupArray(), $USER->GetID(), $arParams["PERMISSION"])) {
        return false;
    }
}
if (!empty($arError)) {
    $e = new CAdminException($arError);
    $res = $e->GetString();
    ShowError($res);
    return false;
}
/********************************************************************
				/Main Data & Permissions
********************************************************************/
/********************************************************************
				Data
********************************************************************/
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:component.php


注:本文中的CForumMessage::CanUserAddMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。