Users.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  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
  460. <?php if ($usr->isDisabled) : ?>
  461. <span class="label label-danger">zablokowany!</span>
  462. <?php else : ?>
  463. <span class="label label-info">aktywny</span>
  464. <?php endif; ?>
  465. [<?php echo $usr->primaryKey; ?>] <b><?php echo $usr->name; ?></b> <code><?php echo $usr->login; ?></code>
  466. <?php if ($idZasobUsersTbl > 0) : ?>
  467. <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idZasobUsersTbl; ?>#EDIT/<?php echo $usr->primaryKey; ?>"
  468. class="btn btn-xs btn-link"><span class="glyphicon glyphicon-pencil"></span> edytuj</a>
  469. <?php endif; ?>
  470. <a href="index.php?_route=Users&_task=syncUser&usrLogin=<?php echo $usr->login; ?>"
  471. class="btn btn-xs btn-link"><span class="glyphicon glyphicon-retweet"></span> synchronizuj do LDAP</a>
  472. </blockquote>
  473. <h4>Przypisane grupy (<?php echo (!empty($stanowiska))? count($stanowiska) : 0; ?>):</h4>
  474. <?php if (!empty($stanowiska)) : ?>
  475. <ul class="conn_groups-list">
  476. <?php foreach ($stanowiska as $vProfile) : ?>
  477. <li class="conn_groups-list_item">
  478. <?php echo $vProfile->group->realName; ?>
  479. <?php if ($vProfile->localisationId > 0) : ?>
  480. (lokalizacja [<?php echo $vProfile->localisationId; ?>])
  481. <?php endif; ?>
  482. <form class="form-inline frm-groups" action="" method="POST">
  483. <input type="hidden" name="_subTask" value="removeUserGroup">
  484. <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>
  485. </form>
  486. </li>
  487. <?php endforeach; ?>
  488. </ul>
  489. <?php endif; ?>
  490. <?php if ($typeSpecialUserGroups && $typeSpecialTelboxes) : ?>
  491. <h4>Dodaj grupę:</h4>
  492. <form class="form-horizontal" action="" method="POST">
  493. <input type="hidden" name="_subTask" value="addUserGroup">
  494. <div class="form-group">
  495. <label class="col-sm-3 control-label" for="idGroup">Grupa</label>
  496. <div class="col-sm-9">
  497. <?php
  498. $fName = 'idGroup';
  499. $fldParams = array();
  500. $fldParams['allowCreate'] = false;
  501. $fldParams['ajaxDataUrlBase'] = "index.php?_route=Users&_task=typeSpecialIdGroup";
  502. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  503. echo $typeSpecialUserGroups->showFormItem($tblID = -1, $fName, $selValue = '', $fldParams);
  504. ?>
  505. </div>
  506. </div>
  507. <div class="form-group">
  508. <label class="col-sm-3 control-label" for="addTelboxesID">Lokalizacja</label>
  509. <div class="col-sm-9">
  510. <?php
  511. $fName = 'addTelboxesID';
  512. $fldParams = array();
  513. $fldParams['allowCreate'] = false;
  514. $fldParams['ajaxDataUrlBase'] = "index.php?_route=Users&_task=typeSpecialIdTelboxes";
  515. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  516. echo $typeSpecialTelboxes->showFormItem($tblID = -1, $fName, $selValue = '', $fldParams);
  517. ?>
  518. </div>
  519. </div>
  520. <div class="form-group">
  521. <div class="col-sm-9 col-sm-offset-3">
  522. <button type="submit" class="btn btn-xs btn-primary">dodaj grupę</button>
  523. </div>
  524. </div>
  525. </form>
  526. <?php endif; ?>
  527. </div>
  528. <?php
  529. {// show table crm_auth_profile
  530. $idZasobCrmAuthProfile = ProcesHelper::getZasobTableID('CRM_AUTH_PROFILE');
  531. if ($idZasobCrmAuthProfile <= 0) throw new Exception("Can not find id zasob 'CRM_AUTH_PROFILE'");
  532. $zasobObj = ProcesHelper::getZasobTableInfo($idZasobCrmAuthProfile);
  533. if (!$zasobObj) throw new Exception("Zasob TABELA ID={$idZasobCrmAuthProfile} nie istnieje");
  534. UserActivity::add($idZasobCrmAuthProfile);
  535. $userAcl = User::getAcl();
  536. if (!$userAcl->hasTableAcl($zasobObj->ID)) throw new Exception("Brak uprawnień do tabeli ID={$zasobObj->ID}");
  537. $tblAcl = $userAcl->getTableAcl($zasobObj->ID);
  538. $forceTblAclInit = ('1' == V::get('_force', '', $_GET));
  539. $tblAcl->init($forceTblAclInit);
  540. $forceFilterInit = array();
  541. $filterInit = new stdClass();
  542. $filterInit->currSortCol = 'ID';
  543. $filterInit->currSortFlip = 'desc';
  544. foreach ($_GET as $k => $v) {
  545. if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
  546. $filterInit->$k = $v;
  547. }
  548. else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
  549. $filterInit->$k = $v;
  550. }
  551. else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
  552. $fldName = substr($k, 3);
  553. $forceFilterInit[$fldName] = $v;
  554. }
  555. }
  556. $forceFilterInit['REMOTE_ID'] = $usr->primaryKey;
  557. $forceFilterInit['REMOTE_TABLE'] = 'ADMIN_USERS';
  558. $tbl = new TableAjax($tblAcl);
  559. $tbl->setLabel($zasobObj->OPIS);
  560. $tbl->setFilterInit($filterInit);
  561. if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
  562. $tbl->addRowFunction('edit');
  563. $tbl->addRowFunction('hist');
  564. $tbl->addRowFunction('files');
  565. $tbl->addRowFunction('cp');
  566. $tbl->showProcesInit(false);// hide Proces filter field
  567. echo $tbl->render();
  568. }
  569. }
  570. public function sortStanowiskaByType($a, $b) {
  571. if ($a->group->type != $a->group->type) {
  572. if ($a->group->type == 'network') {
  573. return 1;
  574. }
  575. else if ($a->group->type == 'local') {
  576. return -1;
  577. }
  578. }
  579. return 0;
  580. }
  581. public function removeUserGroup($usrLogin, $idProfileToRemove) {
  582. if (!$usrLogin) throw new Exception("Wrong param user login!");
  583. if (!$idProfileToRemove) throw new Exception("Wrong param id profile to remove!");
  584. $usrStorageDB = UserStorageFactory::getStorage('DB');
  585. if (!$usrStorageDB) throw new Exception("Error storage not exists!");
  586. $profile = $usrStorageDB->getProfileById($idProfileToRemove);
  587. if (!$profile) throw new Exception("Error profile not exists!");
  588. $usrStorageDB->removeUserGroupByProfileId($usrLogin, $profile->group, $idProfileToRemove);
  589. }
  590. public function addUserGroup($usrLogin, $idGroup, $idTelboxes) {
  591. DBG::_('DBG_NG', '>0', 'post', $_POST, __CLASS__, __FUNCTION__, __LINE__);
  592. if (!$usrLogin) throw new Exception("Wrong param user login!");
  593. $usrStorageDB = UserStorageFactory::getStorage('DB');
  594. if (!$usrStorageDB) throw new Exception("Error storage not exists!");
  595. $usr = $usrStorageDB->getUser($usrLogin);
  596. if (!$usr) throw new Exception("Użytkownik {$usrLogin} nie istnieje.");
  597. if ($idGroup > 0) {
  598. $groupToAdd = $usrStorageDB->getGroupWithoutNested($idGroup);
  599. if (!$groupToAdd) throw new Exception("Grupa [{$idGroup}] nie istnieje");
  600. $added = $usrStorageDB->addUserGroup($usrLogin, $groupToAdd, $idTelboxes);
  601. }
  602. }
  603. public function typeSpecialIdGroupAction() {
  604. header("Content-type: application/json");
  605. $typeSpecialUserGroups = TypespecialVariable::getInstance(-1, '__USER_GROUPS');
  606. $query = V::get('q', '', $_REQUEST);
  607. $rawRows = null;
  608. $rows = $typeSpecialUserGroups->getValuesWithExports($query);
  609. DBG::_('DBG', '>0', "rows(q={$query})", $rows, __CLASS__, __FUNCTION__, __LINE__);
  610. foreach ($rows as $kID => $vItem) {
  611. $itemJson = new stdClass();
  612. $itemJson->id = $vItem->id;
  613. $itemJson->name = $vItem->param_out;
  614. if (!empty($vItem->exports)) {
  615. $itemJson->exports = $vItem->exports;
  616. }
  617. $jsonData[] = $itemJson;
  618. }
  619. echo json_encode($jsonData);
  620. }
  621. public function typeSpecialIdTelboxesAction() {
  622. header("Content-type: application/json");
  623. $typeSpecialTelboxes = TypespecialVariable::getInstance(-1, '__TELBOXES');
  624. $query = V::get('q', '', $_REQUEST);
  625. $rawRows = null;
  626. $rows = $typeSpecialTelboxes->getValuesWithExports($query);
  627. DBG::_('DBG', '>0', "rows(q={$query})", $rows, __CLASS__, __FUNCTION__, __LINE__);
  628. foreach ($rows as $kID => $vItem) {
  629. $itemJson = new stdClass();
  630. $itemJson->id = $vItem->id;
  631. $itemJson->name = $vItem->param_out;
  632. if (!empty($vItem->exports)) {
  633. $itemJson->exports = $vItem->exports;
  634. }
  635. $jsonData[] = $itemJson;
  636. }
  637. echo json_encode($jsonData);
  638. }
  639. public function syncGroupAction() {
  640. $idGroup = V::get('idGroup', 0, $_GET, 'int');
  641. $group = null;
  642. SE_Layout::gora();
  643. SE_Layout::menu();
  644. echo '<div class="container">';
  645. try {
  646. if (!$idGroup) throw new Exception("Brak numeru grupy!");
  647. $idZasobTableZasoby = ProcesHelper::getZasobTableID('CRM_LISTA_ZASOBOW');
  648. $usrStorageDB = UserStorageFactory::getStorage('DB');
  649. if ($usrStorageDB) $group = $usrStorageDB->getGroup($idGroup);
  650. ?>
  651. <h4>Synchronizacja grupy do bazy LDAP</h4>
  652. <blockquote>
  653. Grupa [<?php echo $idGroup; ?>]:
  654. <?php if ($group) : ?>
  655. <code><?php echo $group->type; ?></code> <?php echo $group->zasobDESC; ?>
  656. <?php endif; ?>
  657. <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>
  658. <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>
  659. </blockquote>
  660. <?php
  661. $this->syncGroup($idGroup);
  662. } catch (Exception $e) {
  663. ?><div class="alert alert-danger"><?php echo $e->getMessage(); ?></div><?php
  664. }
  665. echo '</div>';// .container
  666. SE_Layout::dol();
  667. }
  668. public function syncGroup($idGroup) {
  669. $usrStorageDB = UserStorageFactory::getStorage('DB');
  670. $usrStorageLdap = UserStorageFactory::getStorage('MacOSX');
  671. if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
  672. if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
  673. $groupFrom = $usrStorageDB->getGroup($idGroup);
  674. if (!$groupFrom) {
  675. $db = DB::getDB();
  676. $zasob = $db->get_by_id('CRM_LISTA_ZASOBOW', $idGroup);
  677. if (!$zasob) {
  678. throw new Exception("Zasób {$idGroup} nie istnieje");
  679. } else {
  680. throw new Exception("Zasób {$idGroup} nie jest grupą tylko {$zasob->TYPE}");
  681. }
  682. }
  683. else {
  684. $synUsers = new SyncUsers($usrStorageDB, $usrStorageLdap);
  685. $syncTodoList = $synUsers->getSyncGroupTodoList($idGroup, $syncNestedGroups = true);
  686. ?>
  687. <?php if (empty($syncTodoList)) : ?>
  688. <div class="alert alert-info">Brak zadań do wykonania - grupa zsynchronizowana</div>
  689. <?php else : ?>
  690. <div class="well">
  691. <p>Lista zadań do wykonania:</p>
  692. <ul>
  693. <?php foreach ($syncTodoList as $vTask) : ?>
  694. <li><?php echo $vTask; ?></li>
  695. <?php endforeach; ?>
  696. </ul>
  697. </div>
  698. <?php endif; ?>
  699. <?php
  700. if ('1' == V::get('_runSync', '', $_POST)) {
  701. $synced = $synUsers->syncGroup($idGroup, $syncNestedGroups = true);
  702. if (!$synced) {
  703. ?>
  704. <div class="alert alert-danger">
  705. Nie udało się zsynchronizować grupy [<?php echo $idGroup; ?>].
  706. </div>
  707. <?php
  708. 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>';
  709. }
  710. else {
  711. ?>
  712. <div class="alert alert-success">
  713. Synchronizacja grupy [<?php echo $idGroup; ?>] zakończona powodzeniem.
  714. </div>
  715. <?php
  716. }
  717. }
  718. else {
  719. ?>
  720. <form action="" method="POST">
  721. <input type="hidden" name="_runSync" value="1">
  722. <input type="submit" value="Synchronizuj" class="btn btn-primary btn-big">
  723. </form>
  724. <?php
  725. }
  726. }
  727. }
  728. public function syncUserAction() {
  729. SE_Layout::gora();
  730. SE_Layout::menu();
  731. $usrLogin = V::get('usrLogin', '', $_GET);
  732. echo '<div class="container">';
  733. try {
  734. if (empty($usrLogin)) throw new Exception("Empty user login");
  735. $usrStorageDB = UserStorageFactory::getStorage('DB');
  736. $usrStorageLdap = UserStorageFactory::getStorage('MacOSX');
  737. if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
  738. if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
  739. echo '<h4>' . "Synchronizacja do LDAP" . '</h4>';
  740. $usrFrom = $usrStorageDB->getUser($usrLogin);
  741. DBG::_('DBG_SU', '>1', 'User from:', $usrFrom, __CLASS__, __FUNCTION__, __LINE__);
  742. if ($usrFrom) {
  743. $idZasobUsersTbl = ProcesHelper::getZasobTableID('ADMIN_USERS');
  744. $idZasobPermsTbl = ProcesHelper::getZasobTableID('CRM_AUTH_PROFILE');
  745. ?>
  746. <blockquote>
  747. Użytkownik
  748. <?php if ($usrFrom->isDisabled) : ?>
  749. <span class="label label-danger">zablokowany!</span>
  750. <?php else : ?>
  751. <span class="label label-info">aktywny</span>
  752. <?php endif; ?>
  753. [<?php echo $usrFrom->primaryKey; ?>] <b><?php echo $usrFrom->name; ?></b> <code><?php echo $usrFrom->login; ?></code>
  754. <?php if ($idZasobUsersTbl > 0) : ?>
  755. <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idZasobUsersTbl; ?>#EDIT/<?php echo $usrFrom->primaryKey; ?>"
  756. class="btn btn-xs btn-link"><span class="glyphicon glyphicon-pencil"></span> edytuj</a>
  757. <?php endif; ?>
  758. <?php if ($idZasobPermsTbl > 0) : ?>
  759. <a href="index.php?_route=Users&_task=userGroups&usrLogin=<?php echo $usrFrom->login; ?>"
  760. class="btn btn-xs btn-link"><span class="glyphicon glyphicon-user"></span> ustal stanowisko</a>
  761. <?php endif; ?>
  762. </blockquote>
  763. <?php
  764. }
  765. $this->syncUser($usrLogin, $usrStorageDB, $usrStorageLdap);
  766. } catch (Exception $e) {
  767. ?><div class="alert alert-danger"><?php echo $e->getMessage(); ?></div><?php
  768. }
  769. echo '</div>';// .container
  770. SE_Layout::dol();
  771. }
  772. public function syncUser($userName, $usrStorageDB, $usrStorageLdap) {
  773. if (empty($userName)) throw new Exception("Empty user login");
  774. if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
  775. if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
  776. $synUsers = new SyncUsers($usrStorageDB, $usrStorageLdap);
  777. $syncTodoList = $synUsers->getSyncUserTodoList($userName);
  778. ?>
  779. <?php if (empty($syncTodoList)) : ?>
  780. <div class="alert alert-info">Brak zadań do wykonania - użytkownik zsynchronizowany</div>
  781. <?php else : ?>
  782. <div class="well">
  783. <p>Lista zadań do wykonania:</p>
  784. <ul>
  785. <?php foreach ($syncTodoList as $vTask) : ?>
  786. <li><?php echo $vTask; ?></li>
  787. <?php endforeach; ?>
  788. </ul>
  789. </div>
  790. <?php endif; ?>
  791. <?php
  792. if ('1' == V::get('_runSync', '', $_POST)) {
  793. $synced = $synUsers->syncUser($userName, $syncGroups = true, $syncDisabled = true);
  794. if (!$synced) {
  795. ?>
  796. <div class="alert alert-danger">
  797. Nie udało się zsynchronizować uprawnień użytkownika <?php echo $userName; ?>.
  798. </div>
  799. <?php
  800. $errorsList = $synUsers->getErrorsMsgListWithDbg();
  801. if (!empty($errorsList)) {
  802. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">';
  803. echo "Błędy:\n" . implode("\n", $errorsList);
  804. echo '</pre>';
  805. }
  806. }
  807. else {
  808. ?>
  809. <div class="alert alert-success">
  810. Synchronizacja uprawnień użytkownika <?php echo $userName; ?> zakończona powodzeniem.
  811. </div>
  812. <?php
  813. }
  814. }
  815. else {
  816. ?>
  817. <form action="" method="POST">
  818. <input type="hidden" name="_runSync" value="1">
  819. <input type="submit" value="Synchronizuj" class="btn btn-primary btn-big">
  820. </form>
  821. <?php
  822. }
  823. }
  824. }