示例#1
0
 function GetPublicList($arFilter = array(), $strSqlOrder = "ORDER BY C.C_SORT, C.ID, V.DATE_START desc")
 {
     global $DB, $USER;
     $err_mess = CVote::err_mess() . "<br>Function: GetPublicList<br>Line: ";
     $arSqlSearch = array();
     $strSqlSearch = "";
     $arFilter = is_array($arFilter) ? $arFilter : array();
     foreach ($arFilter as $key => $val) {
         if (empty($val) || is_string($val) && $val === "NOT_REF") {
             continue;
         }
         $key = strtoupper($key);
         switch ($key) {
             case "SITE":
                 $val = is_array($val) ? implode(" | ", $val) : $val;
                 $match = $arFilter[$key . "_EXACT_MATCH"] == "N" ? "Y" : "N";
                 $arSqlSearch[] = GetFilterQuery("CS.SITE_ID", $val, $match);
                 $left_join = "LEFT JOIN b_vote_channel_2_site CS ON (C.ID = CS.CHANNEL_ID)";
                 break;
             case "CHANNEL":
                 $match = $arFilter[$key . "_EXACT_MATCH"] == "N" ? "Y" : "N";
                 if (is_array($val)) {
                     $arr = array();
                     foreach ($val as $v) {
                         $v = trim($v);
                         if (strLen($v) > 0) {
                             $arr[] = GetFilterQuery("C.SYMBOLIC_NAME", $v, $match);
                         }
                     }
                     if (!empty($arr)) {
                         $arSqlSearch[] = "((" . implode(") OR (", $arr) . "))";
                     }
                 } else {
                     $arSqlSearch[] = GetFilterQuery("C.SYMBOLIC_NAME", $val, $match);
                 }
                 break;
             case "FIRST_SITE_ID":
             case "LID":
                 $match = $arFilter[$key . "_EXACT_MATCH"] == "N" ? "Y" : "N";
                 $arSqlSearch[] = GetFilterQuery("C.FIRST_SITE_ID", $val, $match);
                 break;
         }
     }
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $is_admin = $USER->IsAdmin();
     $groups = $USER->GetGroups();
     $strSql = "\n\t\t\tSELECT C.TITLE CHANNEL_TITLE, V.*,\n\t\t\t\t" . $DB->DateToCharFunction("V.DATE_START") . "\tDATE_START,\n\t\t\t\t" . $DB->DateToCharFunction("V.DATE_END") . "\tDATE_END, \n\t\t\t\tV4.MAX_PERMISSION, V4.LAMP\n\t\t\tFROM (\n\t\t\t\tSELECT V.CHANNEL_ID, V.ID,\n\t\t\t\t\t" . ($is_admin ? "2" : "max(G.PERMISSION)") . " as MAX_PERMISSION, \n\t\t\t\t\tIF((C.VOTE_SINGLE = 'Y'), \n\t\t\t\t\t\t(IF(V.ID = VV.ACTIVE_VOTE_ID, 'green', 'red')), \n\t\t\t\t\t\t(IF(V.ACTIVE = 'Y' AND V.DATE_START <= NOW() AND NOW() <= V.DATE_END, 'green', 'red'))) LAMP \n\t\t\t\tFROM b_vote V\n\t\t\t\tINNER JOIN b_vote_channel C ON (C.ACTIVE = 'Y' AND C.HIDDEN = 'N' AND V.CHANNEL_ID = C.ID)\n\t\t\t\tLEFT JOIN (\n\t\t\t\t\tSELECT VVV.CHANNEL_ID, MAX(VVV.ID) AS ACTIVE_VOTE_ID\n\t\t\t\t\tFROM b_vote VVV, b_vote_channel CCC\n\t\t\t\t\tWHERE VVV.CHANNEL_ID = CCC.ID AND CCC.VOTE_SINGLE='Y' AND VVV.ACTIVE = 'Y' \n\t\t\t\t\t\tAND NOW() >= VVV.DATE_START AND VVV.DATE_END >= NOW()\n\t\t\t\t\tGROUP BY VVV.CHANNEL_ID) VV ON (VV.CHANNEL_ID = V.CHANNEL_ID)\n\t\t\t\tLEFT JOIN b_vote_channel_2_group G ON (G.CHANNEL_ID = C.ID and G.GROUP_ID in ({$groups}))\n\t\t\t\t{$left_join}\n\t\t\t\tWHERE\n\t\t\t\t\t{$strSqlSearch}\n\t\t\t\t\tAND V.ACTIVE = 'Y' AND V.DATE_START <= NOW()\n\t\t\t\tGROUP BY V.CHANNEL_ID, V.ID\n\t\t\t\t" . ($is_admin ? "" : "\n\t\t\t\tHAVING MAX_PERMISSION > 0") . "\n\t\t\t) V4\n\t\t\tINNER JOIN b_vote V ON (V4.ID = V.ID)\n\t\t\tINNER JOIN b_vote_channel C ON (V4.CHANNEL_ID = C.ID) \n\t\t\t" . $DB->ForSql($strSqlOrder);
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     return $res;
 }
示例#2
0
    $arParams["~" . strToUpper($URL) . "_TEMPLATE"] = $arParams[strToUpper($URL) . "_TEMPLATE"];
    $arParams[strToUpper($URL) . "_TEMPLATE"] = htmlspecialcharsbx($arParams["~" . strToUpper($URL) . "_TEMPLATE"]);
}
/********************************************************************
				/Input params
********************************************************************/
/********************************************************************
				Data
********************************************************************/
$arResult["VOTES"] = array();
$arResult["NAV_STRING"] = "";
$db_res = GetVoteList($arParams["CHANNEL_SID"], array("bDescPageNumbering" => false, "nPageSize" => 10, "bShowAll" => false));
if ($db_res) {
    $arResult["NAV_STRING"] = $db_res->GetPageNavString(GetMessage("VOTE_PAGES"));
    while ($res = $db_res->Fetch()) {
        $res["USER_ALREADY_VOTE"] = CVote::UserAlreadyVote($res["ID"], $_SESSION["VOTE_USER_ID"], $res["UNIQUE_TYPE"], $res["KEEP_IP_SEC"], $GLOBALS["USER"]->GetID()) ? "Y" : "N";
        $res["URL"] = array("~VOTE_RESULT" => CComponentEngine::MakePathFromTemplate($arParams["~VOTE_RESULT_TEMPLATE"], array("VOTE_ID" => $res["ID"])), "~VOTE_FORM" => CComponentEngine::MakePathFromTemplate($arParams["~VOTE_FORM_TEMPLATE"], array("VOTE_ID" => $res["ID"])), "VOTE_RESULT" => CComponentEngine::MakePathFromTemplate($arParams["VOTE_RESULT_TEMPLATE"], array("VOTE_ID" => $res["ID"])), "VOTE_FORM" => CComponentEngine::MakePathFromTemplate($arParams["VOTE_FORM_TEMPLATE"], array("VOTE_ID" => $res["ID"])));
        $res["IMAGE"] = CFile::GetFileArray($res["IMAGE_ID"]);
        // For custom
        foreach ($res["URL"] as $key => $val) {
            $res[$key . "_URL"] = $val;
        }
        $res["TITLE"] = htmlspecialcharsEx($res["TITLE"]);
        if ($res['DESCRIPTION_TYPE'] == 'text') {
            $res['DESCRIPTION'] = htmlspecialcharsbx($res['DESCRIPTION']);
        }
        $arResult["VOTES"][$res["ID"]] = $res;
    }
}
/********************************************************************
				/Data
示例#3
0
}
$arParams["CONTROL_ID"] = preg_match("/^[a-zA-Z0-9_]+\$/", $arParams["CONTROL_ID"]) ? $arParams["CONTROL_ID"] : randString();
$arParams["bVarsFromForm"] = $arParams["bVarsFromForm"] ? true : false;
/********************************************************************
				/Input params
********************************************************************/
/********************************************************************
				Data
********************************************************************/
$arResult["CONTROL_UID"] = md5(randString(15));
$arResult["VOTES"] = array();
if ($arParams["bVarsFromForm"]) {
    $arResult["VOTES"] = is_array($_POST[$arParams["~INPUT_NAME"]]) ? $_POST[$arParams["~INPUT_NAME"] . "_DATA"] : array($_POST[$arParams["~INPUT_NAME"] . "_DATA"]);
} else {
    if (!empty($arParams["INPUT_VALUE"])) {
        $db_res = CVote::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arParams["CHANNEL_ID"], "ACTIVE" => "Y", "@ID" => $arParams["INPUT_VALUE"]));
        while ($res = $db_res->Fetch()) {
            $arResult["VOTES"][$res["ID"]] = $res + array("QUESTIONS" => array());
        }
        if (!empty($arResult["VOTES"])) {
            $db_res = CVoteQuestion::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arParams["CHANNEL_ID"], "ACTIVE" => "Y", "@VOTE_ID" => array_keys($arResult["VOTES"])));
            while ($res = $db_res->Fetch()) {
                $arResult["VOTES"][$res["VOTE_ID"]]["QUESTIONS"][$res["ID"]] = $res + array("ANSWERS" => array());
            }
            $db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arParams["CHANNEL_ID"], "ACTIVE" => "Y", "@VOTE_ID" => array_keys($arResult["VOTES"])));
            while ($res = $db_res->Fetch()) {
                if ($res["FIELD_TYPE"] == 1) {
                    $arResult["VOTES"][$res["VOTE_ID"]]["QUESTIONS"][$res["QUESTION_ID"]]["MULTI"] = "Y";
                }
                $arResult["VOTES"][$res["VOTE_ID"]]["QUESTIONS"][$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res;
            }
示例#4
0
                     $arSonetFields = array_intersect_key($arSonetFields, array_flip(array("TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "PARAMS")));
                     CSocNetLog::Update($arRes["ID"], $arSonetFields);
                     CSocNetLogRights::SetForSonet($arRes["ID"], $arParams["MODE"] == "GROUP" ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, $arParams["MODE"] == "GROUP" ? $arParams["SOCNET_GROUP_ID"] : $arParams["USER_ID"], "forum", "view");
                 } else {
                     $dbRes = CSocNetLogComments::GetList(array(), array("EVENT_ID" => "forum", "SOURCE_ID" => $MID1), false, false, array("ID"));
                     if ($arRes = $dbRes->Fetch()) {
                         // message/comment
                         $arSonetFields = array_intersect_key($arSonetFields, array_flip(array("MESSAGE", "TEXT_MESSAGE", "PARAMS")));
                         CSocNetLogComments::Update($arRes["ID"], $arSonetFields);
                     }
                 }
             }
             $url = ForumAddPageParams(CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $arParams["FID"], "TID" => $arParams["TID"], "MID" => intVal($arParams["MID"]), "UID" => $arParams["USER_ID"], "GID" => $arParams["SOCNET_GROUP_ID"])), array("result" => $arNote["code"]));
             LocalRedirect($url);
         } elseif (intVal($arFieldsG["PARAM2"]) > 0 && $arFieldsG["PARAM1"] == "VT") {
             CVote::Delete($arFieldsG["PARAM2"]);
         }
     }
     if (!empty($strErrorMessage)) {
         $arError[] = array("id" => $arParams["MESSAGE_TYPE"], "text" => $strErrorMessage);
     }
 } elseif ($arResult["VIEW"] == "Y") {
     $bVarsFromForm = true;
     $arFields = array("FORUM_ID" => intVal($arParams["FID"]), "TOPIC_ID" => intVal($arParams["TID"]), "MESSAGE_ID" => intVal($arParams["MID"]), "USER_ID" => intVal($GLOBALS["USER"]->GetID()));
     $arFiles = array();
     $arFilesExists = array();
     $res = array();
     foreach ($_FILES as $key => $val) {
         if (substr($key, 0, strLen("FILE_NEW")) == "FILE_NEW" && !empty($val["name"])) {
             $arFiles[] = $_FILES[$key];
         }
示例#5
0
 public static function Fetch()
 {
     if ($res = parent::Fetch()) {
         if ($res["LAMP"] == "yellow" && !empty($res["CHANNEL_ID"])) {
             $res["LAMP"] = $res["ID"] == CVote::GetActiveVoteId($res["CHANNEL_ID"]) ? "green" : "red";
         }
     }
     return $res;
 }
示例#6
0
 public static function Delete($ID)
 {
     global $DB;
     $err_mess = CAllVoteChannel::err_mess() . "<br>Function: Delete<br>Line: ";
     $ID = intval($ID);
     if ($ID <= 0) {
         return true;
     }
     /***************** Event onBeforeVoteChannelDelete ******************/
     foreach (GetModuleEvents("vote", "onBeforeVoteChannelDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     // drop votes
     $z = $DB->Query("SELECT ID FROM b_vote WHERE CHANNEL_ID='{$ID}'", false, $err_mess . __LINE__);
     while ($zr = $z->Fetch()) {
         CVote::Delete($zr["ID"]);
     }
     $DB->Query("DELETE FROM b_vote_channel_2_group WHERE CHANNEL_ID=" . $ID, false, $err_mess . __LINE__);
     $DB->Query("DELETE FROM b_vote_channel_2_site WHERE CHANNEL_ID=" . $ID, false, $err_mess . __LINE__);
     $res = $DB->Query("DELETE FROM b_vote_channel WHERE ID=" . $ID, false, $err_mess . __LINE__);
     /***************** Event onAfterVoteChannelDelete ******************/
     foreach (GetModuleEvents("vote", "onAfterVoteChannelDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     /***************** /Event ******************************************/
     return $res;
 }
示例#7
0
 function Delete($ID)
 {
     global $DB;
     $ID = intVal($ID);
     $arMessage = array();
     if ($ID > 0) {
         $arMessage = CForumMessage::GetByID($ID, array("FILTER" => "N"));
     }
     if (empty($arMessage)) {
         return false;
     }
     /***************** Event onBeforeMessageAdd ************************/
     foreach (GetModuleEvents("forum", "onBeforeMessageDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     $AUTHOR_ID = intVal($arMessage["AUTHOR_ID"]);
     $TOPIC_ID = intVal($arMessage["TOPIC_ID"]);
     $FORUM_ID = intVal($arMessage["FORUM_ID"]);
     $DB->StartTransaction();
     // delete votes
     if ($arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0 && IsModuleInstalled("vote")) {
         CModule::IncludeModule("vote");
         CVote::Delete($arMessage["PARAM2"]);
     }
     // delete files
     CForumFiles::Delete(array("MESSAGE_ID" => $ID), array("DELETE_MESSAGE_FILE" => "Y"));
     // delete message
     $DB->Query("DELETE FROM b_forum_message WHERE ID=" . $ID);
     // after delete
     $db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID), false, 1);
     $res = false;
     if (!($db_res && ($res = $db_res->Fetch()))) {
         CForumTopic::Delete($TOPIC_ID);
     } else {
         // if deleted message was first
         if ($arMessage["NEW_TOPIC"] == "Y") {
             $DB->Update('b_forum_message', array('NEW_TOPIC' => '"Y"'), "WHERE ID=" . $res["ID"]);
         }
         CForumTopic::SetStat($TOPIC_ID);
     }
     $DB->Commit();
     $GLOBALS["USER_FIELD_MANAGER"]->Delete("FORUM_MESSAGE", $ID);
     if ($AUTHOR_ID > 0) {
         CForumUser::SetStat($AUTHOR_ID);
     }
     CForumNew::SetStat($FORUM_ID);
     /***************** Event onBeforeMessageAdd ************************/
     foreach (GetModuleEvents("forum", "onAfterMessageDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arMessage));
     }
     /***************** /Event ******************************************/
     if (CModule::IncludeModule("search")) {
         CSearch::DeleteIndex("forum", $ID);
         if (is_array($res) && !empty($res)) {
             CForumMessage::Reindex($res["ID"], $res);
         }
     }
     return true;
 }
示例#8
0
?>
" size="10"></td>
</tr>
<tr>
	<td nowrap><?php 
echo GetMessage("VOTE_F_VOTE");
?>
</td>
	<td nowrap><input type="text" name="find_vote" size="47" value="<?php 
echo htmlspecialcharsbx($find_vote);
?>
"><?php 
echo InputType("checkbox", "find_vote_exact_match", "Y", $find_vote_exact_match, false, "", "title='" . GetMessage("VOTE_EXACT_MATCH") . "'");
?>
&nbsp;<?php 
echo ShowFilterLogicHelp();
?>
<br><?php 
echo SelectBox("find_vote_id", CVote::GetDropDownList(), GetMessage("VOTE_ALL"), htmlspecialcharsbx($find_vote_id));
?>
</td>
</tr>
<?php 
$oFilter->Buttons(array("table_id" => $sTableID, "url" => $APPLICATION->GetCurPage(), "form" => "form1"));
$oFilter->End();
#############################################################
?>
</form>
<?php 
$lAdmin->DisplayList();
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
示例#9
0
        $VOTE_ID = intVal($arQuestion["VOTE_ID"]);
        $db_res = CVoteAnswer::GetList($ID);
        if ($db_res && ($res = $db_res->Fetch())) {
            do {
                $arAnswers[$ii] = $res;
                $ii++;
            } while ($res = $db_res->Fetch());
        }
    }
}
if ($ID <= 0) {
    $arQuestion = array("ACTIVE" => "Y", "VOTE_ID" => $VOTE_ID, "C_SORT" => CVoteQuestion::GetNextSort($VOTE_ID), "QUESTION" => "", "QUESTION_TYPE" => "html", "IMAGE_ID" => "", "DIAGRAM" => "Y", "REQUIRED" => "N", "DIAGRAM_TYPE" => VOTE_DEFAULT_DIAGRAM_TYPE, "TEMPLATE" => "default.php", "TEMPLATE_NEW" => "default.php");
}
$VOTE_ID = intVal($VOTE_ID);
$arVote = array();
$db_res = CVote::GetByID($VOTE_ID);
if (!($db_res && ($arVote = $db_res->Fetch()))) {
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
    echo "<a href='vote_list.php?lang=" . LANGUAGE_ID . "' class='navchain'>" . GetMessage("VOTE_VOTE_LIST") . "</a>";
    echo ShowError(GetMessage("VOTE_NOT_FOUND"));
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
    die;
}
$arVote["TITLE"] = strlen($arVote["TITLE"]) > 0 ? $arVote["TITLE"] : TruncateText($arVote["DESCRIPTION_TYPE"] == "html" ? strip_tags($arVote["DESCRIPTION"]) : $arVote["DESCRIPTION"], 200);
$db_res = CVoteChannel::GetByID($arVote["CHANNEL_ID"]);
$arChannel = $db_res->Fetch();
$adminChain->AddItem(array("TEXT" => htmlspecialcharsbx($arChannel["TITLE"]), "LINK" => "vote_channel_edit.php?ID={$arChannel['ID']}&lang=" . LANGUAGE_ID));
$adminChain->AddItem(array("TEXT" => htmlspecialcharsbx($arVote["TITLE"]), "LINK" => "vote_edit.php?ID={$arVote['ID']}&lang=" . LANGUAGE_ID));
$sDocTitle = $ID > 0 ? str_replace("#ID#", $ID, GetMessage("VOTE_EDIT_RECORD")) : GetMessage("VOTE_NEW_RECORD");
$APPLICATION->SetTitle($sDocTitle);
/********************************************************************
示例#10
0
function ShowVoteResults($VOTE_ID, $template1="")
{
	global $APPLICATION;
	$VOTE_ID = GetVoteDataByID($VOTE_ID, $arChannel, $arVote, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $arGroupAnswers, "Y");
	if (intval($VOTE_ID)>0)
	{
		/***** for old pre-component templates **********/
		global $VOTE_PERMISSION;
		$VOTE_PERMISSION = CVote::UserGroupPermission($arChannel["ID"]);
		/***** /old *************************************/

		$perm = CVoteChannel::GetGroupPermission($arChannel["ID"]);
		if (intval($perm)>=1)
		{
			$template = (strlen($arVote["RESULT_TEMPLATE"])<=0) ? "default.php" : $arVote["RESULT_TEMPLATE"];
			require_once ($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/vote/include.php");
			IncludeModuleLangFile(__FILE__);
			$path = COption::GetOptionString("vote", "VOTE_TEMPLATE_PATH_VOTE");
			if (strlen($template1)>0) $template = $template1;
			if ($APPLICATION->GetShowIncludeAreas())
			{
				$arIcons = Array();
				if (CModule::IncludeModule("fileman"))
				{
					$arIcons[] =
							Array(
								"URL" => "/bitrix/admin/fileman_file_edit.php?lang=".LANGUAGE_ID."&site=".SITE_ID."&full_src=Y&path=". urlencode($path.$template),
								"SRC" => "/bitrix/images/vote/panel/edit_template.gif",
								"ALT" => GetMessage("VOTE_PUBLIC_ICON_TEMPLATE")
							);
					$arrUrl = parse_url($_SERVER["REQUEST_URI"]);
					$arIcons[] =
							Array(
								"URL" => "/bitrix/admin/fileman_file_edit.php?lang=".LANGUAGE_ID."&site=".SITE_ID."&full_src=Y&path=". urlencode($arrUrl["path"]),
								"SRC" => "/bitrix/images/vote/panel/edit_file.gif",
								"ALT" => GetMessage("VOTE_PUBLIC_ICON_HANDLER")
							);
				}
				$arIcons[] =
						Array(
							"URL" => "/bitrix/admin/vote_edit.php?lang=".LANGUAGE_ID."&ID=".$VOTE_ID,
							"SRC" => "/bitrix/images/vote/panel/edit_vote.gif",
							"ALT" => GetMessage("VOTE_PUBLIC_ICON_SETTINGS")
						);
				echo $APPLICATION->IncludeStringBefore($arIcons);
			}
			$template = Rel2Abs('/', $template);
			include($_SERVER["DOCUMENT_ROOT"].$path.$template);
			if ($APPLICATION->GetShowIncludeAreas())
			{
				echo $APPLICATION->IncludeStringAfter();
			}
		}
	}
}
示例#11
0
	/**
	 * <p>Удаляет сообщение с кодом <i>ID</i>.</p> <p><b>Примечание</b>. Метод использует внутреннюю транзакцию. Если у вас используется <b>MySQL</b> и <b>InnoDB</b>, и ранее была открыта транзакция, то ее необходимо закрыть до подключения метода.</p>
	 *
	 *
	 *
	 *
	 * @param int $ID  Код сообщения, которое необходимо удалить.
	 *
	 *
	 *
	 * @return bool 
	 *
	 *
	 * <h4>See Also</h4> 
	 * <ul><li>Перед удалением сообщения следует проверить возможность
	 * удаления методом <a
	 * href="http://dev.1c-bitrix.ru/api_help/forum/developer/cforummessage/canuserdeletemessage.php">CForumMessage::CanUserDeleteMessage</a>
	 * </li></ul>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/forum/developer/cforummessage/delete.php
	 * @author Bitrix
	 */
	public static function Delete($ID)
	{
		global $DB;
		$ID = intVal($ID);
		$arMessage = array();
		if ($ID > 0)
			$arMessage = CForumMessage::GetByID($ID, array("FILTER" => "N"));
		if (empty($arMessage))
			return false;
/***************** Event onBeforeMessageAdd ************************/
		$events = GetModuleEvents("forum", "onBeforeMessageDelete");
		while ($arEvent = $events->Fetch())
		{
			if (ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage)) === false)
				return false;
		}
/***************** /Event ******************************************/
		$AUTHOR_ID = intVal($arMessage["AUTHOR_ID"]);
		$TOPIC_ID = intVal($arMessage["TOPIC_ID"]);
		$FORUM_ID = intVal($arMessage["FORUM_ID"]);

		$DB->StartTransaction();
		// delete votes
		if ($arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0 && IsModuleInstalled("vote")):
			CModule::IncludeModule("vote");
			CVote::Delete($arMessage["PARAM2"]);
		endif;
		// delete files
		CForumFiles::Delete(array("MESSAGE_ID" => $ID), array("DELETE_MESSAGE_FILE" => "Y"));
		// delete message
		$DB->Query("DELETE FROM b_forum_message WHERE ID=".$ID);
		// after delete
		$db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID), false, 1);
		$res = false;
		if (!($db_res && $res = $db_res->Fetch())):
			CForumTopic::Delete($TOPIC_ID);
		else:
			// if deleted message was first
			if ($arMessage["NEW_TOPIC"] == "Y"):
				$DB->Query("UPDATE b_forum_message SET NEW_TOPIC='Y' WHERE ID=".$res["ID"]);
			endif;
			CForumTopic::SetStat($TOPIC_ID);
		endif;
		$DB->Commit();

		$GLOBALS["USER_FIELD_MANAGER"]->Delete("FORUM_MESSAGE", $ID);

		if ($AUTHOR_ID > 0):
			CForumUser::SetStat($AUTHOR_ID);
		endif;
		CForumNew::SetStat($FORUM_ID);
/***************** Event onBeforeMessageAdd ************************/
		$events = GetModuleEvents("forum", "onAfterMessageDelete");
		while ($arEvent = $events->Fetch())
			ExecuteModuleEventEx($arEvent, array($ID, $arMessage));
/***************** /Event ******************************************/
		if (CModule::IncludeModule("search"))
		{
			CSearch::DeleteIndex("forum", $ID);
		}
		return true;
	}
示例#12
0
<?php

if ($_SERVER["REQUEST_METHOD"] == "POST" && array_key_exists("PUBLIC_VOTE_ID", $_REQUEST) && intval($_REQUEST["PUBLIC_VOTE_ID"]) > 0 && array_key_exists("vote", $_REQUEST) && strlen($_REQUEST["vote"]) > 0) {
    if (CModule::IncludeModule("vote")) {
        CVote::KeepVoting();
    }
}
示例#13
0
	public static function Delete($ID)
	{
		global $DB, $CACHE_MANAGER;
		$err_mess = (CAllVoteChannel::err_mess())."<br>Function: Delete<br>Line: ";
		$ID = intval($ID);
		if ($ID <= 0):
			return true;
		endif;
		/***************** Event onBeforeVoteChannelDelete ******************/
		$events = GetModuleEvents("vote", "onBeforeVoteChannelDelete");
		while ($arEvent = $events->Fetch()) {
			if (ExecuteModuleEventEx($arEvent, array(&$ID)) === false)
				return false; }
		/***************** /Event ******************************************/

		// drop votes
		$strSql = "SELECT ID FROM b_vote WHERE CHANNEL_ID='$ID'";
		$z = $DB->Query($strSql, false, $err_mess.__LINE__);
		while ($zr = $z->Fetch()) CVote::Delete($zr["ID"]);
		
		$DB->Query("DELETE FROM b_vote_channel_2_group WHERE CHANNEL_ID=".$ID, false, $err_mess.__LINE__);
		$DB->Query("DELETE FROM b_vote_channel_2_site WHERE CHANNEL_ID=".$ID, false, $err_mess.__LINE__);
		$res = $DB->Query("DELETE FROM b_vote_channel WHERE ID=".$ID, false, $err_mess.__LINE__);
		/***************** Event onAfterVoteChannelDelete ******************/
		$events = GetModuleEvents("vote", "onAfterVoteChannelDelete");
		while ($arEvent = $events->Fetch())
			ExecuteModuleEventEx($arEvent, array($ID));
		/***************** /Event ******************************************/
		return $res;
	}
示例#14
0
$arParams["PERMISSION"] = $arParams["PERMISSION"] === false ? CVoteChannel::GetGroupPermission($arResult["VOTE"]["CHANNEL_ID"]) : $arParams["PERMISSION"];
if ($arParams["PERMISSION"] <= 0) {
    return false;
} elseif ($GLOBALS["VOTING_OK"] == "Y" && $GLOBALS["VOTING_ID"] == $arParams["VOTE_ID"] && !empty($arParams["VOTE_RESULT_TEMPLATE"])) {
    $var = array("VOTE_ID", "VOTING_OK", "VOTE_SUCCESSFULL", "view_result", "view_form");
    $url = CComponentEngine::MakePathFromTemplate($arParams["VOTE_RESULT_TEMPLATE"], array("VOTE_ID" => $arVote["ID"]));
    if (strpos($url, "?") === false) {
        $url .= "?";
    } elseif (($token = substr($url, strpos($url, "?") + 1)) && !empty($token) && preg_match_all("/(?<=^|\\&)\\w+(?=\$|\\=)/is", $token, $matches)) {
        $var = array_merge($var, $matches);
    }
    $strNavQueryString = DeleteParam($var);
    LocalRedirect($url . "&VOTE_SUCCESSFULL=Y&VOTE_ID=" . intval($_REQUEST["VOTE_ID"]) . ($strNavQueryString != "" ? "&" : "") . $strNavQueryString);
}
$voteUserID = $_SESSION["VOTE_USER_ID"] ? $_SESSION["VOTE_USER_ID"] : intval($GLOBALS["APPLICATION"]->get_cookie("VOTE_USER_ID"));
$arParams["VOTED"] = CVote::UserAlreadyVote($arResult["VOTE_ID"], $voteUserID, $arResult["VOTE"]["UNIQUE_TYPE"], $arResult["VOTE"]["KEEP_IP_SEC"], $GLOBALS["USER"]->GetID());
$isUserCanVote = $arParams["VOTED"] == false;
$arParams["CAN_VOTE"] = $arResult["CAN_VOTE"] = $isUserCanVote && $arParams["PERMISSION"] > 1 ? "Y" : "N";
$arParams["CAN_REVOTE"] = $arParams["VOTED"] == 8 && $arParams["PERMISSION"] > 1 ? "Y" : "N";
$bShowResult = $arResult["VOTE"]["LAMP"] != "green" || $arParams["CAN_VOTE"] != "Y" && $arParams["CAN_REVOTE"] != "Y";
if (!$bShowResult) {
    $bShowResult = $_REQUEST["view_result"] == "Y" || $GLOBALS["VOTING_OK"] == "Y" && $GLOBALS["VOTING_ID"] == $arResult["VOTE_ID"] || $GLOBALS["USER_ALREADY_VOTE"] == "Y" && $arParams["CAN_REVOTE"] != "Y" || $_REQUEST["VOTE_SUCCESSFULL"] == "Y" && $_REQUEST["VOTE_ID"] == $arResult["VOTE_ID"];
    if ($_REQUEST["view_form"] == "Y") {
        $bShowResult = false;
    } else {
        if (!$bShowResult) {
            $bShowResult = $arParams["CAN_REVOTE"] == "Y";
            if ($bShowResult && $GLOBALS["VOTING_ID"] == $arResult["VOTE"]["ID"] && $GLOBALS["VOTING_OK"] != "Y") {
                $bShowResult = false;
            }
        }
示例#15
0
 function Delete($ID)
 {
     global $DB;
     $ID = intVal($ID);
     $bCanDelete = true;
     /***************** Event OnBeforeForumDelete ***********************/
     foreach (GetModuleEvents("forum", "OnBeforeForumDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID)) === false) {
             $bCanDelete = false;
             break;
         }
     }
     /***************** /Event ******************************************/
     if (!$bCanDelete) {
         return false;
     }
     /***************** Event OnForumDelete *****************************/
     foreach (GetModuleEvents("forum", "OnForumDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$ID));
     }
     /***************** /Event ******************************************/
     /***************** Cleaning cache **********************************/
     unset($GLOBALS["FORUM_CACHE"]["FORUM"][$ID]);
     if (CACHED_b_forum !== false) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum");
     }
     if (CACHED_b_forum_perms !== false) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum_perms");
     }
     if (CACHED_b_forum2site !== false) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum2site");
     }
     /***************** Cleaning cache/**********************************/
     /***************** Search module ***********************************/
     set_time_limit(0);
     if (CModule::IncludeModule("search")) {
         CSearch::DeleteIndex("forum", false, $ID);
     }
     CForumFiles::Delete(array("FORUM_ID" => $ID), array("DELETE_FORUM_FILE" => "Y"));
     $DB->StartTransaction();
     // Update USER statistic
     $arProcAuth = array();
     $db_res = CForumMessage::GetList(array(), array("FORUM_ID" => $ID, "!AUTHOR_ID" => 0));
     while ($res = $db_res->Fetch()) {
         $res["AUTHOR_ID"] = intVal($res["AUTHOR_ID"]);
         if (!in_array($res["AUTHOR_ID"], $arProcAuth)) {
             $arProcAuth[] = intVal($res["AUTHOR_ID"]);
         }
     }
     if (IsModuleInstalled("vote")) {
         $db_res = CForumMessage::GetList(array(), array("FORUM_ID" => $ID, "PARAM1" => "VT", "!PARAM2" => 0));
         if ($db_res && ($res = $db_res->Fetch())) {
             CModule::IncludeModule("vote");
             do {
                 CVote::Delete($res["PARAM2"]);
             } while ($res = $db_res->Fetch());
         }
     }
     if (!$DB->Query("DELETE FROM b_forum_subscribe WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum_message WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum_topic WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum_perms WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum2site WHERE FORUM_ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     if (!$DB->Query("DELETE FROM b_forum WHERE ID=" . $ID, true)) {
         $DB->Rollback();
         return false;
     }
     // Update USER statistic
     foreach ($arProcAuth as $i => $procAuth) {
         CForumUser::SetStat($procAuth);
     }
     $DB->Commit();
     /***************** Event OnAfterForumDelete ************************/
     foreach (GetModuleEvents("forum", "OnAfterForumDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     /***************** /Event ******************************************/
     return true;
 }
示例#16
0
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/include.php";
$old_module_version = CVote::IsOldVersion();
IncludeModuleLangFile(__FILE__);
$module_id = "vote";
$VOTE_RIGHT = $APPLICATION->GetGroupRight($module_id);
if ($VOTE_RIGHT >= "R") {
    $arAllOptions = $arDisplayOptions = array(array("USE_HTML_EDIT", GetMessage("VOTE_USE_HTML_EDIT"), array("checkbox", "Y")), array("VOTE_COMPATIBLE_OLD_TEMPLATE", GetMessage("VOTE_COMPATIBLE"), array("checkbox", "Y")), array("VOTE_DIR", GetMessage("VOTE_PUBLIC_DIR"), array("text", 45)), array("VOTE_TEMPLATE_PATH", GetMessage("VOTE_TEMPLATE_VOTES"), array("text", 45)), array("VOTE_TEMPLATE_PATH_VOTE", GetMessage("VOTE_TEMPLATE_RESULTS_VOTE"), array("text", 45)), array("VOTE_TEMPLATE_PATH_QUESTION", GetMessage("VOTE_TEMPLATE_RESULTS_QUESTION"), array("text", 45)), array("VOTE_TEMPLATE_PATH_QUESTION_NEW", GetMessage("VOTE_TEMPLATE_RESULTS_QUESTION_NEW"), array("text", 45)));
    if ($REQUEST_METHOD == "GET" && $VOTE_RIGHT == "W" && strlen($RestoreDefaults) > 0 && check_bitrix_sessid()) {
        COption::RemoveOption("vote");
        $z = CGroup::GetList($v1 = "id", $v2 = "asc", array("ACTIVE" => "Y", "ADMIN" => "N"));
        while ($zr = $z->Fetch()) {
            $APPLICATION->DelGroupRight($module_id, array($zr["ID"]));
        }
    }
    if ($REQUEST_METHOD == "POST" && strlen($Update) > 0 && $VOTE_RIGHT == "W" && check_bitrix_sessid()) {
        while (list($key, $name) = each($arAllOptions)) {
            $val = ${$name}[0];
            if ($name[2][0] == "checkbox" && $val != "Y") {
                $val = "N";
            } elseif (!array_key_exists($name[0], $_POST)) {
                continue;
            }
            COption::SetOptionString($module_id, $name[0], $val);
        }
    }
    if (COption::GetOptionString("vote", "VOTE_COMPATIBLE_OLD_TEMPLATE", "Y") == "N") {
        unset($arDisplayOptions[2]);
        unset($arDisplayOptions[3]);
        unset($arDisplayOptions[4]);
示例#17
0
/********************************************************************
				/ACTIONS
********************************************************************/
if ($ID > 0) {
    $db_res = CVote::GetByID($ID);
    if ($db_res && ($res = $db_res->Fetch())) {
        $arVote = $res;
        $arChannel = $arChannels[$arVote["CHANNEL_ID"]];
    } else {
        $ID = 0;
    }
}
if ($ID <= 0) {
    $arChannel = current($arChannels);
    reset($arChannels);
    $arVote = array("CHANNEL_ID" => isset($_REQUEST['CHANNEL_ID']) && intval($_REQUEST['CHANNEL_ID']) > 0 ? intval($_REQUEST['CHANNEL_ID']) : $arChannel["ID"], "C_SORT" => CVote::GetNextSort($arChannel["ID"]), "ACTIVE" => "Y", "DATE_START" => $arChannel["VOTE_SINGLE"] != "N" ? CVote::GetNextStartDate($arChannel["ID"]) : "", "UNIQUE_TYPE" => 12, "DELAY" => 10, "DELAY_TYPE" => "M", "DESCRIPTION_TYPE" => "html", "IMAGE_ID" => 0, "EVENT1" => "vote", "EVENT2" => strtolower($arChannel["SYMBOLIC_NAME"]), "TEMPLATE" => "default.php");
}
if ($bVarsFromForm) {
    if (!empty($arVote["IMAGE_ID"])) {
        unset($arFields["IMAGE_ID"]);
    }
    $arVote = $arFields;
}
foreach ($arVote as $key => $val) {
    $arVote["~" . $key] = $val;
    $arVote[$key] = htmlspecialcharsEx($val);
}
$sDocTitle = $ID > 0 ? str_replace("#ID#", $ID, GetMessage("VOTE_EDIT_RECORD")) : GetMessage("VOTE_NEW_RECORD");
if (isset($_REQUEST['docopy']) || isset($_REQUEST['COPYID'])) {
    $sDocTitle = GetMessage("VOTE_NEW_RECORD");
}
示例#18
0
            $arFields["LANG"][] = array("LID" => $lang, "NAME" => $name, "DESCRIPTION" => $description);
        }
        $arGroup[$key] = CForumGroup::Add($arFields);
    }
}
$arFieldsParams = array("SHOW_VOTE" => "N", "VOTE_CHANNEL_ID" => 0, "VOTE_GROUP_ID" => 0, "VOTE_ID" => 0, "FORUMS_ID" => "");
if (CModule::IncludeModule("vote")) {
    $db_res = CVoteChannel::GetList($by, $order, array('SYMBOLIC_NAME' => 'FORUM', 'SYMBOLIC_NAME_EXACT_MATCH' => 'Y'), $is_filtered);
    if ($db_res && ($res = $db_res->Fetch())) {
        $arFieldsParams = array("SHOW_VOTE" => "Y", "VOTE_CHANNEL_ID" => $res["ID"], "VOTE_GROUP_ID" => 0);
        //Registered users group
        $dbResult = CGroup::GetList($by, $order, array("STRING_ID" => "REGISTERED_USERS"));
        if ($dbResult && ($res = $dbResult->Fetch())) {
            $arFieldsParams["VOTE_GROUP_ID"] = $res["ID"];
        }
        $db_res = CVote::GetList($by, $order, array("CHANNEL_ID" => $arFieldsParams["VOTE_CHANNEL_ID"]), $is_filtered);
        if ($db_res && ($res = $db_res->Fetch())) {
            $arFieldsParams["VOTE_ID"] = intVal($res["ID"]);
        }
    }
}
// Forums
$arForums = array();
$arReplaceForums = array();
$db_res = CForumNew::GetList(array(), array("SITE_ID" => $SITE_ID));
if ($db_res && ($res = $db_res->Fetch())) {
    do {
        $arForums[$res["ID"]] = $res["NAME"];
    } while ($res = $db_res->Fetch());
}
// Forum № 1
示例#19
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     $aMsg = array();
     $ID = intVal($ID);
     $ACTION = $ACTION == "UPDATE" ? "UPDATE" : "ADD";
     $arQuestion = array();
     if ($ID > 0 && $ACTION == "UPDATE") {
         $db_res = CVoteQuestion::GetByID($ID);
         if (!($db_res && ($arQuestion = $db_res->Fetch()))) {
             $aMsg[] = array("id" => "ID", "text" => GetMessage("VOTE_QUESTION_NOT_FOUND"));
         }
     }
     unset($arFields["ID"]);
     if (is_set($arFields, "VOTE_ID") || $ACTION == "ADD") {
         $arFields["VOTE_ID"] = intVal($arFields["VOTE_ID"]);
         if ($arFields["VOTE_ID"] <= 0) {
             $aMsg[] = array("id" => "VOTE_ID", "text" => GetMessage("VOTE_FORGOT_VOTE_ID"));
         }
     }
     if (is_set($arFields, "QUESTION") || $ACTION == "ADD") {
         $arFields["QUESTION"] = trim($arFields["QUESTION"]);
         if (empty($arFields["QUESTION"])) {
             $aMsg[] = array("id" => "QUESTION", "text" => GetMessage("VOTE_FORGOT_QUESTION"));
         }
     }
     if (is_set($arFields, "IMAGE_ID") && strLen($arFields["IMAGE_ID"]["name"]) <= 0 && strLen($arFields["IMAGE_ID"]["del"]) <= 0) {
         unset($arFields["IMAGE_ID"]);
     } elseif (is_set($arFields, "IMAGE_ID")) {
         if ($str = CFile::CheckImageFile($arFields["IMAGE_ID"])) {
             $aMsg[] = array("id" => "IMAGE_ID", "text" => $str);
         } else {
             $arFields["IMAGE_ID"]["MODULE_ID"] = "vote";
             if (!empty($arQuestion)) {
                 $arFields["IMAGE_ID"]["old_file"] = $arQuestion["IMAGE_ID"];
             }
         }
     }
     if (is_set($arFields, "ACTIVE") || $ACTION == "ADD") {
         $arFields["ACTIVE"] = $arFields["ACTIVE"] == "N" ? "N" : "Y";
     }
     unset($arFields["TIMESTAMP_X"]);
     if (is_set($arFields, "C_SORT") || $ACTION == "ADD") {
         $arFields["C_SORT"] = intVal($arFields["C_SORT"]) > 0 ? intVal($arFields["C_SORT"]) : 100;
     }
     if (is_set($arFields, "COUNTER") || $ACTION == "ADD") {
         $arFields["COUNTER"] = intVal($arFields["COUNTER"]);
     }
     if (is_set($arFields, "QUESTION_TYPE") || $ACTION == "ADD") {
         $arFields["QUESTION_TYPE"] = $arFields["QUESTION_TYPE"] == "html" ? "html" : "text";
     }
     if (is_set($arFields, "DIAGRAM") || $ACTION == "ADD") {
         $arFields["DIAGRAM"] = $arFields["DIAGRAM"] == "N" ? "N" : "Y";
     }
     if (is_set($arFields, "DIAGRAM_TYPE") && (empty($arFields["DIAGRAM_TYPE"]) || in_array($arFields["DIAGRAM_TYPE"], GetVoteDiagramArray()))) {
         $arFields["DIAGRAM_TYPE"] = VOTE_DEFAULT_DIAGRAM_TYPE;
     }
     if (is_set($arFields, "TEMPLATE")) {
         $arFields["TEMPLATE"] = substr(trim($arFields["TEMPLATE"]), 0, 255);
     }
     if (is_set($arFields, "TEMPLATE_NEW")) {
         $arFields["TEMPLATE_NEW"] = substr(trim($arFields["TEMPLATE_NEW"]), 0, 255);
     }
     if ((is_set($arFields, "TEMPLATE") || is_set($arFields, "TEMPLATE_NEW")) && COption::GetOptionString("vote", "VOTE_COMPATIBLE_OLD_TEMPLATE", "Y") == "Y") {
         $old_module_version = CVote::IsOldVersion();
         if ($old_module_version != "Y") {
             unset($arFields["TEMPLATE"]);
         } else {
             unset($arFields["TEMPLATE_NEW"]);
         }
     }
     if (!empty($aMsg)) {
         global $APPLICATION;
         $e = new CAdminException(array_reverse($aMsg));
         $APPLICATION->ThrowException($e);
         return false;
     }
     return true;
 }
示例#20
0
/********************************************************************
				/ACTIONS
********************************************************************/
/********************************************************************
				Data
********************************************************************/
$rsData = CVote::GetList($by, $order, $arFilter, $is_filtered);
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("VOTE_PAGES")));
$lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "s_id", "default" => true), array("id" => "LAMP", "content" => GetMessage("VOTE_LAMP"), "sort" => "s_lamp", "default" => true), array("id" => "DATE_START", "content" => GetMessage("VOTE_DATE_START"), "sort" => "s_date_start", "default" => true), array("id" => "DATE_END", "content" => GetMessage("VOTE_DATE_END"), "sort" => "s_date_end", "default" => true), array("id" => "CHANNEL_ID", "content" => GetMessage("VOTE_CHANNEL"), "sort" => "s_channel", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("VOTE_ACTIVE"), "sort" => "s_active", "default" => true), array("id" => "C_SORT", "content" => GetMessage("VOTE_C_SORT"), "sort" => "s_c_sort", "default" => true), array("id" => "TITLE", "content" => GetMessage("VOTE_TITLE"), "sort" => "s_title", "default" => true), array("id" => "QUESTIONS", "content" => GetMessage("VOTE_QUESTIONS"), "default" => true), array("id" => "COUNTER", "content" => GetMessage("VOTE_COUNTER"), "sort" => "s_counter", "default" => true)));
while ($arRes = $rsData->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arRes);
    $row->AddViewField("ID", "<a href='vote_edit.php?lang=" . LANGUAGE_ID . "&ID={$f_ID}' title='" . GetMessage("VOTE_EDIT_TITLE") . "'>{$f_ID}</a>");
    if ($f_LAMP == "yellow") {
        $arRes["LAMP"] = $f_LAMP = $f_ID == CVote::GetActiveVoteId($arRes["CHANNEL_ID"]) ? "green" : "red";
    }
    $lamp = $f_LAMP;
    if ($f_LAMP == "green") {
        $lamp = "<div class=\"lamp-green\" title=\"" . GetMessage("VOTE_LAMP_ACTIVE") . "\"></div>";
    } elseif ($f_LAMP == "red") {
        $lamp = "<div class=\"lamp-red\" title=\"" . ($f_ACTIVE != 'Y' ? GetMessage("VOTE_NOT_ACTIVE") : GetMessage("VOTE_ACTIVE_RED_LAMP")) . "\"></div>";
    }
    $row->AddViewField("LAMP", $lamp);
    $row->AddSelectField("CHANNEL_ID", $arChannelsTitle);
    $row->AddCheckField("ACTIVE");
    $row->AddInputField("C_SORT");
    $row->AddInputField("TITLE", array());
    $row->AddViewField("QUESTIONS", "<a title=\"" . GetMessage("VOTE_QUESTIONS_TITLE") . "\" href=\"vote_question_list.php?lang=" . LANGUAGE_ID . "&VOTE_ID={$f_ID}\">{$f_QUESTIONS}</a>&nbsp;[<a title=\"" . GetMessage("VOTE_QUESTIONS_ADD") . "\" href=\"vote_question_edit.php?lang=" . LANGUAGE_ID . "&VOTE_ID={$f_ID}\">+</a>]");
    $row->AddViewField("COUNTER", "<a href=\"vote_user_votes.php?lang=" . LANGUAGE_ID . "&find_vote_id={$f_ID}&find_valid=Y&set_filter=Y\" title=\"" . GetMessage("VOTE_VOTES_TITLE") . "\">{$f_COUNTER}</a>");
    $arActions = array();
示例#21
0
 if (empty($arMessage)) {
     ShowError(GetMessage("F_ERROR_MESSAGE_NOT_FOUND"));
     return 0;
 }
 $arResult["TOPIC"] = $arMessage["TOPIC_INFO"];
 $arResult["TOPIC_FILTER"] = CForumTopic::GetByID($arMessage["TOPIC_ID"]);
 $arResult["MESSAGE"] = $arMessage;
 $arResult["MESSAGE"]["FILES"] = array();
 $db_res = CForumFiles::GetList(array(), array("MESSAGE_ID" => $arParams["MID"]));
 if ($db_res && ($res = $db_res->Fetch())) {
     do {
         $arResult["MESSAGE"]["FILES"][$res["FILE_ID"]] = $res;
     } while ($res = $db_res->Fetch());
 }
 if ($arParams["SHOW_VOTE"] == "Y" && $arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0) {
     $db_vote = CVote::GetByID(intVal($arMessage["PARAM2"]));
     if ($db_vote && ($arVote = $db_vote->GetNext())) {
         $arResult['DATE_END'] = $arVote['DATE_END'];
     }
     $db_res = CVoteQuestion::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arParams["VOTE_CHANNEL_ID"], "VOTE_ID" => $arMessage["PARAM2"]));
     if ($db_res && ($res = $db_res->Fetch())) {
         do {
             $arResult["~QUESTIONS"][$res["ID"]] = $res;
             $arResult["~QUESTIONS"][$res["ID"]]["ANSWERS"] = array();
         } while ($res = $db_res->Fetch());
     }
     if (!empty($arResult["~QUESTIONS"])) {
         $db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"), array("VOTE_ID" => $arMessage["PARAM2"]));
         if ($db_res && ($res = $db_res->Fetch())) {
             do {
                 if (is_set($arResult["~QUESTIONS"], $res["QUESTION_ID"])) {
示例#22
0
 function Delete($ID)
 {
     global $DB;
     $ID = intVal($ID);
     $arTopic = CForumTopic::GetByID($ID);
     if (empty($arTopic)) {
         return false;
     }
     /***************** Event onBeforeTopicDelete ***********************/
     $events = GetModuleEvents("forum", "onBeforeTopicDelete");
     while ($arEvent = $events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID, $arTopic)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     $arAuthor = array();
     $arVotes = array();
     $db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $ID));
     while ($res = $db_res->Fetch()) {
         if (intVal($res["AUTHOR_ID"]) > 0) {
             $arAuthor[intVal($res["AUTHOR_ID"])] = $res["AUTHOR_ID"];
         }
         if ($res["PARAM1"] == "VT" && intVal($res["PARAM2"]) > 0) {
             $arVotes[] = intVal($res["PARAM2"]);
         }
     }
     if (!empty($arVotes) && IsModuleInstalled("vote") && CModule::IncludeModule("vote")) {
         foreach ($arVotes as $res) {
             CVote::Delete($res);
         }
     }
     //		$DB->StartTransaction();
     CForumFiles::Delete(array("TOPIC_ID" => $ID), array("DELETE_TOPIC_FILE" => "Y"));
     $DB->Query("DELETE FROM b_forum_subscribe WHERE TOPIC_ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_message WHERE TOPIC_ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_user_topic WHERE TOPIC_ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_topic WHERE ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_topic WHERE TOPIC_ID = " . $ID . "");
     $DB->Query("DELETE FROM b_forum_stat WHERE TOPIC_ID = " . $ID . "");
     //		$DB->Commit();
     unset($GLOBALS["FORUM_CACHE"]["TOPIC"][$ID]);
     unset($GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$ID]);
     foreach ($arAuthor as $key) {
         CForumUser::SetStat($key);
     }
     CForumNew::SetStat($arTopic["FORUM_ID"]);
     if (IsModuleInstalled("search") && CModule::IncludeModule("search")) {
         CSearch::DeleteIndex("forum", false, $arTopic["FORUM_ID"], $ID);
     }
     /***************** Event onAfterTopicDelete ************************/
     $events = GetModuleEvents("forum", "onAfterTopicDelete");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array(&$ID, $arTopic));
     }
     /***************** /Event ******************************************/
     return true;
 }
示例#23
0
 function GetPublicList($arFilter = array(), $strSqlOrder = "ORDER BY C.C_SORT, C.ID, V.DATE_START desc")
 {
     $err_mess = CVote::err_mess() . "<br>Function: GetPublicList<br>Line: ";
     global $DB, $USER;
     $arSqlSearch = array();
     $strSqlSearch = "";
     $arSqlSearch_1 = array();
     $strSqlSearch_1 = "";
     if (is_array($arFilter)) {
         $filter_keys = array_keys($arFilter);
         for ($i = 0; $i < count($filter_keys); $i++) {
             $key = $filter_keys[$i];
             $val = $arFilter[$filter_keys[$i]];
             if (strlen($val) <= 0 || $val == "NOT_REF") {
                 continue;
             }
             if (is_array($val) && count($val) <= 0) {
                 continue;
             }
             $match_value_set = in_array($key . "_EXACT_MATCH", $filter_keys) ? true : false;
             $key = strtoupper($key);
             switch ($key) {
                 case "SITE":
                     if (is_array($val)) {
                         $val = implode(" | ", $val);
                     }
                     $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $match_value_set ? "Y" : "N";
                     $arSqlSearch_1[] = GetFilterQuery("CS.SITE_ID", $val, $match);
                     $strSqlSearch_1 = GetFilterSqlSearch($arSqlSearch_1);
                     $where = " and exists (SELECT 'x' FROM b_vote_channel_2_site CS WHERE {$strSqlSearch_1} and C.ID = CS.CHANNEL_ID) ";
                     break;
                 case "CHANNEL":
                     $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $match_value_set ? "Y" : "N";
                     $arSqlSearch[] = GetFilterQuery("C.SYMBOLIC_NAME", $val, $match);
                     break;
                 case "FIRST_SITE_ID":
                 case "LID":
                     $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $match_value_set ? "Y" : "N";
                     $arSqlSearch[] = GetFilterQuery("C.FIRST_SITE_ID", $val, $match);
                     break;
             }
         }
     }
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $arGroups = $USER->GetUserGroupArray();
     if (!is_array($arGroups)) {
         $arGroups[] = 2;
     }
     $groups = implode(",", $arGroups);
     if (!$USER->IsAdmin()) {
         $strSql = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tC.TITLE CHANNEL_TITLE, \r\n\t\t\t\t\tV.ID, V.CHANNEL_ID, V.C_SORT, V.ACTIVE, V.COUNTER, V.TITLE, V.DESCRIPTION, V.DESCRIPTION_TYPE, V.IMAGE_ID, V.EVENT1, V.EVENT2, V.EVENT3, V.UNIQUE_TYPE, V.KEEP_IP_SEC, V.DELAY, V.DELAY_TYPE, V.TEMPLATE, V.RESULT_TEMPLATE, V.NOTIFY,\r\n\t\t\t\t\t" . $DB->DateToCharFunction("V.DATE_START") . "\t\tDATE_START,\r\n\t\t\t\t\t" . $DB->DateToCharFunction("V.DATE_END") . "\t\tDATE_END,\r\n\t\t\t\t\tmax(G.PERMISSION)\t\t\t\t\t\t\t\tMAX_PERMISSION,\r\n\t\t\t\t\tcase \r\n\t\t\t\t\t\twhen V.ACTIVE='N' or getdate() not between V.DATE_START and V.DATE_END then 'red'\r\n\t\t\t\t\t\telse 'green'\r\n\t\t\t\t\tend\t\t\t\t\t\t\t\t\t\t\t\tLAMP\r\n\t\t\t\tFROM\r\n\t\t\t\t\tb_vote V\r\n\t\t\t\tINNER JOIN b_vote_channel C ON (C.ID = V.CHANNEL_ID and C.ACTIVE = 'Y')\r\n\t\t\t\tINNER JOIN b_vote_channel_2_group G ON (G.CHANNEL_ID = C.ID and G.GROUP_ID in ({$groups}))\r\n\t\t\t\tWHERE\r\n\t\t\t\t\t{$strSqlSearch}\r\n\t\t\t\tand V.ACTIVE = 'Y'\r\n\t\t\t\tand V.DATE_START<=getdate()\t\t\t\t\t\r\n\t\t\t\t{$where}\r\n\t\t\t\tGROUP BY\r\n\t\t\t\t\tC.ID, C.TITLE, \r\n\t\t\t\t\tV.ID, V.CHANNEL_ID, V.C_SORT, V.ACTIVE, V.COUNTER, V.TITLE, V.DESCRIPTION, V.DESCRIPTION_TYPE, V.IMAGE_ID, V.EVENT1, V.EVENT2, V.EVENT3, V.UNIQUE_TYPE, V.KEEP_IP_SEC, V.DELAY, V.DELAY_TYPE, V.TEMPLATE, V.RESULT_TEMPLATE, V.NOTIFY,\r\n\t\t\t\t\tV.DATE_START, V.DATE_END, \r\n\t\t\t\t\tC.C_SORT, C.ID\r\n\t\t\t\tHAVING \r\n\t\t\t\t\tmax(G.PERMISSION)>0\r\n\t\t\t\t{$strSqlOrder}\r\n\t\t\t\t";
     } else {
         $strSql = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tC.TITLE CHANNEL_TITLE, \r\n\t\t\t\t\tV.ID, V.CHANNEL_ID, V.C_SORT, V.ACTIVE, V.COUNTER, V.TITLE, V.DESCRIPTION, V.DESCRIPTION_TYPE, V.IMAGE_ID, V.EVENT1, V.EVENT2, V.EVENT3, V.UNIQUE_TYPE, V.KEEP_IP_SEC, V.DELAY, V.DELAY_TYPE, V.TEMPLATE, V.RESULT_TEMPLATE, V.NOTIFY,\r\n\t\t\t\t\t" . $DB->DateToCharFunction("V.DATE_START") . "\t\tDATE_START,\r\n\t\t\t\t\t" . $DB->DateToCharFunction("V.DATE_END") . "\t\tDATE_END,\r\n\t\t\t\t\t2\t\t\t\t\t\t\t\t\t\t\t\tMAX_PERMISSION,\r\n\t\t\t\t\tcase \r\n\t\t\t\t\t\twhen V.ACTIVE='N' or getdate() not between V.DATE_START and V.DATE_END then 'red'\r\n\t\t\t\t\t\telse 'green'\r\n\t\t\t\t\tend\t\t\t\t\t\t\t\t\t\t\t\tLAMP\r\n\t\t\t\tFROM\r\n\t\t\t\t\tb_vote V\r\n\t\t\t\tINNER JOIN b_vote_channel C ON (C.ID = V.CHANNEL_ID and C.ACTIVE = 'Y')\r\n\t\t\t\tWHERE\r\n\t\t\t\t\t{$strSqlSearch}\r\n\t\t\t\tand V.ACTIVE = 'Y'\r\n\t\t\t\tand V.DATE_START<=getdate()\r\n\t\t\t\t{$where}\r\n\t\t\t\tGROUP BY\r\n\t\t\t\t\tC.ID, C.TITLE, \r\n\t\t\t\t\tV.ID, V.CHANNEL_ID, V.C_SORT, V.ACTIVE, V.COUNTER, V.TITLE, V.DESCRIPTION, V.DESCRIPTION_TYPE, V.IMAGE_ID, V.EVENT1, V.EVENT2, V.EVENT3, V.UNIQUE_TYPE, V.KEEP_IP_SEC, V.DELAY, V.DELAY_TYPE, V.TEMPLATE, V.RESULT_TEMPLATE, V.NOTIFY, \r\n\t\t\t\t\tV.DATE_START, V.DATE_END,\r\n\t\t\t\t\tC.C_SORT, C.ID\r\n\t\t\t\t{$strSqlOrder}\r\n\t\t\t\t";
     }
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     return $res;
 }
示例#24
0
文件: vote.php 项目: Satariall/izurit
 function GetPublicList($arFilter = array(), $strSqlOrder = "ORDER BY C.C_SORT, C.ID, V.DATE_START desc", $params = array())
 {
     global $DB, $USER;
     $err_mess = CVote::err_mess() . "<br>Function: GetPublicList<br>Line: ";
     $arSqlSearch = array();
     $arFilter = is_array($arFilter) ? $arFilter : array();
     $params = is_array($params) ? $params : array();
     $left_join = "";
     foreach ($arFilter as $key => $val) {
         if (empty($val) || is_string($val) && $val === "NOT_REF") {
             continue;
         }
         $key = strtoupper($key);
         switch ($key) {
             case "SITE":
                 $val = is_array($val) ? implode(" | ", $val) : $val;
                 $match = $arFilter[$key . "_EXACT_MATCH"] == "N" ? "Y" : "N";
                 $arSqlSearch[] = GetFilterQuery("CS.SITE_ID", $val, $match);
                 $left_join = "LEFT JOIN b_vote_channel_2_site CS ON (C.ID = CS.CHANNEL_ID)";
                 break;
             case "CHANNEL":
                 $match = $arFilter[$key . "_EXACT_MATCH"] == "N" ? "Y" : "N";
                 if (is_array($val)) {
                     $arr = array();
                     foreach ($val as $v) {
                         $v = trim($v);
                         if (!empty($v)) {
                             $arr[] = GetFilterQuery("C.SYMBOLIC_NAME", $v, $match);
                         }
                     }
                     if (!empty($arr)) {
                         $arSqlSearch[] = "((" . implode(") OR (", $arr) . "))";
                     }
                 } else {
                     $arSqlSearch[] = GetFilterQuery("C.SYMBOLIC_NAME", $val, $match);
                 }
                 break;
             case "FIRST_SITE_ID":
             case "LID":
                 $match = $arFilter[$key . "_EXACT_MATCH"] == "N" ? "Y" : "N";
                 $arSqlSearch[] = GetFilterQuery("C.FIRST_SITE_ID", $val, $match);
                 break;
         }
     }
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $is_admin = in_array(1, $USER->GetUserGroupArray());
     $groups = $USER->GetGroups();
     $iCnt = 0;
     if (array_key_exists("bDescPageNumbering", $params) && $params["nTopCount"] <= 0 || $params["bCount"] === true) {
         $strSql = "SELECT COUNT(V1.ID) CNT\n\t\t\t\tFROM (\n\t\t\t\t\tSELECT V.CHANNEL_ID, V.ID, " . ($is_admin ? "2" : "max(G.PERMISSION)") . " as MAX_PERMISSION\n\t\t\t\t\tFROM b_vote V\n\t\t\t\t\tINNER JOIN b_vote_channel C ON (C.ACTIVE = 'Y' AND C.HIDDEN = 'N' AND V.CHANNEL_ID = C.ID)\n\t\t\t\t\tLEFT JOIN b_vote_channel_2_group G ON (G.CHANNEL_ID = C.ID and G.GROUP_ID in ({$groups}))\n\t\t\t\t\t{$left_join}\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t{$strSqlSearch}\n\t\t\t\t\t\tAND V.ACTIVE = 'Y' AND V.DATE_START <= NOW()\n\t\t\t\t\tGROUP BY V.CHANNEL_ID, V.ID\n\t\t\t\t\t" . ($is_admin ? "" : "\n\t\t\t\t\tHAVING MAX_PERMISSION > 0") . "\n\t\t\t\t) V1";
         $db_res = $DB->Query($strSql, false, $err_mess . __LINE__);
         if ($db_res && ($res = $db_res->Fetch())) {
             $iCnt = intval($res["CNT"]);
         }
         if ($params["bCount"] === true) {
             return $iCnt;
         }
     }
     $strSql = "\n\t\t\tSELECT C.TITLE CHANNEL_TITLE, V.*,\n\t\t\t\t" . $DB->DateToCharFunction("V.DATE_START") . "\tDATE_START,\n\t\t\t\t" . $DB->DateToCharFunction("V.DATE_END") . "\tDATE_END, \n\t\t\t\tV4.MAX_PERMISSION, V4.LAMP\n\t\t\tFROM (\n\t\t\t\tSELECT V.CHANNEL_ID, V.ID,\n\t\t\t\t\t" . ($is_admin ? "2" : "max(G.PERMISSION)") . " as MAX_PERMISSION, \n\t\t\t\t\tIF((C.VOTE_SINGLE = 'Y'), \n\t\t\t\t\t\t(IF(V.ID = VV.ACTIVE_VOTE_ID, 'green', 'red')), \n\t\t\t\t\t\t(IF(V.ACTIVE = 'Y' AND V.DATE_START <= NOW() AND NOW() <= V.DATE_END, 'green', 'red'))) LAMP \n\t\t\t\tFROM b_vote V\n\t\t\t\tINNER JOIN b_vote_channel C ON (C.ACTIVE = 'Y' AND C.HIDDEN = 'N' AND V.CHANNEL_ID = C.ID)\n\t\t\t\tLEFT JOIN (\n\t\t\t\t\tSELECT VVV.CHANNEL_ID, MAX(VVV.ID) AS ACTIVE_VOTE_ID\n\t\t\t\t\tFROM b_vote VVV, b_vote_channel CCC\n\t\t\t\t\tWHERE VVV.CHANNEL_ID = CCC.ID AND CCC.VOTE_SINGLE='Y' AND VVV.ACTIVE = 'Y' \n\t\t\t\t\t\tAND NOW() >= VVV.DATE_START AND VVV.DATE_END >= NOW()\n\t\t\t\t\tGROUP BY VVV.CHANNEL_ID) VV ON (VV.CHANNEL_ID = V.CHANNEL_ID)\n\t\t\t\tLEFT JOIN b_vote_channel_2_group G ON (G.CHANNEL_ID = C.ID and G.GROUP_ID in ({$groups}))\n\t\t\t\t{$left_join}\n\t\t\t\tWHERE\n\t\t\t\t\t{$strSqlSearch}\n\t\t\t\t\tAND V.ACTIVE = 'Y' AND V.DATE_START <= NOW()\n\t\t\t\tGROUP BY V.CHANNEL_ID, V.ID\n\t\t\t\t" . ($is_admin ? "" : "\n\t\t\t\tHAVING MAX_PERMISSION > 0") . "\n\t\t\t) V4\n\t\t\tINNER JOIN b_vote V ON (V4.ID = V.ID)\n\t\t\tINNER JOIN b_vote_channel C ON (V4.CHANNEL_ID = C.ID) \n\t\t\t" . $DB->ForSql($strSqlOrder);
     if (array_key_exists("bDescPageNumbering", $params) && $params["nTopCount"] <= 0) {
         $db_res = new CDBResult();
         $db_res->NavQuery($strSql, $iCnt, $params);
     } else {
         if ($params["nTopCount"] > 0) {
             $strSql .= " LIMIT 0," . intval($params["nTopCount"]);
         }
         $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $db_res;
 }
示例#25
0
global $APPLICATION, $DB, $adminChain, $CACHE_MANAGER;
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/prolog.php";
$VOTE_RIGHT = $APPLICATION->GetGroupRight("vote");
if ($VOTE_RIGHT == "D") {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/include.php";
IncludeModuleLangFile(__FILE__);
define("HELP_FILE", "vote_list.php");
$sTableID = "tbl_vote_question";
$oSort = new CAdminSorting($sTableID, "ID", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);
$aMenu = array();
$VOTE_ID = intval($_REQUEST["VOTE_ID"]);
$z = CVote::GetByID($VOTE_ID);
if (!($arVote = $z->Fetch())) {
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
    echo "<a href='vote_list.php?lang=" . LANGUAGE_ID . "' class='navchain'>" . GetMessage("VOTE_VOTE_LIST") . "</a>";
    echo ShowError(GetMessage("VOTE_NOT_FOUND"));
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
    die;
}
$t = CVoteChannel::GetByID($arVote["CHANNEL_ID"]);
$arChannel = $t->Fetch();
$adminChain->AddItem(array("TEXT" => htmlspecialcharsbx($arChannel["TITLE"]), "LINK" => "vote_channel_edit.php?ID={$arChannel['ID']}&lang=" . LANGUAGE_ID));
$adminChain->AddItem(array("TEXT" => strlen($arVote["TITLE"]) > 0 ? htmlspecialcharsbx($arVote["TITLE"]) : TruncateText($arVote["DESCRIPTION_TYPE"] == "html" ? strip_tags($arVote["DESCRIPTION"]) : htmlspecialcharsbx($arVote["DESCRIPTION"]), 200), "LINK" => "vote_edit.php?ID={$arVote['ID']}&lang=" . LANGUAGE_ID));
$arFilterFields = array("find_id", "find_id_exact_match", "find_active", "find_diagram", "find_required", "find_question", "find_question_exact_match");
$lAdmin->InitFilter($arFilterFields);
/********************************************************************
				Actions
示例#26
0
 function GetAdminListViewHTML($arUserField, $arHtmlControl)
 {
     $return = '&nbsp;';
     $return_url = $GLOBALS["APPLICATION"]->GetCurPageParam("", array("admin_history", "mode", "table_id"));
     if ($arHtmlControl["VALUE"] > 0) {
         $db_res = CVote::GetByIDEx($arHtmlControl["VALUE"]);
         if ($db_res && ($arVote = $db_res->GetNext())) {
             if ($arVote["LAMP"] == "yellow") {
                 $arVote["LAMP"] = $arVote["ID"] == CVote::GetActiveVoteId($arVote["CHANNEL_ID"]) ? "green" : "red";
             }
             $return = "<div class=\"lamp-red\" title=\"" . ($arVote["ACTIVE"] != 'Y' ? GetMessage("VOTE_NOT_ACTIVE") : GetMessage("VOTE_ACTIVE_RED_LAMP")) . "\"  style=\"display:inline-block;\"></div>";
             if ($arVote["LAMP"] == "green") {
                 $return = "<div class=\"lamp-green\" title=\"" . GetMessage("VOTE_LAMP_ACTIVE") . "\" style=\"display:inline-block;\"></div>";
             }
             $return .= " [<a href='vote_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $arVote["ID"] . "&return_url=" . urlencode($return_url) . "' title='" . GetMessage("VOTE_EDIT_TITLE") . "'>" . $arVote["ID"] . "</a>] ";
             $return .= $arVote["TITLE"] . (!empty($arVote["DESCRIPTION"]) ? " <i>(" . $arVote["DESCRIPTION"] . ")</i>" : "");
             if ($arVote["COUNTER"] > 0) {
                 $return .= GetMessage("VOTE_VOTES") . " <a href=\"vote_user_votes.php?lang=" . LANGUAGE_ID . "&find_vote_id=" . $arVote["ID"] . "&find_valid=Y&set_filter=Y\">" . $arVote["COUNTER"] . "</a>";
             }
         }
     }
     return $return;
 }
示例#27
0
function VoteVoteEditFromArray($CHANNEL_ID, $VOTE_ID = false, $arFields = array(), $params = array())
{
    $CHANNEL_ID = intVal($CHANNEL_ID);
    if ($CHANNEL_ID <= 0 || empty($arFields)) {
        return false;
    } elseif (CVote::UserGroupPermission($CHANNEL_ID) <= 0) {
        return false;
    }
    $aMsg = array();
    $params = is_array($params) ? $params : array();
    $params["UNIQUE_TYPE"] = is_set($params, "UNIQUE_TYPE") ? intVal($params["UNIQUE_TYPE"]) : 20;
    $params["DELAY"] = is_set($params, "DELAY") ? intVal($params["DELAY"]) : 10;
    $params["DELAY_TYPE"] = is_set($params, "DELAY_TYPE") && in_array($params['DELAY_TYPE'], array("S", "M", "H", "D")) ? $params["DELAY_TYPE"] : "D";
    $arVote = array();
    $arQuestions = array();
    $arFieldsQuestions = array();
    $arFieldsVote = array("CHANNEL_ID" => $CHANNEL_ID, "AUTHOR_ID" => $GLOBALS["USER"]->GetID(), "UNIQUE_TYPE" => $params["UNIQUE_TYPE"], "DELAY" => $params["DELAY"], "DESCRIPTION_TYPE" => $params["DELAY_TYPE"]);
    if (!empty($arFields["DATE_START"])) {
        $arFieldsVote["DATE_START"] = $arFields["DATE_START"];
    }
    if (!empty($arFields["DATE_END"])) {
        $arFieldsVote["DATE_END"] = $arFields["DATE_END"];
    }
    if (!empty($arFields["TITLE"])) {
        $arFieldsVote["TITLE"] = $arFields["TITLE"];
    }
    if (isset($arFields["ACTIVE"])) {
        $arFieldsVote["ACTIVE"] = $arFields["ACTIVE"];
    }
    if (isset($arFields["NOTIFY"])) {
        $arFieldsVote["NOTIFY"] = $arFields["NOTIFY"];
    }
    if (isset($arFields["URL"])) {
        $arFieldsVote["URL"] = $arFields["URL"];
    }
    /************** Fatal errors ***************************************/
    if (!CVote::CheckFields("UPDATE", $arFieldsVote)) {
        $e = $GLOBALS['APPLICATION']->GetException();
        $aMsg[] = array("id" => "VOTE_ID", "text" => $e->GetString());
    } elseif (intval($VOTE_ID) > 0) {
        $db_res = CVote::GetByID($VOTE_ID);
        if (!($db_res && ($res = $db_res->Fetch()))) {
            $aMsg[] = array("id" => "VOTE_ID", "text" => GetMessage("VOTE_VOTE_NOT_FOUND", array("#ID#", $VOTE_ID)));
        } elseif ($res["CHANNEL_ID"] != $CHANNEL_ID) {
            $aMsg[] = array("id" => "CHANNEL_ID", "text" => GetMessage("VOTE_CHANNEL_ID_ERR"));
        } else {
            $arVote = $res;
            $db_res = CVoteQuestion::GetList($arVote["ID"], $by = "s_id", $order = "asc", array(), $is_filtered);
            if ($db_res && ($res = $db_res->Fetch())) {
                do {
                    $arQuestions[$res["ID"]] = $res + array("ANSWERS" => array());
                } while ($res = $db_res->Fetch());
            }
            $db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"), array("VOTE_ID" => $arVote["ID"]));
            if ($db_res && ($res = $db_res->Fetch())) {
                do {
                    $arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res;
                } while ($res = $db_res->Fetch());
            }
        }
    }
    if (!empty($aMsg)) {
        $e = new CAdminException(array_reverse($aMsg));
        $GLOBALS["APPLICATION"]->ThrowException($e);
        return false;
    }
    /************** Fatal errors/***************************************/
    if (!empty($arFieldsVote["TITLE"]) && !empty($arVote["TITLE"])) {
        $q = reset($arQuestions);
        if ($arVote["TITLE"] == substr($q["QUESTION"], 0, strlen($arVote["TITLE"]))) {
            unset($arFieldsVote["TITLE"]);
        }
    }
    /************** Check Data *****************************************/
    // Questions
    $arFields["QUESTIONS"] = is_array($arFields["QUESTIONS"]) ? $arFields["QUESTIONS"] : array();
    $iQuestions = 0;
    foreach ($arFields["QUESTIONS"] as $key => $arQuestion) {
        if ($arQuestion["DEL"] != "Y") {
            $arQuestion["ID"] = intval($arQuestion["ID"]);
            $arQuestion = array("ID" => $arQuestion["ID"] > 0 && is_set($arQuestions, $arQuestion["ID"]) ? $arQuestion["ID"] : false, "QUESTION" => trim($arQuestion["QUESTION"]), "ANSWERS" => is_array($arQuestion["ANSWERS"]) ? $arQuestion["ANSWERS"] : array());
            $arAnswers = $arQuestion["ID"] > 0 ? $arQuestions[$arQuestion["ID"]]["ANSWERS"] : array();
            foreach ($arQuestion["ANSWERS"] as $keya => $arAnswer) {
                $arAnswer["ID"] = intVal($arAnswer["ID"]);
                $arAnswer["MESSAGE"] = trim($arAnswer["MESSAGE"]);
                if (!empty($arAnswer["MESSAGE"]) && $arAnswer["DEL"] != "Y") {
                    $arQuestion["ANSWERS"][$keya] = array("MESSAGE" => $arAnswer["MESSAGE"], "FIELD_TYPE" => $arAnswer["FIELD_TYPE"]);
                    if ($arAnswer["ID"] > 0 && is_set($arAnswers, $arAnswer["ID"])) {
                        $arQuestion["ANSWERS"][$keya]["ID"] = $arAnswer["ID"];
                        unset($arAnswers[$arAnswer["ID"]]);
                    }
                }
            }
        }
        if ($arQuestion["DEL"] == "Y" || empty($arQuestion["QUESTION"]) || empty($arQuestion["ANSWERS"])) {
            if ($arQuestion["DEL"] != "Y" && !(empty($arQuestion["QUESTION"]) && empty($arQuestion["ANSWERS"]))) {
                $aMsg[] = array("id" => "QUESTION_" . $key, "text" => empty($arQuestion["QUESTION"]) ? GetMessage("VOTE_QUESTION_EMPTY", array("#NUMBER#" => $key)) : GetMessage("VOTE_ANSWERS_EMPTY", array("#QUESTION#" => $arQuestion["QUESTION"])));
            }
            continue;
        }
        if ($arQuestion["ID"] > 0) {
            unset($arQuestions[$arQuestion["ID"]]);
            foreach ($arAnswers as $arAnswer) {
                $arQuestion["ANSWERS"][] = $arAnswer + array("DEL" => "Y");
            }
        }
        $iQuestions++;
        $arFieldsQuestions[$key] = $arQuestion;
    }
    foreach ($arQuestions as $arQuestion) {
        $arFieldsQuestions[] = $arQuestion + array("DEL" => "Y");
    }
    if (!empty($aMsg)) {
        $e = new CAdminException(array_reverse($aMsg));
        $GLOBALS["APPLICATION"]->ThrowException($e);
        return false;
    } elseif (empty($arFieldsQuestions) && $VOTE_ID <= 0) {
        return true;
    } elseif ($params["bOnlyCheck"] == "Y") {
        return true;
    }
    /************** Check Data/*****************************************/
    /************** Main actions with return ***************************/
    if (empty($arFieldsVote["TITLE"])) {
        $q = reset($arFieldsQuestions);
        $arFieldsVote["TITLE"] = null;
        do {
            if ($q["DEL"] != "Y") {
                $arFieldsVote["TITLE"] = $q["QUESTION"];
                break;
            }
        } while ($q = next($arFieldsQuestions));
        reset($arFieldsQuestions);
    }
    if (empty($arVote)) {
        $arFieldsVote["UNIQUE_TYPE"] = $params["UNIQUE_TYPE"];
        $arFieldsVote["DELAY"] = $params["DELAY"];
        $arFieldsVote["DELAY_TYPE"] = $params["DELAY_TYPE"];
        $arVote["ID"] = intval(CVote::Add($arFieldsVote));
    } else {
        CVote::Update($VOTE_ID, $arFieldsVote);
    }
    if ($iQuestions > 0 && $arVote["ID"] > 0) {
        $iQuestions = 0;
        foreach ($arFieldsQuestions as $arQuestion) {
            if ($arQuestion["DEL"] == "Y") {
                CVoteQuestion::Delete($arQuestion["ID"]);
                continue;
            } elseif ($arQuestion["ID"] > 0) {
                $arQuestion["C_SORT"] = ($iQuestions + 1) * 10;
                CVoteQuestion::Update($arQuestion["ID"], $arQuestion);
            } else {
                $arQuestion["C_SORT"] = ($iQuestions + 1) * 10;
                $arQuestion["VOTE_ID"] = $arVote["ID"];
                $arQuestion["ID"] = intVal(CVoteQuestion::Add($arQuestion));
                if ($arQuestion["ID"] <= 0) {
                    continue;
                }
            }
            $iQuestions++;
            $iAnswers = 0;
            foreach ($arQuestion["ANSWERS"] as $arAnswer) {
                if ($arAnswer["DEL"] == "Y") {
                    CVoteAnswer::Delete($arAnswer["ID"]);
                    continue;
                }
                if ($arAnswer["ID"] > 0) {
                    $arAnswer["C_SORT"] = $iAnswers * 10;
                    CVoteAnswer::Update($arAnswer["ID"], $arAnswer);
                } else {
                    $arAnswer["QUESTION_ID"] = $arQuestion["ID"];
                    $arAnswer["C_SORT"] = ($iAnswers + 1) * 10;
                    $arAnswer["ID"] = intVal(CVoteAnswer::Add($arAnswer));
                    if ($arAnswer["ID"] <= 0) {
                        continue;
                    }
                }
                $iAnswers++;
            }
            if ($iAnswers <= 0) {
                CVoteQuestion::Delete($arQuestion["ID"]);
                $iQuestions--;
            }
        }
    }
    if (intVal($arVote["ID"]) <= 0) {
        return false;
    } elseif ($iQuestions <= 0) {
        CVote::Delete($arVote["ID"]);
        return 0;
    }
    return $arVote["ID"];
    /************** Actions/********************************************/
    /*	$arFields = array(
    		"ID" => 345, 
    		"TITLE" => "test", 
    		"...", 
    		"QUESTIONS" => array(
    			array(
    				"ID" => 348, 
    				"QUESTION" => "test", 
    				"ANSWERS" => array(
    					array(
    						"ID" => 340, 
    						"MESSAGE" => "test"), 
    					array(
    						"ID" => 0, 
    						"MESSAGE" => "test"), 
    					array(
    						"ID" => 350,
    						"DEL" => "Y",  
    						"MESSAGE" => "test")
    					)
    				), 
    			array(
    				"ID" => 351, 
    				"DEL" => "Y", 
    				"QUESTION" => "test", 
    				"ANSWERS" => array(
    					array(
    						"ID" => 0, 
    						"MESSAGE" => "test"), 
    					array(
    						"ID" => 478,
    						"DEL" => "Y",  
    						"MESSAGE" => "test")
    					)
    				), 
    			array(
    				"ID" => 0, 
    				"QUESTION" => "test", 
    				"ANSWERS" => array(
    					array(
    						"ID" => 0, 
    						"MESSAGE" => "test"), 
    					)
    				), 
    			)
    		);
    */
}
示例#28
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("vote")) {
    return;
}
$arrChannels = array();
$arrVotes = array();
$rs = CVoteChannel::GetList($v1, $v2, array(), $v3);
while ($arChannel = $rs->Fetch()) {
    $arrChannels[$arChannel["SID"]] = "[" . $arChannel["SID"] . "] " . $arChannel["TITLE"];
    $rsVotes = CVote::GetList($v1, $v2, array("CHANNEL_ID" => $arChannel["ID"]), $v3);
    while ($arVote = $rsVotes->Fetch()) {
        $arrVotes[$arVote["ID"]] = "[" . $arVote["ID"] . "] (" . $arChannel["SID"] . ") " . TruncateText($arVote["TITLE"], 40);
    }
}
$arComponentParameters = array("PARAMETERS" => array("VOTE_ID" => array("NAME" => GetMessage("VOTE_POLL_ID"), "TYPE" => "LIST", "PARENT" => "BASE", "VALUES" => $arrVotes, "DEFAULT" => '={$_REQUEST["VOTE_ID"]}', "MULTIPLE" => "N", "ADDITIONAL_VALUES" => "Y"), "VOTE_RESULT_TEMPLATE" => array("NAME" => GetMessage("VOTE_RESULT_PAGE"), "TYPE" => "STRING", "PARENT" => "URL_TEMPLATES", "COLS" => 45, "DEFAULT" => "vote_result.php?VOTE_ID=#VOTE_ID#"), "CACHE_TIME" => array("DEFAULT" => 3600)));
示例#29
0
	function CheckFields($arUserField, $value)
	{
		if (!($arUserField && is_array($arUserField["USER_TYPE"]) &&
			$arUserField["USER_TYPE"]["CLASS_NAME"] == __CLASS__))
			return true;
		$arData = (isset($GLOBALS[$arUserField["FIELD_NAME"]."_DATA"]) ? $GLOBALS[$arUserField["FIELD_NAME"]."_DATA"] : false);
		$aMsg = array();

		if (!empty($arData) && CModule::IncludeModule("vote"))
		{
			$arVote = array(
				"ID" => $value,
				"CHANNEL_ID" => $arUserField["SETTINGS"]["CHANNEL_ID"],
				"TITLE" => $arData["TITLE"],
				"URL" => $arData["URL"],
				"NOTIFY" => $arUserField["SETTINGS"]["NOTIFY"],
				"DATE_END" => GetTime((isset($arData["DATE_END"]) ? MakeTimeStamp($arData["DATE_END"]) : 1924984799), "FULL"),
				"QUESTIONS" => array());

			$arVoteQuestions = array();
			$arQuestions = is_array($arData["QUESTIONS"]) ? $arData["QUESTIONS"] : array();

			if (!$arVote["ID"]) {
				$arVote["DATE_START"] = GetTime(CVote::GetNowTime(), "FULL");
			} else {
				$db_res = CVoteQuestion::GetListEx(array("ID" => "ASC"),
					array("CHANNEL_ID" => $arVote["CHANNEL_ID"], "VOTE_ID" => $arVote["ID"]));
				if ($db_res && $res = $db_res->Fetch()) {
					do {
						$arVoteQuestions[$res["ID"]] = $res + array("ANSWERS" => array());
					} while ($res = $db_res->Fetch());
				}
				if (!empty($arVoteQuestions)) {
					$db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"),
						array("CHANNEL_ID" => $arVote["CHANNEL_ID"], "VOTE_ID" => $arVote["ID"]));
					if ($db_res && $res = $db_res->Fetch()) {
						do {
							if (is_set($arVoteQuestions, $res["QUESTION_ID"]))
								$arVoteQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res;
						} while ($res = $db_res->Fetch());
					}
				}
			}

			foreach ($arQuestions as $key => $arQuestion)
			{
				$res = array(
					"ID" => (array_key_exists($arQuestion["ID"], $arVoteQuestions) ? $arQuestion["ID"] : false),
					"QUESTION" => trim($arQuestion["QUESTION"]),
					"MULTI" => ($arQuestion["MULTI"] == "Y" ? "Y" : "N"),
					"ANSWERS" => array());

				$arQuestion["ANSWERS"] = (is_array($arQuestion["ANSWERS"]) ?
					$arQuestion["ANSWERS"] : array());

				$arVoteAnswers = ($res["ID"] > 0 ? $arVoteQuestions[$res["ID"]]["ANSWERS"] : array());
				foreach ($arQuestion["ANSWERS"] as $arAnswer)
				{

					$resa = array(
						"ID" => (array_key_exists($arAnswer["ID"], $arVoteAnswers) ? $arAnswer["ID"] : false),
						"MESSAGE" => trim($arAnswer["MESSAGE"]),
						"FIELD_TYPE" => ($res["MULTI"] == "Y" ? 1 : 0));

					if (empty($resa["MESSAGE"])){ continue; }
					if (!!$resa["ID"]) { unset($arVoteAnswers[$resa["ID"]]); }

					$res["ANSWERS"][] = $resa;
				}
				foreach ($arVoteAnswers as $arAnswer) {
					$res["ANSWERS"][] = array_merge($arAnswer, array("DEL" => "Y")); }

				if (empty($res["ANSWERS"]) && empty($res["QUESTION"]) && !$res["ID"]) { continue; }
				if (!!$res["ID"]) { unset($arVoteQuestions[$res["ID"]]); }

				$arVote["QUESTIONS"][] = $res;
			}

			$arVoteParams = array();
			if (!empty($arVote["QUESTIONS"]))
			{
				$arVoteParams = array(
					"UNIQUE_TYPE" => $arUserField["SETTINGS"]['UNIQUE'],
					"DELAY" => intval($arUserField["SETTINGS"]['UNIQUE_IP_DELAY']["DELAY"]),
					"DELAY_TYPE" => $arUserField["SETTINGS"]['UNIQUE_IP_DELAY']["DELAY_TYPE"]);
			}

			if (!VoteVoteEditFromArray($arUserField["SETTINGS"]["CHANNEL_ID"], $arVote["ID"],
				$arVote, ($res = ($arVoteParams + array("bOnlyCheck" => "Y")))))
			{
				$aMsg[] = array(
					"id" => $arUserField["FIELD_NAME"],
					"text" => (($e = $GLOBALS['APPLICATION']->GetException()) && $e ? preg_replace("/\<br(.*?)\>/", " ", $e->GetString()) : GetMessage("VT_UNKNOWN_ERROR_ADD_VOTE"))
				);
			}
			else
			{
				$GLOBALS[__CLASS__.$arUserField["ENTITY_VALUE_ID"]] = array("VOTE" => $arVote, "PARAMS" => $arVoteParams);
			}
		}
		return $aMsg;
	}
示例#30
0
    	{
    		$channels[] = Array(
    			"text" => $__arChannel["TITLE"],
    			"url" => "vote_list.php?lang=".LANGUAGE_ID."&find_channel_id=".$__arChannel["ID"]."&set_filter=Y",
    			"more_url" => Array(),
    			"title" => GetMessage("VOTE_GROUP_LST").$__arChannel["TITLE"]
    		);
    	}
    */
    CModule::IncludeModule('vote');
    $menuResults = array();
    if (method_exists($this, "IsSectionActive") && $this->IsSectionActive("menu_vote_channels") || defined('BX_ADMIN_FORM_MENU_OPEN') && BX_ADMIN_FORM_MENU_OPEN == 1) {
        $by = "s_c_sort";
        $order = "asc";
        $rChannels = CVoteChannel::GetList($by, $order, $arFilter, $is_filtered);
        while ($arChannel = $rChannels->Fetch()) {
            if (intval($arChannel["VOTES"]) > 0) {
                $menuChannel = array("text" => htmlspecialcharsEx($arChannel["TITLE"]), "url" => "vote_user_votes_table.php?lang=" . LANGUAGE_ID . "&CHANNEL_ID=" . $arChannel['ID'], "module_id" => "vote", "page_icon" => "vote_page_icon", "items_id" => "vote_channel_" . $arChannel["ID"], "items" => array());
                $obVote = CVote::GetList($by, $order, array("CHANNEL_ID" => $arChannel["ID"]), $is_filtered);
                while ($arVote = $obVote->GetNext()) {
                    $menuVote = array("items_id" => "vote_channel_" . $arChannel["ID"], "text" => $arVote["TITLE"], "title" => GetMessage("VOTE_MENU_POLL_DESCRIPTION") . '\'' . htmlspecialcharsEx($arVote["TITLE"]) . '\'', "module_id" => "vote", "url" => "vote_user_votes_table.php?lang=" . LANGUAGE_ID . "&VOTE_ID=" . $arVote['ID']);
                    $menuChannel["items"][] = $menuVote;
                }
                $menuResults[] = $menuChannel;
            }
        }
    }
    $aMenu = array("parent_menu" => "global_menu_services", "section" => "vote", "sort" => 100, "module_id" => "vote", "text" => GetMessage("VOTE_MENU_MAIN"), "title" => GetMessage("VOTE_MENU_MAIN_TITLE"), "icon" => "vote_menu_icon", "page_icon" => "vote_page_icon", "items_id" => "menu_vote", "items" => array(array("text" => GetMessage("VOTE_MENU_CHANNEL"), "url" => "vote_channel_list.php?lang=" . LANGUAGE_ID, "title" => GetMessage("VOTE_MENU_CHANNEL_ALT"), "more_url" => array("vote_channel_edit.php")), array("text" => GetMessage("VOTE_MENU_VOTE"), "url" => "vote_list.php?lang=" . LANGUAGE_ID, "more_url" => array("vote_edit.php", "vote_question_list.php", "vote_question_edit.php", "vote_results.php", "vote_preview.php"), "title" => GetMessage("VOTE_MENU_VOTE_ALT")), array("text" => GetMessage("VOTE_MENU_USER"), "url" => "vote_user_list.php?lang=" . LANGUAGE_ID, "more_url" => array(), "title" => GetMessage("VOTE_MENU_USER_ALT")), array("text" => GetMessage("VOTE_MENU_RESULT"), "items_id" => "menu_vote_channels", "module_id" => "vote", "url" => "vote_user_votes.php?lang=" . LANGUAGE_ID, "dynamic" => true, "more_url" => array("vote_user_results.php", "vote_user_results_table.php"), "title" => GetMessage("VOTE_MENU_RESULT_ALT"), "items" => $menuResults)));
    return $aMenu;
}
return false;