예제 #1
0
파일: lib.php 프로젝트: Satariall/izurit
function __form_CreateForm($SID, $__current_dir)
{
    // check collisions
    $dbTmpForm = CForm::GetBySID($SID);
    if ($arTmpForm = $dbTmpForm->Fetch()) {
        return false;
    }
    //$dirName = ToLower($SID);
    $formConfigFile = $__current_dir . '/form.php';
    $fieldsConfigFile = $__current_dir . '/fields.php';
    // check config existence
    if (!file_exists($formConfigFile) || !file_exists($fieldsConfigFile)) {
        return false;
    }
    // load form config
    $arForm = array();
    require $formConfigFile;
    // setup form
    if ($FORM_ID = CForm::Set($arForm, false, 'N')) {
        // load fields config
        $arFormFields = array();
        require $fieldsConfigFile;
        // setup form fields
        foreach ($arFormFields as $key => $arField) {
            CFormField::Set($arField, false, 'N');
        }
        $arStatus = array('FORM_ID' => $FORM_ID, 'TITLE' => 'DEFAULT', 'CSORT' => 100, 'ACTIVE' => 'Y', 'DEFAULT_VALUE' => 'Y', 'arPERMISSION_MOVE' => array(0));
        CFormStatus::Set($arStatus, false, 'N');
    }
    return $FORM_ID;
}
예제 #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"]);
     }
 }
예제 #3
0
function CreateForm($arForm, $arFormFields, $langFile)
{
    if (!CModule::IncludeModule("form")) {
        return false;
    }
    // set defaults
    $arFieldDefaults = array("ACTIVE" => "Y", "C_SORT" => 0, "ADDITIONAL" => "N", "TITLE_TYPE" => "text", "IN_RESULTS_TABLE" => "Y", "IN_EXCEL_TABLE" => "Y");
    foreach ($arFormFields as $key => $arField) {
        if ($arFormFields['ADDITIONAL'] == 'Y' && !is_set($arFormFields['C_SORT'])) {
            $arFormFields['C_SORT'] = 5000;
        }
        $arFieldDefaults["C_SORT"] += 100;
        $arFormFields[$key] = array_merge($arFieldDefaults, $arField);
        $arFormFields[$key]["TITLE"] = GetMessage($arField["SID"] . "_QUESTION");
    }
    $rsLanguage = CLanguage::GetList($by, $order, array());
    while ($arLanguage = $rsLanguage->Fetch()) {
        WizardServices::IncludeServiceLang($langFile, $arLanguage["LID"]);
        $arForm["arMENU"][$arLanguage["LID"]] = GetMessage(substr($arForm["SID"], 0, -3) . "_MENU_NAME");
    }
    $dbForm = CForm::GetBySID($arForm["SID"]);
    if ($dbForm->Fetch()) {
        return;
    }
    WizardServices::IncludeServiceLang("status.php");
    if ($formID = CForm::Set($arForm, false, "N")) {
        // setup form fields
        foreach ($arFormFields as $key => $arField) {
            $arField["FORM_ID"] = $formID;
            $fieldID = CFormField::Set($arField, false, "N");
        }
        if ($arTemplates = CForm::SetMailTemplate($formID)) {
            CForm::Set(array('SID' => $arForm['SID'], 'arMAIL_TEMPLATE' => $arTemplates), $formID, 'N');
        }
        $arStatuses = array(array("FORM_ID" => $formID, "TITLE" => GetMessage("STATUS_NEW"), "C_SORT" => 100, "ACTIVE" => "Y", "DEFAULT_VALUE" => "Y", "CSS" => "statusgray", "arPERMISSION_VIEW" => array(0), "arPERMISSION_MOVE" => array(0), "arPERMISSION_EDIT" => array(0), "arPERMISSION_DELETE" => array(0)), array("FORM_ID" => $formID, "TITLE" => GetMessage("STATUS_RECEIVED"), "C_SORT" => 200, "ACTIVE" => "Y", "DEFAULT_VALUE" => "N", "CSS" => "statusblue", "arPERMISSION_VIEW" => array(0)), array("FORM_ID" => $formID, "TITLE" => GetMessage("STATUS_DONE"), "C_SORT" => 300, "ACTIVE" => "Y", "DEFAULT_VALUE" => "N", "CSS" => "statusgreen", "arPERMISSION_VIEW" => array(0)), array("FORM_ID" => $formID, "TITLE" => GetMessage("STATUS_REFUSE"), "C_SORT" => 400, "ACTIVE" => "Y", "DEFAULT_VALUE" => "N", "CSS" => "statusred", "arPERMISSION_VIEW" => array(0)));
        foreach ($arStatuses as $key => $arStatus) {
            if ($STATUS_ID = CFormStatus::Set($arStatus, false, "N")) {
                if ($arStatus['DEFAULT_VALUE'] == 'N' && ($arTemplates = CFormStatus::SetMailTemplate($formID, $STATUS_ID))) {
                    foreach ($arTemplates as $TEMPLATE_ID) {
                        if (null == $em) {
                            $em = new CEventMessage();
                        }
                        $em->Update($TEMPLATE_ID, array('MESSAGE' => GetMessage('STATUS_MESSAGE')));
                    }
                    CFormStatus::Set(array('FORM_ID' => $formID, 'arMAIL_TEMPLATE' => $arTemplates), $STATUS_ID, 'N');
                }
            }
        }
    }
    return $formID;
}
예제 #4
0
	/**
	 * <p>Устанавливает новый <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#status">статус</a> для <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#result">результата</a>. Возвращает "true" в случае успеха, в противном случае - "false".</p>
	 *
	 *
	 *
	 *
	 * @param int $result_id  ID <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#result">результата</a>.
	 *
	 *
	 *
	 * @param int $status_id  ID нового <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#status">статуса</a>.
	 *
	 *
	 *
	 * @param string $check_rights = "Y" Флаг необходимости проверки прав текущего пользователя.
	 * Возможны следующие значения: <ul> <li> <b>Y</b> - права необходимо
	 * проверить; </li> <li> <b>N</b> - права не нужно проверять. </li> </ul> Для
	 * успешной установки нового <a
	 * href="http://dev.1c-bitrix.ru/api_help/form/terms.php#status">статуса</a> для указанного <a
	 * href="http://dev.1c-bitrix.ru/api_help/form/terms.php#result">результата</a> необходимо
	 * обладать следующими <a
	 * href="http://dev.1c-bitrix.ru/api_help/form/permissions.php">правами</a>: <ol> <li>На веб-форму к
	 * которой принадлежит редактируемый результат: <br><br><b>[20] Работа со
	 * всеми результатами в соответствии с их статусами</b> <br><br>или, в
	 * случае, если вы являетесь создателем удаляемого результата,
	 * достаточно права: <br><br><b>[15] Работа со своим результатом в
	 * соответствии с его статусом</b> <br> </li> <li>На статус, в котором
	 * находится редактируемый результат, необходимо иметь право:
	 * <br><br><b>[EDIT] редактирование</b> <br> </li> <li>На новый статус <i>status_id</i>
	 * необходимо иметь право: <br><br><b>[MOVE] перевод результатов в данный
	 * статус</b> </li> </ol> Параметр необязательный. По умолчанию - "Y" (права
	 * необходимо проверить).
	 *
	 *
	 *
	 * @return bool 
	 *
	 *
	 * <h4>Example</h4> 
	 * <pre>
	 * &lt;?
	 * $RESULT_ID = 189; // ID результата
	 * $STATUS_ID = 1; // ID статуса "Опубликовано"
	 * 
	 * // установим новый статус для результата
	 * // с проверкой прав текущего пользователя
	 * if (<b>CFormResult::SetStatus</b>($RESULT_ID, $STATUS_ID))
	 * {
	 *     echo "Статус #".$STATUS_ID." для результата #".$RESULT_ID." успешно установлен.";
	 * }
	 * else // ошибка
	 * {
	 *     global $strError;
	 *     echo $strError;
	 * }
	 * ?&gt;
	 * </pre>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/form/classes/cformresult/setstatus.php
	 * @author Bitrix
	 */
	public static function SetStatus($RESULT_ID, $NEW_STATUS_ID, $CHECK_RIGHTS="Y")
	{
		$err_mess = (CAllFormResult::err_mess())."<br>Function: SetStatus<br>Line: ";
		global $DB, $USER, $strError, $APPLICATION;
		$NEW_STATUS_ID = intval($NEW_STATUS_ID);
		$RESULT_ID = intval($RESULT_ID);

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

		$strSql = "SELECT USER_ID, FORM_ID FROM b_form_result WHERE ID='".$RESULT_ID."'";
		$z = $DB->Query($strSql, false, $err_mess.__LINE__);
		if ($zr = $z->Fetch())
		{
			$WEB_FORM_ID = intval($zr["FORM_ID"]);

			// rights check
			$RIGHT_OK = "N";
			if ($CHECK_RIGHTS!="Y")
			{
				$dbRes = CFormStatus::GetByID($NEW_STATUS_ID);
				if ($dbRes->Fetch())
				{
					$RIGHT_OK="Y";
				}
			}
			else
			{
				// form rights
				$F_RIGHT = CForm::GetPermission($WEB_FORM_ID);
				if ($F_RIGHT>=20 || ($F_RIGHT>=15 && $USER->GetID()==$zr["USER_ID"]))
				{
					// result rights
					$arrRESULT_PERMISSION = CFormResult::GetPermissions($RESULT_ID, $v);

					// new status rights
					$arrNEW_STATUS_PERMISSION = CFormStatus::GetPermissions($NEW_STATUS_ID);

					if (in_array("EDIT", $arrRESULT_PERMISSION) && in_array("MOVE", $arrNEW_STATUS_PERMISSION))
					{
						$RIGHT_OK = "Y";
					}
				}
			}

			if ($RIGHT_OK=="Y")
			{
				$dbEvents = GetModuleEvents('form', 'onBeforeResultStatusChange');
				while ($arEvent = $dbEvents->Fetch())
				{
					ExecuteModuleEventEx($arEvent, array($WEB_FORM_ID, $RESULT_ID, &$NEW_STATUS_ID, $CHECK_RIGHTS));

					if ($ex = $APPLICATION->GetException())
						$strError .= $ex->GetString().'<br />';
				}

				if (strlen($strError) <= 0)
				{
					// call handler before change status
					CForm::ExecHandlerBeforeChangeStatus($RESULT_ID, "SET_STATUS", $NEW_STATUS_ID);
					$arFields = Array(
						"TIMESTAMP_X"	=> $DB->GetNowFunction(),
						"STATUS_ID"		=> "'".intval($NEW_STATUS_ID)."'"
						);
					$DB->Update("b_form_result",$arFields,"WHERE ID='".$RESULT_ID."'",$err_mess.__LINE__);

					$dbEvents = GetModuleEvents('form', 'onAfterResultStatusChange');
					while ($arEvent = $dbEvents->Fetch())
					{
						ExecuteModuleEventEx($arEvent, array($WEB_FORM_ID, $RESULT_ID, $NEW_STATUS_ID, $CHECK_RIGHTS));
					}

					// call handler after change status
					CForm::ExecHandlerAfterChangeStatus($RESULT_ID, "SET_STATUS");
					return true;
				}
			}
			else $strError .= GetMessage("FORM_ERROR_ACCESS_DENIED")."<br>";
		}
		else $strError .= GetMessage("FORM_ERROR_RESULT_NOT_FOUND")."<br>";
		return false;
	}
예제 #5
0
if ($_REQUEST['action'] == 'delete') {
    if ($USER->CanDoOperation('edit_other_settings')) {
        $ID = intval($_REQUEST['ID']);
        $emessage = new CEventMessage();
        $DB->StartTransaction();
        if (!$emessage->Delete($ID)) {
            $DB->Rollback();
        } else {
            $DB->Commit();
        }
    }
    die;
}
//$dbRes = CFormStatus::GetByID($STATUS_ID);
//$q = CForm::GetByID($WEB_FORM_ID);
//$arrForm = $q->Fetch();
$arTemplates = CFormStatus::SetMailTemplate($WEB_FORM_ID, $STATUS_ID, "Y", '', true);
IncludeModuleLangFile(__FILE__);
$strNote .= GetMessage("FORM_GENERATING_FINISHED") . "<br>";
$arReturn = array('NOTE' => $strNote, 'TEMPLATES' => $arTemplates);
//$APPLICATION->SetTitle(GetMessage("FORM_PAGE_TITLE"));
//require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_popup_admin.php")
?>
<script>
_processData(<?php 
echo CUtil::PhpToJsObject($arReturn);
?>
);
</script>
<?php 
//require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_popup_admin.php")
예제 #6
0
     if ($RESULT_ID > 0) {
         if (intval($arrResult["USER_ID"]) > 0) {
             $rsUser = CUser::GetByID($arrResult["USER_ID"]);
         }
     } else {
         $rsUser = CUser::GetByID($USER->GetID());
     }
 } else {
     $rsUser = CUser::GetByID($arrVALUES["USER_ID"]);
 }
 if (null != $rsUser) {
     $arUser = $rsUser->Fetch();
 }
 $RESULT_STATUS_FORM = '';
 if ($EDIT_STATUS == 'Y' && $bResultStatusChangeAccess) {
     $dbStatusList = CFormStatus::GetDropdown($WEB_FORM_ID, array("MOVE"), $arUser['ID']);
     if ($RESULT_ID > 0) {
         $RESULT_STATUS_FORM .= '<input type="radio" value="NOT_REF" id="status_' . $arForm['SID'] . '_NOT_REF" name="status_' . $arForm['SID'] . '" checked="checked" /><label for="status_' . $arForm['SID'] . '_NOT_REF">' . GetMessage('FORM_RESULT_EDIT_STATUS_DONTCHANGE') . '</label><br />';
         $i = 1;
     } else {
         $i = 0;
     }
     while ($arStatus = $dbStatusList->Fetch()) {
         $arStatus['REFERENCE'] = str_replace('[' . $arStatus['REFERENCE_ID'] . ']', '[<a href="/bitrix/admin/form_status_edit.php?lang=' . LANG . '&WEB_FORM_ID=' . $WEB_FORM_ID . '&ID=' . $arStatus['REFERENCE_ID'] . '">' . $arStatus['REFERENCE_ID'] . '</a>]', htmlspecialcharsEx($arStatus['REFERENCE']));
         $RESULT_STATUS_FORM .= '<input type="radio" value="' . $arStatus['REFERENCE_ID'] . '" id="status_' . $arForm['SID'] . '_' . $arStatus['REFERENCE_ID'] . '" name="status_' . $arForm['SID'] . '" ' . ($RESULT_ID <= 0 && $i++ == 0 ? 'checked="checked"' : '') . ' /><label for="status_' . $arForm['SID'] . '_' . $arStatus['REFERENCE_ID'] . '">' . $arStatus['REFERENCE'] . '</label><br />';
     }
 }
 // start form output
 echo ShowError($strError);
 $tabControl = new CAdminTabControl("tabControl", $arTabs);
 $tabControl->Begin();
예제 #7
0
</td>
	</tr>
	<?php 
        }
        ?>

	<?php 
        if (!$bSimple) {
            ?>
		<tr>
			<td><?php 
            echo GetMessage("FORM_F_STATUS");
            ?>
</td>
			<td><?php 
            echo SelectBox("find_status", CFormStatus::GetDropdown($WEB_FORM_ID, array("VIEW")), GetMessage("FORM_ALL"), htmlspecialcharsbx($find_status));
            ?>
</td>
		</tr>
		<tr>
			<td>
				<?php 
            echo GetMessage("FORM_F_STATUS_ID");
            ?>
</td>
			<td><?php 
            echo CForm::GetTextFilter("status_id");
            ?>
</td>
		</tr>
	<?php 
예제 #8
0
				}
				$DB->Commit();
			break;
		}
	}

	if (!$_REQUEST["mode"])
		LocalRedirect("form_status_list.php?lang=".LANGUAGE_ID."&WEB_FORM_ID=".$WEB_FORM_ID);
}



//////////////////////////////////////////////////////////////////////
// initialize list - preparing data

$rsData = CFormStatus::GetList($WEB_FORM_ID, $by, $order, $arFilter, $is_filtered);
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();

// set navigation
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("FORM_PAGES")));

$lAdmin->AddHeaders(array(
	array("id"=>"ID", "content"=>"ID", "sort"=>"s_id", "default"=>true),
	array("id"=>"TIMESTAMP_X", "content"=>GetMessage("FORM_TIMESTAMP"), "sort"=>"s_timestamp", "default"=>true),
	array("id"=>"ACTIVE", "content"=>GetMessage("FORM_ACTIVE"), "sort"=>"s_active", "default"=>true),
	array("id"=>"C_SORT", "content"=>GetMessage("FORM_C_SORT"), "sort"=>"s_sort", "default"=>true),
	array("id"=>"DEFAULT_VALUE", "content"=>GetMessage("FORM_DEFAULT"), "sort"=>"s_default", "default"=>true),
	array("id"=>"TITLE", "content"=>GetMessage("FORM_TITLE"), "sort"=>"s_title", "default"=>true),
	array("id"=>"DESCRIPTION", "content"=>GetMessage("FORM_DESCRIPTION"), "sort"=>"s_description", "default"=>true),
	array("id"=>"RESULTS", "content"=>GetMessage("FORM_RESULTS"), "sort"=>"s_results", "default"=>true),
예제 #9
0
		if (intval($arResult["arResultData"]["USER_ID"])>0)
		{
			$rsUser = CUser::GetByID($arResult["arResultData"]["USER_ID"]);
			$arUser = $rsUser->Fetch();

			$arResult["RESULT_USER_ID"] = $arResult["arResultData"]["USER_ID"];
			$arResult["RESULT_USER_LOGIN"] = $arUser["LOGIN"];
			$arResult["RESULT_USER_EMAIL"] = $arUser["USER_EMAIL"];
			$arResult["RESULT_USER_FIRST_NAME"] = $arUser["NAME"];
			$arResult["RESULT_USER_LAST_NAME"] = $arUser["LAST_NAME"];
			$arResult["RESULT_USER_SECOND_NAME"] = $arUser["SECOND_NAME"];
		}

		$arResult["isResultStatusChangeAccess"] = in_array("EDIT", $arResult["arrRESULT_PERMISSION"]) ? "Y" : "N";

		$arResult["RESULT_STATUS_FORM"] = $arResult["isResultStatusChangeAccess"] == "Y" ? SelectBox("status_".$arResult["WEB_FORM_NAME"], CFormStatus::GetDropdown($arParams["WEB_FORM_ID"], array("MOVE"), $arResult["RESULT_USER_ID"]), " ", "", "") : "";

		// define variables to assign
		$arResult = array_merge(
			$arResult,
			array(
				"RESULT_ID" => $arParams["RESULT_ID"],
				"WEB_FORM_ID" => $arParams["WEB_FORM_ID"],

				"RESULT_STATUS" => "<span class='".$arResult["arResultData"]["STATUS_CSS"]."'>".$arResult["arResultData"]["STATUS_TITLE"]."</span>",

				"RESULT_USER_AUTH" => $arResult["arResultData"]["USER_AUTH"] == "Y" ? "Y" : "N",

				"RESULT_DATE_CREATE" => $arResult["arResultData"]["DATE_CREATE"],
				"RESULT_TIMESTAMP_X" => $arResult["arResultData"]["TIMESTAMP_X"],
예제 #10
0
 function GetDropdown($FORM_ID, $PERMISSION = array("MOVE"), $OWNER_ID = 0)
 {
     $err_mess = CFormStatus::err_mess() . "<br>Function: GetDropdown<br>Line: ";
     global $DB, $USER, $strError;
     $FORM_ID = intval($FORM_ID);
     if (CForm::IsAdmin()) {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tS.ID\t\t\t\t\t\t\t\tREFERENCE_ID,\n\t\t\t\t\tconcat('[',S.ID,'] ',S.TITLE)\t\tREFERENCE\n\t\t\t\tFROM\n\t\t\t\t\tb_form_status S\n\t\t\t\tWHERE\n\t\t\t\t\tS.FORM_ID = {$FORM_ID}\n\t\t\t\tand S.ACTIVE = 'Y'\n\t\t\t\tORDER BY S.C_SORT\n\t\t\t\t";
     } else {
         if (is_array($PERMISSION)) {
             $arrPERMISSION = $PERMISSION;
         } else {
             if (intval($PERMISSION) == 2) {
                 $PERMISSION = "MOVE";
             }
             if (intval($PERMISSION) == 1) {
                 $PERMISSION = "VIEW, MOVE";
             }
             $arrPERMISSION = explode(",", $PERMISSION);
         }
         $str = "''";
         $arrPERM = array();
         if (is_array($arrPERMISSION) && count($arrPERMISSION) > 0) {
             foreach ($arrPERMISSION as $perm) {
                 $arrPERM[] = trim($perm);
                 $str .= ",'" . $DB->ForSql(trim($perm)) . "'";
             }
         }
         $arGroups = $USER->GetUserGroupArray();
         if (!is_array($arGroups)) {
             $arGroups[] = 2;
         }
         if ($OWNER_ID == $USER->GetID() || in_array("VIEW", $arrPERM) && in_array("MOVE", $arrPERM)) {
             $arGroups[] = 0;
         }
         if (is_array($arGroups) && count($arGroups) > 0) {
             $groups = implode(",", $arGroups);
         }
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tS.ID\t\t\t\t\t\t\t\tREFERENCE_ID,\n\t\t\t\t\tconcat('[',S.ID,'] ',S.TITLE)\t\tREFERENCE\n\t\t\t\tFROM\n\t\t\t\t\tb_form_status S,\n\t\t\t\t\tb_form_status_2_group G\n\t\t\t\tWHERE\n\t\t\t\t\tS.FORM_ID = {$FORM_ID}\n\t\t\t\tand S.ACTIVE = 'Y'\n\t\t\t\tand G.STATUS_ID = S.ID\n\t\t\t\tand G.GROUP_ID in ({$groups})\n\t\t\t\tand G.PERMISSION in ({$str})\n\t\t\t\tGROUP BY\n\t\t\t\t\tS.ID, S.TITLE\n\t\t\t\tORDER BY S.C_SORT\n\t\t\t\t";
     }
     //echo "<pre>".$strSql."</pre>";
     $z = $DB->Query($strSql, false, $err_mess . __LINE__);
     return $z;
 }
예제 #11
0
 function GetPermissions($RESULT_ID, &$CURRENT_STATUS_ID)
 {
     $err_mess = CFormResult::err_mess() . "<br>Function: GetPermissions<br>Line: ";
     global $DB, $USER, $strError;
     $USER_ID = intval($USER->GetID());
     $RESULT_ID = intval($RESULT_ID);
     $arrReturn = array();
     $arGroups = $USER->GetUserGroupArray();
     if (!is_array($arGroups)) {
         $arGroups[] = 2;
     }
     if (CForm::IsAdmin()) {
         return CFormStatus::GetMaxPermissions();
     } else {
         $arr = array();
         if (is_array($arGroups) && count($arGroups) > 0) {
             $groups = implode(",", $arGroups);
         }
         $strSql = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tG.PERMISSION,\r\n\t\t\t\t\tR.STATUS_ID\r\n\t\t\t\tFROM\r\n\t\t\t\t\tb_form_result R,\r\n\t\t\t\t\tb_form_status_2_group G\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tR.ID = {$RESULT_ID}\r\n\t\t\t\tand R.STATUS_ID = G.STATUS_ID\r\n\t\t\t\tand (\r\n\t\t\t\t\t(G.GROUP_ID in ({$groups}) and nvl(R.USER_ID,0) <> {$USER_ID}) or\r\n\t\t\t\t\t(G.GROUP_ID in ({$groups},0) and nvl(R.USER_ID,0) = {$USER_ID})\r\n\t\t\t\t\t)\r\n\t\t\t\t";
         $z = $DB->Query($strSql, false, $err_mess . __LINE__);
         while ($zr = $z->Fetch()) {
             $arrReturn[] = $zr["PERMISSION"];
             $CURRENT_STATUS_ID = $zr["STATUS_ID"];
         }
     }
     return $arrReturn;
 }
예제 #12
0
 function GetStatusDropdown($WEB_FORM_ID, $PERMISSION = "MOVE", $OWNER_ID = 0)
 {
     return CFormStatus::GetDropdown($WEB_FORM_ID, $PERMISSION, $OWNER_ID);
 }
예제 #13
0
	public static function GetDropdown($FORM_ID, $PERMISSION = array("MOVE"), $OWNER_ID=0)
	{
		$err_mess = (CFormStatus::err_mess())."<br>Function: GetDropdown<br>Line: ";
		global $DB, $USER, $strError;
		$FORM_ID = intval($FORM_ID);
		if (CForm::IsAdmin())
		{
			$strSql = "
				SELECT
					S.ID								REFERENCE_ID,
					concat('[',S.ID,'] ',S.TITLE)		REFERENCE
				FROM
					b_form_status S
				WHERE
					S.FORM_ID = $FORM_ID
				and S.ACTIVE = 'Y'
				ORDER BY S.C_SORT
				";
		}
		else
		{
			if (is_array($PERMISSION)) $arrPERMISSION = $PERMISSION;
			else
			{
				if (intval($PERMISSION)==2) $PERMISSION = "MOVE";
				if (intval($PERMISSION)==1) $PERMISSION = "VIEW, MOVE";
				$arrPERMISSION = explode(",",$PERMISSION);
			}
			$str = "''";
			$arrPERM = array();
			if (is_array($arrPERMISSION) && count($arrPERMISSION)>0)
			{
				foreach ($arrPERMISSION as $perm)
				{
					$arrPERM[] = trim($perm);
					$str .= ",'".$DB->ForSql(trim($perm))."'";
				}
			}
			$arGroups = $USER->GetUserGroupArray();
			if (!is_array($arGroups)) $arGroups[] = 2;
			if ($OWNER_ID==$USER->GetID() || (in_array("VIEW",$arrPERM) && in_array("MOVE",$arrPERM))) $arGroups[] = 0;
			if (is_array($arGroups) && count($arGroups)>0) $groups = implode(",",$arGroups);
			$strSql = "
				SELECT
					S.ID								REFERENCE_ID,
					concat('[',S.ID,'] ',S.TITLE)		REFERENCE
				FROM
					b_form_status S,
					b_form_status_2_group G
				WHERE
					S.FORM_ID = $FORM_ID
				and S.ACTIVE = 'Y'
				and G.STATUS_ID = S.ID
				and G.GROUP_ID in ($groups)
				and G.PERMISSION in ($str)
				GROUP BY
					S.ID, S.TITLE
				ORDER BY S.C_SORT
				";
		}
		//echo "<pre>".$strSql."</pre>";
		$z = $DB->Query($strSql, false, $err_mess.__LINE__);
		return $z;
	}
예제 #14
0
	public static function SetMailTemplate($WEB_FORM_ID, $STATUS_ID, $ADD_NEW_TEMPLATE="Y", $old_SID="", $bReturnFullInfo = false)
	{
		global $DB, $MESS, $strError;
		$err_mess = (CAllForm::err_mess())."<br>Function: SetMailTemplate<br>Line: ";
		$arrReturn = array();
		$WEB_FORM_ID = intval($WEB_FORM_ID);
		$q = CForm::GetByID($WEB_FORM_ID);
		if ($arrForm = $q->Fetch())
		{
			$dbRes = CFormStatus::GetByID($STATUS_ID);
			if ($arrStatus = $dbRes->Fetch())
			{
				$MAIL_EVENT_TYPE = "FORM_STATUS_CHANGE_".$arrForm["SID"]."_".$arrStatus['ID'];
				if (strlen($old_SID)>0)
					$old_MAIL_EVENT_TYPE = "FORM_STATUS_CHANGE_".$old_SID."_".$arrStatus['ID'];

				$et = new CEventType;
				$em = new CEventMessage;

				if (strlen($MAIL_EVENT_TYPE)>0)
					$et->Delete($MAIL_EVENT_TYPE);

				$z = CLanguage::GetList($v1, $v2);
				$OLD_MESS = $MESS;
				$MESS = array();
				while ($arLang = $z->Fetch())
				{
					IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/form/admin/form_status_mail.php", $arLang["LID"]);

					$str = "";
					$str .= "#EMAIL_TO# - ".GetMessage("FORM_L_EMAIL_TO")."\n";
					$str .= "#RS_FORM_ID# - ".GetMessage("FORM_L_FORM_ID")."\n";
					$str .= "#RS_FORM_NAME# - ".GetMessage("FORM_L_NAME")."\n";
					$str .= "#RS_FORM_SID# - ".GetMessage("FORM_L_SID")."\n";
					$str .= "#RS_RESULT_ID# - ".GetMessage("FORM_L_RESULT_ID")."\n";
					$str .= "#RS_DATE_CREATE# - ".GetMessage("FORM_L_DATE_CREATE")."\n";
					$str .= "#RS_USER_ID# - ".GetMessage("FORM_L_USER_ID")."\n";
					$str .= "#RS_USER_EMAIL# - ".GetMessage("FORM_L_USER_EMAIL")."\n";
					$str .= "#RS_USER_NAME# - ".GetMessage("FORM_L_USER_NAME")."\n";
					$str .= "#RS_STATUS_ID# - ".GetMessage("FORM_L_STATUS_ID")."\n";
					$str .= "#RS_STATUS_NAME# - ".GetMessage("FORM_L_STATUS_NAME")."\n";

					$et->Add(
							Array(
							"LID"			=> $arLang["LID"],
							"EVENT_NAME"	=> $MAIL_EVENT_TYPE,
							"NAME"			=> str_replace(array('#FORM_SID#', '#STATUS_NAME#'), array($arrForm['SID'], $arrStatus['TITLE']), GetMessage("FORM_CHANGE_STATUS")),
							"DESCRIPTION"	=> $str
							)
						);
				}
				// create new event type for old templates
				if (strlen($old_MAIL_EVENT_TYPE)>0 && $old_MAIL_EVENT_TYPE!=$MAIL_EVENT_TYPE)
				{
					$e = $em->GetList($by="id",$order="desc",array("EVENT_NAME"=>$old_MAIL_EVENT_TYPE));
					while ($er=$e->Fetch())
					{
						$em->Update($er["ID"],array("EVENT_NAME"=>$MAIL_EVENT_TYPE));
					}
					if (strlen($old_MAIL_EVENT_TYPE)>0)
						$et->Delete($old_MAIL_EVENT_TYPE);
				}

				if ($ADD_NEW_TEMPLATE=="Y")
				{
					$z = CSite::GetList($v1, $v2);
					while ($arSite = $z->Fetch()) $arrSiteLang[$arSite["ID"]] = $arSite["LANGUAGE_ID"];

					$arrFormSite = CForm::GetSiteArray($WEB_FORM_ID);
					if (is_array($arrFormSite) && count($arrFormSite)>0)
					{
						foreach($arrFormSite as $sid)
						{
							IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/form/admin/form_status_mail.php", $arrSiteLang[$sid]);

							$SUBJECT = GetMessage("FORM_CHANGE_STATUS_S");
							$MESSAGE = GetMessage("FORM_CHANGE_STATUS_B");

							// добавляем новый шаблон
							$arFields = Array(
								"ACTIVE"		=> "Y",
								"EVENT_NAME"	=> $MAIL_EVENT_TYPE,
								"LID"			=> $sid,
								"EMAIL_FROM"	=> "#DEFAULT_EMAIL_FROM#",
								"EMAIL_TO"		=> "#EMAIL_TO#",
								"SUBJECT"		=> $SUBJECT,
								"MESSAGE"		=> $MESSAGE,
								"BODY_TYPE"		=> "text"
								);
							//echo '<pre>'; print_r($arFields); echo '</pre>';
							$TEMPLATE_ID = $em->Add($arFields);
							if ($bReturnFullInfo)
								$arrReturn[] = array(
									'ID' => $TEMPLATE_ID,
									'FIELDS' => $arFields,
								);
							else
								$arrReturn[] = $TEMPLATE_ID;

						}
					}
				}

				CFormStatus::Set(array('FORM_ID' => $WEB_FORM_ID, 'MAIL_EVENT_TYPE' => $MAIL_EVENT_TYPE), $STATUS_ID, 'N');

				$MESS = $OLD_MESS;
			}
		}
		return $arrReturn;
	}
예제 #15
0
		CHttpRequest.Send(url);
	}
}
//-->
</script>
	<?php 
if ($ID > 0) {
    ?>
	<tr>
		<td width="40%" valign="top"><?php 
    echo GetMessage("FORM_MAIL_TEMPLATE");
    ?>
</td>
		<td width="60%" valign="top" nowrap style="padding:0px" id="form_templates">
			<?php 
    $arr = CFormStatus::GetTemplateList($ID);
    //echo '<pre>'; print_r($arr); echo '</pre>';
    if (is_array($arr) && count($arr) > 0) {
        $arrMAIL = array();
        reset($arr);
        if (is_array($arr["reference_id"])) {
            foreach ($arr['reference_id'] as $key => $value) {
                $arrMAIL[$value] = $arr["reference"][$key];
            }
        }
        ?>
				<?php 
        if (count($arrMAIL) > 0) {
            echo '<table cellspacing="0" cellpadding="0" id="form_templates_table"><tbody>';
        }
        ?>
예제 #16
0
    ?>
"<?php 
    echo $mult == $RESTRICT_TIME_MULTIPLYER ? " selected=\"selected\"" : "";
    ?>
><?php 
    echo $title;
    ?>
</option>
	<?php 
}
?>
		</select></td>
	</tr>
	<?php 
if (!$bSimple && $ID > 0) {
    $rsStatusList = CFormStatus::GetList($ID, $by = "s_sort", $order = "asc", array("ACTIVE" => "Y"), $is_filtered);
    ?>
	<tr>
		<td><?php 
    echo GetMessage('FORM_RESTRICT_STATUS');
    ?>
: </td>
		<td><select name="RESTRICT_STATUS[]" id="RESTRICT_STATUS" multiple="multiple" rows="3" <?php 
    echo $str_USE_RESTRICTIONS == "Y" ? "" : "disabled=\"1\"";
    ?>
>
			<?php 
    while ($arStatus = $rsStatusList->GetNext()) {
        ?>
		<option value="<?php 
        echo $arStatus["ID"];
예제 #17
0
            }
        }
        reset($arResult["arrFORM_FILTER"]);
        foreach ($arResult["arrFORM_FILTER"] as $f_sid => $arrF) {
            foreach ($arrF as $key => $arr) {
                if (strlen($arrF["FILTER_TITLE"]) <= 0) {
                    $title = $arrF["TITLE_TYPE"] == "html" ? strip_tags($arrF["TITLE"]) : htmlspecialcharsbx($arrF["TITLE"]);
                    $arrResult["arrFORM_FILTER"][$f_sid][$key]["FILTER_TITLE"] = TruncateText($title, 100);
                } else {
                    $arrResult["arrFORM_FILTER"][$f_sid][$key]["FILTER_TITLE"] = htmlspecialcharsbx($arrF["FILTER_TITLE"]);
                }
            }
        }
        $arParams["by"] = htmlspecialcharsbx($arParams["by"]);
        $arParams["order"] = htmlspecialcharsbx($arParams["order"]);
        $arResult["res_counter"] = intval($arResult["res_counter"]);
        $arrPermissions = array("MOVE", "VIEW");
        foreach ($arrPermissions as $perm) {
            $rsStatuses = CFormStatus::GetDropdown($arParams["WEB_FORM_ID"], array($perm));
            $arResult["arStatuses_" . $perm] = array();
            while ($arStatus = $rsStatuses->Fetch()) {
                $arResult["arStatuses_" . $perm][] = array("REFERENCE_ID" => htmlspecialcharsbx($arStatus["REFERENCE_ID"]), "REFERENCE" => htmlspecialcharsbx($arStatus["REFERENCE"]));
            }
        }
        $this->IncludeComponentTemplate();
    } else {
        echo ShowError(GetMessage("FORM_INCORRECT_FORM_ID"));
    }
} else {
    echo ShowError(GetMessage("FORM_MODULE_NOT_INSTALLED"));
}
예제 #18
0
 function GetMaxPermissions()
 {
     return CFormStatus::GetMaxPermissions();
 }
예제 #19
0
	function GetPermissions($RESULT_ID, &$CURRENT_STATUS_ID)
	{
		$err_mess = (CFormResult::err_mess())."<br>Function: GetPermissions<br>Line: ";
		global $DB, $USER, $strError;
		$USER_ID = intval($USER->GetID());
		$RESULT_ID = intval($RESULT_ID);
		$arrReturn = array();
		$arGroups = $USER->GetUserGroupArray();
		if (!is_array($arGroups)) $arGroups[] = 2;
		if (CForm::IsAdmin()) return CFormStatus::GetMaxPermissions();
		else
		{
			$arr = array();
			if (is_array($arGroups) && count($arGroups)>0) $groups = implode(",",$arGroups);
			$strSql = "
				SELECT
					G.PERMISSION,
					R.STATUS_ID
				FROM
					b_form_result R,
					b_form_status_2_group G
				WHERE
					R.ID = $RESULT_ID
				and R.STATUS_ID = G.STATUS_ID
				and (
					(G.GROUP_ID in ($groups) and ifnull(R.USER_ID,0) <> $USER_ID) or
					(G.GROUP_ID in ($groups,0) and ifnull(R.USER_ID,0) = $USER_ID)
					)
				";
			$z = $DB->Query($strSql, false, $err_mess.__LINE__);
			while ($zr = $z->Fetch())
			{
				$arrReturn[] = $zr["PERMISSION"];
				$CURRENT_STATUS_ID = $zr["STATUS_ID"];
			}
		}
		return $arrReturn;
	}
예제 #20
0
 function Delete($ID, $CHECK_RIGHTS = "Y")
 {
     global $DB, $strError;
     $err_mess = CAllForm::err_mess() . "<br>Function: Delete<br>Line: ";
     $ID = intval($ID);
     if ($CHECK_RIGHTS != "Y" || CForm::IsAdmin()) {
         // delete form results
         if (CForm::Reset($ID, "N")) {
             // delete temporary template
             $tmp_filename = $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/tmp/form/form_" . $ID . ".php";
             if (file_exists($tmp_filename)) {
                 @unlink($tmp_filename);
             }
             // delete form statuses
             $rsStatuses = CFormStatus::GetList($ID, $by, $order, $arFilter, $is_filtered);
             while ($arStatus = $rsStatuses->Fetch()) {
                 CFormStatus::Delete($arStatus["ID"], "N");
             }
             // delete from fields & questions
             $rsFields = CFormField::GetList($ID, "ALL", $by, $order, array(), $is_filtered);
             while ($arField = $rsFields->Fetch()) {
                 CFormField::Delete($arField["ID"], "N");
             }
             // delete form image
             $strSql = "SELECT IMAGE_ID FROM b_form WHERE ID='{$ID}' and IMAGE_ID>0";
             $z = $DB->Query($strSql, false, $err_mess . __LINE__);
             while ($zr = $z->Fetch()) {
                 CFile::Delete($zr["IMAGE_ID"]);
             }
             // delete mail event type and mail templates, assigned to the current form
             $q = CForm::GetByID($ID);
             $qr = $q->Fetch();
             if (strlen(trim($qr["MAIL_EVENT_TYPE"])) > 0) {
                 // delete mail templates
                 $em = new CEventMessage();
                 $e = $em->GetList($by = "id", $order = "desc", array("EVENT_NAME" => $qr["MAIL_EVENT_TYPE"], "EVENT_NAME_EXACT_MATCH" => "Y"));
                 while ($er = $e->Fetch()) {
                     $em->Delete($er["ID"]);
                 }
                 // delete mail event type
                 $et = new CEventType();
                 $et->Delete($qr["MAIL_EVENT_TYPE"]);
             }
             // delete site assignment
             $DB->Query("DELETE FROM b_form_2_site WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__);
             // delete mail templates assignment
             $DB->Query("DELETE FROM b_form_2_mail_template WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__);
             // delete form menu
             $DB->Query("DELETE FROM b_form_menu WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__);
             // delete from rights
             $DB->Query("DELETE FROM b_form_2_group WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__);
             // and finally delete form
             $DB->Query("DELETE FROM b_form WHERE ID='{$ID}'", false, $err_mess . __LINE__);
             return true;
         }
     } else {
         $strError .= GetMessage("FORM_ERROR_ACCESS_DENIED") . "<br>";
     }
     return false;
 }
예제 #21
0
</td>
									<?php 
                    if (in_array("EDIT", $arrRESULT_PERMISSION) && $F_RIGHT >= 25) {
                        ?>
										<td><font class="smalltext"><?php 
                        echo GetMessage("FORM_CHANGE_TO");
                        ?>
</font></td>
										<td><input type="hidden" name="STATUS_PREV_<?php 
                        echo $GLOBALS["f_ID"];
                        ?>
" value="<?php 
                        echo $GLOBALS["f_STATUS_ID"];
                        ?>
"><?php 
                        echo SelectBox("STATUS_" . $GLOBALS["f_ID"], CFormStatus::GetDropdown($WEB_FORM_ID, array("MOVE"), $GLOBALS["f_USER_ID"]), " ", "", "class='inputselect'");
                        ?>
</td>
									<?php 
                    }
                    // endif (in_array("EDIT",$arrRESULT_PERMISSION) && $F_RIGHT>=25);
                    ?>
									</tr>
									<?php 
                }
                // endif ($SHOW_STATUS == "Y")
                ?>
								</table>
							</td>
						</tr>
						<?php 
예제 #22
0
 public function ShowResultStatusForm()
 {
     if ($this->isResultStatusChangeAccess()) {
         return SelectBox("status_" . $this->arForm["SID"], CFormStatus::GetDropdown($this->WEB_FORM_ID, array("MOVE"), $this->arResult["USER_ID"]), " ", "", "");
     } else {
         return "";
     }
 }
예제 #23
0
 function Copy($ID, $CHECK_RIGHTS = "Y", $NEW_FORM_ID = false)
 {
     global $DB, $APPLICATION, $strError;
     $err_mess = CAllFormStatus::err_mess() . "<br>Function: Copy<br>Line: ";
     $ID = intval($ID);
     $NEW_FORM_ID = intval($NEW_FORM_ID);
     $rsStatus = CFormStatus::GetByID($ID);
     if ($arStatus = $rsStatus->Fetch()) {
         $RIGHT_OK = "N";
         if ($CHECK_RIGHTS != "Y" || CForm::IsAdmin()) {
             $RIGHT_OK = "Y";
         } else {
             $F_RIGHT = CForm::GetPermission($arStatus["FORM_ID"]);
             // если имеем право на просмотр параметров формы
             if ($F_RIGHT >= 25) {
                 // если задана новая форма
                 if ($NEW_FORM_ID > 0) {
                     $NEW_F_RIGHT = CForm::GetPermission($NEW_FORM_ID);
                     // если имеем полный доступ на новую форму
                     if ($NEW_F_RIGHT >= 30) {
                         $RIGHT_OK = "Y";
                     }
                 } elseif ($F_RIGHT >= 30) {
                     $RIGHT_OK = "Y";
                 }
             }
         }
         // если права проверили то
         if ($RIGHT_OK == "Y") {
             CFormStatus::GetPermissionList($ID, $arPERMISSION_VIEW, $arPERMISSION_MOVE, $arPERMISSION_EDIT, $arPERMISSION_DELETE);
             // копируем
             $arFields = array("FORM_ID" => $NEW_FORM_ID > 0 ? $NEW_FORM_ID : $arStatus["FORM_ID"], "C_SORT" => $arStatus["C_SORT"], "ACTIVE" => $arStatus["ACTIVE"], "TITLE" => $arStatus["TITLE"], "DESCRIPTION" => $arStatus["DESCRIPTION"], "CSS" => $arStatus["CSS"], "HANDLER_OUT" => $arStatus["HANDLER_OUT"], "HANDLER_IN" => $arStatus["HANDLER_IN"], "DEFAULT_VALUE" => $arStatus["DEFAULT_VALUE"], "arPERMISSION_VIEW" => $arPERMISSION_VIEW, "arPERMISSION_MOVE" => $arPERMISSION_MOVE, "arPERMISSION_EDIT" => $arPERMISSION_EDIT, "arPERMISSION_DELETE" => $arPERMISSION_DELETE);
             $NEW_ID = CFormStatus::Set($arFields);
             return $NEW_ID;
         } else {
             $strError .= GetMessage("FORM_ERROR_ACCESS_DENIED") . "<br>";
         }
     } else {
         $strError .= GetMessage("FORM_ERROR_STATUS_NOT_FOUND") . "<br>";
     }
     return false;
 }