コード例 #1
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
/********************************************************************
				Data
********************************************************************/
/************** Votings ********************************************/
if ($arResult["SHOW_VOTES"] == "Y") {
    if ($_GET["VOTE_USER"] == "Y" && $USER->IsAuthorized() && check_bitrix_sessid()) {
        ForumVote4User($arParams["UID"], $_GET["VOTES"], strlen($_GET["CANCEL_VOTE"]) > 0 ? True : False, $strErrorMessage, $strOKMessage);
        if (empty($strErrorMessage)) {
            LocalRedirect($arResult["URL"]["~PROFILE_VIEW"]);
        }
    }
    $strNotesText = "";
    $bCanVote = CForumUser::IsAdmin();
    $bCanUnVote = False;
    $arUserRank = CForumUser::GetUserRank(intVal($USER->GetParam("USER_ID")));
    $arUserPoints = CForumUserPoints::GetByID(intVal($USER->GetParam("USER_ID")), $arParams["UID"]);
    if ($arUserPoints) {
        $bCanUnVote = True;
        $strNotesText .= str_replace("#POINTS#", $arUserPoints["POINTS"], str_replace("#END#", ForumNumberRusEnding($arUserPoints["POINTS"]), GetMessage("F_ALREADY_VOTED1"))) . ". \n";
        if (CForumUser::IsAdmin()) {
            $strNotesText .= GetMessage("F_ALREADY_VOTED_ADMIN");
        } elseif (intVal($arUserPoints["POINTS"]) < intVal($arUserRank["VOTES"])) {
            $bCanVote = True;
            $strNotesText .= str_replace("#POINTS#", intVal($arUserRank["VOTES"]) - intVal($arUserPoints["POINTS"]), str_replace("#END#", ForumNumberRusEnding(intVal($arUserRank["VOTES"]) - intVal($arUserPoints["POINTS"])), GetMessage("F_ALREADY_VOTED3")));
        }
    } elseif (intVal($arUserRank["VOTES"]) > 0 || CForumUser::IsAdmin()) {
        $bCanVote = True;
        $strNotesText .= GetMessage("F_NOT_VOTED");
        if (!CForumUser::IsAdmin()) {
            $strNotesText .= str_replace("#POINTS#", $arUserRank["VOTES"], str_replace("#END#", ForumNumberRusEnding($arUserRank["VOTES"]), GetMessage("F_NOT_VOTED1"))) . ". \n";
        } else {
コード例 #2
0
ファイル: include.php プロジェクト: DarneoStudio/bitrix
function ForumVote4User($UID, $VOTES, $bDelVote, &$strErrorMessage, &$strOKMessage)
{
    global $USER;
    $arError = array();
    $arNote = array();
    $UID = IntVal($UID);
    $VOTES = IntVal($VOTES);
    $bDelVote = $bDelVote ? true : false;
    $CurrUserID = 0;
    if ($UID <= 0) {
        $arError[] = GetMessage("F_NO_VPERS");
    } else {
        if (!$USER->IsAuthorized()) {
            $arError[] = GetMessage("FORUM_GV_ERROR_AUTH");
        } else {
            $CurrUserID = IntVal($USER->GetParam("USER_ID"));
            if ($CurrUserID == $UID && !CForumUser::IsAdmin()) {
                $arError[] = GetMessage("FORUM_GV_OTHER");
            } else {
                $arUserRank = CForumUser::GetUserRank($CurrUserID);
                if (IntVal($arUserRank["VOTES"]) <= 0 && !$bDelVote && !CForumUser::IsAdmin()) {
                    $arError[] = GetMessage("FORUM_GV_ERROR_NO_VOTE");
                } else {
                    if (!CForumUser::IsAdmin() || $VOTES <= 0) {
                        $VOTES = IntVal($arUserRank["VOTES"]);
                    }
                    if ($VOTES == 0) {
                        $VOTES = 1;
                    }
                    // no ranks configured
                    $arFields = array("POINTS" => $VOTES);
                    $arUserPoints = CForumUserPoints::GetByID($CurrUserID, $UID);
                    if ($arUserPoints) {
                        if ($bDelVote || $VOTES <= 0) {
                            if (CForumUserPoints::Delete($CurrUserID, $UID)) {
                                $arNote[] = GetMessage("FORUM_GV_SUCCESS_UNVOTE");
                            } else {
                                $arError[] = GetMessage("FORUM_GV_ERROR_VOTE");
                            }
                        } else {
                            if (IntVal($arUserPoints["POINTS"]) < IntVal($arUserRank["VOTES"]) || CForumUser::IsAdmin()) {
                                if (CForumUserPoints::Update(IntVal($USER->GetParam("USER_ID")), $UID, $arFields)) {
                                    $arNote[] = GetMessage("FORUM_GV_SUCCESS_VOTE_UPD");
                                } else {
                                    $arError[] = GetMessage("FORUM_GV_ERROR_VOTE_UPD");
                                }
                            } else {
                                $arError[] = GetMessage("FORUM_GV_ALREADY_VOTE");
                            }
                        }
                    } else {
                        if (!$bDelVote && $VOTES > 0) {
                            $arFields["FROM_USER_ID"] = $USER->GetParam("USER_ID");
                            $arFields["TO_USER_ID"] = $UID;
                            if (CForumUserPoints::Add($arFields)) {
                                $arNote[] = GetMessage("FORUM_GV_SUCCESS_VOTE_ADD");
                            } else {
                                $arError[] = GetMessage("FORUM_GV_ERROR_VOTE_ADD");
                            }
                        } else {
                            $arError[] = GetMessage("FORUM_GV_ERROR_A");
                        }
                    }
                }
            }
        }
    }
    if (!empty($arError)) {
        $strErrorMessage .= implode(".\n", $arError) . ".\n";
    }
    if (!empty($arNote)) {
        $strOKMessage .= implode(".\n", $arNote) . ".\n";
    }
    if (empty($arError)) {
        return True;
    } else {
        return False;
    }
}
コード例 #3
0
ファイル: index.php プロジェクト: webgksupport/alpina
}
$db_res = CForumPoints2Post::GetList();
if (!($db_res && ($res = $db_res->Fetch()))) {
    $arFields = array("MIN_NUM_POSTS" => 1, "POINTS_PER_POST" => "0.5000");
    CForumPoints2Post::Add($arFields);
    $arFields = array("MIN_NUM_POSTS" => 50, "POINTS_PER_POST" => "0.8000");
    CForumPoints2Post::Add($arFields);
}
/* User */
$res = CForumUser::GetByUSER_ID(1);
if (empty($res) || !is_array($res)) {
    $arFields = array("=LAST_VISIT" => $DB->GetNowFunction(), "USER_ID" => 1);
    $ID = CForumUser::Add($arUserFields);
}
/* Vote */
$res = CForumUserPoints::GetByID(1, 1);
if (!$res) {
    $arFields = array("POINTS" => 1000, "FROM_USER_ID" => 1, "TO_USER_ID" => 1);
    $ID = CForumUserPoints::Add($arFields);
}
// Forum group
$arGroup = array("PUBLIC" => 0, "PARTNER" => 0, "COMMENTS" => 0);
$db_res = CForumGroup::GetListEx(array(), array("LID" => LANGUAGE_ID));
if ($db_res && ($res = $db_res->Fetch())) {
    do {
        if (GetMessage("F_GROUP_PUBLIC") == $res["NAME"]) {
            $arGroup["PUBLIC"] = intVal($res["ID"]);
        } elseif (GetMessage("F_GROUP_PARTNER") == $res["NAME"]) {
            $arGroup["PARTNER"] = intVal($res["ID"]);
        } elseif (GetMessage("F_GROUP_COMMENTS") == $res["NAME"]) {
            $arGroup["COMMENTS"] = intVal($res["ID"]);
コード例 #4
0
            ?>
</a>]</small>
		<?php 
        }
        ?>
	</h2><?php 
        // ********************  VOTINGS  ************************
        if (COption::GetOptionString("forum", "SHOW_VOTES", "Y") == "Y" && $USER->IsAuthorized() && ($USER->IsAdmin() || IntVal($USER->GetParam("USER_ID")) != $UID)) {
            $strNotesText = "";
            $bCanVote = False;
            $bCanUnVote = False;
            if ($USER->IsAdmin()) {
                $bCanVote = True;
            }
            $arUserRank = CForumUser::GetUserRank(IntVal($USER->GetParam("USER_ID")));
            $arUserPoints = CForumUserPoints::GetByID(IntVal($USER->GetParam("USER_ID")), $UID);
            if ($arUserPoints) {
                $bCanUnVote = True;
                $strNotesText .= str_replace("#POINTS#", $arUserPoints["POINTS"], str_replace("#END#", ForumNumberRusEnding($arUserPoints["POINTS"]), GetMessage("FV_ALREADY_VOTED1"))) . ". \n";
                if (IntVal($arUserPoints["POINTS"]) < IntVal($arUserRank["VOTES"]) && !$USER->IsAdmin()) {
                    $bCanVote = True;
                    $strNotesText .= str_replace("#POINTS#", IntVal($arUserRank["VOTES"]) - IntVal($arUserPoints["POINTS"]), str_replace("#END#", ForumNumberRusEnding(IntVal($arUserRank["VOTES"]) - IntVal($arUserPoints["POINTS"])), GetMessage("FV_ALREADY_VOTED3")));
                } elseif ($USER->IsAdmin()) {
                    $strNotesText .= GetMessage("FV_ALREADY_VOTED_ADMIN");
                }
            } else {
                if (IntVal($arUserRank["VOTES"]) > 0 || $USER->IsAdmin()) {
                    $bCanVote = True;
                    $strNotesText .= GetMessage("FV_NOT_VOTED");
                    if (!$USER->IsAdmin()) {
                        $strNotesText .= str_replace("#POINTS#", $arUserRank["VOTES"], str_replace("#END#", ForumNumberRusEnding($arUserRank["VOTES"]), GetMessage("FV_NOT_VOTED1"))) . ". \n";