1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
access_edit.php
См. документацию.
1<?php
2
4
5require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
6require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
7
9
10$popupWindow = new CJSPopup('', array("SUFFIX"=>($_GET['subdialog'] == 'Y'? 'subdialog':'')));
11
12if (IsModuleInstalled("fileman"))
13{
14 if (!$USER->CanDoOperation('fileman_edit_existent_folders') && !$USER->CanDoOperation('fileman_admin_folders'))
15 $popupWindow->ShowError(GetMessage("FOLDER_EDIT_ACCESS_DENIED"));
16}
17
19
20//Folder path
21$path = "/";
22if (isset($_REQUEST["path"]) && $_REQUEST["path"] <> '')
23 $path = $io->CombinePath("/", $_REQUEST["path"]);
24
25//Site ID
27if (isset($_REQUEST["site"]) && $_REQUEST["site"] <> '')
28{
29 $obSite = CSite::GetByID($_REQUEST["site"]);
30 if ($arSite = $obSite->Fetch())
31 $site = $_REQUEST["site"];
32}
33
34//Document Root
35$documentRoot = CSite::GetSiteDocRoot($site);
36
37//Check path permissions
38if (!$io->FileExists($documentRoot.$path) && !$io->DirectoryExists($documentRoot.$path))
39 $popupWindow->ShowError(GetMessage("ACCESS_EDIT_FILE_NOT_FOUND")." (".htmlspecialcharsbx($path).")");
40elseif (!$USER->CanDoFileOperation('fm_edit_existent_folder', array($site, $path)))
41 $popupWindow->ShowError(GetMessage("FOLDER_EDIT_ACCESS_DENIED"));
42elseif (!$USER->CanDoFileOperation('fm_edit_permission', array($site, $path)))
43 $popupWindow->ShowError(GetMessage("EDIT_ACCESS_TO_DENIED")." \"".htmlspecialcharsbx($path)."\"");
44
45//Lang
46if (!isset($_REQUEST["lang"]) || $_REQUEST["lang"] == '')
47 $lang = LANGUAGE_ID;
48
49//BackUrl
50$back_url = ($_REQUEST["back_url"] ?? "");
51
52//Is a folder?
53$isFolder = $io->DirectoryExists($documentRoot.$path);
54
55//Get only used user group from .access.php file
57
60
62while(true)
63{
64 //Cut / from the end
65 $currentPath = rtrim($currentPath, "/");
66
67 if ($currentPath == '')
68 {
69 $accessFile = "/.access.php";
70 $name = "/";
71 }
72 else
73 {
74 //Find file or folder name
75 $position = mb_strrpos($currentPath, "/");
76 if ($position === false)
77 break;
78
79 $name = mb_substr($currentPath, $position + 1);
80 $name = TrimUnsafe($name); //security fix: under Windows "my." == "my"
81
82 //Find parent folder
83 $currentPath = mb_substr($currentPath, 0, $position + 1);
84 $accessFile = $currentPath.".access.php";
85 }
86
87 $PERM = Array();
88 if ($io->FileExists($documentRoot.$accessFile))
89 include($io->GetPhysicalName($documentRoot.$accessFile));
90
91 if ($assignFileName == "")
92 {
94 $assignFolderName = ($name == "/" ? "/" : $currentPath);
95 }
96
97 if (isset($PERM[$name]) && is_array($PERM[$name]))
98 $arUserGroupsID = array_merge($arUserGroupsID, array_keys($PERM[$name]));
99
100 if ($currentPath == '')
101 break;
102}
103
104foreach($arUserGroupsID as $key=>$val)
105 if(preg_match('/^[0-9]+$/', $val))
107
108$arUserGroupsID = array_unique($arUserGroupsID);
109
110//Get all tasks
112$obTask = CTask::GetList(array("LETTER" => "ASC"), array("MODULE_ID" => "main", "BINDING" => "file"));
113while($arTask = $obTask->Fetch())
114 $arPermTypes[$arTask["ID"]] = CTask::GetLangTitle($arTask["NAME"], $arTask["MODULE_ID"]);
115
116//Current file/folder permissions
118if($io->FileExists($documentRoot.$assignFolderName.".access.php"))
119{
120 $PERM = array();
121 include($io->GetPhysicalName($documentRoot.$assignFolderName.".access.php"));
122
123 foreach($PERM as $file => $arPerm)
124 foreach($arPerm as $code => $permission)
125 $currentPermission[$file][(preg_match('/^[0-9]+$/', $code)? "G".$code : $code)] = $permission;
126}
127
129
130//Save permissions
131if ($_SERVER["REQUEST_METHOD"] == "POST" && !check_bitrix_sessid())
132{
133 $strWarning = GetMessage("MAIN_SESSION_EXPIRED");
134}
135elseif ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_REQUEST["save"]))
136{
137 $arSavePermission = array();
138
139 if (isset($_POST["REMOVE_PERMISSIONS"]) && $_POST["REMOVE_PERMISSIONS"] == "Y")
140 {
141 if($path != "/")
142 {
143 $APPLICATION->RemoveFileAccessPermission(array($site, $path));
144
145 if ($e = $APPLICATION->GetException())
146 $strWarning = $e->msg;
147 }
148 }
149 else
150 {
151 if (isset($_POST["PERMISSION"]) && is_array($_POST["PERMISSION"]))
152 {
154 $arSavePermission = $currentPermission[$assignFileName];
155
156 $isAdmin = $USER->IsAdmin();
157
158 foreach ($_POST["PERMISSION"] as $groupID => $taskID)
159 {
160 if($groupID !== "*")
161 {
162 $groupID = trim($groupID);
163 if($groupID == '')
164 continue;
165 }
166 elseif (!$isAdmin)
167 continue;
168
169 // if not set task - delete permission
170 $taskID = intval($taskID);
171 if ($taskID <= 0)
172 {
173 unset($arSavePermission[$groupID]);
174 continue;
175 }
176
177 $obTask = CTask::GetById($taskID);
178 if ( ($arTask = $obTask->Fetch()) && $arTask["LETTER"] && $arTask["SYS"] == "Y")
179 $permLetter = $arTask["LETTER"];
180 else
181 $permLetter = "T_".$taskID;
182
183 $arSavePermission[$groupID] = $permLetter;
184 }
185 }
186
187 $APPLICATION->SetFileAccessPermission(array($site, $path), $arSavePermission);
188
189 if ($e = $APPLICATION->GetException())
190 $strWarning = $e->msg;
191 }
192
193 //Close window
194 if ($strWarning == "")
195 {
196 $popupWindow->Close($bReload=($_GET['subdialog'] <> 'Y'), $back_url);
197 die();
198 }
199}
200
201echo CJSCore::Init(array('access'), true);
202
203//HTML output
204if ($isFolder)
205 $popupWindow->ShowTitlebar(GetMessage("EDIT_ACCESS_TO_FOLDER"));
206else
207 $popupWindow->ShowTitlebar(GetMessage("EDIT_ACCESS_TO_FILE"));
208
209$popupWindow->StartDescription($isFolder ? "bx-access-folder" : "bx-access-page");
210
211if ($strWarning != "")
212 $popupWindow->ShowValidationError($strWarning);
213?>
214
215<p><b><?=($isFolder ? GetMessage("EDIT_ACCESS_TO_FOLDER") : GetMessage("EDIT_ACCESS_TO_FILE"))?></b> <?=htmlspecialcharsbx($path);?></p>
216
217<?
218$popupWindow->EndDescription();
219$popupWindow->StartContent();
220?>
221
222<table class="bx-width100" id="bx_permission_table">
223 <tr>
224 <td width="45%"><b><?=GetMessage("EDIT_ACCESS_USER_GROUP")?></b></td>
225 <td><b><?=GetMessage("EDIT_ACCESS_PERMISSION")?></b> </td>
226 </tr>
227 <tr class="empty">
228 <td colspan="2"></td>
229 </tr>
230
231<?
232//names for access codes
233$access = new CAccess();
235
236//sort codes by sorted names
237$positions = array_flip(array_keys($arNames));
238usort($arUserGroupsID,
239 function($a, $b) use ($positions)
240 {
241 if(!isset($positions[$a]) && !isset($positions[$b])) return 0;
242 if(!isset($positions[$a])) return 1;
243 if(!isset($positions[$b])) return -1;
244 return ($positions[$a] > $positions[$b]? 1 : -1);
245 }
246);
247
248//Javascript variables
249$jsTaskArray = "window.BXTaskArray = {'0':'".CUtil::JSEscape(GetMessage("EDIT_ACCESS_SET_INHERIT"))."'";
250foreach ($arPermTypes as $taskID => $taskTitle)
251 $jsTaskArray .= ",'".$taskID."':'".CUtil::JSEscape($taskTitle)."'";
252$jsTaskArray .= "};";
253
255$jsInheritPermID = "var jsInheritPermIDs = [";
257
258foreach($arUserGroupsID as $access_code):
259
260 //Restore post value if error occured
261 $errorOccured = ($strWarning != "" && isset($_POST["PERMISSION"]) && is_array($_POST["PERMISSION"]) && array_key_exists($access_code, $_POST["PERMISSION"]));
262
263 //Inherit Task
264 list ($inheritTaskID) = $APPLICATION->GetFileAccessPermission(Array($site, $assignFolderName), Array($access_code), true);
265
266 if (!array_key_exists($inheritTaskID, $arPermTypes))
267 {
268 if ($access_code == "*")
269 $inheritTaskID = CTask::GetIdByLetter("D", "main", "file");
270 else
271 continue;
272 }
273
274 //Current permission
276
277 if ($errorOccured)
278 {
279 //Restore post value if error occured
280 $currentPerm = intval($_POST["PERMISSION"][$access_code]);
281 }
283 {
284 $permLetter = $currentPermission[$assignFileName][$access_code];
285
286 if (str_starts_with($permLetter, "T_"))
287 {
288 $currentPerm = intval(substr($permLetter, 2));
289 if (!array_key_exists($currentPerm, $arPermTypes))
290 $currentPerm = false;
291 }
292 else
293 $currentPerm = CTask::GetIdByLetter($permLetter, "main", "file");
294 }
295
296 if ($currentPerm === false && $access_code == "*" && $path == "/")
297 $currentPerm = $inheritTaskID;
298
299 if ($access_code == "*")
300 $jsInheritPerm = $inheritTaskID;
301
302 $permissionID = $access_code."_".intval($currentPerm)."_".intval($inheritTaskID);?>
303
304 <tr>
305 <td><?=(
306 $access_code == "*" ?
307 GetMessage("EDIT_ACCESS_ALL_GROUPS")
308 : ($arNames[$access_code]["provider"] <> '' ? '<b>'.htmlspecialcharsbx($arNames[$access_code]["provider"]).': </b> ' : '')
309 . htmlspecialcharsbx($arNames[$access_code]["name"])
310 )?></td>
311 <td>
312 <?if ($currentPerm === false && $path != "/"): //Inherit permission
314 ?>
315
316 <div id="bx_permission_view_<?=$permissionID?>" onclick="BXEditPermission('<?=$permissionID?>')" class="edit-field" style="width:90%;">
317 <?=GetMessage("EDIT_ACCESS_SET_INHERITED")." &quot;".htmlspecialcharsEx($arPermTypes[$inheritTaskID])."&quot;"?>
318 </div>
319
320 <div id="bx_permission_edit_<?=$permissionID?>" style="display:none;"></div>
321
322 <?
323 else: //Current permission
324 $bWasCurrentPerm = true;
325 ?>
326
327 <select name="PERMISSION[<?=$access_code?>]" style="width:90%;" id="bx_task_list_<?=$permissionID?>">
328
329 <?if ($path == "/"):?>
330 <option value="0"><?=GetMessage("EDIT_ACCESS_NOT_SET")?></option>
331 <?else:?>
332 <option value="0"><?=GetMessage("EDIT_ACCESS_SET_INHERIT")." &quot;".htmlspecialcharsEx($arPermTypes[$inheritTaskID])."&quot;"?></option>
333 <?endif?>
334
335 <?foreach ($arPermTypes as $taskID => $taskTitle):?>
336 <option value="<?=$taskID?>"<?if ($currentPerm == $taskID):?> selected="selected"<?endif?>><?=htmlspecialcharsEx($taskTitle);?></option>
337 <?endforeach?>
338
339 </select>
340
341 <?endif?>
342 </td>
343 </tr>
344
345<?
347
348$jsInheritPermID .= "];";
349?>
350
351</table>
352
353<p><a href="javascript:void(0)" onclick="BX.Access.ShowForm({callback:BXAddNewPermission})"><?=GetMessage("EDIT_ACCESS_ADD_PERMISSION")?></a></p>
354
355<?if($bWasCurrentPerm && $path != "/"):?>
356 <p><b><a href="javascript:void(0)" onclick="BXClearPermission()"><?=($isFolder? GetMessage("EDIT_ACCESS_REMOVE_PERM"):GetMessage("EDIT_ACCESS_REMOVE_PERM_FILE"))?></a></b></p>
357 <input type="hidden" name="REMOVE_PERMISSIONS" id="REMOVE_PERMISSIONS" value="">
358<?endif?>
359
360<input type="hidden" name="save" value="Y" />
361<?
362$popupWindow->EndContent();
363$popupWindow->ShowStandardButtons();
364
366foreach($arUserGroupsID as $code)
367 $arSel[$code] = true;
368?>
369
370<script>
371BX.Access.Init();
372BX.Access.SetSelected(<?=Json::encode($arSel)?>);
373
374<?=$jsTaskArray?>
375
376window.BXAddNewPermission = function(arRights)
377{
378 var table = document.getElementById("bx_permission_table");
379
380 for(var provider in arRights)
381 {
382 for(var id in arRights[provider])
383 {
384 //Create new row
385 var tableRow = table.insertRow(table.rows.length);
386
387 var groupTD = tableRow.insertCell(0);
388 var currentTD = tableRow.insertCell(1);
389
390 var pr = BX.Access.GetProviderName(provider);
391 groupTD.innerHTML = (pr? '<b>'+BX.util.htmlspecialchars(pr)+':</b> ':'')+BX.util.htmlspecialchars(arRights[provider][id].name);
392
393 //Insert Task Select
394 var permissionID = Math.round(Math.random() * 100000);
395 var taskSelect = BXCreateTaskList(permissionID, 0, 0, id);
396 taskSelect.onblur = "";
397
398 currentTD.appendChild(taskSelect);
399 }
400 }
401
402 return false;
403};
404
405window.BXCreateTaskList = function(permissionID, currentPermission, inheritPermission, userGroupID)
406{
407 var select = document.createElement("SELECT");
408 select.name = "PERMISSION["+userGroupID+"]";
409 select.style.width = "90%";
410 select.onblur = function(){BXBlurEditPermission(select, permissionID)};
411 select.id = "bx_task_list_" + permissionID;
412
413 //For IE 5.0
414 var selectDocument = select.ownerDocument;
415 if (!selectDocument)
416 selectDocument = select.document;
417
418 var selectedIndex = 0;
419
420 <?if ($path == "/"):?>
421 window.BXTaskArray["0"] = "<?=CUtil::JSEscape(GetMessage("EDIT_ACCESS_NOT_SET"))?>";
422 <?else:?>
423 window.BXTaskArray["0"] = "<?=CUtil::JSEscape(GetMessage("EDIT_ACCESS_SET_INHERIT"))?>" + " \"" + window.BXTaskArray[(inheritPermission == 0 ? <?=intval($jsInheritPerm)?> : inheritPermission)] + "\"";
424 <?endif?>
425
426 for(var taskID in BXTaskArray)
427 {
428 var option = selectDocument.createElement("OPTION");
429 option.text = window.BXTaskArray[taskID];
430 option.value = taskID;
431
432 select.options.add(option);
433
434 if (taskID == currentPermission)
435 selectedIndex = select.options.length - 1;
436 }
437
438 select.selectedIndex = selectedIndex;
439
440 return select;
441};
442
443window.BXBlurEditPermission = function(select, permissionID)
444{
445 var viewPermission = document.getElementById("bx_permission_view_" + permissionID);
446 var setPermission = select.options[select.selectedIndex].value;
447
448 var arPermID = permissionID.split("_");
449 var userGroupID = arPermID[0];
450 var currentPermission = arPermID[1];
451
452 if (setPermission == currentPermission)
453 {
454 var editPermission = document.getElementById("bx_permission_edit_" + permissionID);
455
456 viewPermission.style.display = "block";
457 editPermission.style.display = "none";
458
459 while (editPermission.firstChild)
460 editPermission.removeChild(editPermission.firstChild);
461 }
462};
463
464window.BXEditPermission = function(permissionID)
465{
466 if (document.getElementById("bx_task_list_" + permissionID))
467 return;
468
469 var arPermID = permissionID.split("_"); //Format permissionID: UserGroup_CurrentPermission_InheritPermission
470
471 var userGroupID = arPermID[0];
472 var currentPermission = arPermID[1];
473 var inheritPermission = arPermID[2];
474
475 if (userGroupID == "0")
476 userGroupID = "*";
477
478 var editPermission = document.getElementById("bx_permission_edit_" + permissionID);
479 var viewPermission = document.getElementById("bx_permission_view_" + permissionID);
480
481 editPermission.style.display = "block";
482 viewPermission.style.display = "none";
483
484 var taskSelect = BXCreateTaskList(permissionID, currentPermission, inheritPermission, userGroupID);
485
486 editPermission.appendChild(taskSelect);
487 taskSelect.focus();
488};
489
490
491window.BXCreateAccessHint = function()
492{
493 var table = document.getElementById("bx_permission_table");
494 var tableRow = table.rows[0];
495
496 var groupTD = tableRow.cells[0];
497 var currentTD = tableRow.cells[1];
498
499 var oBXHint = new BXHint("<?=CUtil::JSEscape(GetMessage("EDIT_ACCESS_PERMISSION_INFO"))?>");
500 currentTD.appendChild(oBXHint.oIcon);
501
502
504
505 for (var index = 0; index < jsInheritPermIDs.length; index++)
506 oBXHint = new BXHint("<?=CUtil::JSEscape(GetMessage("EDIT_ACCESS_SET_PERMISSION"))?>", document.getElementById("bx_permission_view_"+ jsInheritPermIDs[index]), {"width":200});
507};
508
509window.BXClearPermission = function()
510{
511 if(confirm('<?=CUtil::JSEscape(GetMessage("EDIT_ACCESS_REMOVE_PERM_CONF"))?>'))
512 {
513 BX("REMOVE_PERMISSIONS").value = "Y";
514 BX.WindowManager.Get().PostParameters();
515 }
516};
517
518window.BXCreateAccessHint();
519</script>
520
521<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");?>
$path
Определения access_edit.php:21
$assignFolderName
Определения access_edit.php:59
$currentPermission
Определения access_edit.php:117
return select
Определения access_edit.php:440
$arSel
Определения access_edit.php:365
$jsInheritPermID
Определения access_edit.php:255
if(!array_key_exists($inheritTaskID, $arPermTypes)) $currentPerm
Определения access_edit.php:275
if($path=="/")<?else:?> window BXTaskArray["0"]
Определения access_edit.php:423
$popupWindow
Определения access_edit.php:10
$back_url
Определения access_edit.php:50
<?endif?> for(var taskID in BXTaskArray) select selectedIndex
Определения access_edit.php:438
$positions
Определения access_edit.php:237
$currentPath
Определения access_edit.php:61
window BXBlurEditPermission
Определения access_edit.php:443
$arUserGroupsID
Определения access_edit.php:56
$jsInheritPerm
Определения access_edit.php:254
$permissionID
Определения access_edit.php:302
$bWasCurrentPerm
Определения access_edit.php:256
if( $_SERVER elseif["REQUEST_METHOD"]=="POST" &&!check_bitrix_sessid())( $_SERVER["REQUEST_METHOD"]=="POST" &&isset( $_REQUEST["save"]))
Определения access_edit.php:135
$isFolder
Определения access_edit.php:53
$arPermTypes
Определения access_edit.php:111
$assignFileName
Определения access_edit.php:58
$jsTaskArray
Определения access_edit.php:249
$obTask
Определения access_edit.php:112
<?=$taskID?> selected
Определения access_edit.php:348
global $APPLICATION
Определения include.php:80
if($canUseYandexMarket) $strWarning
Определения options.php:74
Определения json.php:9
static GetLangTitle($name, $module="main")
Определения task.php:410
static GetIdByLetter($letter, $module, $binding='module')
Определения task.php:451
static GetList($arOrder=['MODULE_ID'=> 'asc', 'LETTER'=> 'asc'], $arFilter=[])
Определения task.php:185
static GetInstance()
Определения virtual_io.php:60
static Init($arExt=array(), $bReturn=false)
Определения jscore.php:66
Определения jspopup.php:10
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
Определения file_new.php:677
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $USER
Определения csv_new_run.php:40
$io
Определения csv_new_run.php:98
endif
Определения csv_new_setup.php:990
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
foreach(['Bitrix\\Main'=> '/lib', 'Psr\\Container'=> '/vendor/psr/container/src', 'Psr\\Log'=> '/vendor/psr/log/src', 'Psr\\Http\\Message'=> '/vendor/psr/http-message/src', 'Psr\\Http\\Client'=> '/vendor/psr/http-client/src', 'Http\\Promise'=> '/vendor/php-http/promise/src', 'PHPMailer\\PHPMailer'=> '/vendor/phpmailer/phpmailer/src', 'GeoIp2'=> '/vendor/geoip2/geoip2/src', 'MaxMind\\Db'=> '/vendor/maxmind-db/reader/src/MaxMind/Db', 'PhpParser'=> '/vendor/nikic/php-parser/lib/PhpParser', 'Recurr'=> '/vendor/simshaun/recurr/src/Recurr',] as $namespace=> $namespacePath) $documentRoot
Определения autoload.php:27
if(!defined('SITE_ID')) $lang
Определения include.php:91
if(!is_array($deviceNotifyCodes)) $access
Определения options.php:174
$arNames
Определения options.php:175
check_bitrix_sessid($varname='sessid')
Определения tools.php:4686
IsModuleInstalled($module_id)
Определения tools.php:5301
TrimUnsafe($path)
Определения tools.php:2934
htmlspecialcharsEx($str)
Определения tools.php:2685
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
$name
Определения menu_edit.php:35
return false
Определения prolog_main_admin.php:185
global_menu_<?echo $menu["menu_id"]?> adm main menu item icon adm main menu item text text adm main menu hover adm submenu menucontainer menu_id menu_id items_id items_id desktop menu_id block none adm global submenu<?=($subMenuDisplay=="block" ? " adm-global-submenu-active" :"")?> global_submenu_<?echo $menu["menu_id"]?> text MAIN_PR_ADMIN_FAV items adm submenu items wrap adm submenu items stretch wrap BX adminMenu itemsStretchScroll()"> <table class if (!empty( $menu["items"])) elseif ( $menu[ 'menu_id']=='desktop') if ( $menu[ 'menu_id']=='desktop') endforeach
Определения prolog_main_admin.php:255
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
font style
Определения invoice.php:442
else $a
Определения template.php:137
$val
Определения options.php:1793
const SITE_ID
Определения sonet_set_content_view.php:12
$site
Определения yandex_run.php:614