Users.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. <?php
  2. Lib::loadClass('RouteBase');
  3. Lib::loadClass('UserStorageFactory');
  4. Lib::loadClass('ProcesHelper');
  5. Lib::loadClass('SyncUsers');
  6. Lib::loadClass('UsersHelper');
  7. Lib::loadClass('UsersLdapHelper');
  8. Lib::loadClass('TypespecialVariable');
  9. Lib::loadClass('TableAjax');
  10. Lib::loadClass('UserActivity');
  11. class Route_Users extends RouteBase {
  12. public function handleAuth() {
  13. if (!User::logged()) {
  14. throw new HttpException('Unauthorized', 401);
  15. }
  16. }
  17. public function defaultAction() {
  18. SE_Layout::gora();
  19. SE_Layout::menu();
  20. $this->menu();
  21. SE_Layout::dol();
  22. }
  23. public function menu() {
  24. $usrLogin = User::getLogin();
  25. ?>
  26. <div class="container">
  27. <h3>Użytkownicy i grupy</h3>
  28. <ul>
  29. <li>
  30. <form class="form-inline" action="index.php" method="GET">
  31. <input type="hidden" name="_route" value="Users">
  32. <input type="hidden" name="_task" value="syncUser">
  33. <label for="usrLogin">login: </label>
  34. <input type="text" name="usrLogin" value="<?php echo $usrLogin; ?>">
  35. <input type="submit" value="Synchronizuj do bazy LDAP" class="btn btn-xs btn-default">
  36. </form>
  37. </li>
  38. <li>
  39. <form class="form-inline" action="index.php" method="GET">
  40. <input type="hidden" name="_route" value="Users">
  41. <input type="hidden" name="_task" value="userGroups">
  42. <label for="usrLogin">login: </label>
  43. <input type="text" name="usrLogin" value="<?php echo $usrLogin; ?>">
  44. <input type="submit" value="Dodaj grupy" class="btn btn-xs btn-default">
  45. </form>
  46. </li>
  47. <li>
  48. <form class="form-inline" action="index.php" method="GET">
  49. <input type="hidden" name="_route" value="Users">
  50. <input type="hidden" name="_task" value="nestedGroups">
  51. <label for="idGroup">id grupy: </label>
  52. <input type="text" name="idGroup" value="">
  53. <input type="submit" value="Grupy uprawnień" class="btn btn-xs btn-default">
  54. </form>
  55. </li>
  56. </ul>
  57. </div>
  58. <?php
  59. }
  60. public function nestedGroupsAction() {
  61. SE_Layout::gora();
  62. SE_Layout::menu();
  63. echo '<div class="container">';
  64. try {
  65. $idGroup = V::get('idGroup', 0, $_GET, 'int');
  66. if (empty($idGroup)) throw new Exception("Empty group id");
  67. $subTask = V::get('_subTask', '', $_POST);
  68. $successMsg = null;
  69. if ('removeParentGroup' == $subTask) {
  70. $idParentGroupToRemove = V::get('idParentGroupToRemove', 0, $_POST, 'int');
  71. $this->nestedGroupsRemoveParentGroup($idGroup, $idParentGroupToRemove);
  72. $successMsg = "Usunięto grupę nadrzędną [{$idParentGroupToRemove}] do grupy [{$idGroup}]";
  73. } else if ('removeNestedGroup' == $subTask) {
  74. $idNestedGroupToRemove = V::get('idNestedGroupToRemove', 0, $_POST, 'int');
  75. $this->nestedGroupsRemoveNestedGroup($idGroup, $idNestedGroupToRemove);
  76. $successMsg = "Usunięto grupę zagnieżdżoną [{$idNestedGroupToRemove}] do grupy [{$idGroup}]";
  77. } else if ('addParentGroup' == $subTask) {
  78. $idParentGroupToAdd = V::get('idParentGroupToAdd', 0, $_POST, 'int');
  79. $this->nestedGroupsAddParentGroup($idGroup, $idParentGroupToAdd);
  80. $successMsg = "Dodano grupę nadrzędną [{$idParentGroupToAdd}] do grupy [{$idGroup}]";
  81. } else if ('addNestedGroup' == $subTask) {
  82. $idNestedGroupToAdd = V::get('idNestedGroupToAdd', 0, $_POST, 'int');
  83. $this->nestedGroupsAddNestedGroup($idGroup, $idNestedGroupToAdd);
  84. $successMsg = "Dodano grupę zagnieżdżoną [{$idNestedGroupToAdd}] do grupy [{$idGroup}]";
  85. }
  86. if (!empty($successMsg)) {
  87. ?><div class="alert alert-success"><?php echo $successMsg; ?></div><?php
  88. }
  89. $this->printFormNestedGroups($idGroup);
  90. } catch (Exception $e) {
  91. ?><div class="alert alert-danger"><?php echo $e->getMessage(); ?>
  92. <br><a href="index.php?_route=Users">wróć</a>
  93. </div><?php
  94. echo UserActivity::showListInContainer();
  95. }
  96. echo '</div>';// .container
  97. SE_Layout::dol();
  98. }
  99. public function nestedGroupsRemoveParentGroup($idGroup, $idParentGroupToRemove) {
  100. if (!$idGroup) throw new Exception("Wrong param id group!");
  101. if (!$idParentGroupToRemove) throw new Exception("Wrong param id parent group to remove!");
  102. $usrStorageDB = UserStorageFactory::getStorage('DB');
  103. if (!$usrStorageDB) throw new Exception("Error: storage db not exists!");
  104. $group = $usrStorageDB->getGroupWithoutNested($idGroup);
  105. if (!$group) throw new Exception("Error: group not exists!");
  106. $parentGroup = $usrStorageDB->getGroupWithoutNested($idParentGroupToRemove);
  107. if (!$parentGroup) throw new Exception("Error: parent group not exists!");
  108. $usrStorageDB->removeParentGroup($idGroup, $idParentGroupToRemove);
  109. }
  110. public function nestedGroupsRemoveNestedGroup($idGroup, $idNestedGroupToRemove) {
  111. if (!$idGroup) throw new Exception("Wrong param id group!");
  112. if (!$idNestedGroupToRemove) throw new Exception("Wrong param id parent group to remove!");
  113. $usrStorageDB = UserStorageFactory::getStorage('DB');
  114. if (!$usrStorageDB) throw new Exception("Error: storage db not exists!");
  115. $group = $usrStorageDB->getGroupWithoutNested($idGroup);
  116. if (!$group) throw new Exception("Error: group not exists!");
  117. $nestedGroup = $usrStorageDB->getGroupWithoutNested($idNestedGroupToRemove);
  118. if (!$nestedGroup) throw new Exception("Error: nested group not exists!");
  119. $usrStorageDB->removeNestedGroup($idGroup, $idNestedGroupToRemove);
  120. }
  121. public function nestedGroupsAddParentGroup($idGroup, $idParentGroupToAdd) {
  122. if ($idGroup <= 0) throw new Exception("Wrong param id group");
  123. if ($idParentGroupToAdd <= 0) throw new Exception("Wrong param id parent group to add");
  124. $usrStorageDB = UserStorageFactory::getStorage('DB');
  125. if (!$usrStorageDB) throw new Exception("Error: storage db not exists!");
  126. $group = $usrStorageDB->getGroupWithoutNested($idGroup);
  127. if (!$group) throw new Exception("Error: group [{$idGroup}] not exists!");
  128. $parentGroup = $usrStorageDB->getGroupWithoutNested($idParentGroupToAdd);
  129. if (!$parentGroup) throw new Exception("Error: parent group [{$idParentGroupToAdd}] not exists!");
  130. $usrStorageDB->addParentGroup($idGroup, $idParentGroupToAdd);
  131. }
  132. public function nestedGroupsAddNestedGroup($idGroup, $idNestedGroupToAdd) {
  133. if ($idGroup <= 0) throw new Exception("Wrong param id group");
  134. if ($idNestedGroupToAdd <= 0) throw new Exception("Wrong param id parent group to add");
  135. $usrStorageDB = UserStorageFactory::getStorage('DB');
  136. if (!$usrStorageDB) throw new Exception("Error: storage db not exists!");
  137. $group = $usrStorageDB->getGroupWithoutNested($idGroup);
  138. if (!$group) throw new Exception("Error: group not exists!");
  139. $nestedGroup = $usrStorageDB->getGroupWithoutNested($idNestedGroupToAdd);
  140. if (!$nestedGroup) throw new Exception("Error: nested group [{$idNestedGroupToAdd}] not exists!");
  141. $usrStorageDB->addNestedGroup($idGroup, $idNestedGroupToAdd);
  142. }
  143. public function printFormNestedGroups($idGroup) {
  144. $linkTypeIdNestedGroups = 5;
  145. if (!$idGroup) throw new Exception("Wrong param group id!");
  146. $usrStorageDB = UserStorageFactory::getStorage('DB');
  147. if (!$usrStorageDB) throw new Exception("Error storage not exists!");
  148. $group = $usrStorageDB->getGroup($idGroup);
  149. if (!$group) throw new Exception("Grupa {$idGroup} nie istnieje.");
  150. DBG::_('DBG_SU', '>1', 'group', $group, __CLASS__, __FUNCTION__, __LINE__);
  151. {
  152. $idZasob = ProcesHelper::getZasobTableID('ITEM_LINKS');
  153. if ($idZasob <= 0) throw new Exception("Brak zasobu dla tabeli 'ITEM_LINKS'");
  154. $zasobObj = ProcesHelper::getZasobTableInfo($idZasob);
  155. if (!$zasobObj) throw new Exception("Zasob TABELA ID={$idZasob} nie istnieje");
  156. UserActivity::add($idZasob);
  157. $userAcl = User::getAcl();
  158. $userAcl->fetchGroups();
  159. if (!$userAcl->hasTableAcl($zasobObj->ID)) throw new Exception("Brak uprawnień do tabeli ID={$zasobObj->ID}");
  160. }
  161. if (V::get('_testUsrGroupsLdapLvl0', '', $_GET)) {
  162. $usrLogin = User::getLogin();
  163. $groups = array(); $groupsLvl3 = array();
  164. $groupsNetwork = UsersLdapHelper::getUserGroups($usrLogin, 0);
  165. foreach ($groupsNetwork as $vGroup) {
  166. $groups[$vGroup->cn] = $vGroup->appleUID;
  167. }
  168. DBG::_(true, true, "groups ldap lvl 0", $groups, __CLASS__, __FUNCTION__, __LINE__);
  169. $groupsNetwork = UsersLdapHelper::getUserGroups($usrLogin, 3);
  170. foreach ($groupsNetwork as $vGroup) {
  171. $groupsLvl3[$vGroup->cn] = $vGroup->appleUID;
  172. }
  173. DBG::_(true, true, "groups ldap lvl 3", $groupsLvl3, __CLASS__, __FUNCTION__, __LINE__);
  174. }
  175. $group->getParentGroups();
  176. DBG::_('DBG_NG', '>1', "group with nested", $group, __CLASS__, __FUNCTION__, __LINE__);
  177. $typeSpecialNestedGroups = TypespecialVariable::getInstance(-1, '__NESTED_GROUPS');
  178. $groupUsers = array();
  179. $groupNestedUsers = array();
  180. $idZasobTableUsers = ProcesHelper::getZasobTableID('ADMIN_USERS');
  181. if ($group->zasobID > 0) {
  182. $groupUsers = UsersHelper::getUsersByGroupId($idGroup);
  183. $groupNestedUsers = UsersHelper::getUsersByGroupsIds(array_keys($group->nestedGroups), array_keys($groupUsers));
  184. }
  185. $idZasobTableZasoby = ProcesHelper::getZasobTableID('CRM_LISTA_ZASOBOW');
  186. ?>
  187. <style type="text/css">
  188. .frm-groups .selectize-control { float:left; }
  189. .conn_groups {}
  190. .conn_groups .conn_groups-list {}
  191. .conn_groups .conn_groups-list .conn_groups-list_item { line-height:22px; }
  192. .conn_groups .conn_groups-list .conn_groups-list_item form { display:inline; margin:0; }
  193. .conn_groups .conn_groups-list_item-rmBtn { display:inline; margin:0; padding:0 6px; border:none; opacity:0.4; }
  194. .conn_groups .conn_groups-list_item-editBtn { margin:0 6px; padding:0; border:none; opacity:0.4; }
  195. .conn_groups .conn_groups-list_item:hover .conn_groups-list_item-rmBtn { display:inline; opacity:1; }
  196. .conn_groups .conn_groups-list_item:hover .conn_groups-list_item-editBtn { opacity:1; }
  197. .users-with-perms {}
  198. .users-with-perms address { padding:0 6px; border:1px solid #eee; }
  199. .users-with-perms address:hover { border-color:#333; }
  200. </style>
  201. <div class="container conn_groups">
  202. <h4>Grupy uprawnień
  203. <!-- <em style="color:#ccc;">(Nested Groups)</em> -->
  204. </h4>
  205. <blockquote>
  206. Grupa [<?php echo $idGroup; ?>]: <code><?php echo $group->type; ?></code> <?php echo $group->zasobDESC; ?>
  207. <a class="btn btn-xs btn-link" href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idZasobTableZasoby; ?>#EDIT/<?php echo $idGroup; ?>" title="Edytuj rekord"><i class="glyphicon glyphicon-pencil"></i> edytuj</a>
  208. <a class="btn btn-xs btn-link" href="index.php?_route=Users&_task=syncGroup&idGroup=<?php echo $idGroup; ?>"><i class="glyphicon glyphicon-retweet"></i> synchronizuj do LDAP</a>
  209. </blockquote>
  210. <br>
  211. <div class="row">
  212. <div class="col-md-6">
  213. <!-- <p><b>Grupy posiadające dostęp do rekordów grupy [<?php echo $group->zasobID; ?>] <?php echo $group->zasobDESC; ?></b> <em>(<?php echo (!empty($group->parentGroups))? count($group->parentGroups) : 0; ?>)</em>:
  214. </p> -->
  215. <blockquote>
  216. <!-- <h5>Ustal grupy, które będą miały uprawnienia do rekordów dostępnych dla
  217. [<?php echo $group->zasobID; ?>] <?php echo $group->zasobDESC; ?>
  218. </h5>
  219. <small>np. grupy podrzędnych pracowników.</small> -->
  220. <h5>Udostępnij rekordy innym grupom</h5>
  221. <small>np. przełożonemu.</small>
  222. </blockquote>
  223. <ul class="conn_groups-list">
  224. <?php if (!empty($group->nestedGroups)) : ?>
  225. <?php foreach ($group->nestedGroups as $vNestedGroup) : ?>
  226. <li class="conn_groups-list_item">
  227. [<?php echo $vNestedGroup->zasobID; ?>]
  228. <?php echo $vNestedGroup->type; ?>
  229. <?php echo $vNestedGroup->zasobDESC; ?>
  230. <a href="index.php?_route=Users&_task=nestedGroups&idGroup=<?php echo $vNestedGroup->zasobID; ?>" class="glyphicon glyphicon-pencil conn_groups-list_item-editBtn" title="Edytuj grupę"> </a>
  231. <form action="" method="POST" class="form-inline frm-groups">
  232. <input type="hidden" name="_subTask" value="removeNestedGroup">
  233. <button name="idNestedGroupToRemove" value="<?php echo $vNestedGroup->zasobID; ?>" class="btn-link btn-sm conn_groups-list_item-rmBtn" title="usuń grupę"><i class="glyphicon glyphicon-remove"></i></button>
  234. </form>
  235. </li>
  236. <?php endforeach; ?>
  237. <?php endif; ?>
  238. <?php if ($typeSpecialNestedGroups) : ?>
  239. <li>
  240. <form action="" method="POST" class="form-inline frm-groups">
  241. <input type="hidden" name="_subTask" value="addNestedGroup">
  242. <?php
  243. $fName = 'idNestedGroupToAdd';
  244. $fldParams = array();
  245. $fldParams['allowCreate'] = false;
  246. $fldParams['ajaxDataUrlBase'] = "index.php?_route=Users&_task=typeSpecialIdNestedGroup";
  247. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  248. echo $typeSpecialNestedGroups->showFormItem($tblID = -1, $fName, $selValue = '', $fldParams);
  249. ?>
  250. <button class="btn">dodaj</button>
  251. </form>
  252. </li>
  253. <?php endif; ?>
  254. </ul>
  255. <!-- <p><b>Grupy do rekordów, których posiada dostęp grupa [<?php echo $group->zasobID; ?>] <?php echo $group->zasobDESC; ?></b> <em>(<?php echo (!empty($group->parentGroups))? count($group->parentGroups) : 0; ?>)</em>:
  256. </p> -->
  257. <blockquote>
  258. <h5>Grupy, które udostępniają rekordy</h5>
  259. <small>np. grupy podrzędnych pracowników lub dział, podmiot.</small>
  260. </blockquote>
  261. <ul class="conn_groups-list">
  262. <?php if (!empty($group->parentGroups)) : ?>
  263. <?php foreach ($group->parentGroups as $vParentGroup) : ?>
  264. <li class="conn_groups-list_item">
  265. [<?php echo $vParentGroup->zasobID; ?>]
  266. <?php // if ('DZIAL' == $vParentGroup->type) : ?>
  267. <?php echo $vParentGroup->type; ?>
  268. <?php // endif; ?>
  269. <?php echo $vParentGroup->zasobDESC; ?>
  270. <a href="index.php?_route=Users&_task=nestedGroups&idGroup=<?php echo $vParentGroup->zasobID; ?>" class="glyphicon glyphicon-pencil conn_groups-list_item-editBtn" title="Edytuj grupę"> </a>
  271. <form action="" method="POST" class="form-inline frm-groups">
  272. <input type="hidden" name="_subTask" value="removeParentGroup">
  273. <button name="idParentGroupToRemove" value="<?php echo $vParentGroup->zasobID; ?>" class="btn-link btn-sm conn_groups-list_item-rmBtn" title="usuń grupę"><i class="glyphicon glyphicon-remove"></i></button>
  274. </form>
  275. </li>
  276. <?php endforeach; ?>
  277. <?php endif; ?>
  278. <?php if ($typeSpecialNestedGroups) : ?>
  279. <li>
  280. <form action="" method="POST" class="form-inline frm-groups">
  281. <input type="hidden" name="_subTask" value="addParentGroup">
  282. <?php
  283. $fName = 'idParentGroupToAdd';
  284. $fldParams = array();
  285. $fldParams['allowCreate'] = false;
  286. $fldParams['ajaxDataUrlBase'] = "index.php?_route=Users&_task=typeSpecialIdNestedGroup";
  287. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  288. echo $typeSpecialNestedGroups->showFormItem($tblID = -1, $fName, $selValue = '', $fldParams);
  289. ?>
  290. <button class="btn">dodaj</button>
  291. </form>
  292. </li>
  293. <?php endif; ?>
  294. </ul>
  295. </div>
  296. <div class="col-md-6 users-with-perms">
  297. <h5>Użytkownicy:</h5>
  298. <?php if (empty($groupUsers)) : ?>
  299. <div class="alert">Brak użytkowników przypisanych bezpośrednio do grupy</div>
  300. <?php else : ?>
  301. <div class="row">
  302. <?php foreach ($groupUsers as $usr) : ?>
  303. <div class="col-md-6">
  304. <address>
  305. <strong><?php echo $usr->ADM_NAME; ?></strong>
  306. <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idZasobTableUsers; ?>#EDIT/<?php echo $usr->ID; ?>" class="glyphicon glyphicon-pencil" title="Edytuj rekord"> </a>
  307. <br><em><?php echo $usr->EMPLOYEE_TYPE; ?></em>
  308. <?php if (!empty($usr->ADM_PHONE)) : ?>
  309. <br><abbr title="Telefon">Tel.:</abbr> <?php echo $usr->ADM_PHONE; ?>
  310. <?php endif; ?>
  311. <?php if (!empty($usr->EMAIL)) : ?>
  312. <br><a href="mailto:<?php echo $usr->EMAIL; ?>"><?php echo $usr->EMAIL; ?></a>
  313. <?php endif; ?>
  314. </address>
  315. </div>
  316. <?php endforeach; ?>
  317. </div>
  318. <?php endif; ?>
  319. <h5>Użytwkonicy z uprawnieniami do rekordów</h5>
  320. <?php if (empty($groupNestedUsers)) : ?>
  321. <div class="alert">Brak</div>
  322. <?php else : ?>
  323. <div class="row">
  324. <?php foreach ($groupNestedUsers as $usr) : ?>
  325. <div class="col-md-6">
  326. <address>
  327. <strong><?php echo $usr->ADM_NAME; ?></strong>
  328. <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idZasobTableUsers; ?>#EDIT/<?php echo $usr->ID; ?>" class="glyphicon glyphicon-pencil" title="Edytuj rekord"> </a>
  329. <br><em><?php echo $usr->EMPLOYEE_TYPE; ?></em>
  330. <?php if (!empty($usr->ADM_PHONE)) : ?>
  331. <br><abbr title="Telefon">Tel.:</abbr> <?php echo $usr->ADM_PHONE; ?>
  332. <?php endif; ?>
  333. <?php if (!empty($usr->EMAIL)) : ?>
  334. <br><a href="mailto:<?php echo $usr->EMAIL; ?>"><?php echo $usr->EMAIL; ?></a>
  335. <?php endif; ?>
  336. </address>
  337. </div>
  338. <?php endforeach; ?>
  339. </div>
  340. <?php endif; ?>
  341. </div>
  342. </div>
  343. </div>
  344. <?php
  345. {// render table
  346. $tblAcl = $userAcl->getTableAcl($zasobObj->ID);
  347. $forceTblAclInit = ('1' == V::get('_force', '', $_GET));
  348. $tblAcl->init($forceTblAclInit);
  349. $forceFilterInit = array();
  350. $filterInit = new stdClass();
  351. $filterInit->currSortCol = 'ID';
  352. $filterInit->currSortFlip = 'desc';
  353. foreach ($_GET as $k => $v) {
  354. if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
  355. $filterInit->$k = $v;
  356. }
  357. else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
  358. $filterInit->$k = $v;
  359. }
  360. else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
  361. $fldName = substr($k, 3);
  362. $forceFilterInit[$fldName] = $v;
  363. }
  364. }
  365. $tblZasobyID = ProcesHelper::getZasobTableID('CRM_LISTA_ZASOBOW');
  366. $forceFilterInit['TABLE_1_NAME'] = 'CRM_LISTA_ZASOBOW';
  367. $forceFilterInit['TABLE_1_ZASOB_ID'] = $tblZasobyID;
  368. $forceFilterInit['TABLE_1_ID'] = $group->zasobID;
  369. $forceFilterInit['TABLE_2_NAME'] = 'CRM_LISTA_ZASOBOW';
  370. $forceFilterInit['TABLE_2_ZASOB_ID'] = $tblZasobyID;
  371. $forceFilterInit['LINKS_TYPE_ID'] = $linkTypeIdNestedGroups;
  372. $tbl = new TableAjax($tblAcl);
  373. $tbl->setLabel($zasobObj->OPIS);
  374. $tbl->setFilterInit($filterInit);
  375. if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
  376. $tbl->addRowFunction('edit');
  377. $tbl->addRowFunction('hist');
  378. $tbl->addRowFunction('files');
  379. $tbl->addRowFunction('cp');
  380. $tbl->showProcesInit(false);// hide Proces filter field
  381. echo $tbl->render();
  382. }
  383. }
  384. public function typeSpecialIdNestedGroupAction() {
  385. header("Content-type: application/json");
  386. $typeSpecialNestedGroups = TypespecialVariable::getInstance(-1, '__NESTED_GROUPS');
  387. $query = V::get('q', '', $_REQUEST);
  388. $rawRows = null;
  389. $rows = $typeSpecialNestedGroups->getValuesWithExports($query);
  390. DBG::_('DBG', '>0', "rows(q={$query})", $rows, __CLASS__, __FUNCTION__, __LINE__);
  391. foreach ($rows as $kID => $vItem) {
  392. $itemJson = new stdClass();
  393. $itemJson->id = $vItem->id;
  394. $itemJson->name = $vItem->param_out;
  395. if (!empty($vItem->exports)) {
  396. $itemJson->exports = $vItem->exports;
  397. }
  398. $jsonData[] = $itemJson;
  399. }
  400. echo json_encode($jsonData);
  401. }
  402. public function userGroupsAction() {
  403. SE_Layout::gora();
  404. SE_Layout::menu();
  405. $usrLogin = V::get('usrLogin', '', $_GET);
  406. echo '<div class="container">';
  407. try {
  408. if (empty($usrLogin)) throw new Exception("Empty user login");
  409. $subTask = V::get('_subTask', '', $_POST);
  410. if ('removeUserGroup' == $subTask) {
  411. $idProfileToRemove = V::get('idProfileToRemove', 0, $_POST, 'int');
  412. $this->removeUserGroup($usrLogin, $idProfileToRemove);
  413. ?><div class="alert alert-info">Użytkownik został usunięty z danej grupy</div><?php
  414. } else if ('addUserGroup' == $subTask) {
  415. $idGroup = V::get('idGroup', 0, $_POST, 'int');
  416. $idTelboxes = V::get('addTelboxesID', 0, $_POST, 'int');
  417. $this->addUserGroup($usrLogin, $idGroup, $idTelboxes);
  418. ?><div class="alert alert-info">Dodano grupę [<?php echo $idGroup; ?>] do użytkownika [<?php echo $usrLogin; ?>]</div><?php
  419. }
  420. $this->printFormUserGroup($usrLogin);
  421. } catch (Exception $e) {
  422. ?><div class="alert alert-danger"><?php echo $e->getMessage(); ?>
  423. <br><a href="index.php?_route=Users&_task=userGroups&usrLogin=<?php echo $usrLogin; ?>">wróć</a>
  424. </div><?php
  425. echo UserActivity::showListInContainer();
  426. }
  427. echo '</div>';// .container
  428. SE_Layout::dol();
  429. }
  430. public function printFormUserGroup($usrLogin) {
  431. if (empty($usrLogin)) throw new Exception("Empty user login");
  432. $usrStorageDB = UserStorageFactory::getStorage('DB');
  433. if (!$usrStorageDB) throw new Exception("Storage DB not exists!");
  434. $usr = $usrStorageDB->getUser($usrLogin);
  435. if (!$usr) throw new Exception("Użytkownik '{$usrLogin}' nie istnieje.");
  436. $stanowiska = array();
  437. $stanowiska = $usrStorageDB->getUserProfiles($usrLogin, $fetchNested = false);
  438. uasort($stanowiska, array($this, 'sortStanowiskaByType'));
  439. $groups = UsersHelper::getGroupByUser($usr->primaryKey);
  440. DBG::_('DBG_SU', '>1', 'groups', $groups, __CLASS__, __FUNCTION__, __LINE__);
  441. $groupsNetwork = UsersLdapHelper::getUserGroups($usrLogin, 3);
  442. DBG::_('DBG_SU', '>1', 'groupsNetwork', $groupsNetwork, __CLASS__, __FUNCTION__, __LINE__);
  443. $typeSpecialUserGroups = TypespecialVariable::getInstance(-1, '__USER_GROUPS');
  444. $typeSpecialTelboxes = TypespecialVariable::getInstance(-1, '__TELBOXES');
  445. $idZasobUsersTbl = ProcesHelper::getZasobTableID('ADMIN_USERS');
  446. ?>
  447. <style type="text/css">
  448. .frm-groups .selectize-control { float:left; }
  449. .conn_groups {}
  450. .conn_groups .conn_groups-list {}
  451. .conn_groups .conn_groups-list .conn_groups-list_item { line-height:22px; }
  452. .conn_groups .conn_groups-list .conn_groups-list_item form { display:inline; margin:0; }
  453. .conn_groups .conn_groups-list_item-rmBtn { /*display:none;*/ opacity:0.4; margin:0; padding:0 10px; border:none; }
  454. .conn_groups .conn_groups-list_item:hover .conn_groups-list_item-rmBtn { /*display:inline;*/ opacity:1; }
  455. </style>
  456. <div class="conn_groups">
  457. <h4>Ustalanie stanowiska</h4>
  458. <blockquote>
  459. Użytkownik [<?php echo $usr->primaryKey; ?>] <b><?php echo $usr->name; ?></b> <code><?php echo $usr->login; ?></code>
  460. <?php if ($idZasobUsersTbl > 0) : ?>
  461. <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idZasobUsersTbl; ?>#EDIT/<?php echo $usr->primaryKey; ?>"
  462. class="btn btn-xs btn-link"><span class="glyphicon glyphicon-pencil"></span> edytuj</a>
  463. <?php endif; ?>
  464. <a href="index.php?_route=Users&_task=syncUser&usrLogin=<?php echo $usr->login; ?>"
  465. class="btn btn-xs btn-link"><span class="glyphicon glyphicon-retweet"></span> synchronizuj do LDAP</a>
  466. </blockquote>
  467. <h4>Przypisane grupy (<?php echo (!empty($stanowiska))? count($stanowiska) : 0; ?>):</h4>
  468. <?php if (!empty($stanowiska)) : ?>
  469. <ul class="conn_groups-list">
  470. <?php foreach ($stanowiska as $vProfile) : ?>
  471. <li class="conn_groups-list_item">
  472. <?php echo $vProfile->group->realName; ?>
  473. <?php if ($vProfile->localisationId > 0) : ?>
  474. (lokalizacja [<?php echo $vProfile->localisationId; ?>])
  475. <?php endif; ?>
  476. <form class="form-inline frm-groups" action="" method="POST">
  477. <input type="hidden" name="_subTask" value="removeUserGroup">
  478. <button name="idProfileToRemove" value="<?php echo $vProfile->profileId; ?>" class="btn-link btn-sm conn_groups-list_item-rmBtn" title="usuń grupę" onclick="return confirm('Czy jesteś pewien że chcesz usunąć przypisanie do grupy <?php echo $vProfile->group->realName; ?>?');"><i class="glyphicon glyphicon-remove"></i></button>
  479. </form>
  480. </li>
  481. <?php endforeach; ?>
  482. </ul>
  483. <?php endif; ?>
  484. <?php if ($typeSpecialUserGroups && $typeSpecialTelboxes) : ?>
  485. <h4>Dodaj grupę:</h4>
  486. <form class="form-horizontal" action="" method="POST">
  487. <input type="hidden" name="_subTask" value="addUserGroup">
  488. <div class="form-group">
  489. <label class="col-sm-3 control-label" for="idGroup">Grupa</label>
  490. <div class="col-sm-9">
  491. <?php
  492. $fName = 'idGroup';
  493. $fldParams = array();
  494. $fldParams['allowCreate'] = false;
  495. $fldParams['ajaxDataUrlBase'] = "index.php?_route=Users&_task=typeSpecialIdGroup";
  496. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  497. echo $typeSpecialUserGroups->showFormItem($tblID = -1, $fName, $selValue = '', $fldParams);
  498. ?>
  499. </div>
  500. </div>
  501. <div class="form-group">
  502. <label class="col-sm-3 control-label" for="addTelboxesID">Lokalizacja</label>
  503. <div class="col-sm-9">
  504. <?php
  505. $fName = 'addTelboxesID';
  506. $fldParams = array();
  507. $fldParams['allowCreate'] = false;
  508. $fldParams['ajaxDataUrlBase'] = "index.php?_route=Users&_task=typeSpecialIdTelboxes";
  509. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  510. echo $typeSpecialTelboxes->showFormItem($tblID = -1, $fName, $selValue = '', $fldParams);
  511. ?>
  512. </div>
  513. </div>
  514. <div class="form-group">
  515. <div class="col-sm-9 col-sm-offset-3">
  516. <button type="submit" class="btn btn-xs btn-primary">dodaj grupę</button>
  517. </div>
  518. </div>
  519. </form>
  520. <?php endif; ?>
  521. </div>
  522. <?php
  523. {// show table crm_auth_profile
  524. $idZasobCrmAuthProfile = ProcesHelper::getZasobTableID('CRM_AUTH_PROFILE');
  525. if ($idZasobCrmAuthProfile <= 0) throw new Exception("Can not find id zasob 'CRM_AUTH_PROFILE'");
  526. $zasobObj = ProcesHelper::getZasobTableInfo($idZasobCrmAuthProfile);
  527. if (!$zasobObj) throw new Exception("Zasob TABELA ID={$idZasobCrmAuthProfile} nie istnieje");
  528. UserActivity::add($idZasobCrmAuthProfile);
  529. $userAcl = User::getAcl();
  530. if (!$userAcl->hasTableAcl($zasobObj->ID)) throw new Exception("Brak uprawnień do tabeli ID={$zasobObj->ID}");
  531. $tblAcl = $userAcl->getTableAcl($zasobObj->ID);
  532. $forceTblAclInit = ('1' == V::get('_force', '', $_GET));
  533. $tblAcl->init($forceTblAclInit);
  534. $forceFilterInit = array();
  535. $filterInit = new stdClass();
  536. $filterInit->currSortCol = 'ID';
  537. $filterInit->currSortFlip = 'desc';
  538. foreach ($_GET as $k => $v) {
  539. if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
  540. $filterInit->$k = $v;
  541. }
  542. else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
  543. $filterInit->$k = $v;
  544. }
  545. else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
  546. $fldName = substr($k, 3);
  547. $forceFilterInit[$fldName] = $v;
  548. }
  549. }
  550. $forceFilterInit['REMOTE_ID'] = $usr->primaryKey;
  551. $forceFilterInit['REMOTE_TABLE'] = 'ADMIN_USERS';
  552. $tbl = new TableAjax($tblAcl);
  553. $tbl->setLabel($zasobObj->OPIS);
  554. $tbl->setFilterInit($filterInit);
  555. if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
  556. $tbl->addRowFunction('edit');
  557. $tbl->addRowFunction('hist');
  558. $tbl->addRowFunction('files');
  559. $tbl->addRowFunction('cp');
  560. $tbl->showProcesInit(false);// hide Proces filter field
  561. echo $tbl->render();
  562. }
  563. }
  564. public function sortStanowiskaByType($a, $b) {
  565. if ($a->group->type != $a->group->type) {
  566. if ($a->group->type == 'network') {
  567. return 1;
  568. }
  569. else if ($a->group->type == 'local') {
  570. return -1;
  571. }
  572. }
  573. return 0;
  574. }
  575. public function removeUserGroup($usrLogin, $idProfileToRemove) {
  576. if (!$usrLogin) throw new Exception("Wrong param user login!");
  577. if (!$idProfileToRemove) throw new Exception("Wrong param id profile to remove!");
  578. $usrStorageDB = UserStorageFactory::getStorage('DB');
  579. if (!$usrStorageDB) throw new Exception("Error storage not exists!");
  580. $profile = $usrStorageDB->getProfileById($idProfileToRemove);
  581. if (!$profile) throw new Exception("Error profile not exists!");
  582. $usrStorageDB->removeUserGroupByProfileId($usrLogin, $profile->group, $idProfileToRemove);
  583. }
  584. public function addUserGroup($usrLogin, $idGroup, $idTelboxes) {
  585. DBG::_('DBG_NG', '>0', 'post', $_POST, __CLASS__, __FUNCTION__, __LINE__);
  586. if (!$usrLogin) throw new Exception("Wrong param user login!");
  587. $usrStorageDB = UserStorageFactory::getStorage('DB');
  588. if (!$usrStorageDB) throw new Exception("Error storage not exists!");
  589. $usr = $usrStorageDB->getUser($usrLogin);
  590. if (!$usr) throw new Exception("Użytkownik {$usrLogin} nie istnieje.");
  591. if ($idGroup > 0) {
  592. $groupToAdd = $usrStorageDB->getGroupWithoutNested($idGroup);
  593. if (!$groupToAdd) throw new Exception("Grupa [{$idGroup}] nie istnieje");
  594. $added = $usrStorageDB->addUserGroup($usrLogin, $groupToAdd, $idTelboxes);
  595. }
  596. }
  597. public function typeSpecialIdGroupAction() {
  598. header("Content-type: application/json");
  599. $typeSpecialUserGroups = TypespecialVariable::getInstance(-1, '__USER_GROUPS');
  600. $query = V::get('q', '', $_REQUEST);
  601. $rawRows = null;
  602. $rows = $typeSpecialUserGroups->getValuesWithExports($query);
  603. DBG::_('DBG', '>0', "rows(q={$query})", $rows, __CLASS__, __FUNCTION__, __LINE__);
  604. foreach ($rows as $kID => $vItem) {
  605. $itemJson = new stdClass();
  606. $itemJson->id = $vItem->id;
  607. $itemJson->name = $vItem->param_out;
  608. if (!empty($vItem->exports)) {
  609. $itemJson->exports = $vItem->exports;
  610. }
  611. $jsonData[] = $itemJson;
  612. }
  613. echo json_encode($jsonData);
  614. }
  615. public function typeSpecialIdTelboxesAction() {
  616. header("Content-type: application/json");
  617. $typeSpecialTelboxes = TypespecialVariable::getInstance(-1, '__TELBOXES');
  618. $query = V::get('q', '', $_REQUEST);
  619. $rawRows = null;
  620. $rows = $typeSpecialTelboxes->getValuesWithExports($query);
  621. DBG::_('DBG', '>0', "rows(q={$query})", $rows, __CLASS__, __FUNCTION__, __LINE__);
  622. foreach ($rows as $kID => $vItem) {
  623. $itemJson = new stdClass();
  624. $itemJson->id = $vItem->id;
  625. $itemJson->name = $vItem->param_out;
  626. if (!empty($vItem->exports)) {
  627. $itemJson->exports = $vItem->exports;
  628. }
  629. $jsonData[] = $itemJson;
  630. }
  631. echo json_encode($jsonData);
  632. }
  633. public function syncGroupAction() {
  634. $idGroup = V::get('idGroup', 0, $_GET, 'int');
  635. $group = null;
  636. SE_Layout::gora();
  637. SE_Layout::menu();
  638. echo '<div class="container">';
  639. try {
  640. if (!$idGroup) throw new Exception("Brak numeru grupy!");
  641. $idZasobTableZasoby = ProcesHelper::getZasobTableID('CRM_LISTA_ZASOBOW');
  642. $usrStorageDB = UserStorageFactory::getStorage('DB');
  643. if ($usrStorageDB) $group = $usrStorageDB->getGroup($idGroup);
  644. ?>
  645. <h4>Synchronizacja grupy do bazy LDAP</h4>
  646. <blockquote>
  647. Grupa [<?php echo $idGroup; ?>]:
  648. <?php if ($group) : ?>
  649. <code><?php echo $group->type; ?></code> <?php echo $group->zasobDESC; ?>
  650. <?php endif; ?>
  651. <a class="btn btn-xs btn-link" href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idZasobTableZasoby; ?>#EDIT/<?php echo $idGroup; ?>" title="Edytuj rekord"><i class="glyphicon glyphicon-pencil"></i> edytuj</a>
  652. <a class="btn btn-xs btn-link" href="index.php?_route=Users&_task=nestedGroups&idGroup=<?php echo $idGroup; ?>"><i class="glyphicon glyphicon-random"></i> ustal powiązania między grupami uprawnień</a>
  653. </blockquote>
  654. <?php
  655. $this->syncGroup($idGroup);
  656. } catch (Exception $e) {
  657. ?><div class="alert alert-danger"><?php echo $e->getMessage(); ?></div><?php
  658. }
  659. echo '</div>';// .container
  660. SE_Layout::dol();
  661. }
  662. public function syncGroup($idGroup) {
  663. $usrStorageDB = UserStorageFactory::getStorage('DB');
  664. $usrStorageLdap = UserStorageFactory::getStorage('MacOSX');
  665. if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
  666. if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
  667. $groupFrom = $usrStorageDB->getGroup($idGroup);
  668. if (!$groupFrom) {
  669. $db = DB::getDB();
  670. $zasob = $db->get_by_id('CRM_LISTA_ZASOBOW', $idGroup);
  671. if (!$zasob) {
  672. throw new Exception("Zasób {$idGroup} nie istnieje");
  673. } else {
  674. throw new Exception("Zasób {$idGroup} nie jest grupą tylko {$zasob->TYPE}");
  675. }
  676. }
  677. else {
  678. $synUsers = new SyncUsers($usrStorageDB, $usrStorageLdap);
  679. $syncTodoList = $synUsers->getSyncGroupTodoList($idGroup, $syncNestedGroups = true);
  680. ?>
  681. <?php if (empty($syncTodoList)) : ?>
  682. <div class="alert alert-info">Brak zadań do wykonania - grupa zsynchronizowana</div>
  683. <?php else : ?>
  684. <div class="well">
  685. <p>Lista zadań do wykonania:</p>
  686. <ul>
  687. <?php foreach ($syncTodoList as $vTask) : ?>
  688. <li><?php echo $vTask; ?></li>
  689. <?php endforeach; ?>
  690. </ul>
  691. </div>
  692. <?php endif; ?>
  693. <?php
  694. if ('1' == V::get('_runSync', '', $_POST)) {
  695. $synced = $synUsers->syncGroup($idGroup, $syncNestedGroups = true);
  696. if (!$synced) {
  697. ?>
  698. <div class="alert alert-danger">
  699. Nie udało się zsynchronizować grupy [<?php echo $idGroup; ?>].
  700. </div>
  701. <?php
  702. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;display:none;">errors: (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($synUsers->getErrorsMsgListWithDbg());echo'</pre>';
  703. }
  704. else {
  705. ?>
  706. <div class="alert alert-success">
  707. Synchronizacja grupy [<?php echo $idGroup; ?>] zakończona powodzeniem.
  708. </div>
  709. <?php
  710. }
  711. }
  712. else {
  713. ?>
  714. <form action="" method="POST">
  715. <input type="hidden" name="_runSync" value="1">
  716. <input type="submit" value="Synchronizuj" class="btn btn-primary btn-big">
  717. </form>
  718. <?php
  719. }
  720. }
  721. }
  722. public function syncUserAction() {
  723. SE_Layout::gora();
  724. SE_Layout::menu();
  725. $usrLogin = V::get('usrLogin', '', $_GET);
  726. echo '<div class="container">';
  727. try {
  728. if (empty($usrLogin)) throw new Exception("Empty user login");
  729. $usrStorageDB = UserStorageFactory::getStorage('DB');
  730. $usrStorageLdap = UserStorageFactory::getStorage('MacOSX');
  731. if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
  732. if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
  733. echo '<h4>' . "Synchronizacja do LDAP" . '</h4>';
  734. $usrFrom = $usrStorageDB->getUser($usrLogin);
  735. DBG::_('DBG_SU', '>1', 'User from:', $usrFrom, __CLASS__, __FUNCTION__, __LINE__);
  736. if ($usrFrom) {
  737. $idZasobUsersTbl = ProcesHelper::getZasobTableID('ADMIN_USERS');
  738. $idZasobPermsTbl = ProcesHelper::getZasobTableID('CRM_AUTH_PROFILE');
  739. ?>
  740. <blockquote>
  741. Użytkownik [<?php echo $usrFrom->primaryKey; ?>] <b><?php echo $usrFrom->name; ?></b> <code><?php echo $usrFrom->login; ?></code>
  742. <?php if ($idZasobUsersTbl > 0) : ?>
  743. <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idZasobUsersTbl; ?>#EDIT/<?php echo $usrFrom->primaryKey; ?>"
  744. class="btn btn-xs btn-link"><span class="glyphicon glyphicon-pencil"></span> edytuj</a>
  745. <?php endif; ?>
  746. <?php if ($idZasobPermsTbl > 0) : ?>
  747. <a href="index.php?_route=Users&_task=userGroups&usrLogin=<?php echo $usrFrom->login; ?>"
  748. class="btn btn-xs btn-link"><span class="glyphicon glyphicon-user"></span> ustal stanowisko</a>
  749. <?php endif; ?>
  750. </blockquote>
  751. <?php
  752. }
  753. $this->syncUser($usrLogin, $usrStorageDB, $usrStorageLdap);
  754. } catch (Exception $e) {
  755. ?><div class="alert alert-danger"><?php echo $e->getMessage(); ?></div><?php
  756. }
  757. echo '</div>';// .container
  758. SE_Layout::dol();
  759. }
  760. public function syncUser($userName, $usrStorageDB, $usrStorageLdap) {
  761. if (empty($userName)) throw new Exception("Empty user login");
  762. if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
  763. if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
  764. $synUsers = new SyncUsers($usrStorageDB, $usrStorageLdap);
  765. $syncTodoList = $synUsers->getSyncUserTodoList($userName);
  766. ?>
  767. <?php if (empty($syncTodoList)) : ?>
  768. <div class="alert alert-info">Brak zadań do wykonania - użytkownik zsynchronizowany</div>
  769. <?php else : ?>
  770. <div class="well">
  771. <p>Lista zadań do wykonania:</p>
  772. <ul>
  773. <?php foreach ($syncTodoList as $vTask) : ?>
  774. <li><?php echo $vTask; ?></li>
  775. <?php endforeach; ?>
  776. </ul>
  777. </div>
  778. <?php endif; ?>
  779. <?php
  780. if ('1' == V::get('_runSync', '', $_POST)) {
  781. $synced = $synUsers->syncUser($userName, $syncGroups = true, $syncDisabled = true);
  782. if (!$synced) {
  783. ?>
  784. <div class="alert alert-danger">
  785. Nie udało się zsynchronizować uprawnień użytkownika <?php echo $userName; ?>.
  786. </div>
  787. <?php
  788. $errorsList = $synUsers->getErrorsMsgListWithDbg();
  789. if (!empty($errorsList)) {
  790. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">';
  791. echo "Błędy:\n" . implode("\n", $errorsList);
  792. echo '</pre>';
  793. }
  794. }
  795. else {
  796. ?>
  797. <div class="alert alert-success">
  798. Synchronizacja uprawnień użytkownika <?php echo $userName; ?> zakończona powodzeniem.
  799. </div>
  800. <?php
  801. }
  802. }
  803. else {
  804. ?>
  805. <form action="" method="POST">
  806. <input type="hidden" name="_runSync" value="1">
  807. <input type="submit" value="Synchronizuj" class="btn btn-primary btn-big">
  808. </form>
  809. <?php
  810. }
  811. }
  812. }