superedit-VIEWTABLE_AJAX.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. $tblAcl->init($forceTblAclInit);
  26. Lib::loadClass('TableAjax');
  27. $forceFilterInit = array();
  28. $filterInit = new stdClass();
  29. $filterInit->currSortCol = 'ID';
  30. $filterInit->currSortFlip = 'desc';
  31. foreach ($_GET as $k => $v) {
  32. if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
  33. $filterInit->$k = $v;
  34. }
  35. else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
  36. $filterInit->$k = $v;
  37. }
  38. else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
  39. $fldName = substr($k, 3);
  40. $forceFilterInit[$fldName] = $v;
  41. }
  42. }
  43. $tbl = new TableAjax($tblAcl);
  44. $tblLabel = array();
  45. if (!empty($zasobObj->DESC_PL)) $tblLabel []= $zasobObj->DESC_PL;
  46. if (!empty($zasobObj->OPIS)) $tblLabel []= $zasobObj->OPIS;
  47. $tblLabel = implode(" - ", $tblLabel);
  48. $tbl->setLabel($tblLabel);
  49. $tbl->setFilterInit($filterInit);
  50. if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
  51. $tbl->addRowFunction('edit');
  52. $tbl->addRowFunction('hist');
  53. $tbl->addRowFunction('files');
  54. $tbl->addRowFunction('cp');
  55. echo $tbl->render();
  56. }