|
|
@@ -0,0 +1,79 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+Lib::loadClass('RouteBase');
|
|
|
+Lib::loadClass('ProcesHelper');
|
|
|
+Lib::loadClass('TableAjax');
|
|
|
+// Lib::loadClass('Request');
|
|
|
+// Lib::loadClass('Response');
|
|
|
+Lib::loadClass('UI');
|
|
|
+
|
|
|
+class Route_ViewTableAjax extends RouteBase {
|
|
|
+
|
|
|
+ public function defaultAction() {
|
|
|
+ UI::gora();
|
|
|
+ UI::menu();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $typeName = V::get('typeName', '', $_GET, 'word');
|
|
|
+ if (!$typeName) throw new Exception("Wrong param typeName");
|
|
|
+ $tblAcl = $this->getAclFromTypeName($typeName, $forceTblAclInit = ('1' == V::get('_force', '', $_GET)));
|
|
|
+
|
|
|
+ $forceFilterInit = array();
|
|
|
+ $filterInit = new stdClass();
|
|
|
+ $filterInit->currSortCol = 'ID';
|
|
|
+ $filterInit->currSortFlip = 'desc';
|
|
|
+ foreach ($_GET as $k => $v) {
|
|
|
+ if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
|
|
|
+ $filterInit->$k = $v;
|
|
|
+ }
|
|
|
+ else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
|
|
|
+ $filterInit->$k = $v;
|
|
|
+ }
|
|
|
+ else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
|
|
|
+ $fldName = substr($k, 3);
|
|
|
+ $forceFilterInit[$fldName] = $v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $tbl = new TableAjax($tblAcl);
|
|
|
+ $tblLabel = array();
|
|
|
+ $zasobObj = ProcesHelper::getZasobTableInfo($tblAcl->getID());
|
|
|
+ if (!$zasobObj) throw new Exception("Zasob TABELA ID=" . $tblAcl->getID() . " nie istnieje");
|
|
|
+ if (!empty($zasobObj->DESC_PL)) $tblLabel []= $zasobObj->DESC_PL;
|
|
|
+ if (!empty($zasobObj->OPIS)) $tblLabel []= $zasobObj->OPIS;
|
|
|
+ $tblLabel = implode(" - ", $tblLabel);
|
|
|
+ $tbl->setLabel($tblLabel);
|
|
|
+ $tbl->setFilterInit($filterInit);
|
|
|
+ if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
|
|
|
+ $tbl->addRowFunction('edit');
|
|
|
+ $tbl->addRowFunction('hist');
|
|
|
+ $tbl->addRowFunction('files');
|
|
|
+ $tbl->addRowFunction('cp');
|
|
|
+ $tbl->addRowFunction('msgs');
|
|
|
+ echo $tbl->render();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ UI::startContainer();
|
|
|
+ UI::alert('danger', "<strong>Wystąpiły błędy!</strong> " . $e->getMessage());
|
|
|
+ UI::endContainer();
|
|
|
+ }
|
|
|
+ UI::dol();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param string $typeName - 'p5_default_db:TEST_PERMS'
|
|
|
+ */
|
|
|
+ public function getAclFromTypeName($typeName, $forceTblAclInit) {
|
|
|
+ $userAcl = User::getAcl();
|
|
|
+ $userAcl->fetchGroups();
|
|
|
+ $typeEx = explode(':', $typeName);
|
|
|
+ if (2 != count($typeEx)) throw new Exception("Could not get acl for '{$typeName}' - syntax error");
|
|
|
+ if ('p5_' != substr($typeEx[0], 0, 3)) throw new Exception("Could not get acl for '{$typeName}' - prefix error");
|
|
|
+ $sourceName = substr($typeEx[0], 3);
|
|
|
+ $objName = $typeEx[1];
|
|
|
+ $acl = $userAcl->getObjectAcl($sourceName, $objName);
|
|
|
+ if (!$acl) throw new Exception("Could not get acl for '{$typeName}'");
|
|
|
+ $acl->init($forceTblAclInit);
|
|
|
+ return $acl;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|