本文整理汇总了PHP中CForumUser::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumUser::Add方法的具体用法?PHP CForumUser::Add怎么用?PHP CForumUser::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumUser
的用法示例。
在下文中一共展示了CForumUser::Add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Add
public static function Add($arFields)
{
global $DB;
if (!CForumUserPoints::CheckFields("ADD", $arFields)) {
return false;
}
$arInsert = $DB->PrepareInsert("b_forum_user_points", $arFields);
$strDatePostField = "";
$strDatePostValue = "";
if (!is_set($arFields, "DATE_UPDATE")) {
$strDatePostField .= ", DATE_UPDATE";
$strDatePostValue .= ", " . $DB->GetNowFunction() . "";
}
$strSql = "INSERT INTO b_forum_user_points(" . $arInsert[0] . $strDatePostField . ") VALUES(" . $arInsert[1] . $strDatePostValue . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
// Recount user points
if (intVal($arFields["TO_USER_ID"]) > 0) {
$arUserFields = array("POINTS" => CForumUser::CountUserPoints($arFields["TO_USER_ID"]));
$arUser = CForumUser::GetByUSER_ID($arFields["TO_USER_ID"]);
if ($arUser) {
CForumUser::Update(intVal($arUser["ID"]), $arUserFields);
} else {
$arUserFields["USER_ID"] = $arFields["TO_USER_ID"];
$ID_tmp = CForumUser::Add($arUserFields);
}
}
return true;
}
示例2: elseif
}
}
} elseif ($action == "send") {
$USER_INFO = array();
if (!empty($_REQUEST["USER_ID"])) {
if (intval($_REQUEST["USER_ID"]) > 0) {
$USER_INFO = CForumUser::GetByUSER_ID($_REQUEST["USER_ID"]);
}
if (empty($USER_INFO)) {
$USER_INFO = CForumUser::GetByLogin($_REQUEST["USER_ID"]);
}
if (empty($USER_INFO)) {
$rUser = $USER->GetByID(intval($_REQUEST['USER_ID']));
if ($rUser && ($arUser = $rUser->Fetch())) {
$arUserFields["USER_ID"] = intval($_REQUEST['USER_ID']);
$USER_ID = CForumUser::Add($arUserFields);
$USER_INFO = CForumUser::GetByUSER_ID($USER_ID);
}
}
}
if (empty($USER_INFO)) {
$arError[] = array("id" => "bad_user_info", "text" => str_replace("##", htmlspecialcharsEx($_REQUEST["USER_ID"]), GetMessage("PM_USER_NOT_FOUND")));
} else {
$arrVars = array("AUTHOR_ID" => $USER->GetID(), "POST_SUBJ" => $_REQUEST["POST_SUBJ"], "POST_MESSAGE" => $_REQUEST["POST_MESSAGE"], "USE_SMILES" => $_REQUEST["USE_SMILES"], "USER_ID" => $USER_INFO["USER_ID"], "COPY_TO_OUTBOX" => $_REQUEST["COPY_TO_OUTBOX"], "REQUEST_IS_READ" => $_REQUEST["REQUEST_IS_READ"]);
$arParams["MID"] = CForumPrivateMessage::Send($arrVars);
if (intVal($arParams["MID"]) <= 0) {
$err = $APPLICATION->GetException();
$arError[] = array("id" => "bad_send", "text" => $err->GetString());
} elseif ($arParams["version"] == 2) {
$db_res = CForumPrivateMessage::GetListEx(array(), array("ID" => $arParams["MID"]));
if (!($db_res && ($res = $db_res->GetNext()))) {
示例3: array
}
}
if ($strError == '') {
if (CModule::IncludeModule("forum")) {
$APPLICATION->ResetException();
$arforumFields = array("SHOW_NAME" => $_REQUEST["forum_SHOW_NAME"] == "Y" ? "Y" : "N", "DESCRIPTION" => $_REQUEST["forum_DESCRIPTION"], "INTERESTS" => $_REQUEST["forum_INTERESTS"], "SIGNATURE" => $_REQUEST["forum_SIGNATURE"], "AVATAR" => $_FILES["forum_AVATAR"]);
$arforumFields["AVATAR"]["del"] = $_REQUEST["forum_AVATAR_del"];
$ar_res = CForumUser::GetByUSER_ID($arResult["ID"]);
if ($ar_res) {
$arforumFields["AVATAR"]["old_file"] = $ar_res["AVATAR"];
$FORUM_USER_ID = IntVal($ar_res["ID"]);
$FORUM_USER_ID1 = CForumUser::Update($FORUM_USER_ID, $arforumFields);
$forum_res = IntVal($FORUM_USER_ID1) > 0;
} else {
$arforumFields["USER_ID"] = $arResult["ID"];
$FORUM_USER_ID = CForumUser::Add($arforumFields);
$forum_res = IntVal($FORUM_USER_ID) > 0;
}
if ($ex = $APPLICATION->GetException()) {
$strError = $ex->GetString();
}
}
}
if ($strError == '') {
if (CModule::IncludeModule("blog")) {
$APPLICATION->ResetException();
$arblogFields = array("ALIAS" => $_REQUEST["blog_ALIAS"], "DESCRIPTION" => $_REQUEST["blog_DESCRIPTION"], "INTERESTS" => $_REQUEST["blog_INTERESTS"], "AVATAR" => $_FILES["blog_AVATAR"]);
$arblogFields["AVATAR"]["del"] = $_REQUEST["blog_AVATAR_del"];
$ar_res = CBlogUser::GetByID($arResult["ID"], BLOG_BY_USER_ID);
if ($ar_res) {
$arblogFields["AVATAR"]["old_file"] = $ar_res["AVATAR"];
示例4: RegisterUSER_OLD
/**
* @param array $arFields
* @return bool
* @deprecated
* @see CALLForumStat::RegisterUSER()
*/
public static function RegisterUSER_OLD($arFields = array())
{
global $DB, $USER;
$tmp = "";
if ($_SESSION["FORUM"]["SHOW_NAME"] == "Y" && strLen(trim($USER->GetFormattedName(false))) > 0) {
$tmp = $USER->GetFormattedName(false);
} else {
$tmp = $USER->GetLogin();
}
$session_id = "'" . $DB->ForSQL(session_id(), 255) . "'";
$Fields = array("FS.USER_ID" => intVal($USER->GetID()), "FS.IP_ADDRESS" => "'" . $DB->ForSql($_SERVER["REMOTE_ADDR"], 15) . "'", "FS.SHOW_NAME" => "'" . $DB->ForSQL($tmp, 255) . "'", "FS.LAST_VISIT" => $DB->GetNowFunction(), "FS.FORUM_ID" => intVal($arFields["FORUM_ID"]), "FS.TOPIC_ID" => intVal($arFields["TOPIC_ID"]));
$FieldsForInsert = array("USER_ID" => $Fields["FS.USER_ID"], "IP_ADDRESS" => $Fields["FS.IP_ADDRESS"], "SHOW_NAME" => $Fields["FS.SHOW_NAME"], "LAST_VISIT" => $Fields["FS.LAST_VISIT"], "FORUM_ID" => $Fields["FS.FORUM_ID"], "TOPIC_ID" => $Fields["FS.TOPIC_ID"], "PHPSESSID" => $session_id);
if (intVal($USER->GetID()) > 0) {
$FieldsForUpdate = $Fields;
$FieldsForUpdate["FU.LAST_VISIT"] = $DB->GetNowFunction();
$rows = $DB->Update("b_forum_user FU, b_forum_stat FS", $FieldsForUpdate, "WHERE (FU.USER_ID=" . $Fields["FS.USER_ID"] . ") AND (FS.PHPSESSID=" . $session_id . ")", "File: " . __FILE__ . "<br>Line: " . __LINE__, false);
if (intVal($rows) < 2) {
if (intVal($rows) <= 0) {
$rows = $DB->Update("b_forum_user", array("USER_ID" => $Fields["FS.USER_ID"]), "WHERE (USER_ID=" . $Fields["FS.USER_ID"] . ")", "File: " . __FILE__ . "<br>Line: " . __LINE__, false);
if (intVal($rows) <= 0) {
$ID = CForumUser::Add(array("USER_ID" => $Fields["FS.USER_ID"]));
}
$rows = $DB->Update("b_forum_stat", array("USER_ID" => $Fields["FS.USER_ID"], "IP_ADDRESS" => $Fields["FS.IP_ADDRESS"], "SHOW_NAME" => $Fields["FS.SHOW_NAME"], "LAST_VISIT" => $Fields["FS.LAST_VISIT"], "FORUM_ID" => $Fields["FS.FORUM_ID"], "TOPIC_ID" => $Fields["FS.TOPIC_ID"]), "WHERE (PHPSESSID=" . $session_id . ")", "File: " . __FILE__ . "<br>Line: " . __LINE__, false);
if (intVal($rows) <= 0) {
$DB->Insert("b_forum_stat", $FieldsForInsert, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
}
} else {
$rows = $DB->Update("b_forum_stat", array("USER_ID" => $Fields["FS.USER_ID"], "IP_ADDRESS" => $Fields["FS.IP_ADDRESS"], "SHOW_NAME" => $Fields["FS.SHOW_NAME"], "LAST_VISIT" => $Fields["FS.LAST_VISIT"], "FORUM_ID" => $Fields["FS.FORUM_ID"], "TOPIC_ID" => $Fields["FS.TOPIC_ID"]), "WHERE (PHPSESSID=" . $session_id . ")", "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (intVal($rows) <= 0) {
$DB->Insert("b_forum_stat", $FieldsForInsert, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
return true;
}
示例5: array
$APPLICATION->ThrowException($USER->LAST_ERROR);
}
// Update Forum info about user
if (!$APPLICATION->GetException()) {
$arFields = array("SHOW_NAME" => $_POST["FORUM_SHOW_NAME"] == "Y" ? "Y" : "N", "HIDE_FROM_ONLINE" => $_POST["FORUM_HIDE_FROM_ONLINE"] == "Y" ? "Y" : "N", "SUBSC_GROUP_MESSAGE" => $_POST["FORUM_SUBSC_GROUP_MESSAGE"] == "Y" ? "Y" : "N", "SUBSC_GET_MY_MESSAGE" => $_POST["FORUM_SUBSC_GET_MY_MESSAGE"] == "Y" ? "Y" : "N", "DESCRIPTION" => $_POST["FORUM_DESCRIPTION"], "INTERESTS" => $_POST["FORUM_INTERESTS"], "SIGNATURE" => $_POST["FORUM_SIGNATURE"], "AVATAR" => $_FILES["FORUM_AVATAR"]);
$arFields["AVATAR"]["del"] = $_POST["FORUM_AVATAR_del"];
if (CForumUser::IsAdmin()) {
$arFields["ALLOW_POST"] = $_POST["FORUM_ALLOW_POST"] != "Y" ? "N" : "Y";
}
$ar_res = CForumUser::GetByUSER_ID($arParams["UID"]);
if ($ar_res) {
$arFields["AVATAR"]["old_file"] = $ar_res["AVATAR"];
$FID = CForumUser::Update($ar_res["ID"], $arFields);
} else {
$arFields["USER_ID"] = $arParams["UID"];
$FID = CForumUser::Add($arFields);
}
if (intVal($FID) <= 0 && !$APPLICATION->GetException()) {
$APPLICATION->ThrowException(GetMessage("FP_ERR_PROF"));
}
}
}
if ($APPLICATION->GetException()) {
$bVarsFromForm = true;
} else {
if ($USER->GetId() == $arParams["UID"]) {
$USER->Authorize($arParams["UID"]);
}
if ($_POST["OLD_LOGIN"] != $_POST["LOGIN"] || strLen($_POST["NEW_PASSWORD"]) > 0) {
$USER->SendUserInfo($USER->GetParam("USER_ID"), LANG, GetMessage("FP_CHG_REG_INFO"), true);
}
示例6: Delete
/**
* <p>Функция удаляет из голосования голоса, отданные пользователем с кодом FROM_USER_ID пользователю с кодом TO_USER_ID.</p>
*
*
*
*
* @param int $FROM_USER_ID Код пользователя, отдавшего голос.
*
*
*
* @param int $TO_USER_ID Код пользователя, которому был отдан голос.
*
*
*
* @return bool <p>Функция возвращает True в случае успешного удаления и False - в
* случае ошибки.</p>
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/forum/developer/cforumuserpoints/cforumuserpoints__delete.8bd6061a.php
* @author Bitrix
*/
public static function Delete($FROM_USER_ID, $TO_USER_ID)
{
global $DB;
$FROM_USER_ID = IntVal($FROM_USER_ID);
if ($FROM_USER_ID<=0) return False;
$TO_USER_ID = IntVal($TO_USER_ID);
if ($TO_USER_ID<=0) return False;
$DB->Query("DELETE FROM b_forum_user_points WHERE FROM_USER_ID = ".$FROM_USER_ID." AND TO_USER_ID = ".$TO_USER_ID);
// Recount user points.
$arUserFields = array();
$arUserFields["POINTS"] = CForumUser::CountUserPoints($TO_USER_ID);
$arUser = CForumUser::GetByUSER_ID($TO_USER_ID);
if ($arUser)
{
CForumUser::Update($arUser["ID"], $arUserFields);
}
else
{
$arUserFields["USER_ID"] = $TO_USER_ID;
$ID_tmp = CForumUser::Add($arUserFields);
}
return true;
}
示例7: AddComment_Review_CreateRoot_Forum
function AddComment_Review_CreateRoot_Forum($arElement, $forumID, $bPostFirstMessage = false, $strFirstMessage = "")
{
if (!CModule::IncludeModule("forum")) {
return false;
}
if ($bPostFirstMessage && strlen($strFirstMessage) <= 0) {
return false;
}
// Add Topic
$arUserStart = array("ID" => intVal($arElement["~CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
if ($arUserStart["ID"] > 0) {
$res = array();
$db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arElement["~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($arElement["~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"];
$GLOBALS["DB"]->StartTransaction();
$arFields = array("TITLE" => $arElement["~NAME"], "TAGS" => $arElement["~TAGS"], "FORUM_ID" => $forumID, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "APPROVED" => "Y", "XML_ID" => "IBLOCK_" . $arElement["ID"]);
if (isset($arElement["ENTITY_TYPE"]) && $arElement["ENTITY_TYPE"] == SONET_ENTITY_GROUP && isset($arElement["ENTITY_ID"]) && intval($arElement["ENTITY_ID"]) > 0) {
$arFields["SOCNET_GROUP_ID"] = intval($arElement["ENTITY_ID"]);
}
$TOPIC_ID = CForumTopic::Add($arFields);
if ($bPostFirstMessage && intVal($TOPIC_ID) > 0) {
if (COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
$strFirstMessage = CFilterUnquotableWords::Filter($strFirstMessage);
}
// Add post as new message
$arFields = array("POST_MESSAGE" => $strFirstMessage, "AUTHOR_ID" => $arUserStart["ID"], "AUTHOR_NAME" => $arUserStart["NAME"], "FORUM_ID" => $forumID, "TOPIC_ID" => $TOPIC_ID, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => "IB", "PARAM2" => intVal($arElement["ID"]));
$MID = CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
if (intVal($MID) <= 0) {
$arError[] = array("code" => "message is not added 1", "title" => GetMessage("F_ERR_ADD_MESSAGE"));
CForumTopic::Delete($TOPIC_ID);
$TOPIC_ID = 0;
} elseif ($arParams["SUBSCRIBE_AUTHOR_ELEMENT"] == "Y" && intVal($arResult["ELEMENT"]["~CREATED_BY"]) > 0) {
if ($arUserStart["USER_PROFILE"] == "N") {
$arUserStart["FORUM_USER_ID"] = CForumUser::Add(array("USER_ID" => $arResult["ELEMENT"]["~CREATED_BY"]));
}
if (intVal($arUserStart["FORUM_USER_ID"]) > 0) {
CForumSubscribe::Add(array("USER_ID" => $arResult["ELEMENT"]["~CREATED_BY"], "FORUM_ID" => $arParams["FORUM_ID"], "SITE_ID" => SITE_ID, "TOPIC_ID" => $TID, "NEW_TOPIC_ONLY" => "N"));
BXClearCache(true, "/bitrix/forum/user/" . $arResult["ELEMENT"]["~CREATED_BY"] . "/subscribe/");
// Sorry, Max.
}
}
} elseif (intVal($TOPIC_ID) <= 0) {
$GLOBALS["DB"]->Rollback();
return false;
}
$GLOBALS["DB"]->Commit();
return $TOPIC_ID;
}
示例8: ForumSetLastVisit
function ForumSetLastVisit($FID = false, $TID = false, $arAddParams = array())
{
global $DB;
// For custom components
$GLOBALS["FID"] = $FID = $FID === false && intVal($GLOBALS["FID"]) > 0 ? intVal($GLOBALS["FID"]) : $FID;
if ($GLOBALS["USER"]->IsAuthorized()) {
$GLOBALS["SHOW_FORUM_ICON"] = true;
// out-of-date param
$USER_ID = $GLOBALS["USER"]->GetID();
$arUserFields = array("=LAST_VISIT" => $DB->GetNowFunction());
if (!is_array($_SESSION["FORUM"]["USER"]) || $_SESSION["FORUM"]["USER"]["USER_ID"] != $GLOBALS["USER"]->GetID()) {
$_SESSION["FORUM"]["USER"] = CForumUser::GetByUSER_ID($USER_ID);
if (!$_SESSION["FORUM"]["USER"]) {
$arUserFields["USER_ID"] = $USER_ID;
CForumUser::Add($arUserFields);
$_SESSION["FORUM"]["USER"] = CForumUser::GetByUSER_ID($USER_ID);
}
$_SESSION["FORUM"]["SHOW_NAME"] = $_SESSION["FORUM"]["USER"]["SHOW_NAME"];
}
if (!is_set($arUserFields, "USER_ID")) {
CForumUser::Update($USER_ID, $arUserFields, false, true);
}
}
ForumInitParams();
if ($_SESSION["SESS_SEARCHER_ID"] > 0 && CModule::IncludeModule("statistic")) {
return;
} else {
CForumStat::RegisterUSER(array("SITE_ID" => SITE_ID, "FORUM_ID" => $FID, "TOPIC_ID" => $TID));
}
return true;
}
示例9: strip_tags
$sImage = $arResult["FORUM"]["ALLOW_IMG"] == "Y" ? "[IMG]" . $arImage["SRC"] . "[/IMG]" : '';
}
}
$sElementPreview = $arResult["ELEMENT"]["~PREVIEW_TEXT"];
if ($arAllow["HTML"] != "Y") {
$sElementPreview = strip_tags($sElementPreview);
}
$arFields = array("POST_MESSAGE" => str_replace(array("#IMAGE#", "#TITLE#", "#BODY#", "#LINK#"), array($sImage, $arResult["ELEMENT"]["~NAME"], $sElementPreview, $url), $arParams["POST_FIRST_MESSAGE_TEMPLATE"]), "AUTHOR_ID" => $arUserStart["ID"], "AUTHOR_NAME" => $arUserStart["NAME"], "FORUM_ID" => $arParams["FORUM_ID"], "TOPIC_ID" => $TID, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => "IB", "PARAM2" => intVal($arParams["ELEMENT_ID"]));
$MID = CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
if (intVal($MID) <= 0) {
$arError[] = array("code" => "message is not added 1", "title" => GetMessage("F_ERR_ADD_MESSAGE"));
CForumTopic::Delete($TID);
$TID = 0;
} elseif ($arParams["SUBSCRIBE_AUTHOR_ELEMENT"] == "Y" && intVal($arResult["ELEMENT"]["~CREATED_BY"]) > 0) {
if ($arUserStart["USER_PROFILE"] == "N") {
$arUserStart["FORUM_USER_ID"] = CForumUser::Add(array("USER_ID" => $arResult["ELEMENT"]["~CREATED_BY"]));
}
if (intVal($arUserStart["FORUM_USER_ID"]) > 0) {
CForumSubscribe::Add(array("USER_ID" => $arResult["ELEMENT"]["~CREATED_BY"], "FORUM_ID" => $arParams["FORUM_ID"], "SITE_ID" => SITE_ID, "TOPIC_ID" => $TID, "NEW_TOPIC_ONLY" => "N"));
BXClearCache(true, "/bitrix/forum/user/" . $arResult["ELEMENT"]["~CREATED_BY"] . "/subscribe/");
// Sorry, Max.
}
}
}
// Second exit point
if (!empty($arError)) {
$DB->Rollback();
return false;
} else {
$DB->Commit();
}