superedit-VIEWTABLE_AJAX.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. function VIEWTABLE_AJAX( $params = array() ) {
  3. SE_Layout::menu();
  4. $zasobID = V::get('ZASOB_ID', 0, $_GET, 'int');
  5. if ($zasobID <= 0) {
  6. echo 'Wrong param ZASOB_ID';
  7. return;
  8. }
  9. Lib::loadClass('ProcesHelper');
  10. $zasobObj = ProcesHelper::getZasobTableInfo($zasobID);
  11. if (!$zasobObj) {
  12. echo "Zasob TABELA ID={$zasobID} nie istnieje";
  13. return;
  14. }
  15. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">zasobObj (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($zasobObj);echo'</pre>';
  16. $userAcl = User::getAcl();
  17. $userAcl->fetchGroups();
  18. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;display:none;">$userAcl (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($userAcl);echo'</pre>';
  19. if (!$userAcl->hasTableAcl($zasobObj->ID)) {
  20. die("Brak uprawnień do tabeli ID={$zasobObj->ID}");
  21. }
  22. $tblAcl = $userAcl->getTableAcl($zasobObj->ID);
  23. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">tblAcl (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($tblAcl);echo'</pre>';
  24. $forceTblAclInit = ('1' == V::get('_force', '', $_GET));
  25. try {
  26. $tblAcl->init($forceTblAclInit);
  27. Lib::loadClass('TableAjax');
  28. $forceFilterInit = array();
  29. $filterInit = new stdClass();
  30. $filterInit->currSortCol = 'ID';
  31. $filterInit->currSortFlip = 'desc';
  32. foreach ($_GET as $k => $v) {
  33. if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
  34. $filterInit->$k = $v;
  35. }
  36. else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
  37. $filterInit->$k = $v;
  38. }
  39. else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
  40. $fldName = substr($k, 3);
  41. $forceFilterInit[$fldName] = $v;
  42. }
  43. }
  44. $tbl = new TableAjax($tblAcl);
  45. $tblLabel = array();
  46. if (!empty($zasobObj->DESC_PL)) $tblLabel []= $zasobObj->DESC_PL;
  47. if (!empty($zasobObj->OPIS)) $tblLabel []= $zasobObj->OPIS;
  48. $tblLabel = implode(" - ", $tblLabel);
  49. $tbl->setLabel($tblLabel);
  50. $tbl->setFilterInit($filterInit);
  51. if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
  52. $tbl->addRowFunction('edit');
  53. $tbl->addRowFunction('hist');
  54. $tbl->addRowFunction('files');
  55. $tbl->addRowFunction('cp');
  56. echo $tbl->render();
  57. } catch (Exception $e) {
  58. ?>
  59. <div class="alert alert-error">
  60. <strong>Wystąpiły błędy!</strong>
  61. <?php echo $e->getMessage(); ?>
  62. </div>
  63. <?php
  64. }
  65. }