本文整理汇总了PHP中CVote::CheckFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CVote::CheckFields方法的具体用法?PHP CVote::CheckFields怎么用?PHP CVote::CheckFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVote
的用法示例。
在下文中一共展示了CVote::CheckFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: VoteVoteEditFromArray
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;
}
//.........这里部分代码省略.........
示例2: array
} else {
$arIMAGE_ID = array();
}
$arIMAGE_ID["del"] = ${"IMAGE_ID_del"};
$arIMAGE_ID["description"] = ${"IMAGE_ID_descr"};
$uniqSession = isset($_REQUEST['UNIQUE_TYPE_SESSION']) ? intval($_REQUEST['UNIQUE_TYPE_SESSION']) : 0;
$uniqCookie = isset($_REQUEST['UNIQUE_TYPE_COOKIE']) ? intval($_REQUEST['UNIQUE_TYPE_COOKIE']) : 0;
$uniqIP = isset($_REQUEST['UNIQUE_TYPE_IP']) ? intval($_REQUEST['UNIQUE_TYPE_IP']) : 0;
$uniqID = isset($_REQUEST['UNIQUE_TYPE_USER_ID']) ? intval($_REQUEST['UNIQUE_TYPE_USER_ID']) : 0;
$uniqIDNew = isset($_REQUEST['UNIQUE_TYPE_USER_ID_NEW']) ? intval($_REQUEST['UNIQUE_TYPE_USER_ID_NEW']) : 0;
$uniqType = $uniqSession | $uniqCookie | $uniqIP | $uniqID | $uniqIDNew;
$uniqType += 5;
$arFields = array("CHANNEL_ID" => $_REQUEST["CHANNEL_ID"], "C_SORT" => intVal($_REQUEST["C_SORT"]), "ACTIVE" => $_REQUEST["ACTIVE"] == "Y" ? "Y" : "N", "DATE_START" => $_REQUEST["DATE_START"], "DATE_END" => $_REQUEST["DATE_END"], "TITLE" => $_REQUEST["TITLE"], "DESCRIPTION" => $_REQUEST["DESCRIPTION"], "DESCRIPTION_TYPE" => $_REQUEST["DESCRIPTION_TYPE"], "IMAGE_ID" => $arIMAGE_ID, "EVENT1" => $_REQUEST["EVENT1"], "EVENT2" => $_REQUEST["EVENT2"], "EVENT3" => $_REQUEST["EVENT3"], "UNIQUE_TYPE" => $uniqType, "DELAY" => $_REQUEST["DELAY"], "DELAY_TYPE" => $_REQUEST["DELAY_TYPE"], "TEMPLATE" => $_REQUEST["TEMPLATE"], "RESULT_TEMPLATE" => $_REQUEST["RESULT_TEMPLATE"], "NOTIFY" => $_REQUEST["NOTIFY"], "URL" => $_REQUEST["URL"]);
$result = false;
$arFields["IMAGE_ID"]["del"] = $_POST["IMAGE_ID_del"];
if (!CVote::CheckFields($ID > 0 ? "UPDATE" : "ADD", $arFields, $ID, array("CHECK_INTERSECTION" => "Y"))) {
} elseif ($ID <= 0) {
$arFields["AUTHOR_ID"] = $GLOBALS["USER"]->GetId();
$result = $ID = CVote::Add($arFields);
} else {
$result = CVote::Update($ID, $arFields);
}
if (!$result) {
$e = $APPLICATION->GetException();
$message = new CAdminMessage(GetMessage("VOTE_GOT_ERROR"), $e);
$bVarsFromForm = true;
} else {
if (isset($_REQUEST['COPYID']) && ($oldID = intval($_REQUEST['COPYID'])) > 0 && ($rCurrentVote = CVote::GetByID($oldID)) && ($arCurrentVote = $rCurrentVote->Fetch())) {
global $DB;
$newImageId = false;
if (intval($arCurrentVote['IMAGE_ID']) > 0 && empty($arIMAGE_ID['name']) && $arIMAGE_ID['del'] != 'Y') {
示例3: Update
public static function Update($ID, $arFields, $strUploadDir = false)
{
global $DB;
$arBinds = array();
$strUploadDir = $strUploadDir === false ? "vote" : $strUploadDir;
$ID = intVal($ID);
if ($ID <= 0 || !CVote::CheckFields("UPDATE", $arFields, $ID)) {
return false;
}
/***************** Event onBeforeVoteUpdate ************************/
foreach (GetModuleEvents("vote", "onBeforeVoteUpdate", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields)) === false) {
return false;
}
}
/***************** /Event ******************************************/
if (empty($arFields)) {
return false;
}
$arFields["~TIMESTAMP_X"] = $DB->GetNowFunction();
if (is_set($arFields, "DESCRIPTION")) {
$arBinds["DESCRIPTION"] = $arFields["DESCRIPTION"];
}
if (array_key_exists("IMAGE_ID", $arFields) && is_array($arFields["IMAGE_ID"]) && (!array_key_exists("MODULE_ID", $arFields["IMAGE_ID"]) || strlen($arFields["IMAGE_ID"]["MODULE_ID"]) <= 0)) {
$arFields["IMAGE_ID"]["MODULE_ID"] = "vote";
}
CFile::SaveForDB($arFields, "IMAGE_ID", $strUploadDir);
$strUpdate = $DB->PrepareUpdateBind("b_vote", $arFields, $strUploadDir, false, $arBinds);
if (!empty($strUpdate)) {
$strSql = "UPDATE b_vote SET " . $strUpdate . " WHERE ID=" . $ID;
$DB->QueryBind($strSql, $arBinds);
}
/***************** Event onAfterVoteUpdate *************************/
foreach (GetModuleEvents("vote", "onAfterVoteUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
/***************** /Event ******************************************/
return $ID;
}
示例4: InitBVar
}
InitBVar($find_id_exact_match);
InitBVar($find_channel_exact_match);
InitBVar($find_title_exact_match);
InitBVar($find_description_exact_match);
if (CheckFilter()) {
$arFilter = array("ID" => $find_id, "ID_EXACT_MATCH" => $find_id_exact_match, "ACTIVE" => $find_active, "DATE_START_1" => $find_date_start_1, "DATE_START_2" => $find_date_start_2, "DATE_END_1" => $find_date_end_1, "DATE_END_2" => $find_date_end_2, "LAMP" => $find_lamp, "CHANNEL_ID" => $find_channel_id, "CHANNEL" => $find_channel, "CHANNEL_EXACT_MATCH" => $find_channel_exact_match, "TITLE" => $find_title, "TITLE_EXACT_MATCH" => $find_title_exact_match, "DESCRIPTION" => $find_description, "DESCRIPTION_EXACT_MATCH" => $find_description_exact_match, "COUNTER_1" => $find_counter_1, "COUNTER_2" => $find_counter_2);
}
if ($lAdmin->EditAction() && $VOTE_RIGHT >= "W" && check_bitrix_sessid()) {
foreach ($FIELDS as $ID => $arFields) {
if (!$lAdmin->IsUpdated($ID)) {
continue;
}
$ID = intVal($ID);
$arFieldsStore = array("ACTIVE" => $arFields['ACTIVE'], "C_SORT" => $arFields['C_SORT'], "TITLE" => $arFields['TITLE'], "CHANNEL_ID" => $arFields['CHANNEL_ID']);
if (!CVote::CheckFields("UPDATE", $arFieldsStore, $ID, array("CHECK_INTERSECTION" => "Y"))) {
$err = $GLOBALS['APPLICATION']->GetException();
$lAdmin->AddUpdateError($ID . ": " . $err->GetString(), $ID);
} elseif (!CVote::Update($ID, $arFieldsStore)) {
$lAdmin->AddUpdateError($ID . ": " . GetMessage("VOTE_SAVE_ERROR"), $ID);
}
}
}
// Group actions
if (($arID = $lAdmin->GroupAction()) && $VOTE_RIGHT >= "W" && check_bitrix_sessid()) {
if ($_REQUEST['action_target'] == 'selected') {
$arID = array();
$rsData = CVote::GetList($by, $order, $arFilter, $is_filtered);
while ($arRes = $rsData->Fetch()) {
$arID[] = $arRes['ID'];
}