Esempio n. 1
1
 /** @return \CDBResult */
 public function getData()
 {
     $formId = $this->getFieldValue('FORM', null);
     $propertyNameId = $this->getFieldValue('PROPERTY_NAME', null);
     $propertyEmailId = $this->getFieldValue('PROPERTY_EMAIL', null);
     $formResultsDb = new \CDBResult();
     if ($formId && $propertyEmailId) {
         $dataResult = array();
         $filter = array();
         $formResultDb = \CFormResult::GetList($formId, $by = "s_timestamp", $order = "asc", $filter, $filtered, "N");
         while ($formResult = $formResultDb->Fetch()) {
             $answerList = \CFormResult::GetDataByID($formResult['ID'], array(), $formResult, $answerList2);
             $data = array();
             foreach ($answerList as $fieldCode => $arFieldsAnswer) {
                 if ($arFieldsAnswer[0]['TITLE_TYPE'] == 'text') {
                     if ($arFieldsAnswer[0]['FIELD_ID'] == $propertyNameId) {
                         $data['NAME'] = $arFieldsAnswer[0]['USER_TEXT'];
                     }
                     if ($arFieldsAnswer[0]['FIELD_ID'] == $propertyEmailId) {
                         $data['EMAIL'] = $arFieldsAnswer[0]['USER_TEXT'];
                     }
                 }
             }
             if (!empty($data['EMAIL'])) {
                 if (intval($formResult['USER_ID']) > 0) {
                     $data['USER_ID'] = intval($formResult['USER_ID']);
                 }
                 $dataResult[] = $data;
             }
         }
         $formResultsDb->InitFromArray($dataResult);
     }
     return $formResultsDb;
 }
Esempio n. 2
0
 function sendOnAfterResultStatusChange($WEB_FORM_ID, $RESULT_ID, $NEW_STATUS_ID = false, $CHECK_RIGHTS = 'Y')
 {
     $NEW_STATUS_ID = intval($NEW_STATUS_ID);
     $dbRes = CForm::GetByID($WEB_FORM_ID);
     if (!($arForm = $dbRes->Fetch())) {
         return;
     }
     CTimeZone::Disable();
     $dbRes = CFormResult::GetByID($RESULT_ID);
     CTimeZone::Enable();
     if (!($arResult = $dbRes->Fetch()) || !$arResult['USER_ID']) {
         return;
     }
     $dbRes = CUser::GetByID($arResult['USER_ID']);
     if (!($arUser = $dbRes->Fetch())) {
         return;
     }
     if (!$NEW_STATUS_ID) {
         $NEW_STATUS_ID = CFormStatus::GetDefault($WEB_FORM_ID);
     }
     $dbRes = CFormStatus::GetByID($NEW_STATUS_ID);
     if (!($arStatus = $dbRes->Fetch()) || strlen($arStatus['MAIL_EVENT_TYPE']) <= 0) {
         return;
     }
     $arTemplates = CFormStatus::GetMailTemplateArray($NEW_STATUS_ID);
     if (!is_array($arTemplates) || count($arTemplates) <= 0) {
         return;
     }
     $arEventFields = array("EMAIL_TO" => $arUser['EMAIL'], "RS_FORM_ID" => $arForm["ID"], "RS_FORM_NAME" => $arForm["NAME"], "RS_FORM_VARNAME" => $arForm["SID"], "RS_FORM_SID" => $arForm["SID"], "RS_RESULT_ID" => $arResult["ID"], "RS_DATE_CREATE" => $arResult["DATE_CREATE"], "RS_USER_ID" => $arResult['USER_ID'], "RS_USER_EMAIL" => $arUser['EMAIL'], "RS_USER_NAME" => $arUser["NAME"] . " " . $arUser["LAST_NAME"], "RS_STATUS_ID" => $arStatus["ID"], "RS_STATUS_NAME" => $arStatus["TITLE"]);
     $dbRes = CEventMessage::GetList($by = "id", $order = "asc", array('ID' => implode('|', $arTemplates), "ACTIVE" => "Y", "EVENT_NAME" => $arStatus["MAIL_EVENT_TYPE"]));
     while ($arTemplate = $dbRes->Fetch()) {
         CEvent::Send($arTemplate["EVENT_NAME"], $arTemplate["SITE_ID"], $arEventFields, "Y", $arTemplate["ID"]);
     }
 }
Esempio n. 3
0
 public function resultsById($RESULT_ID)
 {
     $data = \CFormResult::GetDataByID($RESULT_ID);
     $result = array();
     foreach ($data as $d) {
         $result[$d[0]['FIELD_ID']] = $d[0]['USER_TEXT'];
     }
     return $result;
 }
Esempio n. 4
0
     if ($arFile = CFormResult::GetFileByAnswerID($RESULT_ID, $arAnswer["ID"])) {
         if (intval($arFile["USER_FILE_ID"]) > 0) {
             if ($arFile["USER_FILE_IS_IMAGE"] == "Y") {
                 echo CFile::ShowImage($arFile["USER_FILE_ID"], 0, 0, "border=0", "", true);
                 echo "<br />";
                 echo '<input type="checkbox" value="Y" name="form_image_' . $arAnswer['ID'] . '_del" id="form_image_' . $arAnswer['ID'] . '_del" /><label for="form_image_' . $arAnswer['ID'] . '_del">' . GetMessage('FORM_DELETE_FILE') . '</label><br />';
             }
             //endif;
         }
         //endif;
     }
     // endif
     echo CForm::GetFileField($arAnswer["ID"], $arAnswer["FIELD_WIDTH"], "IMAGE", 0, "", $arAnswer["FIELD_PARAM"]) . '<br />';
     break;
 case "file":
     if ($arFile = CFormResult::GetFileByAnswerID($RESULT_ID, $arAnswer["ID"])) {
         if (intval($arFile["USER_FILE_ID"]) > 0) {
             echo "<a title=\"" . GetMessage("FORM_VIEW_FILE") . "\" target=\"_blank\" class=\"tablebodylink\" href=\"/bitrix/tools/form_show_file.php?rid=" . $RESULT_ID . "&hash=" . $arFile["USER_FILE_HASH"] . "&lang=" . LANGUAGE_ID . "\">" . htmlspecialcharsbx($arFile["USER_FILE_NAME"]) . "</a>&nbsp;(";
             $a = array("b", "Kb", "Mb", "Gb");
             $pos = 0;
             $size = $arFile["USER_FILE_SIZE"];
             while ($size >= 1024) {
                 $size /= 1024;
                 $pos++;
             }
             echo round($size, 2) . " " . $a[$pos];
             echo ")&nbsp;&nbsp;[&nbsp;<a title=\"" . str_replace("#FILE_NAME#", $arFile["USER_FILE_NAME"], GetMessage("FORM_DOWNLOAD_FILE")) . "\" class=\"tablebodylink\" href=\"/bitrix/tools/form_show_file.php?rid=" . $RESULT_ID . "&hash=" . $arFile["USER_FILE_HASH"] . "&lang=" . LANGUAGE_ID . "&action=download\">" . GetMessage("FORM_DOWNLOAD") . "</a>&nbsp;]<br />";
             echo '<input type="checkbox" value="Y" name="form_file_' . $arAnswer['ID'] . '_del" id="form_file_' . $arAnswer['ID'] . '_del" /><label for="form_file_' . $arAnswer['ID'] . '_del">' . GetMessage('FORM_DELETE_FILE') . '</label><br />';
             echo "<br />";
         }
         //endif;
Esempio n. 5
0
 public static function getFormResults($form_id, $arOrder, $selectAnswerFields, $arFilter, $use_cache = true)
 {
     $param_string = serialize(func_get_args());
     if (!is_array($arOrder) || !count($arOrder)) {
         $arOrder = array('ID' => 'ASC');
     }
     $by = key($arOrder);
     $order = current($arOrder);
     $is_filtered = true;
     if ($use_cache) {
         $result = static::getCache(__FUNCTION__ . $param_string . '_form_result');
     }
     if (!is_array($result['RESULT'])) {
         \CModule::IncludeModule('form');
         $dbResult = \CFormResult::GetList($form_id, $by, $order, $arFilter, $is_filtered);
         static::setCache(__FUNCTION__ . $param_string . '_section', $result['RESULT']);
         while ($next = $dbResult->GetNext()) {
             \CFormResult::GetDataByID($next['ID'], $selectAnswerFields, $arResultFields, $arAnswers);
             $next = array_merge($next, $arResultFields);
             $next['ANSWERS'] = $arAnswers;
             $result['RESULT'][] = $next;
         }
         static::setCache(__FUNCTION__ . $param_string . '_form_result', $result['RESULT']);
     }
     return $result;
 }
 function getData(&$arResult)
 {
     global $APPLICATION, $USER;
     //$arResult = $this->__prepareDataForTpl();
     $arResult["WEB_FORM_ID"] = $this->WEB_FORM_ID;
     $arResult["WEB_FORM_NAME"] = $this->WEB_FORM_NAME;
     if ($this->RESULT_ID > 0) {
         $arResult["RESULT_ID"] = $this->RESULT_ID;
     }
     $arResult["F_RIGHT"] = $this->F_RIGHT;
     if (strlen($_REQUEST["web_form_submit"]) > 0 || strlen($_REQUEST["web_form_apply"]) > 0) {
         $this->arrVALUES = $_REQUEST;
         if ($this->RESULT_ID) {
             $this->__form_validate_errors = CForm::Check($this->WEB_FORM_ID, $this->arrVALUES, $this->RESULT_ID);
         } else {
             $this->__form_validate_errors = CForm::Check($this->WEB_FORM_ID, $this->arrVALUES);
         }
         if (!$this->isFormErrors()) {
             if (check_bitrix_sessid()) {
                 $return = false;
                 if ($this->RESULT_ID) {
                     CFormResult::Update($this->RESULT_ID, $this->arrVALUES, $this->arParams["EDIT_ADDITIONAL"]);
                     $this->strFormNote = GetMessage("FORM_DATA_SAVED");
                     if (strlen($_REQUEST["web_form_submit"]) > 0 && !(defined("ADMIN_SECTION") && ADMIN_SECTION === true)) {
                         if ($this->arParams["SEF_MODE"] == "Y") {
                             LocalRedirect($this->arParams["LIST_URL"] . "?strFormNote=" . urlencode($this->strFormNote));
                         } else {
                             LocalRedirect($this->arParams["LIST_URL"] . (strpos($this->arParams["LIST_URL"], "?") === false ? "?" : "&") . "WEB_FORM_ID=" . $this->WEB_FORM_ID . "&strFormNote=" . urlencode($this->strFormNote));
                         }
                         die;
                     }
                     if (strlen($_REQUEST["web_form_apply"]) > 0 && !(defined("ADMIN_SECTION") && ADMIN_SECTION === true) && $this->arParams["SEF_MODE"] == "Y") {
                         // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                         LocalRedirect($this->arParams["EDIT_URL"] . (strpos($this->arParams["EDIT_URL"], "?") === false ? "?" : "&") . "strFormNote=" . urlencode($this->strFormNote));
                         die;
                     }
                     if (defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
                         if (strlen($_REQUEST["web_form_submit"]) > 0) {
                             LocalRedirect(BX_ROOT . "/admin/form_result_list.php?lang=" . LANG . "&WEB_FORM_ID=" . $this->WEB_FORM_ID . "&strFormNote=" . urlencode($this->strFormNote));
                         } elseif (strlen($_REQUEST["web_form_apply"]) > 0) {
                             LocalRedirect(BX_ROOT . "/admin/form_result_edit.php?lang=" . LANG . "&WEB_FORM_ID=" . $this->WEB_FORM_ID . "&RESULT_ID=" . $this->RESULT_ID . "&strFormNote=" . urlencode($this->strFormNote));
                         }
                         die;
                     }
                 } else {
                     if ($this->RESULT_ID = CFormResult::Add($this->WEB_FORM_ID, $this->arrVALUES)) {
                         $this->strFormNote = GetMessage("FORM_DATA_SAVED1") . $this->RESULT_ID . GetMessage("FORM_DATA_SAVED2");
                         CFormResult::SetEvent($this->RESULT_ID);
                         CFormResult::Mail($this->RESULT_ID);
                         if ($this->F_RIGHT >= 15) {
                             if (strlen($_REQUEST["web_form_submit"]) > 0 && strlen($this->arParams["LIST_URL"]) > 0) {
                                 if ($this->arParams["SEF_MODE"] == "Y") {
                                     LocalRedirect($this->arParams["LIST_URL"] . "?strFormNote=" . urlencode($this->strFormNote));
                                 } else {
                                     LocalRedirect($this->arParams["LIST_URL"] . (strpos($this->arParams["LIST_URL"], "?") === false ? "?" : "&") . "WEB_FORM_ID=" . $this->WEB_FORM_ID . "&RESULT_ID=" . $this->RESULT_ID . "&strFormNote=" . urlencode($this->strFormNote));
                                 }
                                 die;
                             } elseif (strlen($_REQUEST["web_form_apply"]) > 0 && strlen($this->arParams["EDIT_URL"]) > 0) {
                                 if ($this->arParams["SEF_MODE"] == "Y") {
                                     LocalRedirect(str_replace("#RESULT_ID#", $this->RESULT_ID . $this->arParams["EDIT_URL"]) . "?strFormNote=" . urlencode($this->strFormNote));
                                 } else {
                                     LocalRedirect($this->arParams["EDIT_URL"] . (strpos($this->arParams["EDIT_URL"], "?") === false ? "?" : "&") . "RESULT_ID=" . $this->RESULT_ID . "&strFormNote=" . urlencode($this->strFormNote));
                                 }
                                 die;
                             }
                             $arResult["return"] = true;
                         } else {
                             LocalRedirect($APPLICATION->GetCurPage() . "?WEB_FORM_ID=" . $this->WEB_FORM_ID . "&strFormNote=" . urlencode($this->strFormNote));
                             die;
                         }
                     } else {
                         $this->__form_validate_errors = $GLOBALS["strError"];
                     }
                 }
             }
         }
     }
     return $arResult;
 }
Esempio n. 7
0
     $txt = "&nbsp;";
 }
 $txt = trim($txt, ",");
 $row->AddViewField("SITE", $txt);
 if ($bSimple) {
     $f_QUESTIONS += $f_C_FIELDS;
     $txt = "<a title=\"" . GetMessage("FORM_QUESTIONS_ALT") . "\" href=\"form_field_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}\">{$f_QUESTIONS}</a>&nbsp;[<a title=\"" . GetMessage("FORM_ADD_QUESTION") . "\" href=\"form_field_edit_simple.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}\">+</a>]";
 } else {
     $txt = "<a title=\"" . GetMessage("FORM_QUESTIONS_ALT") . "\" href=\"form_field_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}\">{$f_QUESTIONS}</a>&nbsp;[<a title=\"" . GetMessage("FORM_ADD_QUESTION") . "\" href=\"form_field_edit.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}\">+</a>]";
 }
 $row->AddViewField("QUESTIONS", $txt);
 $txt = "<a title=\"" . GetMessage("FORM_FIELDS_ALT") . "\" href=\"form_field_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}&additional=Y\">{$f_C_FIELDS}</a>&nbsp;[<a title=\"" . GetMessage("FORM_ADD_FIELD") . "\" href=\"form_field_edit.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}&additional=Y\">+</a>]";
 $row->AddViewField("C_FIELDS", $txt);
 $txt = "<a title=\"" . GetMessage("FORM_STATUSES_ALT") . "\" href=\"form_status_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}\">{$f_STATUSES}</a>&nbsp;[<a title=\"" . GetMessage("FORM_ADD_STATUS") . "\" href=\"form_status_edit.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}\">+</a>]";
 $row->AddViewField("STATUSES", $txt);
 $txt = "<a title=\"" . str_replace("\"#NAME#\"", "", GetMessage("FORM_RESULTS_ALT")) . "\" href=\"form_result_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}\">" . CFormResult::GetCount($f_ID) . "</a>&nbsp;[<a title=\"" . GetMessage("FORM_ADD_RESULT") . "\" href=\"form_result_edit.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}\">+</a>]";
 $row->AddViewField("RESULTS", $txt);
 if ($FORM_RIGHT == "W") {
     $row->AddInputField("C_SORT");
 }
 $arActions = array();
 if ($F_RIGHT >= 25) {
     $arActions[] = array("DEFAULT" => "Y", "ICON" => "edit", "TITLE" => GetMessage("FORM_EDIT_ALT"), "ACTION" => $lAdmin->ActionRedirect("form_edit.php?lang=" . LANGUAGE_ID . "&ID={$f_ID}"), "TEXT" => GetMessage("FORM_EDIT"));
 }
 if (CForm::IsAdmin()) {
     $arActions[] = array("ICON" => "copy", "TITLE" => GetMessage("FORM_COPY_ALT"), "ACTION" => $lAdmin->ActionRedirect("form_list.php?lang=" . LANGUAGE_ID . "&amp;makecopy_id={$f_ID}&" . bitrix_sessid_get()), "TEXT" => GetMessage("FORM_COPY"));
 }
 if ($old_module_version == "Y" && $F_RIGHT >= 10) {
     $arActions[] = array("TITLE" => GetMessage("FORM_PREVIEW_ALT"), "ACTION" => $lAdmin->ActionRedirect("form_view.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID={$f_ID}"), "TEXT" => GetMessage("FORM_PREVIEW"));
 }
 if ($F_RIGHT >= 30) {
 function GetByID_admin($WEB_FORM_ID, $current_section = false)
 {
     $WEB_FORM_ID = intval($WEB_FORM_ID);
     if ($WEB_FORM_ID <= 0) {
         return false;
     }
     $dbForm = CForm::GetByID($WEB_FORM_ID);
     if ($arForm = $dbForm->Fetch()) {
         if (!$current_section) {
             $current_script = basename($GLOBALS['APPLICATION']->GetCurPage());
             switch ($current_script) {
                 case 'form_edit.php':
                     $current_section = 'form';
                     break;
                 case 'form_field_edit.php':
                 case 'form_field_edit_simple.php':
                 case 'form_field_list.php':
                     if (!$bSimple && $_GET['additional'] == 'Y') {
                         $current_section = 'field';
                     } else {
                         $current_section = 'question';
                     }
                     break;
                 case 'form_result_edit.php':
                 case 'form_result_list.php':
                 case 'form_result_view.php':
                 case 'form_view.php':
                     $current_section = 'result';
                     break;
                 case 'form_status_edit.php':
                 case 'form_status_list.php':
                     $current_section = 'status';
                     break;
             }
         }
         $bSimple = COption::GetOptionString("form", "SIMPLE", "Y") == "Y";
         $arForm['ADMIN_MENU'] = array();
         $arForm['ADMIN_MENU'][] = array("ICON" => $current_section == 'form' ? 'btn_active' : '', "TEXT" => GetMessage("FORM_MENU_EDIT"), "LINK" => "/bitrix/admin/form_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $WEB_FORM_ID, "TITLE" => htmlspecialcharsbx(str_replace("#NAME#", $arForm["NAME"], GetMessage("FORM_MENU_EDIT_TITLE"))));
         $arForm['ADMIN_MENU'][] = array("ICON" => $current_section == 'result' ? 'btn_active' : '', "TEXT" => GetMessage("FORM_MENU_RESULTS") . " (" . CFormResult::GetCount($WEB_FORM_ID) . ")", "LINK" => "/bitrix/admin/form_result_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID=" . $WEB_FORM_ID, "TITLE" => htmlspecialcharsbx(str_replace("#NAME#", $arForm["NAME"], GetMessage("FORM_MENU_RESULTS_TITLE"))));
         $arForm['ADMIN_MENU'][] = array("ICON" => $current_section == 'question' ? 'btn_active' : '', "TEXT" => GetMessage("FORM_MENU_QUESTIONS") . " (" . ($bSimple ? $arForm["QUESTIONS"] + $arForm["C_FIELDS"] : $arForm["QUESTIONS"]) . ")", "LINK" => "/bitrix/admin/form_field_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID=" . $WEB_FORM_ID, "TITLE" => htmlspecialcharsbx(str_replace("#NAME#", $arForm["NAME"], GetMessage("FORM_MENU_QUESTIONS_TITLE"))));
         if (!$bSimple) {
             $arForm['ADMIN_MENU'][] = array("ICON" => $current_section == 'field' ? 'btn_active' : '', "TEXT" => GetMessage("FORM_MENU_FIELDS") . " (" . $arForm["C_FIELDS"] . ")", "LINK" => "/bitrix/admin/form_field_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID=" . $WEB_FORM_ID . "&additional=Y", "TITLE" => htmlspecialcharsbx(str_replace("#NAME#", $arForm["NAME"], GetMessage("FORM_MENU_FIELDS_TITLE"))));
             $arForm['ADMIN_MENU'][] = array("ICON" => $current_section == 'status' ? 'btn_active' : '', "TEXT" => GetMessage("FORM_MENU_STATUSES") . " (" . $arForm["STATUSES"] . ")", "LINK" => "/bitrix/admin/form_status_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID=" . $WEB_FORM_ID, "TITLE" => htmlspecialcharsbx(str_replace("#NAME#", $arForm["NAME"], GetMessage("FORM_MENU_STATUSES_TITLE"))));
         }
         return $arForm;
     }
     return false;
 }
Esempio n. 9
0
                 $arResult["arrRESULT_PERMISSION"] = CFormResult::GetPermissions($arParams["RESULT_ID"], $v);
                 // check result rights
                 if (!in_array("VIEW", $arResult["arrRESULT_PERMISSION"])) {
                     $arResult["ERROR"] = "FORM_RESULT_ACCESS_DENIED";
                 } else {
                     if (!$arResultData) {
                         $z = CFormResult::GetByID($arParams["RESULT_ID"]);
                         $arResult["arResultData"] = $z->Fetch();
                     } else {
                         $arResult["arResultData"] = $arResultData;
                     }
                     if ($arResult["arResultData"]) {
                         CForm::GetResultAnswerArray($arParams["WEB_FORM_ID"], $arResult["arrResultColumns"], $arResult["arrVALUES"], $arResult["arrResultAnswersSID"], array("RESULT_ID" => $arParams["RESULT_ID"]));
                         $arResult["arrVALUES"] = $arResult["arrVALUES"][$arParams["RESULT_ID"]];
                     } else {
                         $arResult["arrVALUES"] = CFormResult::GetDataByIDForHTML($arResult["RESULT_ID"], $arParams["SHOW_ADDITIONAL"]);
                     }
                 }
             } else {
                 $arResult["ERROR"] = "FORM_ACCESS_DENIED";
             }
         } else {
             $arResult["ERROR"] = "FORM_RECORD_NOT_FOUND";
         }
     } else {
         $arResult["ERROR"] = "FORM_ACCESS_DENIED";
     }
 } else {
     $arResult["ERROR"] = "FORM_NOT_FOUND";
 }
 // endif ($WEB_FORM_ID>0);
Esempio n. 10
0
/*
##############################################
# Freetrix: SiteManager                        #
# Copyright (c) 2002 - 2011 Freetrix           #
# http://www.freetrixsoft.com                  #
# mailto:admin@freetrixsoft.com                #
##############################################
*/
require_once($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/prolog_before.php");

if (!CModule::IncludeModule("form"))
	die();

if (strlen($_REQUEST["hash"]) > 0)
{
	$arFile = CFormResult::GetFileByHash($_REQUEST["rid"], $_REQUEST["hash"]);
	if ($arFile)
	{
		set_time_limit(0);
		// if we need "download"
		if ($_REQUEST["action"]=="download")
		{
			// download
			CFile::ViewByUser($arFile, array("force_download" => true));
		}
		else // otherwise just view
		{
			if (CFile::CheckImageFile(CFile::MakeFileArray($arFile['FILE_ID'])) === null)
			{
				// display as image
				CFile::ViewByUser($arFile, array("content_type" => $arFile["CONTENT_TYPE"]));
Esempio n. 11
0
 function UpdateField($arFields, $RESULT_ID, $FIELD_ID)
 {
     $err_mess = CFormResult::err_mess() . "<br>Function: UpdateField<br>Line: ";
     global $DB, $strError;
     $arBinds = array();
     $RESULT_ID = intval($RESULT_ID);
     $FIELD_ID = intval($FIELD_ID);
     $DB->StartTransaction();
     $strSql = "SELECT ID FROM b_form_result_answer WHERE RESULT_ID=" . $RESULT_ID . " and FIELD_ID=" . $FIELD_ID . " FOR UPDATE ";
     $z = $DB->Query($strSql, false, $err_mess . __LINE__);
     while ($zr = $z->Fetch()) {
         $strUpdate = $DB->PrepareUpdate("b_form_result_answer", $arFields, "form");
         $strSql = "UPDATE b_form_result_answer SET " . $strUpdate . " WHERE ID=" . $zr["ID"];
         if (is_set($arFields, "ANSWER_TEXT_SEARCH")) {
             $arBinds["ANSWER_TEXT_SEARCH"] = $arFields["ANSWER_TEXT_SEARCH"];
         }
         if (is_set($arFields, "ANSWER_VALUE_SEARCH")) {
             $arBinds["ANSWER_VALUE_SEARCH"] = $arFields["ANSWER_VALUE_SEARCH"];
         }
         if (is_set($arFields, "USER_TEXT_SEARCH")) {
             $arBinds["USER_TEXT_SEARCH"] = $arFields["USER_TEXT_SEARCH"];
         }
         if (is_set($arFields, "USER_TEXT")) {
             $arBinds["USER_TEXT"] = $arFields["USER_TEXT"];
         }
         $DB->QueryBind($strSql, $arBinds);
     }
     $DB->Commit();
 }
Esempio n. 12
0
 function SetEvent($RESULT_ID, $IN_EVENT1 = false, $IN_EVENT2 = false, $IN_EVENT3 = false, $money = "", $currency = "", $goto = "", $chargeback = "N")
 {
     return CFormResult::SetEvent($RESULT_ID, $IN_EVENT1, $IN_EVENT2, $IN_EVENT3, $money, $currency, $goto, $chargeback);
 }
Esempio n. 13
0
 /**
  * Отправляет почтовые уведомления
  */
 protected function sendEmails($resultId)
 {
     \CFormResult::Mail($resultId);
 }
Esempio n. 14
0
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Партнерам");
if (isset($_POST["send"])) {
    CModule::IncludeModule('form');
    $arFields = array(
        "form_text_1" => $_POST["name"],
        "form_text_24" => $_POST["company"],
        "form_text_25" => $_POST["city"],
        "form_text_2" => $_POST["phone"],
        "form_email_3" => $_POST["email"],
        "form_textarea_4" => $_POST["message"],
    );
    if ($RESULT_ID = CFormResult::Add(1, $arFields))
    {
        $successMessage = "Ваше сообщение принято. Спасибо за Ваш отклик.";
    }
    else
    {
        global $strError;
        echo $strError;
    }
}
?>
<?if ($successMessage) : ?>
    <div class="success_message_partner" style="display: none;"><?php 
echo $successMessage;
?>
</div>
<?endif;?>
<?$APPLICATION->IncludeComponent(
Esempio n. 15
0
                    $error = CForm::Check($WEB_FORM_ID, $arrVALUES, $RESULT_ID);
                    if (strlen($error) <= 0) {
                        //echo "<pre>"; print_r($arrVALUES); echo "</pre>";
                        CFormResult::Update($RESULT_ID, $arrVALUES, $EDIT_ADDITIONAL);
                        $strFormNote = GetMessage("FORM_DATA_SAVED");
                        if (strlen($web_form_submit) > 0 && !(defined("ADMIN_SECTION") && ADMIN_SECTION === true)) {
                            LocalRedirect($LIST_URL . "?WEB_FORM_ID=" . $WEB_FORM_ID . "&strFormNote=" . urlencode($strFormNote));
                        } else {
                            $z = CFormResult::GetByID($RESULT_ID);
                            $arrResult = $z->Fetch();
                        }
                    } else {
                        $strError .= $error;
                    }
                } else {
                    $arrVALUES = CFormResult::GetDataByIDForHTML($RESULT_ID, $EDIT_ADDITIONAL);
                }
                $additional = $EDIT_ADDITIONAL == "Y" ? "ALL" : "N";
                CForm::GetDataByID($arrResult["FORM_ID"], $arForm, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $additional);
                echo ShowError($strError);
                echo ShowNote($strFormNote);
                //echo "<pre>"; print_r($arrVALUES); echo "</pre>";
                ?>

				<?php 
                if (!(defined("ADMIN_SECTION") && ADMIN_SECTION === true)) {
                    ?>
				<table cellspacing=0 cellpadding=3 class="tablebody">
					<tr>
						<td><font class="tablebodytext">[&nbsp;<a class="tablebodylink" href="<?php 
                    echo $FORM->arParams["VIEW_URL"];
Esempio n. 16
0
	/**
	 * <p>Создает почтовое событие для отсылки данных <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#result">результата</a> по e-mail. Возвращает "true" в случае успеха, в противном случае - "false".</p>
	 *
	 *
	 *
	 *
	 * @param int $result_id  ID <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#result">результата</a>.
	 *
	 *
	 *
	 * @param mixed $template_id = false ID почтового шаблона.<br><br> Параметр необязательный. По умолчанию -
	 * "false" (будут использованы почтовые шаблоны из настроек
	 * соответствующей веб-формы).
	 *
	 *
	 *
	 * @return bool 
	 *
	 *
	 * <h4>Example</h4> 
	 * <pre>
	 * &lt;?
	 * $RESULT_ID = 189; // ID результата
	 * 
	 * // создадим почтовое событие для отсылки по EMail данных результата
	 * if (<b>CFormResult::Mail</b>($RESULT_ID))
	 * {
	 *     echo "Почтовое событие успешно создано.";
	 * }
	 * else // ошибка
	 * {
	 *     global $strError;
	 *     echo $strError;
	 * }
	 * ?&gt;
	 * </pre>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/form/classes/cformresult/mail.php
	 * @author Bitrix
	 */
	public static function Mail($RESULT_ID, $TEMPLATE_ID = false)
	{
		global $APPLICATION, $DB, $MESS, $strError;

		$err_mess = (CAllFormResult::err_mess())."<br>Function: Mail<br>Line: ";
		$RESULT_ID = intval($RESULT_ID);

		CTimeZone::Disable();
		$arrResult = CFormResult::GetDataByID($RESULT_ID, array(), $arrRES, $arrANSWER);
		CTimeZone::Enable();
		if ($arrResult)
		{
			$z = CForm::GetByID($arrRES["FORM_ID"]);
			if ($arrFORM = $z->Fetch())
			{
				$TEMPLATE_ID = intval($TEMPLATE_ID);

				$arrFormSites = CForm::GetSiteArray($arrRES["FORM_ID"]);
				$arrFormSites = (is_array($arrFormSites)) ? $arrFormSites : array();

				if (!defined('SITE_ID') || !in_array(SITE_ID, $arrFormSites))
					return true;

				$rs = CSite::GetList(($by="sort"), ($order="asc"), array('ID' => implode('|', $arrFormSites)));
				$arrSites = array();
				while ($ar = $rs->Fetch())
				{
					if ($ar["DEF"]=="Y") $def_site_id = $ar["ID"];
					$arrSites[$ar["ID"]] = $ar;
				}

				$arrFormTemplates = CForm::GetMailTemplateArray($arrRES["FORM_ID"]);
				$arrFormTemplates = (is_array($arrFormTemplates)) ? $arrFormTemplates : array();

				$arrTemplates = array();
				$rs = CEventMessage::GetList($by="id", $order="asc", array(
					"ACTIVE"		=> "Y",
					"SITE_ID"		=> SITE_ID,
					"EVENT_NAME"	=> $arrFORM["MAIL_EVENT_TYPE"]
					));

				while ($ar = $rs->Fetch())
				{
					if ($TEMPLATE_ID>0)
					{
						if ($TEMPLATE_ID == $ar["ID"])
						{
							$arrTemplates[$ar["ID"]] = $ar;
							break;
						}
					}
					elseif (in_array($ar["ID"],$arrFormTemplates)) $arrTemplates[$ar["ID"]] = $ar;
				}

				foreach($arrTemplates as $arrTemplate)
				{

					$OLD_MESS = $MESS;
					$MESS = array();
					IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/form/admin/form_mail.php", $arrSites[$arrTemplate["SITE_ID"]]["LANGUAGE_ID"]);

					$USER_AUTH = " ";
					if (intval($arrRES["USER_ID"])>0)
					{
						$w = CUser::GetByID($arrRES["USER_ID"]);
						$arrUSER = $w->Fetch();
						$USER_ID = $arrUSER["ID"];
						$USER_EMAIL = $arrUSER["EMAIL"];
						$USER_NAME = $arrUSER["NAME"]." ".$arrUSER["LAST_NAME"];
						if ($arrRES["USER_AUTH"]!="Y") $USER_AUTH="(".GetMessage("FORM_NOT_AUTHORIZED").")";
					}
					else
					{
						$USER_ID = GetMessage("FORM_NOT_REGISTERED");
						$USER_NAME = "";
						$USER_AUTH = "";
						$USER_EMAIL = "";
					}

					$arEventFields = array(
						"RS_FORM_ID"			=> $arrFORM["ID"],
						"RS_FORM_NAME"			=> $arrFORM["NAME"],
						"RS_FORM_VARNAME"		=> $arrFORM["SID"],
						"RS_FORM_SID"			=> $arrFORM["SID"],
						"RS_RESULT_ID"			=> $arrRES["ID"],
						"RS_DATE_CREATE"		=> $arrRES["DATE_CREATE"],
						"RS_USER_ID"			=> $USER_ID,
						"RS_USER_EMAIL"			=> $USER_EMAIL,
						"RS_USER_NAME"			=> $USER_NAME,
						"RS_USER_AUTH"			=> $USER_AUTH,
						"RS_STAT_GUEST_ID"		=> $arrRES["STAT_GUEST_ID"],
						"RS_STAT_SESSION_ID"	=> $arrRES["STAT_SESSION_ID"]
						);
					$w = CFormField::GetList($arrFORM["ID"], "ALL", $by, $order, array(), $is_filtered);
					while ($wr=$w->Fetch())
					{
						$answer = "";
						$answer_raw = '';
						if (is_array($arrResult[$wr["SID"]]))
						{
							//echo '<pre>'; print_r($wr); echo '</pre>';
							//echo '<pre>'; print_r($arrResult[$wr['SID']]);

							$bHasDiffTypes = false;
							$lastType = '';
							foreach ($arrResult[$wr['SID']] as $arrA)
							{
								if ($lastType == '') $lastType = $arrA['FIELD_TYPE'];
								elseif ($arrA['FIELD_TYPE'] != $lastType)
								{
									$bHasDiffTypes = true;
									break;
								}
							}

							foreach($arrResult[$wr["SID"]] as $arrA)
							{
								if ($wr['ADDITIONAL'] == 'Y')
									$arrA['FIELD_TYPE'] = $wr['FIELD_TYPE'];

								$USER_TEXT_EXIST = (strlen(trim($arrA["USER_TEXT"]))>0);
								$ANSWER_TEXT_EXIST = (strlen(trim($arrA["ANSWER_TEXT"]))>0);
								$ANSWER_VALUE_EXIST = (strlen(trim($arrA["ANSWER_VALUE"]))>0);
								$USER_FILE_EXIST = (intval($arrA["USER_FILE_ID"])>0);

								//echo 'USER_TEXT_EXIST '.$USER_TEXT_EXIST.' '.$USER_TEXT.'<br />';
								//echo 'ANSWER_TEXT_EXIST '.$ANSWER_TEXT_EXIST.' '.$ANSWER_TEXT.'<br />';
								//echo 'ANSWER_VALUE_EXIST '.$ANSWER_VALUE_EXIST.' '.$ANSWER_VALUE.'<br />';
								//echo 'USER_FILE_EXIST '.$USER_FILE_EXIST.' '.$USER_FILE.'<br />';

								if ($arrTemplate["BODY_TYPE"]=="html")
								{
									if (
										$bHasDiffTypes
										&&
										!$USER_TEXT_EXIST
										&&
										(
											$arrA['FIELD_TYPE'] == 'text'
											||
											$arrA['FIELD_TYPE'] == 'textarea'
										)
									)
										continue;

									if (strlen(trim($answer))>0) $answer .= "<br />";
									if (strlen(trim($answer_raw))>0) $answer_raw .= ",";

									if ($ANSWER_TEXT_EXIST)
										$answer .= $arrA["ANSWER_TEXT"].': ';

									switch ($arrA['FIELD_TYPE'])
									{
										case 'text':
										case 'textarea':
										case 'hidden':
										case 'date':
										case 'password':
										case 'integer':

											if ($USER_TEXT_EXIST)
											{
												$answer .= trim($arrA["USER_TEXT"]);
												$answer_raw .= trim($arrA["USER_TEXT"]);
											}

										break;

										case 'email':
										case 'url':

											if ($USER_TEXT_EXIST)
											{
												$answer .= '<a href="'.($arrA['FIELD_TYPE'] == 'email' ? 'mailto:' : '').trim($arrA["USER_TEXT"]).'">'.trim($arrA["USER_TEXT"]).'</a>';
												$answer_raw .= trim($arrA["USER_TEXT"]);
											}

										break;

										case 'checkbox':
										case 'multiselect':
										case 'radio':
										case 'dropdown':

											if ($ANSWER_TEXT_EXIST)
											{
												$answer = substr($answer, 0, -2).' ';
												$answer_raw .= $arrA['ANSWER_TEXT'];
											}

											if ($ANSWER_VALUE_EXIST)
											{
												$answer .= '('.$arrA['ANSWER_VALUE'].') ';
												if (!$ANSWER_TEXT_EXIST)
													$answer_raw .= $arrA['ANSWER_VALUE'];
											}

											if (!$ANSWER_VALUE_EXIST && !$ANSWER_TEXT_EXIST)
												$answer_raw .= $arrA['ANSWER_ID'];

											$answer .= '['.$arrA['ANSWER_ID'].']';

										break;

										case 'file':
										case 'image':

											if ($USER_FILE_EXIST)
											{
												$f = CFile::GetByID($arrA["USER_FILE_ID"]);
												if ($fr = $f->Fetch())
												{
													$file_size = CFile::FormatSize($fr["FILE_SIZE"]);
													$url = ($APPLICATION->IsHTTPS() ? "https://" : "http://").$_SERVER["HTTP_HOST"]. "/bitrix/tools/form_show_file.php?rid=".$RESULT_ID. "&hash=".$arrA["USER_FILE_HASH"]."&lang=".LANGUAGE_ID;

													if ($arrA["USER_FILE_IS_IMAGE"]=="Y")
													{
														$answer .= "<a href=\"$url\">".$arrA["USER_FILE_NAME"]."</a> [".$fr["WIDTH"]." x ".$fr["HEIGHT"]."] (".$file_size.")";
													}
													else
													{
														$answer .= "<a href=\"$url&action=download\">".$arrA["USER_FILE_NAME"]."</a> (".$file_size.")";
													}

													$answer_raw .= $arrA['USER_FILE_NAME'];
												}
											}

										break;
									}
								}
								else
								{
									//echo $bHasDiffTypes.'*'.$USER_TEXT_EXIST.'<br />';

									if (
										$bHasDiffTypes
										&&
										!$USER_TEXT_EXIST
										&&
										(
											$arrA['FIELD_TYPE'] == 'text'
											||
											$arrA['FIELD_TYPE'] == 'textarea'
										)
									)
										continue;

									if (strlen(trim($answer)) > 0) $answer .= "\n";
									if (strlen(trim($answer_raw)) > 0) $answer_raw .= ",";

									if ($ANSWER_TEXT_EXIST)
										$answer .= $arrA["ANSWER_TEXT"].': ';

									switch ($arrA['FIELD_TYPE'])
									{
										case 'text':
										case 'textarea':
										case 'email':
										case 'url':
										case 'hidden':
										case 'date':
										case 'password':
										case 'integer':

											if ($USER_TEXT_EXIST)
											{
												$answer .= trim($arrA["USER_TEXT"]);
												$answer_raw .= trim($arrA["USER_TEXT"]);
											}

										break;

										case 'checkbox':
										case 'multiselect':
										case 'radio':
										case 'dropdown':

											if ($ANSWER_TEXT_EXIST)
											{
												$answer = substr($answer, 0, -2).' ';
												$answer_raw .= $arrA['ANSWER_TEXT'];
											}

											if ($ANSWER_VALUE_EXIST)
											{
												$answer .= '('.$arrA['ANSWER_VALUE'].') ';
												if (!$ANSWER_TEXT_EXIST)
												{
													$answer_raw .= $arrA['ANSWER_VALUE'];
												}
											}

											if (!$ANSWER_VALUE_EXIST && !$ANSWER_TEXT_EXIST)
											{
												$answer_raw .= $arrA['ANSWER_ID'];
											}

											$answer .= '['.$arrA['ANSWER_ID'].']';

										break;

										case 'file':
										case 'image':

											if ($USER_FILE_EXIST)
											{
												$f = CFile::GetByID($arrA["USER_FILE_ID"]);
												if ($fr = $f->Fetch())
												{
													$file_size = CFile::FormatSize($fr["FILE_SIZE"]);
													$url = ($APPLICATION->IsHTTPS() ? "https://" : "http://").$_SERVER["HTTP_HOST"]. "/bitrix/tools/form_show_file.php?rid=".$RESULT_ID. "&hash=".$arrA["USER_FILE_HASH"]."&action=download&lang=".LANGUAGE_ID;

													if ($arrA["USER_FILE_IS_IMAGE"]=="Y")
													{
														$answer .= $arrA["USER_FILE_NAME"]." [".$fr["WIDTH"]." x ".$fr["HEIGHT"]."] (".$file_size.")\n".$url;
													}
													else
													{
														$answer .= $arrA["USER_FILE_NAME"]." (".$file_size.")\n".$url."&action=download";
													}
												}

												$answer_raw .= $arrA['USER_FILE_NAME'];
											}

										break;
									}
								}
							}
						}

						$arEventFields[$wr["SID"]] = (strlen($answer)<=0) ? " " : $answer;
						$arEventFields[$wr["SID"].'_RAW'] = (strlen($answer_raw)<=0) ? " " : $answer_raw;
					}

					CEvent::Send($arrTemplate["EVENT_NAME"], $arrTemplate["SITE_ID"], $arEventFields, "Y", $arrTemplate["ID"]);
					$MESS = $OLD_MESS;
				} //foreach($arrTemplates as $arrTemplate)
				return true;
			}
			else $strError .= GetMessage("FORM_ERROR_FORM_NOT_FOUND")."<br>";
		}
		else $strError .= GetMessage("FORM_ERROR_RESULT_NOT_FOUND")."<br>";
		return false;
	}
Esempio n. 17
0
			{
				// check user session
				if (check_bitrix_sessid())
				{
					$return = false;

					// add result
					if($RESULT_ID = CFormResult::Add($arParams["WEB_FORM_ID"], $arResult["arrVALUES"]))
					{
						//$arResult["FORM_NOTE"] = GetMessage("FORM_DATA_SAVED1").$RESULT_ID.GetMessage("FORM_DATA_SAVED2");
						$arResult["FORM_RESULT"] = 'addok';

						// send email notifications
						CFormCRM::onResultAdded($arParams["WEB_FORM_ID"], $RESULT_ID);
						CFormResult::SetEvent($RESULT_ID);
						CFormResult::Mail($RESULT_ID);

						// choose type of user redirect and do it

						if ($arResult["F_RIGHT"] >= 15)
						{
							if (strlen($_REQUEST["web_form_submit"])>0 && strlen($arParams["LIST_URL"]) > 0)
							{
								if ($arParams["SEF_MODE"] == "Y")
								{
									//LocalRedirect($arParams["LIST_URL"]."?strFormNote=".urlencode($arResult["FORM_NOTE"]));
									LocalRedirect(
										str_replace(
											array('#WEB_FORM_ID#', '#RESULT_ID#'),
											array($arParams['WEB_FORM_ID'], $RESULT_ID),
											$arParams["LIST_URL"]
Esempio n. 18
0
            if (in_array("VIEW", $arrRESULT_PERMISSION)) {
                $additional = $SHOW_ADDITIONAL == "Y" ? "ALL" : "N";
                CForm::GetDataByID($WEB_FORM_ID, $arForm, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $additional);
                CForm::GetResultAnswerArray($WEB_FORM_ID, $arrResultColumns, $arrResultAnswers, $arrResultAnswersSID, array("RESULT_ID" => $RESULT_ID));
                $arrResultAnswers = $arrResultAnswers[$RESULT_ID];
                echo ShowError($strError);
                echo ShowNote($strFormNote);
                if (!(defined("ADMIN_SECTION") && ADMIN_SECTION === true)) {
                    ?>
				<table cellspacing="0" cellpadding="3" class="tablebody">
				<tr>
					<?php 
                    // check user permission for access to web-form
                    if ($F_RIGHT >= 20 || $F_RIGHT >= 15 && $arrResult["USER_ID"] == $USER->GetID()) {
                        // check user permission to access in dependence of status
                        $arrRESULT_PERMISSION = CFormResult::GetPermissions($RESULT_ID, $v);
                        if (in_array("EDIT", $arrRESULT_PERMISSION)) {
                            ?>
							<td><font class="tablebodytext">[&nbsp;<a class="tablebodylink" href="<?php 
                            echo $EDIT_URL;
                            ?>
?RESULT_ID=<?php 
                            echo $RESULT_ID;
                            ?>
&WEB_FORM_ID=<?php 
                            echo $WEB_FORM_ID;
                            ?>
"><?php 
                            echo GetMessage("FORM_EDIT");
                            ?>
</a>&nbsp;]</font></td>
Esempio n. 19
0
								$arAnswer["ID"],
								$arAnswer["FIELD_WIDTH"],
								"IMAGE",
								0,
								"",
								$arAnswer["FIELD_PARAM"]);

							$arResult["QUESTIONS"][$FIELD_SID]["HTML_CODE"][] = $res;

							break;
						case "file":
							if (strlen(trim($arAnswer["MESSAGE"]))>0)
							{
								$res .= $arAnswer["MESSAGE"];
							}
							if ($arFile = CFormResult::GetFileByAnswerID($arParams["RESULT_ID"], $arAnswer["ID"]))
							{
								if (intval($arFile["USER_FILE_ID"])>0)
								{
									$res .= "<a title=\"".GetMessage("FORM_VIEW_FILE")."\" target=\"_blank\" class=\"tablebodylink\" href=\"/freetrix/tools/form_show_file.php?rid=".$arParams["RESULT_ID"]."&hash=".$arFile["USER_FILE_HASH"]."&lang=".LANGUAGE_ID."\">".htmlspecialcharsbx($arFile["USER_FILE_NAME"])."</a>&nbsp;(";
									$res .= CFile::FormatSize($arFile["USER_FILE_SIZE"]);
									$res .= ")&nbsp;&nbsp;[&nbsp;<a title=\"".str_replace("#FILE_NAME#", $arFile["USER_FILE_NAME"], GetMessage("FORM_DOWNLOAD_FILE"))."\" class=\"tablebodylink\" href=\"/freetrix/tools/form_show_file.php?rid=".$arParams["RESULT_ID"]."&hash=".$arFile["USER_FILE_HASH"]."&lang=".LANGUAGE_ID."&action=download\">".GetMessage("FORM_DOWNLOAD")."</a>&nbsp;]<br />";
									$res .= '<input type="checkbox" value="Y" name="form_file_'.$arAnswer['ID'].'_del" id="form_file_'.$arAnswer['ID'].'_del" /><label for="form_file_'.$arAnswer['ID'].'_del">'.GetMessage('FORM_DELETE_FILE').'</label><br />';

									$res .= "<br />";
								} //endif;
							} //endif;


							$res .= CForm::GetFileField(
								$arAnswer["ID"],
Esempio n. 20
0
     if (is_array($arResult["arRID"]) && count($arResult["arRID"]) > 0) {
         $i = 0;
         foreach ($arResult["arRID"] as $rid) {
             if ($i >= $pagen_from && $i < $pagen_from + $page_split) {
                 $arRID_tmp[] = $rid;
                 // array of IDs of results for the page
             }
             $i++;
         }
     }
     $arResult["arRID"] = $arRID_tmp;
 }
 $arResult["arrResults"] = array();
 $arrUsers = array();
 while ($arRes = $rsResults->NavNext(false)) {
     $arRes["arrRESULT_PERMISSION"] = CFormResult::GetPermissions($arRes["ID"], $v);
     $arRes["can_view"] = false;
     $arRes["can_edit"] = false;
     $arRes["can_delete"] = false;
     if ($arParams["F_RIGHT"] >= 20 || $arParams["F_RIGHT"] >= 15 && $arParams["USER_ID"] == $arRes["USER_ID"]) {
         if (in_array("VIEW", $arRes["arrRESULT_PERMISSION"])) {
             $arRes["can_view"] = true;
         }
         if (in_array("EDIT", $arRes["arrRESULT_PERMISSION"])) {
             $arRes["can_edit"] = true;
         }
         if (in_array("DELETE", $arRes["arrRESULT_PERMISSION"])) {
             $arRes["can_delete"] = true;
         }
     }
     $arr = explode(" ", $arRes["TIMESTAMP_X"]);
Esempio n. 21
0
 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();
                 }
             }
         }
     }
 }
Esempio n. 22
0
        $arResult['FORMS'][$FORM_ID] = $arForm;
        $arResult['RESULTS'][$FORM_ID] = array();
        $dbRes = CFormResult::GetList($FORM_ID, $by = 's_timestamp', $order = 'desc', array('USER_ID' => $USER->GetID()), $is_filtered, 'Y', $arParams['NUM_RESULTS']);
        $bFirst = true;
        while ($arRes = $dbRes->GetNext()) {
            //if ($FORM_ID == 6) print_r($arRes);
            if ($bFirst) {
                $arResult['FORMS'][$FORM_ID]['__LAST_TS'] = MakeTimeStamp($arRes['TIMESTAMP_X']);
                $bFirst = false;
            }
            $arValues = CFormResult::GetDataByID($arRes['ID'], array(), $arRes1 = null, $arAnswers = null);
            //if ($FORM_ID == 6) print_r($arValues);
            reset($arValues);
            list(, $first_res) = each($arValues);
            $arRes['__TITLE'] = trim($first_res[0]['USER_TEXT'] ? $first_res[0]['USER_TEXT'] : $first_res[0]['MESSAGE']);
            $arRes['__RIGHTS'] = CFormResult::GetPermissions($arRes['ID'], $status);
            if ($arParams['EDIT_URL'] && in_array('EDIT', $arRes['__RIGHTS'])) {
                $arRes['__LINK'] = str_replace(array('#FORM_ID#', '#RESULT_ID#'), array($FORM_ID, $arRes['ID']), $arParams['EDIT_URL']);
            } elseif ($arParams['VIEW_URL']) {
                $arRes['__LINK'] = str_replace(array('#FORM_ID#', '#RESULT_ID#'), array($FORM_ID, $arRes['ID']), $arParams['VIEW_URL']);
            }
            $arResult['RESULTS'][$FORM_ID][] = $arRes;
        }
    }
    if (!is_array($arResult['RESULTS'][$FORM_ID]) || count($arResult['RESULTS'][$FORM_ID]) <= 0) {
        unset($arResult['FORMS'][$FORM_ID]);
        unset($arResult['RESULTS'][$FORM_ID]);
    }
}
//echo '<pre>'; print_r($arResult['RESULTS'][6]); /*print_r($arResult['FORMS'][6]);*/ echo '</pre>';
if (!function_exists('BX_FSBT')) {
Esempio n. 23
0
			}
		}
	}
}

// если была нажата кнопка "—охранить изменени¤"
if (strlen($save)>0 && $REQUEST_METHOD=="POST" && (check_freetrix_sessid() || defined("FORM_NOT_CHECK_SESSID")))
{
	// обновл¤ем записи
	if (isset($RESULT_ID) && is_array($RESULT_ID))
	{
		foreach ($RESULT_ID as $rid)
		{
			$rid = intval($rid);
			$var_STATUS_PREV = "STATUS_PREV_".$rid;
			$var_STATUS = "STATUS_".$rid;
			if (intval($$var_STATUS)>0 && $$var_STATUS_PREV!=$$var_STATUS)
			{
				CFormResult::SetStatus($rid, $$var_STATUS);
			}
		}
	}
}
//echo "<pre>"; print_r($_REQUEST); echo "</pre>";
//echo "<pre>"; print_r($arFilter); echo "</pre>";
$result = CFormResult::GetList($WEB_FORM_ID, $by, $order, $arFilter, $is_filtered);

$HELP_FILE_ACCESS = $APPLICATION->GetFileAccessPermission("/freetrix/modules/form/help/".LANGUAGE_ID."/index.php");
$MODULE_RIGHT = $APPLICATION->GetGroupRight("form");
$MAIN_RIGHT = $APPLICATION->GetGroupRight("main");
?>
Esempio n. 24
0
	function UpdateField($arFields, $RESULT_ID, $FIELD_ID)
	{
		$err_mess = (CFormResult::err_mess())."<br>Function: UpdateField<br>Line: ";
		global $DB, $strError;
		$RESULT_ID = intval($RESULT_ID);
		$FIELD_ID = intval($FIELD_ID);
		$strUpdate = $DB->PrepareUpdate("b_form_result_answer", $arFields, "form");
		$strSql = "UPDATE b_form_result_answer SET ".$strUpdate." WHERE RESULT_ID=".$RESULT_ID." and FIELD_ID=".$FIELD_ID;
		$DB->Query($strSql, false, $err_mess.__LINE__);
	}
Esempio n. 25
0
 /**
  * <p>Вставка полей ответа на вопрос в шаблон. Параметры поля ввода задаются в настройках вопроса.</p>
  *
  *
  * @param string $FIELD_SID  Строковой идентификатор поля вопроса. Обязательный параметр.
  *
  * @param  $string  CSS-класс для подписи к полю ввода. Необязательный параметр.
  *
  * @param mixed $CSSClass = ""] 
  *
  * @return string <p>Возвращается HTML-код для вставки полей формы</p> <a
  * name="examples"></a><h4>Использование</h4> <pre class="syntax"> &lt;?=$FORM-&gt;ShowInput('MYFIELD_5')?&gt;
  * </pre>
  *
  * <h4>See Also</h4> 
  * <menu> <li><a href="http://dev.1c-bitrix.ru/api_help/form/classes/cformoutput/index.php">Класс CFormOutput</a></li>
  * <li><a
  * href="http://dev.1c-bitrix.ru/api_help/form/classes/cformoutput/showinputcaption.php">CFormOutput::ShowInputCaption</a></li>
  * <li><a
  * href="http://dev.1c-bitrix.ru/api_help/form/classes/cformoutput/showinputcaptionimage.php">CFormOutput::ShowInputCaptionImage</a></li>
  * </menu></b<br><br>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/form/classes/cformoutput/showinput.php
  * @author Bitrix
  */
 public function ShowInput($FIELD_SID, $caption_css_class = '')
 {
     $arrVALUES = $this->arrVALUES;
     if (is_array($this->arAnswers[$FIELD_SID])) {
         $res = "";
         reset($this->arAnswers[$FIELD_SID]);
         if (is_array($this->arDropDown[$FIELD_SID])) {
             reset($this->arDropDown[$FIELD_SID]);
         }
         if (is_array($this->arMutiselect[$FIELD_SID])) {
             reset($this->arMutiselect[$FIELD_SID]);
         }
         while (list($key, $arAnswer) = each($this->arAnswers[$FIELD_SID])) {
             if ($arAnswer["FIELD_TYPE"] == "dropdown" && $show_dropdown == "Y") {
                 continue;
             }
             if ($arAnswer["FIELD_TYPE"] == "multiselect" && $show_multiselect == "Y") {
                 continue;
             }
             if ($key > 0) {
                 $res .= "<br />";
             }
             switch ($arAnswer["FIELD_TYPE"]) {
                 case "radio":
                     $ans_id = "form_checkbox_" . $FIELD_SID . "_" . $arAnswer['ID'];
                     $arAnswer['FIELD_PARAM'] .= ' id="' . $ans_id . '"';
                     $value = CForm::GetRadioValue($FIELD_SID, $arAnswer, $arrVALUES);
                     $input = CForm::GetRadioField($FIELD_SID, $arAnswer["ID"], $value, $arAnswer["FIELD_PARAM"]);
                     if (strlen($ans_id) > 0) {
                         $res .= $input;
                         $res .= "<label for=\"" . $ans_id . "\">";
                         $res .= "<span class=\"" . $caption_css_class . "\">&nbsp;" . $arAnswer["MESSAGE"] . "</span></label>";
                     } else {
                         $res .= "<label>";
                         $res .= $input;
                         $res .= "<span class=\"" . $caption_css_class . "\">&nbsp;" . $arAnswer["MESSAGE"] . "</span></label>";
                     }
                     break;
                 case "checkbox":
                     $ans_id = "form_checkbox_" . $FIELD_SID . "_" . $arAnswer['ID'];
                     $arAnswer['FIELD_PARAM'] .= ' id="' . $ans_id . '"';
                     $value = CForm::GetCheckBoxValue($FIELD_SID, $arAnswer, $arrVALUES);
                     $input = CForm::GetCheckBoxField($FIELD_SID, $arAnswer["ID"], $value, $arAnswer["FIELD_PARAM"]);
                     if (strlen($ans_id) > 0) {
                         $res .= $input;
                         $res .= "<label for=\"" . $ans_id . "\">";
                         $res .= "<span class=\"" . $caption_css_class . "\">&nbsp;" . $arAnswer["MESSAGE"] . "</span></label>";
                     } else {
                         $res .= "<label>";
                         $res .= $input;
                         $res .= "<span class=\"" . $caption_css_class . "\">&nbsp;" . $arAnswer["MESSAGE"] . "</span></label>";
                     }
                     break;
                 case "dropdown":
                     if ($show_dropdown != "Y") {
                         $value = CForm::GetDropDownValue($FIELD_SID, $this->arDropDown, $arrVALUES);
                         $res .= CForm::GetDropDownField($FIELD_SID, $this->arDropDown[$FIELD_SID], $value, $arAnswer["FIELD_PARAM"]);
                         $show_dropdown = "Y";
                     }
                     break;
                 case "multiselect":
                     if ($show_multiselect != "Y") {
                         $value = CForm::GetMultiSelectValue($FIELD_SID, $this->arMultiSelect, $arrVALUES);
                         $res .= CForm::GetMultiSelectField($FIELD_SID, $this->arMultiSelect[$FIELD_SID], $value, $arAnswer["FIELD_HEIGHT"], $arAnswer["FIELD_PARAM"]);
                         $show_multiselect = "Y";
                     }
                     break;
                 case "text":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetTextValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetTextField($arAnswer["ID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "hidden":
                     /*
                     if (strlen(trim($arAnswer["MESSAGE"]))>0)
                     {
                     	$res .= "<span class=\"".$caption_css_class."\">".$arAnswer["MESSAGE"]."</span><br />";
                     }
                     */
                     $value = CForm::GetHiddenValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetHiddenField($arAnswer["ID"], $value, $arAnswer["FIELD_PARAM"]);
                     break;
                 case "password":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetPasswordValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetPasswordField($arAnswer["ID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "email":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetEmailValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetEmailField($arAnswer["ID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "url":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetUrlValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetUrlField($arAnswer["ID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "textarea":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetTextAreaValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetTextAreaField($arAnswer["ID"], $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_HEIGHT"], $arAnswer["FIELD_PARAM"], $value);
                     break;
                 case "date":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . " (" . CSite::GetDateFormat("SHORT") . ")</span><br />";
                     }
                     $value = CForm::GetDateValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetDateField($arAnswer["ID"], $this->arForm["SID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "image":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     if ($this->RESULT_ID) {
                         if ($arFile = CFormResult::GetFileByAnswerID($this->RESULT_ID, $arAnswer["ID"])) {
                             if (intval($arFile["USER_FILE_ID"]) > 0) {
                                 if ($arFile["USER_FILE_IS_IMAGE"] == "Y") {
                                     $res .= CFile::ShowImage($arFile["USER_FILE_ID"], 0, 0, "border=0", "", true);
                                     $res .= "<br />";
                                 }
                                 //endif;
                             }
                             //endif;
                         }
                         // endif
                     }
                     // endif
                     $res .= CForm::GetFileField($arAnswer["ID"], $arAnswer["FIELD_WIDTH"], "IMAGE", 0, "", $arAnswer["FIELD_PARAM"]);
                     break;
                 case "file":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     if ($this->RESULT_ID) {
                         if ($arFile = CFormResult::GetFileByAnswerID($this->RESULT_ID, $arAnswer["ID"])) {
                             if (intval($arFile["USER_FILE_ID"]) > 0) {
                                 $res .= "<a title=\"" . GetMessage("FORM_VIEW_FILE") . "\" target=\"_blank\" class=\"tablebodylink\" href=\"/bitrix/tools/form_show_file.php?rid=" . $this->RESULT_ID . "&hash=" . $arFile["USER_FILE_HASH"] . "&lang=" . LANGUAGE_ID . "\">" . htmlspecialcharsbx($arFile["USER_FILE_NAME"]) . "</a>&nbsp;(";
                                 $res .= CFile::FormatSize($arFile["USER_FILE_SIZE"]);
                                 $res .= ")&nbsp;&nbsp;[&nbsp;<a title=\"" . str_replace("#FILE_NAME#", $arFile["USER_FILE_NAME"], GetMessage("FORM_DOWNLOAD_FILE")) . "\" class=\"tablebodylink\" href=\"/bitrix/tools/form_show_file.php?rid=" . $this->RESULT_ID . "&hash=" . $arFile["USER_FILE_HASH"] . "&lang=" . LANGUAGE_ID . "&action=download\">" . GetMessage("FORM_DOWNLOAD") . "</a>&nbsp;]";
                                 $res .= "<br /><br />";
                             }
                             //endif;
                         }
                         //endif;
                     }
                     $res .= CForm::GetFileField($arAnswer["ID"], $arAnswer["FIELD_WIDTH"], "FILE", 0, "", $arAnswer["FIELD_PARAM"]);
                     break;
             }
             //endswitch;
         }
         //endwhile;
         return $res;
     } elseif (is_array($this->arQuestions[$FIELD_SID]) && $this->arQuestions[$FIELD_SID]["ADDITIONAL"] == "Y") {
         $res = "";
         switch ($this->arQuestions[$FIELD_SID]["FIELD_TYPE"]) {
             case "text":
                 $value = CForm::GetTextAreaValue("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], array(), $this->arrVALUES);
                 $res .= CForm::GetTextAreaField("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], "60", "5", "", $value);
                 break;
             case "integer":
                 $value = CForm::GetTextValue("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], array(), $this->arrVALUES);
                 $res .= CForm::GetTextField("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], $value);
                 break;
             case "date":
                 $value = CForm::GetDateValue("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], array(), $this->arrVALUES);
                 $res .= CForm::GetDateField("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], $arForm["SID"], $value);
                 break;
         }
         //endswitch;
         return $res;
     } else {
         return "";
     }
 }
Esempio n. 26
0
                //endif(!is_array($arrNOT_SHOW_TABLE) || !in_array($arrCol["SID"],$arrNOT_SHOW_TABLE));
            }
            //endwhile(list($key, $arrCol) = each($arrColumns)) ;
        }
        //endif(is_array($arrColumns)) ;
        ?>
						</tr>
						<?php 
        /***********************************************
        						  table body
        			************************************************/
        $j = 0;
        $arrUsers = array();
        while ($arResult = $rsResults->NavNext(true, "f_")) {
            $j++;
            $arrRESULT_PERMISSION = CFormResult::GetPermissions($GLOBALS["f_ID"], $v);
            //echo "<tr><td colspan=10><pre>"; print_r($arrRESULT_PERMISSION); echo "</pre></td></tr>";
            $can_view = false;
            $can_edit = false;
            $can_delete = false;
            if ($F_RIGHT >= 20 || $F_RIGHT >= 15 && $USER_ID == $GLOBALS["f_USER_ID"]) {
                if (in_array("VIEW", $arrRESULT_PERMISSION)) {
                    $can_view = true;
                }
                if (in_array("EDIT", $arrRESULT_PERMISSION)) {
                    $can_edit = true;
                }
                if (in_array("DELETE", $arrRESULT_PERMISSION)) {
                    $can_delete = true;
                }
            }
Esempio n. 27
0
	public static function AddLead($FORM_ID, $RESULT_ID, $arLink = null)
	{
		$FORM_ID = intval($FORM_ID);
		$RESULT_ID = intval($RESULT_ID);

		if ($FORM_ID <= 0 || $RESULT_ID <= 0)
			return false;

		if (!is_array($arLink))
		{
			$dbRes = CFormCrm::GetByFormID($FORM_ID);
			$arLink = $dbRes->Fetch();
		}

		if (!$arLink)
			return false;

		$arResultFields = array();
		$arAnswers = array();

		CFormResult::GetDataByID($RESULT_ID, array(), $arResultFields, $arAnswers);

		$ob = new CFormCrmSender($arLink['CRM_ID']);
		$arCrmF = $ob->GetFields();
		$arCrmFields = array();
		foreach ($arCrmF as $ar)
			$arCrmFields[$ar['ID']] = $ar;

		$arLeadFields = array();
		$dbRes = CFormCrm::GetFields($arLink['ID']);
		while ($arRes = $dbRes->Fetch())
		{
			if (intval($arRes['FIELD_ID']) > 0)
			{
				$bFound = false;
				foreach ($arAnswers as $sid => $arAnswer)
				{
					foreach ($arAnswer as $answer_id => $arAns)
					{
						if ($arAns['FIELD_ID'] == $arRes['FIELD_ID'])
						{
							$bFound = true;
							if ($arCrmFields[$arRes['CRM_FIELD']])
							{
								switch ($arCrmFields[$arRes['CRM_FIELD']]['TYPE'])
								{
									case 'enum':
									{
										if ($arAns['FIELD_TYPE'] == 'dropdown' || $arAns['FIELD_TYPE'] == 'checkbox' || $arAns['FIELD_TYPE'] == 'radio' || $arAns['FIELD_TYPE'] == 'multiselect')
										{
											$arLeadFields[$arRes['CRM_FIELD']] = $arAns['VALUE'];
										}
										else
										{
											$arLeadFields[$arRes['CRM_FIELD']] = $arAns['ANSWER_TEXT'];
										}
									}
									break;
									case 'boolean':
										$arLeadFields[$arRes['CRM_FIELD']] = 'Y';
									break;
									default:
										$arLeadFields[$arRes['CRM_FIELD']] = (strlen($arAns['USER_TEXT']) > 0
											? $arAns['USER_TEXT']
											: (
												strlen($arAns['ANSWER_TEXT']) > 0
												? $arAns['ANSWER_TEXT']
												: $arAns['VALUE']
											)
										);
								}
							}
						}
					}
				}

				if (!$bFound && $arCrmFields[$arRes['CRM_FIELD']] && $arCrmFields[$arRes['CRM_FIELD']]['TYPE'] == 'boolean')
				{
					$arLeadFields[$arRes['CRM_FIELD']] = 'N';
				}
			}
			elseif (strlen($arRes['FIELD_ALT']) > 0)
			{
				switch($arRes['FIELD_ALT'])
				{
					case 'RESULT_ID':
						$arLeadFields[$arRes['CRM_FIELD']] = $arResultFields['ID'];
					break;
					case 'FORM_SID':
						$arLeadFields[$arRes['CRM_FIELD']] = $arResultFields['SID'];
					break;
					case 'FORM_NAME':
						$arLeadFields[$arRes['CRM_FIELD']] = $arResultFields['NAME'];
					break;
					case 'SITE_ID':
						$arLeadFields[$arRes['CRM_FIELD']] = SITE_ID;
					break;
					case 'FORM_ALL':
						$arLeadFields[$arRes['CRM_FIELD']] = self::_getAllFormFields($FORM_ID, $RESULT_ID, $arAnswers);
					break;
					case 'FORM_ALL_HTML':
						$arLeadFields[$arRes['CRM_FIELD']] = self::_getAllFormFieldsHTML($FORM_ID, $RESULT_ID, $arAnswers);
					break;
				}
			}
		}

		$result = $ob->AddLead($arLeadFields);
		if ($result->code() != 201)
		{
			$GLOBALS['APPLICATION']->ThrowException($result->error(), $result->code());
			return false;
		}
		else
		{
			CFormResult::SetCRMFlag($RESULT_ID, 'Y');
			return $result->field('ID');
		}
	}
Esempio n. 28
0
 function Mail($RESULT_ID, $TEMPLATE_ID = false)
 {
     global $DB, $MESS, $strError;
     $err_mess = CAllFormResult::err_mess() . "<br>Function: Mail<br>Line: ";
     $RESULT_ID = intval($RESULT_ID);
     if ($arrResult = CFormResult::GetDataByID($RESULT_ID, array(), $arrRES, $arrANSWER)) {
         $z = CForm::GetByID($arrRES["FORM_ID"]);
         if ($arrFORM = $z->Fetch()) {
             $TEMPLATE_ID = intval($TEMPLATE_ID);
             $rs = CSite::GetList($by = "sort", $order = "asc");
             while ($ar = $rs->Fetch()) {
                 $arrSites[$ar["ID"]] = $ar;
             }
             $arrFormSites = CForm::GetSiteArray($arrRES["FORM_ID"]);
             $arrFormSites = is_array($arrFormSites) ? $arrFormSites : array();
             $arrFormTemplates = CForm::GetMailTemplateArray($arrRES["FORM_ID"]);
             $arrFormTemplates = is_array($arrFormTemplates) ? $arrFormTemplates : array();
             $arrTemplates = array();
             $rs = CEventMessage::GetList($by = "id", $order = "asc", array("ACTIVE" => "Y", "SITE_ID" => $arrFormSites, "EVENT_NAME" => $arrFORM["MAIL_EVENT_TYPE"]));
             while ($ar = $rs->Fetch()) {
                 if ($TEMPLATE_ID > 0) {
                     if ($TEMPLATE_ID == $ar["ID"]) {
                         $arrTemplates[$ar["ID"]] = $ar;
                         break;
                     }
                 } elseif (in_array($ar["ID"], $arrFormTemplates)) {
                     $arrTemplates[$ar["ID"]] = $ar;
                 }
             }
             foreach ($arrTemplates as $arrTemplate) {
                 $OLD_MESS = $MESS;
                 $MESS = array();
                 IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/form/form_mail.php", $arrSites[$arrTemplate["SITE_ID"]]["LANGUAGE_ID"]);
                 $USER_AUTH = " ";
                 if (intval($arrRES["USER_ID"]) > 0) {
                     $w = CUser::GetByID($arrRES["USER_ID"]);
                     $arrUSER = $w->Fetch();
                     $USER_ID = $arrUSER["ID"];
                     $USER_EMAIL = $arrUSER["EMAIL"];
                     $USER_NAME = $arrUSER["NAME"] . " " . $arrUSER["LAST_NAME"];
                     if ($arrRES["USER_AUTH"] != "Y") {
                         $USER_AUTH = "(" . GetMessage("FORM_NOT_AUTHORIZED") . ")";
                     }
                 } else {
                     $USER_ID = GetMessage("FORM_NOT_REGISTERED");
                     $USER_NAME = "";
                     $USER_AUTH = "";
                     $USER_EMAIL = "";
                 }
                 $arEventFields = array("RS_FORM_ID" => $arrFORM["ID"], "RS_FORM_NAME" => $arrFORM["NAME"], "RS_FORM_VARNAME" => $arrFORM["SID"], "RS_FORM_SID" => $arrFORM["SID"], "RS_RESULT_ID" => $arrRES["ID"], "RS_DATE_CREATE" => $arrRES["DATE_CREATE"], "RS_USER_ID" => $USER_ID, "RS_USER_EMAIL" => $USER_EMAIL, "RS_USER_NAME" => $USER_NAME, "RS_USER_AUTH" => $USER_AUTH, "RS_STAT_GUEST_ID" => $arrRES["STAT_GUEST_ID"], "RS_STAT_SESSION_ID" => $arrRES["STAT_SESSION_ID"]);
                 $w = CFormField::GetList($arrFORM["ID"], "ALL", $by, $order, array(), $is_filtered);
                 while ($wr = $w->Fetch()) {
                     $answer = "";
                     if (is_array($arrResult[$wr["SID"]])) {
                         foreach ($arrResult[$wr["SID"]] as $arrA) {
                             $USER_TEXT_EXIST = strlen(trim($arrA["USER_TEXT"])) > 0;
                             $ANSWER_TEXT_EXIST = strlen(trim($arrA["ANSWER_TEXT"])) > 0;
                             $ANSWER_VALUE_EXIST = strlen(trim($arrA["ANSWER_VALUE"])) > 0;
                             $USER_FILE_EXIST = intval($arrA["USER_FILE_ID"]) > 0;
                             if ($arrTemplate["BODY_TYPE"] == "html") {
                                 if (strlen(trim($answer)) > 0) {
                                     $answer .= "<br>";
                                 }
                                 if ($USER_TEXT_EXIST) {
                                     $answer .= $arrA["USER_TEXT"];
                                     if ($ANSWER_TEXT_EXIST || $ANSWER_VALUE_EXIST || $USER_FILE_EXIST) {
                                         $answer .= " ";
                                     }
                                 }
                                 if ($ANSWER_TEXT_EXIST) {
                                     $answer .= $arrA["ANSWER_TEXT"];
                                     if ($ANSWER_VALUE_EXIST || $USER_FILE_EXIST) {
                                         $answer .= " ";
                                     }
                                 }
                                 if ($ANSWER_VALUE_EXIST) {
                                     $answer .= $arrA["ANSWER_VALUE"];
                                     if ($USER_FILE_EXIST) {
                                         $answer .= " ";
                                     }
                                 }
                                 if ($USER_FILE_EXIST) {
                                     $f = CFile::GetByID($arrA["USER_FILE_ID"]);
                                     if ($fr = $f->Fetch()) {
                                         $a = array("b", "Kb", "Mb", "Gb");
                                         $pos = 0;
                                         $size = $arrA["USER_FILE_SIZE"];
                                         while ($size >= 1024) {
                                             $size /= 1024;
                                             $pos++;
                                         }
                                         $file_size = round($size, 2) . " " . $a[$pos];
                                         if ($arrA["USER_FILE_IS_IMAGE"] == "Y") {
                                             $url = "http://" . $_SERVER["HTTP_HOST"] . "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/" . $fr["SUBDIR"] . "/" . $fr["FILE_NAME"];
                                             $answer .= "<a href=\"{$url}\">" . $arrA["USER_FILE_NAME"] . "</a> [" . $fr["WIDTH"] . " x " . $fr["HEIGHT"] . "] (" . $file_size . ")";
                                         } else {
                                             $url = "http://" . $_SERVER["HTTP_HOST"] . "/bitrix/tools/form_show_file.php?rid=" . $RESULT_ID . "&hash=" . $arrA["USER_FILE_HASH"] . "&action=download&&lang=" . LANGUAGE_ID;
                                             $answer .= "<a href=\"{$url}\">" . $arrA["USER_FILE_NAME"] . "</a> (" . $file_size . ")";
                                         }
                                     }
                                 }
                             } else {
                                 if (strlen(trim($answer)) > 0) {
                                     $answer .= "\n";
                                 }
                                 if ($USER_TEXT_EXIST) {
                                     $answer .= trim($arrA["USER_TEXT"]);
                                     if ($ANSWER_TEXT_EXIST || $ANSWER_VALUE_EXIST || $USER_FILE_EXIST) {
                                         $answer .= " ";
                                     }
                                 }
                                 if ($ANSWER_TEXT_EXIST) {
                                     $answer .= $arrA["ANSWER_TEXT"];
                                     if ($ANSWER_VALUE_EXIST || $USER_FILE_EXIST) {
                                         $answer .= " ";
                                     }
                                 }
                                 if ($ANSWER_VALUE_EXIST) {
                                     $answer .= $arrA["ANSWER_VALUE"];
                                     if ($USER_FILE_EXIST) {
                                         $answer .= " ";
                                     }
                                 }
                                 if ($USER_FILE_EXIST) {
                                     $f = CFile::GetByID($arrA["USER_FILE_ID"]);
                                     if ($fr = $f->Fetch()) {
                                         $a = array("b", "Kb", "Mb", "Gb");
                                         $pos = 0;
                                         $size = $arrA["USER_FILE_SIZE"];
                                         while ($size >= 1024) {
                                             $size /= 1024;
                                             $pos++;
                                         }
                                         $file_size = round($size, 2) . " " . $a[$pos];
                                         if ($arrA["USER_FILE_IS_IMAGE"] == "Y") {
                                             $url = "http://" . $_SERVER["HTTP_HOST"] . "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/" . $fr["SUBDIR"] . "/" . $fr["FILE_NAME"];
                                             $answer .= $arrA["USER_FILE_NAME"] . " [" . $fr["WIDTH"] . " x " . $fr["HEIGHT"] . "] (" . $file_size . ")\n" . $url;
                                         } else {
                                             $url = "http://" . $_SERVER["HTTP_HOST"] . "/bitrix/tools/form_show_file.php?rid=" . $RESULT_ID . "&hash=" . $arrA["USER_FILE_HASH"] . "&action=download&&lang=" . LANGUAGE_ID;
                                             $answer .= $arrA["USER_FILE_NAME"] . " (" . $file_size . ")\n" . $url;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $arEventFields[$wr["SID"]] = strlen($answer) <= 0 ? " " : $answer;
                 }
                 //echo "<pre>"; print_r($arEventFields); echo "</pre>";
                 CEvent::Send($arrTemplate["EVENT_NAME"], $arrTemplate["SITE_ID"], $arEventFields, "Y", $arrTemplate["ID"]);
                 $MESS = $OLD_MESS;
             }
             //foreach($arrTemplates as $arrTemplate)
             return true;
         } else {
             $strError .= GetMessage("FORM_ERROR_FORM_NOT_FOUND") . "<br>";
         }
     } else {
         $strError .= GetMessage("FORM_ERROR_RESULT_NOT_FOUND") . "<br>";
     }
     return false;
 }