本文整理汇总了PHP中CForm::GetDataByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CForm::GetDataByID方法的具体用法?PHP CForm::GetDataByID怎么用?PHP CForm::GetDataByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForm
的用法示例。
在下文中一共展示了CForm::GetDataByID方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Show
function Show($WEB_FORM_VARNAME, $arrVALUES=false, $SHOW_TEMPLATE=false, $PREVIEW="N")
{
global $DB, $MESS, $APPLICATION, $USER, $_REQUEST, $HTTP_POST_VARS, $HTTP_GET_VARS, $arrFIELDS;
$err_mess = (CAllForm::err_mess())."<br>Function: Show<br>Line: ";
if ($arrVALUES===false) $arrVALUES = $_REQUEST;
$z = CForm::GetBySID($WEB_FORM_VARNAME);
$zr = $z->Fetch();
$WEB_FORM_ID = $FORM_ID = intval($zr["ID"]);
$WEB_FORM_ID = CForm::GetDataByID($WEB_FORM_ID, $arForm, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect);
if (intval($WEB_FORM_ID)>0)
{
$F_RIGHT = CForm::GetPermission($WEB_FORM_ID);
if (intval($F_RIGHT)>=10)
{
if (strlen(trim($SHOW_TEMPLATE))>0) $template = $SHOW_TEMPLATE;
else
{
if (strlen(trim($arForm["SHOW_TEMPLATE"]))<=0) $template = "default.php";
else $template = $arForm["SHOW_TEMPLATE"];
}
$path = COption::GetOptionString("form","SHOW_TEMPLATE_PATH");
IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/form/include.php");
include(GetLangFileName($_SERVER["DOCUMENT_ROOT"].$path."lang/", "/".$template));
if ($APPLICATION->GetShowIncludeAreas())
{
$arIcons = Array();
if (CModule::IncludeModule("fileman"))
{
$arIcons[] =
Array(
"URL" => "/freetrix/admin/fileman_file_edit.php?lang=".LANGUAGE_ID."&site=".SITE_ID."&full_src=Y&path=". urlencode($path.$template),
"SRC" => "/freetrix/images/form/panel/edit_template.gif",
"ALT" => GetMessage("FORM_PUBLIC_ICON_TEMPLATE")
);
$arrUrl = parse_url($_SERVER["REQUEST_URI"]);
$arIcons[] =
Array(
"URL" => "/freetrix/admin/fileman_file_edit.php?lang=".LANGUAGE_ID."&site=".SITE_ID."&full_src=Y&path=". urlencode($arrUrl["path"]),
"SRC" => "/freetrix/images/form/panel/edit_file.gif",
"ALT" => GetMessage("FORM_PUBLIC_ICON_HANDLER")
);
}
$arIcons[] =
Array(
"URL" => "/freetrix/admin/form_edit.php?lang=".LANGUAGE_ID."&ID=".$WEB_FORM_ID,
"SRC" => "/freetrix/images/form/panel/edit_form.gif",
"ALT" => GetMessage("FORM_PUBLIC_ICON_SETTINGS")
);
echo $APPLICATION->IncludeStringBefore($arIcons);
}
include($_SERVER["DOCUMENT_ROOT"].$path.$template);
if ($APPLICATION->GetShowIncludeAreas())
{
echo $APPLICATION->IncludeStringAfter();
}
}
}
}
示例2: Init
/**
* Form initializing and checking. If form's wrong, returns false
* Use ShowErrorMsg() to output error code
*
* @param array $arParams
* @return bool
*/
function Init($arParams, $admin = false)
{
global $APPLICATION, $USER;
$this->bSimple = COption::GetOptionString("form", "SIMPLE", "Y") == "Y" ? true : false;
$this->comp2 = !empty($arParams["COMPONENT"]);
$this->SHOW_INCLUDE_AREAS = $APPLICATION->GetShowIncludeAreas();
if ($admin) {
$FORM_RIGHT = $APPLICATION->GetGroupRight("form");
if ($FORM_RIGHT <= "D") {
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
$this->__admin = true;
}
$this->arParams = $arParams;
$this->RESULT_ID = intval($arParams["RESULT_ID"]);
if (intval($this->RESULT_ID) <= 0) {
$this->RESULT_ID = intval($_REQUEST["RESULT_ID"]);
}
// if there's result ID try to get form ID
if (intval($this->RESULT_ID) > 0) {
$DBRes = CFormResult::GetByID($this->RESULT_ID);
if ($arrResult = $DBRes->Fetch()) {
$this->WEB_FORM_ID = intval($arrResult["FORM_ID"]);
}
}
if (intval($this->WEB_FORM_ID) <= 0) {
$this->WEB_FORM_ID = intval($arParams["WEB_FORM_ID"]);
}
// if there's no WEB_FORM_ID, try to get it from $_REQUEST;
if (intval($this->WEB_FORM_ID) <= 0) {
$this->WEB_FORM_ID = intval($_REQUEST["WEB_FORM_ID"]);
}
// check WEB_FORM_ID and get web form data
$this->WEB_FORM_ID = CForm::GetDataByID($this->WEB_FORM_ID, $this->arForm, $this->arQuestions, $this->arAnswers, $this->arDropDown, $this->arMultiSelect, $this->__admin || $this->arParams["SHOW_ADDITIONAL"] == "Y" || $this->arParams["EDIT_ADDITIONAL"] == "Y" ? "ALL" : "N", $this->__admin ? 'Y' : 'N');
$this->WEB_FORM_NAME = $this->arForm["SID"];
// if wrong WEB_FORM_ID return error;
if ($this->WEB_FORM_ID > 0) {
// insert chain item
if (strlen($this->arParams["CHAIN_ITEM_TEXT"]) > 0) {
$APPLICATION->AddChainItem($this->arParams["CHAIN_ITEM_TEXT"], $this->arParams["CHAIN_ITEM_LINK"]);
}
// check web form rights;
$this->F_RIGHT = intval(CForm::GetPermission($this->WEB_FORM_ID));
// in no form access - return error
if ($this->isAccessForm()) {
if (!empty($_REQUEST["strFormNote"])) {
$this->strFormNote = $_REQUEST["strFormNote"];
}
if (!$this->comp2 || $this->arParams["COMPONENT"]["componentName"] != "bitrix:form.result.list" || $this->isAccessFormResultList()) {
if ($this->RESULT_ID) {
if ($this->isAccessFormResult($arrResult)) {
$this->arrRESULT_PERMISSION = CFormResult::GetPermissions($this->RESULT_ID, $v);
// check result rights
if (!$this->comp2 && !$this->isAccessFormResultEdit() || $this->comp2 && ($this->arParams["COMPONENT"]["componentName"] == "bitrix:form.result.edit" && !$this->isAccessFormResultEdit() || $this->arParams["COMPONENT"]["componentName"] == "bitrix:form.result.view" && !$this->isAccessFormResultView())) {
$this->__error_msg = "FORM_RESULT_ACCESS_DENIED";
} else {
if (!$arrResult) {
$z = CFormResult::GetByID($this->RESULT_ID);
$this->arResult = $z->Fetch();
} else {
$this->arResult = $arrResult;
}
if ($this->arResult) {
if ($this->comp2 && $this->arParams["COMPONENT"]["componentName"] == "bitrix:form.result.view") {
CForm::GetResultAnswerArray($this->WEB_FORM_ID, $this->arrResultColumns, $this->arrVALUES, $this->arrResultAnswersSID, array("RESULT_ID" => $this->RESULT_ID));
$this->arrVALUES = $this->arrVALUES[$this->RESULT_ID];
} else {
$this->arrVALUES = CFormResult::GetDataByIDForHTML($this->RESULT_ID, $this->arParams["EDIT_ADDITIONAL"]);
}
} else {
$this->__error_msg = "FORM_RECORD_NOT_FOUND";
}
}
} else {
$this->__error_msg = "FORM_ACCESS_DENIED";
}
$this->arForm["USE_CAPTCHA"] = "N";
} else {
// if form uses CAPCHA initialize it
if ($this->arForm["USE_CAPTCHA"] == "Y") {
$this->CaptchaInitialize();
}
}
} else {
$this->__error_msg = "FORM_ACCESS_DENIED";
}
} else {
$this->__error_msg = "FORM_ACCESS_DENIED";
}
// endif ($F_RIGHT>=10);
} else {
$this->__error_msg = "FORM_NOT_FOUND";
}
//.........这里部分代码省略.........
示例3: Check
function Check($WEB_FORM_ID, $arrVALUES = false, $RESULT_ID = false, $CHECK_RIGHTS = "Y", $RETURN_ARRAY = "N")
{
$err_mess = CAllForm::err_mess() . "<br>Function: Check<br>Line: ";
global $DB, $APPLICATION, $USER, $_REQUEST, $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_POST_FILES;
if ($arrVALUES === false) {
$arrVALUES = $_REQUEST;
}
$RESULT_ID = intval($RESULT_ID);
$errors = $RETURN_ARRAY == "Y" ? array() : "";
$WEB_FORM_ID = intval($WEB_FORM_ID);
if ($WEB_FORM_ID > 0) {
// получаем данные по форме
$WEB_FORM_ID = CForm::GetDataByID($WEB_FORM_ID, $arForm, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, "ALL");
$WEB_FORM_ID = intval($WEB_FORM_ID);
if ($WEB_FORM_ID > 0) {
// провер¤ем права
$F_RIGHT = $CHECK_RIGHTS == "Y" ? CForm::GetPermission($WEB_FORM_ID) : 30;
if ($F_RIGHT < 10) {
CForm::__check_PushError($errors, GetMessage("FORM_ACCESS_DENIED_FOR_FORM_WRITE"));
} else {
$NOT_ANSWER = "NOT_ANSWER";
// проходим по вопросам
foreach ($arQuestions as $key => $arQuestion) {
$arAnswerValues = array();
$FIELD_ID = $arQuestion["ID"];
if ($arQuestion["TITLE_TYPE"] == "html") {
$FIELD_TITLE = strip_tags($arQuestion["TITLE"]);
} else {
$FIELD_TITLE = $arQuestion["TITLE"];
}
if ($arQuestion["ADDITIONAL"] != "Y") {
// провер¤ем вопросы формы
$FIELD_SID = $arQuestion["SID"];
$FIELD_REQUIRED = $arQuestion["REQUIRED"];
// массив полей: N - поле не отвечено; Y - поле отвечено;
if ($FIELD_REQUIRED == "Y") {
$REQUIRED_FIELDS[$FIELD_SID] = "N";
}
$startType = "";
$bCheckValidators = true;
// проходим по ответам
if (is_array($arAnswers[$FIELD_SID])) {
foreach ($arAnswers[$FIELD_SID] as $key => $arAnswer) {
$ANSWER_ID = 0;
$FIELD_TYPE = $arAnswer["FIELD_TYPE"];
$FIELD_PARAM = $arAnswer["FIELD_PARAM"];
if ($startType == "") {
$startType = $FIELD_TYPE;
} else {
$bCheckValidators &= $startType == $FIELD_TYPE;
}
switch ($FIELD_TYPE) {
case "radio":
case "dropdown":
$fname = "form_" . $FIELD_TYPE . "_" . $FIELD_SID;
$arAnswerValues[] = $arrVALUES[$fname];
$ANSWER_ID = intval($arrVALUES[$fname]);
if ($ANSWER_ID > 0 && $ANSWER_ID == $arAnswer["ID"]) {
if ($FIELD_REQUIRED == "Y" && !preg_match("/" . $NOT_ANSWER . "/i", $FIELD_PARAM)) {
$REQUIRED_FIELDS[$FIELD_SID] = "Y";
}
}
break;
case "checkbox":
case "multiselect":
$fname = "form_" . $FIELD_TYPE . "_" . $FIELD_SID;
if (is_array($arrVALUES[$fname]) && count($arrVALUES[$fname]) > 0) {
$arAnswerValues = $arrVALUES[$fname];
reset($arrVALUES[$fname]);
foreach ($arrVALUES[$fname] as $ANSWER_ID) {
$ANSWER_ID = intval($ANSWER_ID);
if ($ANSWER_ID > 0 && $ANSWER_ID == $arAnswer["ID"]) {
if ($FIELD_REQUIRED == "Y" && !preg_match("/" . $NOT_ANSWER . "/i", $FIELD_PARAM)) {
$REQUIRED_FIELDS[$FIELD_SID] = "Y";
break;
}
}
}
}
break;
case "text":
case "textarea":
case "password":
case "hidden":
$fname = "form_" . $FIELD_TYPE . "_" . $arAnswer["ID"];
$ANSWER_ID = intval($arAnswer["ID"]);
$USER_TEXT = $arrVALUES[$fname];
$arAnswerValues[] = $arrVALUES[$fname];
if (strlen(trim($USER_TEXT)) > 0) {
if ($FIELD_REQUIRED == "Y") {
$REQUIRED_FIELDS[$FIELD_SID] = "Y";
break;
}
}
break;
case "url":
$fname = "form_" . $FIELD_TYPE . "_" . $arAnswer["ID"];
$arAnswerValues[] = $arrVALUES[$fname];
$ANSWER_ID = intval($arAnswer["ID"]);
$USER_TEXT = $arrVALUES[$fname];
//.........这里部分代码省略.........
示例4: Show
function Show($RESULT_ID, $TEMPLATE = "", $TEMPLATE_TYPE = "show", $SHOW_ADDITIONAL = "N", $SHOW_ANSWER_VALUE = "Y", $SHOW_STATUS = "N")
{
global $DB, $MESS, $APPLICATION, $USER, $HTTP_POST_VARS, $HTTP_GET_VARS, $arrRESULT_PERMISSION, $arrFIELDS;
$err_mess = CAllFormResult::err_mess() . "<br>Function: Show<br>Line: ";
$z = CFormResult::GetByID($RESULT_ID);
if ($zr = $z->Fetch()) {
$arrResult = $zr;
InitBVar($SHOW_ADDITIONAL);
$additional = $SHOW_ADDITIONAL == "Y" ? "ALL" : "N";
$WEB_FORM_ID = $FORM_ID = CForm::GetDataByID($arrResult["FORM_ID"], $arForm, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $additional);
CForm::GetResultAnswerArray($WEB_FORM_ID, $arrResultColumns, $arrResultAnswers, $arrResultAnswersVarname, array("RESULT_ID" => $RESULT_ID));
$arrResultAnswers = $arrResultAnswers[$RESULT_ID];
// проверим общие права на результат
$F_RIGHT = CForm::GetPermission($WEB_FORM_ID);
if (intval($F_RIGHT) >= 20 || $F_RIGHT >= 15 && $zr["USER_ID"] == $USER->GetID()) {
// проверим права в зависимости от статуса результата
$arrRESULT_PERMISSION = CFormResult::GetPermissions($RESULT_ID, $v);
if (in_array("VIEW", $arrRESULT_PERMISSION)) {
if (strlen(trim($TEMPLATE)) > 0) {
$template = $TEMPLATE;
} else {
if ($TEMPLATE_TYPE == "show") {
if (strlen($arrResult["SHOW_RESULT_TEMPLATE"]) <= 0) {
$template = "default.php";
} else {
$template = $arrResult["SHOW_RESULT_TEMPLATE"];
}
} elseif ($TEMPLATE_TYPE == "print") {
if (strlen($arrResult["PRINT_RESULT_TEMPLATE"]) <= 0) {
$template = "default.php";
} else {
$template = $arrResult["PRINT_RESULT_TEMPLATE"];
}
}
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/form/include.php";
if ($TEMPLATE_TYPE == "show") {
$path = COption::GetOptionString("form", "SHOW_RESULT_TEMPLATE_PATH");
} elseif ($TEMPLATE_TYPE == "print") {
$path = COption::GetOptionString("form", "PRINT_RESULT_TEMPLATE_PATH");
}
IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/form/include.php");
include GetLangFileName($_SERVER["DOCUMENT_ROOT"] . $path . "lang/", "/" . $template);
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/form/panel/edit_template.gif", "ALT" => GetMessage("FORM_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/form/panel/edit_file.gif", "ALT" => GetMessage("FORM_PUBLIC_ICON_HANDLER"));
}
$arIcons[] = array("URL" => "/bitrix/admin/form_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $WEB_FORM_ID, "SRC" => "/bitrix/images/form/panel/edit_form.gif", "ALT" => GetMessage("FORM_PUBLIC_ICON_SETTINGS"));
echo $APPLICATION->IncludeStringBefore($arIcons);
}
include $_SERVER["DOCUMENT_ROOT"] . $path . $template;
if ($APPLICATION->GetShowIncludeAreas()) {
echo $APPLICATION->IncludeStringAfter();
}
}
}
}
}
示例5: intval
if ($arResultData = $DBRes->Fetch())
{
$arParams["WEB_FORM_ID"] = intval($arResultData["FORM_ID"]);
}
}
if (intval($arParams["RESULT_ID"]) <= 0 || intval($arParams["WEB_FORM_ID"]) <= 0)
{
$arResult["ERROR"] = "FORM_RECORD_NOT_FOUND";
}
if (strlen($arResult["ERROR"]) <= 0)
{
// check WEB_FORM_ID and get web form data
$arParams["WEB_FORM_ID"] = CForm::GetDataByID($arParams["WEB_FORM_ID"], $arResult["arForm"], $arResult["arQuestions"], $arResult["arAnswers"], $arResult["arDropDown"], $arResult["arMultiSelect"], $arResult["bAdmin"] == 'Y' || $arParams["SHOW_ADDITIONAL"] == "Y" || $arParams["EDIT_ADDITIONAL"] == "Y" ? "ALL" : "N");
$arResult["WEB_FORM_NAME"] = $arResult["arForm"]["SID"];
// if wrong WEB_FORM_ID return error;
if ($arParams["WEB_FORM_ID"] > 0)
{
// insert chain item
if (strlen($arParams["CHAIN_ITEM_TEXT"]) > 0)
{
$APPLICATION->AddChainItem($arParams["CHAIN_ITEM_TEXT"], $arParams["CHAIN_ITEM_LINK"]);
}
// check web form rights;
$arResult["F_RIGHT"] = intval(CForm::GetPermission($arParams["WEB_FORM_ID"]));
示例6: Update
//.........这里部分代码省略.........
* }
* ?>
* </pre>
*
*
*
* <h4>See Also</h4>
* <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/form/classes/cformresult/setfield.php">CFormResult::SetField</a>
* </li> <li> <a
* href="http://dev.1c-bitrix.ru/api_help/form/classes/cformresult/getdatabyidforhtml.php">CFormResult::GetDataByIDForHTML</a>
* </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/form/classes/cformresult/add.php">CFormResult::Add</a> </li>
* </ul><a name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/form/classes/cformresult/update.php
* @author Bitrix
*/
public static function Update($RESULT_ID, $arrVALUES=false, $UPDATE_ADDITIONAL="N", $CHECK_RIGHTS="Y")
{
$err_mess = (CAllFormResult::err_mess())."<br>Function: Update<br>Line: ";
global $DB, $USER, $_REQUEST, $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_POST_FILES, $strError, $APPLICATION;
if ($arrVALUES===false) $arrVALUES = $_REQUEST;
InitBvar($UPDATE_ADDITIONAL);
// check whether such result exists in db
$RESULT_ID = intval($RESULT_ID);
$z = CFormResult::GetByID($RESULT_ID);
if ($zr=$z->Fetch())
{
$arrResult = $zr;
$additional = ($UPDATE_ADDITIONAL=="Y") ? "ALL" : "N";
// get form data
$WEB_FORM_ID = CForm::GetDataByID($arrResult["FORM_ID"], $arForm, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $additional);
if ($WEB_FORM_ID>0)
{
// check form rights
$F_RIGHT = ($CHECK_RIGHTS!="Y") ? 30 : intval(CForm::GetPermission($WEB_FORM_ID));
if ($F_RIGHT>=20 || ($F_RIGHT>=15 && $arrResult["USER_ID"]==$USER->GetID()))
{
// check result rights (its status rights)
$arrRESULT_PERMISSION = ($CHECK_RIGHTS!="Y") ? CFormStatus::GetMaxPermissions() : CFormResult::GetPermissions($RESULT_ID, $v);
// if rights're correct
if (in_array("EDIT", $arrRESULT_PERMISSION))
{
// update result
$arFields = array("TIMESTAMP_X" => $DB->GetNowFunction());
$fname = "status_".$arForm["SID"];
$STATUS_ID = intval($arrVALUES[$fname]);
$bUpdateStatus = false;
// if there's new status defined
if (intval($STATUS_ID)>0)
{
// check new status rights
$arrNEW_STATUS_PERMISSION = ($CHECK_RIGHTS!="Y") ? CFormStatus::GetMaxPermissions() : CFormStatus::GetPermissions($STATUS_ID);
// if rights're correct
if (in_array("MOVE",$arrNEW_STATUS_PERMISSION))
{
// update it
$bUpdateStatus = true;
$arFields["STATUS_ID"] = intval($arrVALUES[$fname]);
}
}
示例7: initFormData
/**
* Получаем данные формы
*/
protected function initFormData()
{
return \CForm::GetDataByID($this->formId, $this->arResult['RAW']['arForm'], $this->arResult['RAW']['arQuestions'], $this->arResult['RAW']['arAnswers'], $this->arResult['RAW']['arDropDown'], $this->arResult['RAW']['arMultiSelect'], 'N');
}