Exemple #1
0
function ForumSpamTopic($topic, &$strErrorMessage, &$strOKMessage, $arAddParams = array())
{
    global $USER;
    $arError = array();
    $arOk = array();
    $arAddParams = !is_array($arAddParams) ? array($arAddParams) : $arAddParams;
    $arAddParams["PERMISSION"] = !empty($arAddParams["PERMISSION"]) ? $arAddParams["PERMISSION"] : false;
    $topic = ForumDataToArray($topic);
    if (empty($topic)) {
        $arError[] = GetMessage("SPAMTOP_NO_TOPIC");
    } else {
        if (!CForumUser::IsAdmin() && !$arAddParams["PERMISSION"]) {
            $db_res = CForumTopic::GetListEx(array(), array("@ID" => implode(",", $topic), "PERMISSION_STRONG" => true));
        } else {
            $db_res = CForumTopic::GetListEx(array(), array("@ID" => implode(",", $topic)));
        }
        if ($db_res && ($res = $db_res->Fetch())) {
            do {
                if (CForumTopic::CanUserDeleteTopic($res["ID"], $USER->GetUserGroupArray(), $USER->GetID(), $arAddParams["PERMISSION"])) {
                    $db_mes = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $res["ID"]));
                    if ($db_mes && ($mes = $db_mes->Fetch() && CModule::IncludeModule("mail"))) {
                        CMailMessage::MarkAsSpam($mes["XML_ID"], "Y");
                    }
                    if (CForumTopic::Delete($res["ID"])) {
                        $arOk[] = GetMessage("SPAMTOP_OK") . " (TID=" . intVal($res["ID"]) . ")";
                        CForumEventLog::Log("topic", "spam", $res["ID"], print_r($res, true) . print_r($mes, true));
                    } else {
                        $arError[] = GetMessage("SPAMTOP_NO") . " (TID=" . intVal($res["ID"]) . ")";
                    }
                } else {
                    $arError[] = GetMessage("SPAMTOP_NO_PERMS") . " (TID=" . intVal($res["ID"]) . ")";
                }
            } while ($res = $db_res->Fetch());
        } else {
            $arError[] = GetMessage("FMT_NO_PERMS_EDIT");
        }
    }
    if (count($arError) > 0) {
        $strErrorMessage .= implode(".\n", $arError) . ".\n";
    }
    if (count($arOk) > 0) {
        $strOKMessage .= implode(".\n", $arOk) . ".\n";
    }
    if (count($arError) > 0) {
        return false;
    } else {
        return true;
    }
}
Exemple #2
0
    }
    if (!empty($sError)) {
        $lAdmin->AddFilterError($sError);
    }
}
$rsData = CForumTopic::GetListEx(array($by => $order), $arFilter, false, 0, array("NoFilter" => true));
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("FM_TOPICS")));
/*******************************************************************/
$lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "TITLE", "content" => GetMessage("FM_TITLE_NAME"), "sort" => "TITLE", "default" => true), array("id" => "DESCRIPTION", "content" => GetMessage("FM_TITLE_DESCRIPTION"), "sort" => "DESCRIPTION", "default" => false), array("id" => "STATE", "content" => GetMessage("FM_TITLE_STATE"), "sort" => "STATE", "default" => true), array("id" => "APPROVED", "content" => GetMessage("FM_TITLE_APPROVED"), "sort" => "APPROVED", "default" => true), array("id" => "SORT", "content" => GetMessage("FM_TITLE_SORT"), "sort" => "SORT", "default" => true), array("id" => "USER_START_NAME", "content" => GetMessage("FM_TITLE_AUTHOR"), "sort" => "USER_START_NAME", "default" => true), array("id" => "START_DATE", "content" => GetMessage("FM_TITLE_DATE_CREATE"), "sort" => "START_DATE", "default" => true), array("id" => "POSTS", "content" => GetMessage("FM_TITLE_MESSAGES"), "sort" => "POSTS", "default" => false), array("id" => "VIEWS", "content" => GetMessage("FM_TITLE_VIEWS"), "sort" => "VIEWS", "default" => false), array("id" => "FORUM_ID", "content" => GetMessage("FM_TITLE_FORUM"), "sort" => "FORUM_NAME", "default" => true), array("id" => "LAST_POST_DATE", "content" => GetMessage("FM_TITLE_LAST_MESSAGE"), "sort" => "LAST_POST_DATE", "default" => false)));
/*******************************************************************/
while ($res = $rsData->NavNext(true, "t_")) {
    $row =& $lAdmin->AddRow($t_ID, $res);
    $bCanUpdateForum = CForumTopic::CanUserUpdateTopic($t_ID, $USER->GetUserGroupArray(), $USER->GetID());
    $bCanDeleteForum = CForumTopic::CanUserDeleteTopic($t_ID, $USER->GetUserGroupArray(), $USER->GetID());
    $row->bReadOnly = !$bCanUpdateForum || !$bCanDeleteForum ? true : false;
    $row->AddField("ID", $t_ID);
    $row->AddInputField("TITLE", array("size" => "35"));
    $row->AddInputField("DESCRIPTION", array("size" => "35"));
    if ($t_STATE != "L") {
        $row->AddSelectField("STATE", array("Y" => GetMessage("F_OPEN"), "N" => GetMessage("F_CLOSE")));
    } else {
        $row->AddField("STATE", "Link");
    }
    $row->AddSelectField("APPROVED", array("Y" => GetMessage("F_SHOW"), "N" => GetMessage("F_HIDE")));
    $row->AddSelectField("SORT", array("100" => GetMessage("F_PINN"), "150" => GetMessage("F_UNPINN")));
    $row->AddInputField("USER_START_NAME", array("size" => "20"));
    $row->AddInputField("START_DATE", array("size" => "16"));
    $row->AddField("POSTS", $t_POSTS);
    $row->AddInputField("VIEWS", array("size" => "2"));
Exemple #3
0
				 | 
				<font class="forumheadtext"><a href="read.php?FID=<?php 
        echo $FID;
        ?>
&TID=<?php 
        echo $TID;
        ?>
&ACTION=<?php 
        echo $arTopic["STATE"] != "Y" ? "STATE_Y" : "STATE_N";
        ?>
"><?php 
        echo $arTopic["STATE"] != "Y" ? "Открыть тему" : "Закрыть тему";
        ?>
</a></font>
				<?php 
        if (CForumTopic::CanUserDeleteTopic($TID, $USER->GetUserGroupArray(), $USER->GetID())) {
            ?>
					&nbsp;|&nbsp;
					<font class="forumheadtext"><a href="read.php?FID=<?php 
            echo $FID;
            ?>
&TID=<?php 
            echo $TID;
            ?>
&ACTION=DEL_TOPIC">Удалить тему</a></font>
			  <?php 
        }
        ?>
		  <?php 
    }
    ?>