本文整理汇总了PHP中CForm::IsAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP CForm::IsAdmin方法的具体用法?PHP CForm::IsAdmin怎么用?PHP CForm::IsAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForm
的用法示例。
在下文中一共展示了CForm::IsAdmin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
}
$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 . "&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) {
$arActions[] = array("SEPARATOR" => true);
$arActions[] = array("TITLE" => GetMessage("FORM_DELETE_RESULTS_ALT"), "ACTION" => "javascript:if(confirm('" . GetMessage("FORM_CONFIRM_DELETE_RESULTS") . "')) window.location='?lang=" . LANGUAGE_ID . "&reset_id=" . $f_ID . "&" . bitrix_sessid_get() . "'", "TEXT" => GetMessage("FORM_DELETE_RESULTS"));
}
if (CForm::IsAdmin()) {
$arActions[] = array("ICON" => "delete", "TITLE" => GetMessage("FORM_DELETE_ALT"), "ACTION" => "javascript:if(confirm('" . GetMessage("FORM_CONFIRM_DELETE") . "')) window.location='?lang=" . LANGUAGE_ID . "&action=delete&ID={$f_ID}&" . bitrix_sessid_get() . "'", "TEXT" => GetMessage("FORM_DELETE"));
}
$row->AddActions($arActions);
}
// list footer
$lAdmin->AddFooter(array(array("title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value" => $rsData->SelectedRowsCount()), array("counter" => true, "title" => GetMessage("MAIN_ADMIN_LIST_CHECKED"), "value" => "0")));
if ($FORM_RIGHT == "W") {
// add list buttons
$lAdmin->AddGroupActionTable(array("delete" => GetMessage("FORM_DELETE_L")));
}
// context menu
if ($FORM_RIGHT == "W") {
$aMenu = array();
$aMenu[] = array("TEXT" => GetMessage("FORM_CREATE"), "TITLE" => GetMessage("FORM_CREATE_TITLE"), "LINK" => "form_edit.php?lang=" . LANG, "ICON" => "btn_new");
$aContext = $aMenu;
示例2: reset
} else {
$arrSelect = $arr;
}
reset($arGroups);
while (list(, $group) = each($arGroups)) {
?>
<tr>
<td width="40%"><?php
echo $group["NAME"] . ":";
?>
</td>
<td width="60%"><?php
$perm = CForm::GetPermission($ID, array($group["ID"]), "Y");
// for simple method: change 20 (work with other results) access mode to 15
/*
if ($bSimple)
$perm = $perm==20 ? 15 : $perm;
*/
echo SelectBoxFromArray("PERMISSION_" . $group["ID"], $arrSelect, $perm, "", 'style="width: 80%;"');
?>
</td>
</tr>
<?php
}
$tabControl->EndTab();
$tabControl->Buttons(array("disabled" => !($ID > 0 && $F_RIGHT >= 30 || CForm::IsAdmin()), "back_url" => strlen($back_url) > 0 ? $back_url : "form_list.php?lang=" . LANGUAGE_ID));
$tabControl->End();
?>
</form>
<?php
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
示例3: Delete
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;
}
示例4: CheckFields
public static function CheckFields(&$arFields, $FIELD_ID, $CHECK_RIGHTS = "Y")
{
$err_mess = CAllFormField::err_mess() . "<br>Function: CheckFields<br>Line: ";
global $DB, $strError;
$str = "";
$FIELD_ID = intval($FIELD_ID);
$FORM_ID = intval($arFields["FORM_ID"]);
if ($FORM_ID <= 0) {
$str .= GetMessage("FORM_ERROR_FORM_ID_NOT_DEFINED") . "<br>";
} else {
$RIGHT_OK = "N";
if ($CHECK_RIGHTS != "Y" || CForm::IsAdmin()) {
$RIGHT_OK = "Y";
} else {
$F_RIGHT = CForm::GetPermission($FORM_ID);
if ($F_RIGHT >= 30) {
$RIGHT_OK = "Y";
}
}
if ($RIGHT_OK == "Y") {
if (strlen(trim($arFields["SID"])) > 0) {
$arFields["VARNAME"] = $arFields["SID"];
} elseif (strlen($arFields["VARNAME"]) > 0) {
$arFields["SID"] = $arFields["VARNAME"];
}
if ($FIELD_ID <= 0 && !is_set($arFields, 'ADDITIONAL')) {
$arFields['ADDITIONAL'] = 'N';
}
if ($FIELD_ID <= 0 || $FIELD_ID > 0 && is_set($arFields, "SID")) {
if (strlen(trim($arFields["SID"])) <= 0) {
$str .= GetMessage("FORM_ERROR_FORGOT_SID") . "<br>";
}
if (preg_match("/[^A-Za-z_01-9]/", $arFields["SID"])) {
$str .= GetMessage("FORM_ERROR_INCORRECT_SID") . "<br>";
} else {
$strSql = "SELECT ID, ADDITIONAL FROM b_form_field WHERE SID='" . $DB->ForSql(trim($arFields["SID"]), 50) . "' and ID<>'" . $FIELD_ID . "' AND FORM_ID='" . $DB->ForSql($arFields["FORM_ID"]) . "'";
$z = $DB->Query($strSql, false, $err_mess . __LINE__);
if ($zr = $z->Fetch()) {
$s = $zr["ADDITIONAL"] == "Y" ? str_replace("#TYPE#", GetMessage("FORM_TYPE_FIELD"), GetMessage("FORM_ERROR_WRONG_SID")) : str_replace("#TYPE#", GetMessage("FORM_TYPE_QUESTION"), GetMessage("FORM_ERROR_WRONG_SID"));
$s = str_replace("#ID#", $zr["ID"], $s);
$str .= $s . "<br>";
} else {
$strSql = "SELECT ID FROM b_form WHERE SID='" . $DB->ForSql(trim($arFields["SID"]), 50) . "'";
$z = $DB->Query($strSql, false, $err_mess . __LINE__);
if ($zr = $z->Fetch()) {
$s = str_replace("#TYPE#", GetMessage("FORM_TYPE_FORM"), GetMessage("FORM_ERROR_WRONG_SID"));
$s = str_replace("#ID#", $zr["ID"], $s);
$str .= $s . "<br>";
}
}
}
}
$str .= CFile::CheckImageFile($arFields["arIMAGE"]);
} else {
$str .= GetMessage("FORM_ERROR_ACCESS_DENIED");
}
}
$strError .= $str;
if (strlen($str) > 0) {
return false;
} else {
return true;
}
}
示例5: Copy
/**
* <p>Копирует <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#status">статус</a>. Возвращает ID нового <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#status">статуса</a> в случае положительного результата, в противном случае - "false".</p>
*
*
*
*
* @param int $status_id ID <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#status">статуса</a> который
* необходимо скопировать.
*
*
*
* @param string $check_rights = "Y" Флаг необходимости проверки <a
* href="http://dev.1c-bitrix.ru/api_help/form/terms.php#permissions">прав</a> текущего
* пользователя. Возможны следующие значения: <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#permissions#module">правами</a>: <ol> <li> <b>[25]
* просмотр параметров веб-формы</b> на ту веб-форму, из которой идет
* копирование; </li> <li> <b>[30] полный доступ</b> на ту веб-форму, в которую
* копируется. </li> </ol> Параметр необязательный. По умолчанию - "Y"
* (права необходимо проверить).
*
*
*
* @param mixed $form_id = false ID <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#form">веб-формы</a> в который
* необходимо скопировать <a
* href="http://dev.1c-bitrix.ru/api_help/form/terms.php#status">статус</a>.<br> Необязательный
* параметр. По умолчанию - "false" (текущая <a
* href="http://dev.1c-bitrix.ru/api_help/form/terms.php#form">веб-форма</a>).
*
*
*
* @return mixed
*
*
* <h4>Example</h4>
* <pre>
* <?
* $status_id = 1; // ID статуса
* // скопируем статус
* if ($NEW_STATUS_ID = <b>CFormStatus::Copy</b>($status_id))
* {
* echo "Статус #1 успешно скопирован в новый статус #".$NEW_STATUS_ID;
* }
* else
* {
* // выведем текст ошибки
* global $strError;
* echo $strError;
* }
* ?>
* </pre>
*
*
*
* <h4>See Also</h4>
* <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/form/classes/cform/copy.php">CForm::Copy</a> </li> <li> <a
* href="http://dev.1c-bitrix.ru/api_help/form/classes/cformfield/copy.php">CFormField::Copy</a> </li> <li> <a
* href="http://dev.1c-bitrix.ru/api_help/form/classes/cformanswer/copy.php">CFormAnswer::Copy</a> </li> </ul><a
* name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/form/classes/cformstatus/copy.php
* @author Bitrix
*/
public static 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")
//.........这里部分代码省略.........
示例6: GetPermissions
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;
}
示例7: GetList
//.........这里部分代码省略.........
break;
case "SITE":
if (is_array($val)) $val = implode(" | ", $val);
$match = ($arFilter[$key."_EXACT_MATCH"]=="N" && $match_value_set) ? "Y" : "N";
$arSqlSearch[] = GetFilterQuery("FS.SITE_ID", $val, $match);
$left_join = "LEFT JOIN b_form_2_site FS ON (F.ID = FS.FORM_ID)";
break;
}
}
}
if ($by == "s_id") $strSqlOrder = "ORDER BY F.ID";
elseif ($by == "s_c_sort" || $by == "s_sort") $strSqlOrder = "ORDER BY F.C_SORT";
elseif ($by == "s_name") $strSqlOrder = "ORDER BY F.NAME";
elseif ($by == "s_varname" || $by == "s_sid") $strSqlOrder = "ORDER BY F.SID";
else
{
$by = "s_sort";
$strSqlOrder = "ORDER BY F.C_SORT";
}
if ($order!="desc")
{
$strSqlOrder .= " asc ";
$order="asc";
}
else
{
$strSqlOrder .= " desc ";
$order="desc";
}
$strSqlSearch = GetFilterSqlSearch($arSqlSearch);
if (CForm::IsAdmin())
{
$strSql = "
SELECT
F.*,
F.SID VARNAME,
F.FIRST_SITE_ID,
F.FIRST_SITE_ID LID,
".$DB->DateToCharFunction("F.TIMESTAMP_X")." TIMESTAMP_X,
count(distinct D1.ID) C_FIELDS,
count(distinct D2.ID) QUESTIONS,
count(distinct S.ID) STATUSES
FROM
b_form F
LEFT JOIN b_form_status S ON (S.FORM_ID = F.ID)
LEFT JOIN b_form_field D1 ON (D1.FORM_ID = F.ID and D1.ADDITIONAL='Y')
LEFT JOIN b_form_field D2 ON (D2.FORM_ID = F.ID and D2.ADDITIONAL<>'Y')
$left_join
WHERE
$strSqlSearch
GROUP BY F.ID
$strSqlOrder
";
}
else
{
$arGroups = $USER->GetUserGroupArray();
if (!is_array($arGroups)) $arGroups[] = 2;
$groups = implode(",",$arGroups);
$def_permission = COption::GetOptionInt("form", "FORM_DEFAULT_PERMISSION", 10);
$strSql = "
SELECT
F.*,
示例8: unset
unset($arAllOptions[3]);
unset($arAllOptions[4]);
unset($arAllOptions[5]);
}
if ($REQUEST_METHOD == "POST" && strlen($Update) > 0 && CForm::IsAdmin() && check_bitrix_sessid()) {
foreach ($arAllOptions as $ar) {
$name = $ar[0];
$val = ${$name};
if ($ar[2][0] == "checkbox" && $val != "Y") {
$val = "N";
}
COption::SetOptionString($module_id, $name, $val);
}
COption::SetOptionString("form", "FORM_DEFAULT_PERMISSION", $FORM_DEFAULT_PERMISSION);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_REQUEST['saveCrm'] && CForm::IsAdmin() && check_bitrix_sessid()) {
if ($_REQUEST['ajax']) {
CUtil::JSPostUnEscape();
}
$arAdditionalAuthData = array();
$lastUpdated = '';
if (is_array($_REQUEST['CRM'])) {
foreach ($_REQUEST['CRM'] as $ID => $arCrm) {
if (is_array($arCrm)) {
$arCrm['ID'] = intval($ID);
if ($arCrm['DELETED'] && $arCrm['ID'] > 0) {
CFormCrm::Delete($arCrm['ID']);
} else {
$arCrmFields = array('NAME' => trim($arCrm['NAME']), 'ACTIVE' => 'Y', 'URL' => trim($arCrm['URL']));
if ($arCrm['ID'] <= 0) {
$arCrm['ID'] = CFormCrm::Add($arCrmFields);
示例9: reset
$groups[$zr["ID"]] = "[" . $zr["ID"] . "] " . $zr["NAME"];
$arGROUPS[] = $ar;
}
reset($arGROUPS);
while (list(, $value) = each($arGROUPS)) {
$APPLICATION->DelGroupRight($module_id, array($value["ID"]));
}
}
$arAllOptions = array(array("USE_HTML_EDIT", GetMessage("FORM_USE_HTML_EDIT"), array("checkbox", "Y")), array("SIMPLE", GetMessage("SIMPLE_MODE"), array("checkbox", "Y")), array("SHOW_TEMPLATE_PATH", GetMessage("FORM_SHOW_TEMPLATE_PATH"), array("text", 45)), array("SHOW_RESULT_TEMPLATE_PATH", GetMessage("FORM_SHOW_RESULT_TEMPLATE_PATH"), array("text", 45)), array("PRINT_RESULT_TEMPLATE_PATH", GetMessage("FORM_PRINT_RESULT_TEMPLATE_PATH"), array("text", 45)), array("EDIT_RESULT_TEMPLATE_PATH", GetMessage("FORM_EDIT_RESULT_TEMPLATE_PATH"), array("text", 45)), array("RECORDS_LIMIT", GetMessage("FORM_RECORDS_LIMIT"), array("text", 5)), array("RESULTS_PAGEN", GetMessage("FORM_RESULTS_PAGEN"), array("text", 5)));
if ($old_module_version != "Y") {
unset($arAllOptions[2]);
unset($arAllOptions[3]);
unset($arAllOptions[4]);
unset($arAllOptions[5]);
}
if ($REQUEST_METHOD == "POST" && strlen($Update) > 0 && CForm::IsAdmin()) {
foreach ($arAllOptions as $ar) {
$name = $ar[0];
$val = ${$name};
if ($ar[3][0] == "checkbox" && $val != "Y") {
$val = "N";
}
COption::SetOptionString($module_id, $name, $val);
}
COption::SetOptionString("form", "FORM_DEFAULT_PERMISSION", $FORM_DEFAULT_PERMISSION);
}
$aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB_SET"), "ICON" => "form_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_SET")), array("DIV" => "edit2", "TAB" => GetMessage("MAIN_TAB_RIGHTS"), "ICON" => "form_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_RIGHTS")));
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$tabControl->Begin();
?>
<form method="POST" action="<?php
示例10: GetDropdown
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: GetDropdown
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;
}