1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
condition.php
См. документацию.
1<?php
2
4
5// Compose string in compliance with selected type of condition
6function ConditionCompose($arRequest, $i = 0)
7{
8 $type = $_REQUEST['selected_type'][$i];
9 if ($type == 'folder' && $arRequest['CONDITION_folder'] <> '')
10 {
11 $cond = 'CSite::InDir(\'' . addslashes($arRequest['CONDITION_folder']) . '\')';
12 }
13 elseif ($type == 'ugroups' && is_array($arRequest['CONDITION_ugroups']))
14 {
15 for ($i = 0; $i < count($arRequest['CONDITION_ugroups']); $i++)
16 {
17 $arRequest['CONDITION_ugroups'][$i] = intval($arRequest['CONDITION_ugroups'][$i]);
18 }
19 $cond = 'CSite::InGroup(array(' . implode(",", $arRequest['CONDITION_ugroups']) . '))';
20 }
21 elseif ($type == 'period' && (MakeTimeStamp($arRequest['CONDITION_period_start']) || MakeTimeStamp($arRequest['CONDITION_period_end'])))
22 {
23 $cond = "CSite::InPeriod(" . intval(MakeTimeStamp($arRequest['CONDITION_period_start'])) . "," . intval(MakeTimeStamp($arRequest['CONDITION_period_end'])) . ")";
24 }
25 elseif ($type == 'url' && $arRequest['CONDITION_url_param'] <> '' && $arRequest['CONDITION_url_value'] <> '')
26 {
27 $cond = '($_GET[\'' . addslashes($arRequest['CONDITION_url_param']) . '\'] ?? "") == \'' . addslashes($arRequest['CONDITION_url_value']) . '\'';
28 }
29 elseif ($type === 'no_access')
30 {
32 }
33 elseif ($type == 'false')
34 {
35 $cond = 'false';
36 }
37 elseif ($type == 'php')
38 {
39 $cond = $arRequest['CONDITION_php'];
40 }
41 return $cond ?? null;
42}
43
44// Parse string and init vars
45function ConditionParse($c = '')
46{
47 global $strCondition, $arGroupsNames, $arDisplay, $arConditionTypes, $strFolder, $strUrl_param, $strUrl_value, $arSelGroups, $strPer_start, $strPer_end, $CurType;
48
49 $strCondition = $c;
50 $arDisplay = [
51 "empty" => "none",
52 "folder" => "none",
53 "ugroups" => "none",
54 "period" => "none",
55 "url" => "none",
56 "no_access" => "none",
57 "php" => "none",
58 "false" => "none",
59 ];
60
61 $CurType = "";
62 $strFolder = "";
63 $strUrl_param = "";
64 $strUrl_value = "";
65 $arSelGroups = [];
66 $strPer_start = "";
67 $strPer_end = "";
68
69 if (preg_match('/^CSite::InDir\‍(\'([^)]+)\'\‍)$/', $c, $r))
70 {
71 $CurType = 'folder';
72 $strFolder = stripslashes($r[1]);
73 }
74 elseif (preg_match('/^CSite::InGroup\‍(array\‍(([0-9, ]+)\‍)\‍)$/', $c, $r))
75 {
76 $CurType = 'ugroups';
77 $arSelGroups = explode(",", str_replace(" ", "", $r[1]));
78 }
79 elseif (preg_match('/^CSite::InPeriod\‍(([0-9]+) *, *([0-9]+)\‍)$/', $c, $r))
80 {
81 $strPer_start = $r[1] == 0 ? "" : ConvertTimeStamp($r[1]);
82 $strPer_end = $r[2] == 0 ? "" : ConvertTimeStamp($r[2]);
83 $CurType = 'period';
84 }
85 elseif (preg_match('/^\$_GET\[\'(.+)\'] *== *\'(.+)\'$/', $c, $r) || preg_match('/^\‍(\$_GET\[\'(.+)\'] *\?\? *""\‍) *== *\'(.+)\'$/', $c, $r))
86 {
87 $CurType = 'url';
88 $strUrl_param = stripslashes($r[1]);
89 $strUrl_value = stripslashes($r[2]);
90 }
92 {
93 $CurType = 'no_access';
94 }
95 elseif ($c == 'false')
96 {
97 $CurType = 'false';
98 }
99 elseif (empty($c))
100 {
101 $CurType = 'empty';
102 }
103 else
104 {
105 $CurType = 'php';
106 }
107
108 $arDisplay[$CurType] = 'block';
109}
110
112{
113 return '$GLOBALS["USER"]->HasNoAccess() && $_SERVER["REMOTE_USER"]==""';
114}
115
116// Insert select-list with condition types
117function ConditionSelect($i = '')
118{
119 global $CurType, $arConditionTypes;
120
121 $types_options = '';
122 foreach ($arConditionTypes as $key => $val)
123 {
124 $types_options .= "<option value=\"{$key}\"" . ($key == $CurType ? " selected" : "") . ">{$val}</option>";
125 }
126
127 echo "<select OnChange=\"ShowSelected('$i')\" id=\"selected_type$i\" name=\"selected_type[$i]\">$types_options</select>";
128}
129
130// Show condition types
131function ConditionShow($arArgs = [])
132{
133 global $strCondition, $APPLICATION, $arGroupsNames, $arDisplay, $arConditionTypes, $strFolder, $strUrl_param, $strUrl_value, $arSelGroups, $strPer_start, $strPer_end, $CurType, $USER;
134
135 $i = $arArgs['i'];
136 $field_name = $arArgs['field_name'];
137 $form = $arArgs['form'];
138 ?>
139 <div style="display:<?= $arDisplay['empty'] ?>" id="type_empty<?= $i ?>"><?= GetMessage("TYPES_EMPTY_COND") ?></div>
140 <? if (isset($arConditionTypes['false'])):?>
141 <div style="display:<?= $arDisplay['false'] ?>" id="type_false<?= $i ?>"><?= GetMessage("TYPES_FALSE_COND") ?></div>
142<?endif; ?>
143 <div style="display:<?= $arDisplay['folder'] ?>" value="<?= htmlspecialcharsbx($strFolder) ?>"
144 id="type_folder<?= $i ?>">
145 <?
147 "event" => "BtnClick$i",
148 "arResultDest" => ["ELEMENT_ID" => "fname$i"],
149 "arPath" => ["PATH" => '/'],
150 "select" => 'DF', // F - file only, D - folder only,
151 "operation" => 'O',// O - open, S - save
152 "showUploadTab" => true,
153 "saveConfig" => true,
154 ]
155 );
156 ?><input title="<?= GetMessage("MAIN_PATH") ?>" type="text" size="25" id="fname<?= $i ?>"
157 name="<?= $field_name ?>[CONDITION_folder]" value="<?= htmlspecialcharsbx($strFolder) ?>">&nbsp;<input
158 type="button" name="browse" value="..." onClick="BtnClick<?= $i ?>()">
159 </div>
160 <div style="display:<?= $arDisplay['ugroups'] ?>" id="type_ugroups<?= $i ?>">
161 <select title="<?= GetMessage("MAIN_USERGROUPS"); ?>" multiple size=5
162 name="<?= $field_name ?>[CONDITION_ugroups][]"><?
163 foreach ($arGroupsNames as $key => $val)
164 {
165 echo '<option value="' . $key . '"' . (in_array($key, $arSelGroups) ? " selected" : "") . '>' . htmlspecialcharsbx($val) . '</option>';
166 }
167 ?></select>
168 </div>
169 <div style="display:<?= $arDisplay['period'] ?>" id="type_period<?= $i ?>">
170 <input title="<?= GetMessage("MAIN_PERIOD_FROM") ?>" type="text" size="10"
171 value="<?= htmlspecialcharsbx($strPer_start) ?>" name="<?= $field_name ?>[CONDITION_period_start]"
172 id="<?= $field_name ?>[CONDITION_period_start]">
173 <?= Calendar($field_name . "[CONDITION_period_start]", $form) ?>
174 -
175 <input title="<?= GetMessage("MAIN_PERIOD_TO") ?>" type="text" size="10"
176 value="<?= htmlspecialcharsbx($strPer_end) ?>" name="<?= $field_name ?>[CONDITION_period_end]">
177 <?= Calendar($field_name . "[CONDITION_period_end]", $form) ?>
178 <span class="required"></span>
179 </div>
180 <div style="display:<?= $arDisplay['url'] ?>" id="type_url<?= $i ?>">
181 <input title="<?= GetMessage("MAIN_URL_FIELD") ?>" type="text" size="10"
182 name="<?= $field_name ?>[CONDITION_url_param]" value="<?= htmlspecialcharsbx($strUrl_param) ?>">
183 =
184 <input title="<?= GetMessage("MAIN_URL_VALUE") ?>" type="text" size="10"
185 name="<?= $field_name ?>[CONDITION_url_value]" value="<?= htmlspecialcharsbx($strUrl_value) ?>">
186 </div>
187 <div style="display:<?= $arDisplay['no_access'] ?>"
188 id="type_no_access<?= $i ?>"><?= GetMessage("TYPES_EMPTY_COND") ?></div>
189 <div style="display:<?= $arDisplay['php'] ?>" id="type_php<?= $i ?>"><input type="text" size="30"
190 name="<?= $field_name ?>[CONDITION_php]"
191 value="<?= htmlspecialcharsex($strCondition) ?>" <? echo((!$USER->CanDoOperation('edit_php')) ? 'disabled' : ''); ?>>
192 </div>
193 <?
194}
195
196// JavaScript for displaying and hiding conditions of different types
197function ConditionJS($arOpt = [])
198{
199 global $arConditionTypes, $arGroupsNames, $USER;
200
201 $arGroupsNames = [];
202 $dbGroups = CGroup::GetList("c_sort", "asc", ["ANONYMOUS" => "N"]);
203 while ($arGroups = $dbGroups->Fetch())
204 {
205 $arGroupsNames[$arGroups["ID"]] = $arGroups["NAME"];
206 }
207
208 $arConditionTypes = [
209 "empty" => GetMessage("TYPES_EMPTY"),
210 "folder" => GetMessage("TYPES_FOLDER"),
211 "ugroups" => GetMessage("TYPES_UGROUPS"),
212 "period" => GetMessage("TYPES_PERIOD"),
213 "url" => GetMessage("TYPES_URL"),
214 "no_access" => GetMessage("TYPES_NO_ACCESS"),
215 "php" => GetMessage("TYPES_PHP"),
216 ];
217
218 if (isset($arOpt['enable_false']) && $arOpt['enable_false'])
219 {
220 $arConditionTypes["false"] = GetMessage("TYPES_FALSE");
221 }
222 ?>
223 <script>
224 function ShowSelected(i)
225 {
226 a = document.getElementById("selected_type" + i).value;
227 <?
228 foreach ($arConditionTypes as $key => $dummy)
229 {
230 print "document.getElementById('type_{$key}'+i).style.display=\"none\"\n";
231 }
232 ?>
233 document.getElementById('type_' + a + i).style.display = "block";
234 }
235 </script>
236 <?
237}
return select
Определения access_edit.php:440
$type
Определения options.php:106
global $APPLICATION
Определения include.php:80
static ShowScript($arConfig)
Определения file_dialog.php:9
static GetList($by='c_sort', $order='asc', $arFilter=[], $SHOW_USERS_AMOUNT="N")
Определения group.php:136
& nbsp
Определения epilog_main_admin.php:38
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$arGroups
Определения options.php:1766
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
global $USER
Определения csv_new_run.php:40
endif
Определения csv_new_setup.php:990
ConditionJS($arOpt=[])
Определения condition.php:197
ConditionSelect($i='')
Определения condition.php:117
ConditionParse($c='')
Определения condition.php:45
ConditionCompose($arRequest, $i=0)
Определения condition.php:6
GetNoAccessConditionString()
Определения condition.php:111
ConditionShow($arArgs=[])
Определения condition.php:131
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643
font style
Определения invoice.php:442
font size
Определения invoice.php:442
$val
Определения options.php:1793
$dbGroups
Определения options.php:2993