index.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <?php
  2. if (cfr('PERMISSIONS')) {
  3. /**
  4. * Performs replication of administrators rights to existing user
  5. *
  6. * @global object $system
  7. * @param string $sourceUser
  8. * @param string $targetUser
  9. */
  10. function zb_PermissionsCopyAdminRights($sourceUser, $targetUser) {
  11. global $system;
  12. $targetRights = array();
  13. $rootUser = '';
  14. $rights = array();
  15. $system->getRightsForUser($sourceUser, $rights, $root, $level);
  16. if ($root) {
  17. $rootUser = 1;
  18. } else {
  19. if (!empty($rights)) {
  20. foreach ($rights as $eachright => $desc) {
  21. $targetRights[$eachright] = 'on';
  22. }
  23. }
  24. }
  25. //writing changes
  26. if ($system->setRightsForUser($targetUser, $targetRights, $rootUser, '1')) {
  27. show_window('', __('Rights cloned'));
  28. log_register("UBADMIN CLONE PERMISSIONS FROM {" . $sourceUser . "} TO {" . $targetUser . "}");
  29. rcms_redirect("?module=permissions&edit=" . $targetUser);
  30. } else {
  31. show_error(__('Error occurred'));
  32. }
  33. }
  34. /**
  35. * Returns login selector with all of administrator users
  36. *
  37. * @param string $excludeuser
  38. * @return string
  39. */
  40. function web_AdminLoginSelector($excludeuser = '') {
  41. $alladdmins = rcms_scandir(USERS_PATH);
  42. $alllogins = array();
  43. if (!empty($alladdmins)) {
  44. foreach ($alladdmins as $eachlogin) {
  45. $alllogins[$eachlogin] = $eachlogin;
  46. }
  47. }
  48. if (!empty($excludeuser)) {
  49. unset($alllogins[$excludeuser]);
  50. }
  51. $result = wf_Selector('admincopyselector', $alllogins, __('Copy rights of this administrator for current user'), '', false);
  52. return ($result);
  53. }
  54. /**
  55. * Returns available administrators list
  56. *
  57. * @return string
  58. */
  59. function web_list_admins() {
  60. $myLogin = whoami();
  61. $allEmployeeLogins = ts_GetAllEmployeeLoginsAssocCached();
  62. $alladmins = rcms_scandir(USERS_PATH);
  63. $cells = wf_TableCell(__('Admin'));
  64. $cells .= wf_TableCell(__('Worker'));
  65. $cells .= wf_TableCell(__('Actions'));
  66. $rows = wf_TableRow($cells, 'row1');
  67. if (!empty($alladmins)) {
  68. foreach ($alladmins as $eachadmin) {
  69. $deletionUrl = '?module=adminreg&deleteadministrator=' . $eachadmin;
  70. $cancelUrl = '?module=permissions';
  71. $deleteControl = wf_ConfirmDialog($deletionUrl, web_delete_icon(), __('Removing this may lead to irreparable results'), '', $cancelUrl, __('Delete') . ' ' . $eachadmin . '?');
  72. $actions = $deleteControl . ' ';
  73. $actions .= wf_Link('?module=adminreg&editadministrator=' . $eachadmin, web_key_icon()) . ' ';
  74. $actions .= wf_Link('?module=permissions&edit=' . $eachadmin, web_edit_icon('Rights')) . ' ';
  75. if (cfr('ROOT')) {
  76. if ($myLogin != $eachadmin) {
  77. $ghostModeLabel = __('Login as') . ' ' . $eachadmin . ' ' . __('in ghost mode');
  78. $actions .= wf_JSAlert('?module=permissions&ghostmode=' . $eachadmin, wf_img('skins/ghost.png', $ghostModeLabel), $ghostModeLabel . '?');
  79. }
  80. }
  81. $cells = wf_TableCell($eachadmin);
  82. $employeeName = '';
  83. if (isset($allEmployeeLogins[$eachadmin])) {
  84. $employeeName .= $allEmployeeLogins[$eachadmin];
  85. }
  86. $cells .= wf_TableCell($employeeName);
  87. $cells .= wf_TableCell($actions);
  88. $rows .= wf_TableRow($cells, 'row5');
  89. }
  90. }
  91. $form = wf_TableBody($rows, '100%', '0', 'sortable');
  92. return($form);
  93. }
  94. /**
  95. * Returns available permissions groups
  96. *
  97. * @param string $groupname
  98. * @return array
  99. */
  100. function zb_PermissionGroup($groupname) {
  101. $path = CONFIG_PATH . "permgroups.ini";
  102. $result = array();
  103. $rawdata = rcms_parse_ini_file($path);
  104. $rawperms = explode(',', $rawdata[$groupname]);
  105. if (!empty($groupname)) {
  106. $result = $rawperms;
  107. $result = array_flip($result);
  108. }
  109. return ($result);
  110. }
  111. /**
  112. * Shows permissions editor for some user
  113. *
  114. * @global object $system
  115. * @param string $login
  116. */
  117. function web_permissions_editor($login) {
  118. global $system;
  119. $regperms = zb_PermissionGroup('USERREG');
  120. $geoperms = zb_PermissionGroup('GEO');
  121. $sysperms = zb_PermissionGroup('SYSTEM');
  122. $finperms = zb_PermissionGroup('FINANCE');
  123. $repperms = zb_PermissionGroup('REPORTS');
  124. $catvperms = zb_PermissionGroup('CATV');
  125. $branchesperms = zb_PermissionGroup('BRANCHES');
  126. $reginputs = '';
  127. $geoinputs = '';
  128. $sysinputs = '';
  129. $fininputs = '';
  130. $repinputs = '';
  131. $catvinputs = '';
  132. $branchesinputs = '';
  133. $miscinputs = '';
  134. $reginputsnames = '';
  135. $eginputsnames = '';
  136. $geoinputsnames = '';
  137. $sysinputsnames = '';
  138. $fininputsnames = '';
  139. $repinputsnames = '';
  140. $catvinputsnames = '';
  141. $branchesinputsnames = '';
  142. $miscinputsnames = '';
  143. $reginputsallchecked = true;
  144. $eginputsallchecked = true;
  145. $geoinputsallchecked = true;
  146. $sysinputsallchecked = true;
  147. $fininputsallchecked = true;
  148. $repinputsallchecked = true;
  149. $catvinputsallchecked = true;
  150. $branchesinputsallchecked = true;
  151. $miscinputsallchecked = true;
  152. $inputs = wf_BackLink('?module=permissions');
  153. //ghost mode controls
  154. $myLogin = whoami();
  155. if (cfr('ROOT')) {
  156. if ($myLogin != $login) {
  157. $ghostModeLabel = __('Login as') . ' ' . $login . ' ' . __('in ghost mode');
  158. $inputs .= ' ' . wf_Link('?module=permissions&ghostmode=' . $login, wf_img('skins/ghost.png') . ' ' . $ghostModeLabel, false, ' ubButton');
  159. }
  160. }
  161. $inputs .= wf_delimiter();
  162. $inputs .= wf_HiddenInput('save', '1');
  163. if ($system->getRightsForUser($login, $rights, $root, $level)) {
  164. if ($root) {
  165. $inputs .= wf_tag('p', false, 'glamour') . wf_CheckInput('rootuser', __('Root administrator'), true, true) . wf_tag('p', true) . wf_CleanDiv();
  166. } else {
  167. $inputs .= wf_tag('p', false, 'glamour') . wf_CheckInput('rootuser', __('Root administrator'), true, false) . wf_tag('p', true) . wf_CleanDiv();
  168. foreach ($system->rights_database as $right_id => $right_desc) {
  169. $InputName = '_rights[' . $right_id . ']';
  170. //sorting inputs
  171. if ((!isset($regperms[$right_id])) AND ( !isset($geoperms[$right_id])) AND ( !isset($sysperms[$right_id])) AND ( !isset($finperms[$right_id])) AND ( !isset($repperms[$right_id])) AND ( !isset($catvperms[$right_id])) AND ( !isset($branchesperms[$right_id]))) {
  172. $miscinputs .= wf_CheckInput($InputName, $right_desc . ' - ' . $right_id, true, user_check_right($login, $right_id));
  173. $miscinputs .= wf_tag('script', false, '', 'type="text/javascript"');
  174. $miscinputs .= '$(\'[name="' . $InputName . '"]\').change( {InputNamesList : $(\'input[name=miscinputsnames]\').val()},
  175. function(EventObject) {
  176. checkIfAllChecked($(\'[name=miscinputscheck]\').attr("id"), EventObject.data.InputNamesList);
  177. } );';
  178. $miscinputs .= wf_tag('script', true);
  179. $miscinputsnames .= $InputName . ',';
  180. if (!user_check_right($login, $right_id))
  181. $miscinputsallchecked = false;
  182. }
  183. //user register rights
  184. if (isset($regperms[$right_id])) {
  185. $reginputs .= wf_CheckInput($InputName, $right_desc . ' - ' . $right_id, true, user_check_right($login, $right_id));
  186. $reginputs .= wf_tag('script', false, '', 'type="text/javascript"');
  187. $reginputs .= '$(\'[name="' . $InputName . '"]\').change( {InputNamesList : $(\'input[name=reginputsnames]\').val()},
  188. function(EventObject) {
  189. checkIfAllChecked($(\'[name=reginputscheck]\').attr("id"), EventObject.data.InputNamesList);
  190. } );';
  191. $reginputs .= wf_tag('script', true);
  192. $reginputsnames .= $InputName . ',';
  193. if (!user_check_right($login, $right_id))
  194. $reginputsallchecked = false;
  195. }
  196. //geo rights
  197. if (isset($geoperms[$right_id])) {
  198. $geoinputs .= wf_CheckInput($InputName, $right_desc . ' - ' . $right_id, true, user_check_right($login, $right_id));
  199. $geoinputs .= wf_tag('script', false, '', 'type="text/javascript"');
  200. $geoinputs .= '$(\'[name="' . $InputName . '"]\').change( {InputNamesList : $(\'input[name=geoinputsnames]\').val()},
  201. function(EventObject) {
  202. checkIfAllChecked($(\'[name=geoinputscheck]\').attr("id"), EventObject.data.InputNamesList);
  203. } );';
  204. $geoinputs .= wf_tag('script', true);
  205. $geoinputsnames .= $InputName . ',';
  206. if (!user_check_right($login, $right_id))
  207. $geoinputsallchecked = false;
  208. }
  209. //system config perms
  210. if (isset($sysperms[$right_id])) {
  211. $sysinputs .= wf_CheckInput($InputName, $right_desc . ' - ' . $right_id, true, user_check_right($login, $right_id));
  212. $sysinputs .= wf_tag('script', false, '', 'type="text/javascript"');
  213. $sysinputs .= '$(\'[name="' . $InputName . '"]\').change( {InputNamesList : $(\'input[name=sysinputsnames]\').val()},
  214. function(EventObject) {
  215. checkIfAllChecked($(\'[name=sysinputscheck]\').attr("id"), EventObject.data.InputNamesList);
  216. } );';
  217. $sysinputs .= wf_tag('script', true);
  218. $sysinputsnames .= $InputName . ',';
  219. if (!user_check_right($login, $right_id))
  220. $sysinputsallchecked = false;
  221. }
  222. //financial inputs
  223. if (isset($finperms[$right_id])) {
  224. $fininputs .= wf_CheckInput($InputName, $right_desc . ' - ' . $right_id, true, user_check_right($login, $right_id));
  225. $fininputs .= wf_tag('script', false, '', 'type="text/javascript"');
  226. $fininputs .= '$(\'[name="' . $InputName . '"]\').change( {InputNamesList : $(\'input[name=fininputsnames]\').val()},
  227. function(EventObject) {
  228. checkIfAllChecked($(\'[name=fininputscheck]\').attr("id"), EventObject.data.InputNamesList);
  229. } );';
  230. $fininputs .= wf_tag('script', true);
  231. $fininputsnames .= $InputName . ',';
  232. if (!user_check_right($login, $right_id))
  233. $fininputsallchecked = false;
  234. }
  235. //reports rights
  236. if (isset($repperms[$right_id])) {
  237. $repinputs .= wf_CheckInput($InputName, $right_desc . ' - ' . $right_id, true, user_check_right($login, $right_id));
  238. $repinputs .= wf_tag('script', false, '', 'type="text/javascript"');
  239. $repinputs .= '$(\'[name="' . $InputName . '"]\').change( {InputNamesList : $(\'input[name=repinputsnames]\').val()},
  240. function(EventObject) {
  241. checkIfAllChecked($(\'[name=repinputscheck]\').attr("id"), EventObject.data.InputNamesList);
  242. } );';
  243. $repinputs .= wf_tag('script', true);
  244. $repinputsnames .= $InputName . ',';
  245. if (!user_check_right($login, $right_id))
  246. $repinputsallchecked = false;
  247. }
  248. //catv rights
  249. if (isset($catvperms[$right_id])) {
  250. $catvinputs .= wf_CheckInput($InputName, $right_desc . ' - ' . $right_id, true, user_check_right($login, $right_id));
  251. $catvinputs .= wf_tag('script', false, '', 'type="text/javascript"');
  252. $catvinputs .= '$(\'[name="' . $InputName . '"]\').change( {InputNamesList : $(\'input[name=catvinputsnames]\').val()},
  253. function(EventObject) {
  254. checkIfAllChecked($(\'[name=catvinputscheck]\').attr("id"), EventObject.data.InputNamesList);
  255. } );';
  256. $catvinputs .= wf_tag('script', true);
  257. $catvinputsnames .= $InputName . ',';
  258. if (!user_check_right($login, $right_id))
  259. $catvinputsallchecked = false;
  260. }
  261. //branches inputs
  262. if (isset($branchesperms[$right_id])) {
  263. $branchesinputs .= wf_CheckInput($InputName, $right_desc . ' - ' . $right_id, true, user_check_right($login, $right_id));
  264. $branchesinputs .= wf_tag('script', false, '', 'type="text/javascript"');
  265. $branchesinputs .= '$(\'[name="' . $InputName . '"]\').change( {InputNamesList : $(\'input[name=branchesinputsnames]\').val()},
  266. function(EventObject) {
  267. checkIfAllChecked($(\'[name=branchesinputscheck]\').attr("id"), EventObject.data.InputNamesList);
  268. } );';
  269. $branchesinputs .= wf_tag('script', true);
  270. $branchesinputsnames .= $InputName . ',';
  271. if (!user_check_right($login, $right_id))
  272. $branchesinputsallchecked = false;
  273. }
  274. }
  275. }
  276. }
  277. //rights grid
  278. $CheckLabelCaption = ($reginputsallchecked) ? __('Uncheck all') : __('Check all');
  279. $inputs .= wf_HiddenInput('reginputsnames', $reginputsnames);
  280. $label = wf_tag('h3') . __('Users registration') . '&emsp;&emsp;&emsp;&emsp;';
  281. $label .= wf_CheckInput('reginputscheck', __($CheckLabelCaption), true, $reginputsallchecked);
  282. $label .= wf_tag('h3', true);
  283. $label .= wf_tag('script', false, '', 'type="text/javascript"');
  284. $label .= '$(\'[name=reginputscheck]\').change( {InputNamesList : $(\'input[name=reginputsnames]\').val()},
  285. function(EventObject) {
  286. checkThemAll($(this).attr("id"), EventObject.data.InputNamesList);
  287. } );';
  288. $label .= wf_tag('script', true);
  289. $tablecells = wf_TableCell($label . $reginputs, '', '', 'valign="top"');
  290. $CheckLabelCaption = ($sysinputsallchecked) ? __('Uncheck all') : __('Check all');
  291. $inputs .= wf_HiddenInput('sysinputsnames', $sysinputsnames);
  292. $label = wf_tag('h3') . __('System settings') . '&emsp;&emsp;&emsp;&emsp;';
  293. $label .= wf_CheckInput('sysinputscheck', __($CheckLabelCaption), true, $sysinputsallchecked);
  294. $label .= wf_tag('h3', true);
  295. $label .= wf_tag('script', false, '', 'type="text/javascript"');
  296. $label .= '$(\'[name=sysinputscheck]\').change( {InputNamesList : $(\'input[name=sysinputsnames]\').val()},
  297. function(EventObject) {
  298. checkThemAll($(this).attr("id"), EventObject.data.InputNamesList);
  299. } );';
  300. $label .= wf_tag('script', true);
  301. $tablecells .= wf_TableCell($label . $sysinputs, '', '', 'valign="top"');
  302. $tablerows = wf_TableRow($tablecells);
  303. $CheckLabelCaption = ($repinputsallchecked) ? __('Uncheck all') : __('Check all');
  304. $inputs .= wf_HiddenInput('repinputsnames', $repinputsnames);
  305. $label = wf_tag('h3') . __('Reports') . '&emsp;&emsp;&emsp;&emsp;';
  306. $label .= wf_CheckInput('repinputscheck', __($CheckLabelCaption), true, $repinputsallchecked);
  307. $label .= wf_tag('h3', true);
  308. $label .= wf_tag('script', false, '', 'type="text/javascript"');
  309. $label .= '$(\'[name=repinputscheck]\').change( {InputNamesList : $(\'input[name=repinputsnames]\').val()},
  310. function(EventObject) {
  311. checkThemAll($(this).attr("id"), EventObject.data.InputNamesList);
  312. } );';
  313. $label .= wf_tag('script', true);
  314. $tablecells = wf_TableCell($label . $repinputs, '', '', 'valign="top"');
  315. $CheckLabelCaption = ($fininputsallchecked) ? __('Uncheck all') : __('Check all');
  316. $inputs .= wf_HiddenInput('fininputsnames', $fininputsnames);
  317. $label = wf_tag('h3') . __('Financial management') . '&emsp;&emsp;&emsp;&emsp;';
  318. $label .= wf_CheckInput('fininputscheck', __($CheckLabelCaption), true, $fininputsallchecked);
  319. $label .= wf_tag('h3', true);
  320. $label .= wf_tag('script', false, '', 'type="text/javascript"');
  321. $label .= '$(\'[name=fininputscheck]\').change( {InputNamesList : $(\'input[name=fininputsnames]\').val()},
  322. function(EventObject) {
  323. checkThemAll($(this).attr("id"), EventObject.data.InputNamesList);
  324. } );';
  325. $label .= wf_tag('script', true);
  326. $tablecells .= wf_TableCell($label . $fininputs, '', '', 'valign="top"');
  327. $tablerows .= wf_TableRow($tablecells);
  328. $CheckLabelCaption = ($catvinputsallchecked) ? __('Uncheck all') : __('Check all');
  329. $inputs .= wf_HiddenInput('catvinputsnames', $catvinputsnames);
  330. $label = wf_tag('h3') . __('CaTV') . '&emsp;&emsp;&emsp;&emsp;';
  331. $label .= wf_CheckInput('catvinputscheck', __($CheckLabelCaption), true, $catvinputsallchecked);
  332. $label .= wf_tag('h3', true);
  333. $label .= wf_tag('script', false, '', 'type="text/javascript"');
  334. $label .= '$(\'[name=catvinputscheck]\').change( {InputNamesList : $(\'input[name=catvinputsnames]\').val()},
  335. function(EventObject) {
  336. checkThemAll($(this).attr("id"), EventObject.data.InputNamesList);
  337. } );';
  338. $label .= wf_tag('script', true);
  339. $tablecells = wf_TableCell($label . $catvinputs, '', '', 'valign="top"');
  340. $CheckLabelCaption = ($geoinputsallchecked) ? __('Uncheck all') : __('Check all');
  341. $inputs .= wf_HiddenInput('geoinputsnames', $geoinputsnames);
  342. $label = wf_tag('h3') . __('Geography') . '&emsp;&emsp;&emsp;&emsp;';
  343. $label .= wf_CheckInput('geoinputscheck', __($CheckLabelCaption), true, $geoinputsallchecked);
  344. $label .= wf_tag('h3', true);
  345. $label .= wf_tag('script', false, '', 'type="text/javascript"');
  346. $label .= '$(\'[name=geoinputscheck]\').change( {InputNamesList : $(\'input[name=geoinputsnames]\').val()},
  347. function(EventObject) {
  348. checkThemAll($(this).attr("id"), EventObject.data.InputNamesList);
  349. } );';
  350. $label .= wf_tag('script', true);
  351. $tablecells .= wf_TableCell($label . $geoinputs, '', '', 'valign="top"');
  352. $tablerows .= wf_TableRow($tablecells);
  353. $CheckLabelCaption = ($miscinputsallchecked) ? __('Uncheck all') : __('Check all');
  354. $inputs .= wf_HiddenInput('miscinputsnames', $miscinputsnames);
  355. $label = wf_tag('h3') . __('Misc rights') . '&emsp;&emsp;&emsp;&emsp;';
  356. $label .= wf_CheckInput('miscinputscheck', __($CheckLabelCaption), true, $miscinputsallchecked);
  357. $label .= wf_tag('h3', true);
  358. $label .= wf_tag('script', false, '', 'type="text/javascript"');
  359. $label .= '$(\'[name=miscinputscheck]\').change( {InputNamesList : $(\'input[name=miscinputsnames]\').val()},
  360. function(EventObject) {
  361. checkThemAll($(this).attr("id"), EventObject.data.InputNamesList);
  362. } );';
  363. $label .= wf_tag('script', true);
  364. $tablecells = wf_TableCell($label . $miscinputs, '', '', 'valign="top"');
  365. $CheckLabelCaption = ($branchesinputsallchecked) ? __('Uncheck all') : __('Check all');
  366. $inputs .= wf_HiddenInput('branchesinputsnames', $branchesinputsnames);
  367. $label = wf_tag('h3') . __('Branches') . '&emsp;&emsp;&emsp;&emsp;';
  368. $label .= wf_CheckInput('branchesinputscheck', __($CheckLabelCaption), true, $branchesinputsallchecked);
  369. $label .= wf_tag('h3', true);
  370. $label .= wf_tag('script', false, '', 'type="text/javascript"');
  371. $label .= '$(\'[name=branchesinputscheck]\').change( {InputNamesList : $(\'input[name=branchesinputsnames]\').val()},
  372. function(EventObject) {
  373. checkThemAll($(this).attr("id"), EventObject.data.InputNamesList);
  374. } );';
  375. $label .= wf_tag('script', true);
  376. $tablecells .= wf_TableCell($label . $branchesinputs, '', '', 'valign="top"');
  377. $tablerows .= wf_TableRow($tablecells);
  378. $inputs .= wf_tag('script', false, '', 'type="text/javascript"');
  379. $inputs .= 'function checkIfAllChecked(CheckObjectID, InputNamesList) {
  380. var AllChecked = true;
  381. InputNamesList = InputNamesList.substring(0, InputNamesList.length - 1);
  382. var ElemArray = InputNamesList.split(",");
  383. ElemArray.forEach( function(Item, Index) {
  384. if ( !$(\'[name="\'+Item+\'"]\').is(\':checked\') ) {
  385. AllChecked = false;
  386. }
  387. } );
  388. var LabelText = (AllChecked) ? \'' . __('Uncheck all') . '\' : \'' . __('Check all') . '\';
  389. $("label[for=\'"+CheckObjectID+"\']").html(LabelText);
  390. $("#"+CheckObjectID).prop(\'checked\', AllChecked);
  391. }
  392. function checkThemAll(CheckObjectID, InputNamesList) {
  393. var CheckVal = $("#"+CheckObjectID).is(\':checked\');
  394. var LabelText = (CheckVal) ? \'' . __('Uncheck all') . '\' : \'' . __('Check all') . '\';
  395. $("label[for=\'"+CheckObjectID+"\']").html(LabelText);
  396. InputNamesList = InputNamesList.substring(0, InputNamesList.length - 1);
  397. var ElemArray = InputNamesList.split(",");
  398. ElemArray.forEach( function(Item, Index) { $(\'[name="\'+Item+\'"]\').prop(\'checked\', CheckVal); } );
  399. }
  400. ';
  401. $inputs .= wf_tag('script', true);
  402. $rightsgrid = $inputs;
  403. $rightsgrid .= wf_Submit('Save') . wf_delimiter();
  404. $rightsgrid .= wf_TableBody($tablerows, '100%', 0, 'glamour');
  405. if ($root) {
  406. $rightsgrid .= wf_tag('script', false, '', 'type="text/javascript"');
  407. $rightsgrid .= '$(\'[name=reginputscheck]\').css(\'visibility\', \'hidden\');
  408. $("label[for=\'"+$(\'[name=reginputscheck]\').attr("id")+"\']").css(\'visibility\', \'hidden\');
  409. $(\'[name=sysinputscheck]\').css(\'visibility\', \'hidden\');
  410. $("label[for=\'"+$(\'[name=sysinputscheck]\').attr("id")+"\']").css(\'visibility\', \'hidden\');
  411. $(\'[name=repinputscheck]\').css(\'visibility\', \'hidden\');
  412. $("label[for=\'"+$(\'[name=repinputscheck]\').attr("id")+"\']").css(\'visibility\', \'hidden\');
  413. $(\'[name=fininputscheck]\').css(\'visibility\', \'hidden\');
  414. $("label[for=\'"+$(\'[name=fininputscheck]\').attr("id")+"\']").css(\'visibility\', \'hidden\');
  415. $(\'[name=catvinputscheck]\').css(\'visibility\', \'hidden\');
  416. $("label[for=\'"+$(\'[name=catvinputscheck]\').attr("id")+"\']").css(\'visibility\', \'hidden\');
  417. $(\'[name=geoinputscheck]\').css(\'visibility\', \'hidden\');
  418. $("label[for=\'"+$(\'[name=geoinputscheck]\').attr("id")+"\']").css(\'visibility\', \'hidden\');
  419. $(\'[name=miscinputscheck]\').css(\'visibility\', \'hidden\');
  420. $("label[for=\'"+$(\'[name=miscinputscheck]\').attr("id")+"\']").css(\'visibility\', \'hidden\');
  421. $(\'[name=branchesinputscheck]\').css(\'visibility\', \'hidden\');
  422. $("label[for=\'"+$(\'[name=branchesinputscheck]\').attr("id")+"\']").css(\'visibility\', \'hidden\');';
  423. $rightsgrid .= wf_tag('script', true);
  424. }
  425. $permission_forms = wf_Form("", 'POST', $rightsgrid, '');
  426. $permission_forms .= wf_CleanDiv();
  427. $permission_forms .= wf_tag('br');
  428. //copy permissions form
  429. $copyinputs = wf_tag('h2') . __('Rights cloning') . wf_tag('h2', true);
  430. $copyinputs .= web_AdminLoginSelector($login);
  431. $copyinputs .= wf_HiddenInput('clonerightsnow', 'true');
  432. $copyinputs .= wf_Submit(__('Clone'));
  433. $copyform = wf_Form("", 'POST', $copyinputs, 'glamour');
  434. $permission_forms .= $copyform;
  435. show_window(__('Rights for') . ' ' . $login, $permission_forms);
  436. }
  437. //if someone editing administrator permissions
  438. if (isset($_GET['edit'])) {
  439. $editname = vf($_GET['edit']);
  440. if (!empty($_POST['save'])) {
  441. if ($system->setRightsForUser($editname, @$_POST['_rights'], @$_POST['rootuser'], @$_POST['level'])) {
  442. show_window('', __('Rights changed'));
  443. log_register('UBADMIN PERMISSIONS CHANGE {' . $editname . '} SUCCESS');
  444. rcms_redirect("?module=permissions&edit=" . $editname);
  445. } else {
  446. show_error(__('Error occurred'));
  447. log_register('UBADMIN PERMISSIONS CHANGE {' . $editname . '} FAIL');
  448. }
  449. }
  450. web_permissions_editor($editname);
  451. }
  452. //if cloning some rights
  453. if (wf_CheckPost(array('clonerightsnow', 'admincopyselector'))) {
  454. if (wf_CheckGet(array('edit'))) {
  455. $targetUser = $_GET['edit'];
  456. $sourceUser = $_POST['admincopyselector'];
  457. zb_PermissionsCopyAdminRights($sourceUser, $targetUser);
  458. }
  459. }
  460. //ghostmode init
  461. if (wf_CheckGet(array('ghostmode'))) {
  462. if (cfr('ROOT')) {
  463. zb_InitGhostMode($_GET['ghostmode']);
  464. rcms_redirect('index.php');
  465. } else {
  466. show_error(__('Access denied'));
  467. }
  468. }
  469. if (!ubRouting::checkGet('passwd') AND ! ubRouting::checkGet('edit')) {
  470. //list of existing administrators
  471. show_window(__('Admins'), web_list_admins());
  472. //other module controls
  473. $primaryControls = wf_Link('?module=adminreg', web_icon_create() . ' ' . __('Administrators registration'), false, 'ubButton');
  474. $primaryControls .= wf_Link('?module=admstats', web_icon_charts() . ' ' . __('Administrators timeline'), false, 'ubButton');
  475. show_window('', $primaryControls);
  476. }
  477. } else {
  478. show_error(__('You cant control this module'));
  479. }