getFieldListByIdZasob() as $fieldName) {// TODO: use getFieldList // echo"
\$acl->canCreateField({$fieldName}): (".$acl->canCreateField($fieldName).")
"; if ($acl->canCreateField($fieldName)) return true; } return false; } public static function hasGeomFields($acl) { foreach ($acl->getFieldListByIdZasob() as $fieldName) { // echo"\$acl->isGeomField({$fieldName}): (".$acl->isGeomField($fieldName).") \$acl->canReadField({$fieldName}): (".$acl->canReadField($fieldName).")
"; if ($acl->isGeomField($fieldName) && $acl->canReadField($fieldName)) return true; } return false; } // @returns array [ field => string(perms like 'RWX') ] public static function getFieldPerms($acl) {// TODO: fetch perms for given Acl by namespace // TODO:? cache session or only current request (static) $fieldPerms = array(); foreach ($acl->getFields() as $idField => $field) { $fieldPerms[ $field['name'] ] = $field['perms']; } return $fieldPerms; } public static function getExportFieldList($acl) { $exportFields = array(); foreach (self::getFieldPerms($acl) as $fieldName => $perms) { if (false !== strpos($perms, 'E')) { $exportFields[] = $fieldName; } } return $exportFields; } public static function getAclByTypeName($typeName, $forceTblAclInit = false) {// TODO: replace getAclFromTypeName in WFS return self::getAclByNamespace(str_replace(':', '/', $typeName), $forceTblAclInit); } public static function getAclByNamespace($namespace, $forceTblAclInit = false) { if ('http' != substr($namespace, 0, 4)) $namespace = Api_WfsNs::getBaseWfsUri() . '/' . $namespace;//Request::getHostUri() . '/' . $namespace; $baseNsUri = Api_WfsNs::getBaseWfsUri(); if ("{$baseNsUri}/" == substr($namespace, 0, strlen($baseNsUri) + 1)) { $schemaNs = substr($namespace, strlen($baseNsUri) + 1); $ns = explode('/', $schemaNs);// "http://biuro.biall-net.pl/wfs/ default_db/{$nazwa_tabeli}/{$nazwa_obj} $sourceName = array_shift($ns);// remove first element - source name $objName = $ns[0]; if ('default_db' == $sourceName || 'p5_default_db' == $sourceName) { $sourceName = 'default_db'; if (1 == count($ns)) { $acl = User::getAcl()->getObjectAcl($sourceName, $objName); if (!$acl) throw new Exception("Could not get acl for '{$schemaNs}'"); $acl->init($forceTblAclInit); return $acl; } else if (2 == count($ns)) { throw new Exception("TODO: default_db: '{$schemaNs}' ns:[ ".implode(", ", $ns)." ]", 501); } else throw new Exception("Nieznany namespace default_db: '{$schemaNs}'", 501); } else if ('default_objects' == $sourceName || 'SystemObjects' == $sourceName || 'p5_objects' == $sourceName) { $sourceName = 'objects'; if (1 == count($ns)) { $acl = User::getAcl()->getObjectAcl($sourceName, $objName); if (!$acl) throw new Exception("Could not get acl for '{$schemaNs}'"); $acl->init($forceTblAclInit); return $acl; } else throw new Exception("Nieznany namespace SystemObjects: '{$schemaNs}'", 501); } else if ('default_objects__x3A__' == substr($sourceName, 0, 22)) {// default_objects__x3A__Zaliczka:Zaliczka $sourceName = 'objects'; if (1 == count($ns)) { $acl = User::getAcl()->getObjectAcl($sourceName, $objName); if (!$acl) throw new Exception("Could not get acl for '{$schemaNs}'"); $acl->init($forceTblAclInit); return $acl; } else throw new Exception("Nieznany namespace SystemObjects: '{$schemaNs}'", 501); } else if ('zasob_' == substr($sourceName, 0, 6)) { $dbName = substr($sourceName, 6); throw new Exception("TODO db[{$dbName}] namespace '{$schemaNs}'", 501); } else throw new Exception("Nieznany namespace '{$schemaNs}'", 501); } else throw new HttpException("Zasoby zewnętrzenj systemu nie są jeszcze zaimplementowane", 501); throw new HttpException("TODO L.".__LINE__." ns({$namespace})", 501); } public static function getMoreFunctionsCell($acl, $args) { $id = V::get('primary_key', 0, $args, 'int'); if ($id <= 0) throw new HttpException("404", 404); $record = V::get('record', null, $args); $rowFunList = array(); $tableName = $acl->getName(); $record = ($record)? $record : $acl->getItem($id); if(1){// TODO: fetch $totalMsgs from TableMsgs $msgs = Router::getRoute('Msgs'); $msgsList = $msgs->getActiveMessagesForTableRecord($tableName, $id); $totalMsgs = count($msgsList); $rowFunc = new stdClass(); $rowFunc->id = 'msgs'; $rowFunc->ico = 'glyphicon glyphicon-envelope'; $rowFunc->href = 'index.php?_route=TableMsgs&_task=tableRow&idTable=' . $acl->getID() . '&idRow=' . $id; $rowFunc->title = "Wiadomości ({$totalMsgs})"; $rowFunc->label = "Wiadomości {$totalMsgs}"; $rowFunList[] = $rowFunc; } if ('CRM_PROCES' == $acl->getName()) {// TODO: mv to table gui xml or php class // procesy5.php?task=CRM_LISTA_ZASOBOW&filtr_id=22001 $rowFunc = new stdClass(); $rowFunc->ico = 'glyphicon glyphicon-eye-open'; $rowFunc->href = "procesy5.php?task=CRM_PROCES&filtr_id={$id}"; $rowFunc->title = "Zobacz na drzewie procesów {{$id}}"; $rowFunList[] = $rowFunc; $wskazniki = ProcesHelper::get_wskazniki($id); $connectedZasobyTotal = count($wskazniki); $rowFunc = new stdClass(); $rowFunc->ico = 'glyphicon glyphicon-random'; $rowFunc->href = "index.php?MENU_INIT=PROCES_ADD_ZASOB&procesID={$id}"; $rowFunc->title = "Powiązane zasoby {$connectedZasobyTotal}"; $rowFunList[] = $rowFunc; } if ('CRM_LISTA_ZASOBOW' == $acl->getName()) {// TODO: mv to table gui xml or php class // procesy5.php?task=CRM_LISTA_ZASOBOW&filtr_id=22001 $rowFunc = new stdClass(); $rowFunc->ico = 'glyphicon glyphicon-eye-open'; $rowFunc->href = "procesy5.php?task=CRM_LISTA_ZASOBOW&filtr_id={$id}"; $rowFunc->title = "Zobacz na drzewie zasobów [{$id}]"; $rowFunList[] = $rowFunc; // index.php?MENU_INIT=ZASOB_OBOWIAZKI&id_zasob=22001 $rowFunc = new stdClass(); $rowFunc->ico = 'glyphicon glyphicon-random'; $rowFunc->href = "index.php?MENU_INIT=ZASOB_OBOWIAZKI&id_zasob={$id}"; $rowFunc->title = "Powiązane procesy (OB)"; $rowFunList[] = $rowFunc; // index.php?MENU_INIT=ZASOB_EXTERNAL_IDS&id_zasob=22001 $rowFunc = new stdClass(); $rowFunc->ico = 'glyphicon glyphicon-random'; $rowFunc->href = "index.php?MENU_INIT=ZASOB_EXTERNAL_IDS&id_zasob={$id}"; $rowFunc->title = "Powiązane dane (IDS)"; $rowFunList[] = $rowFunc; $groupTypeList = array(); $groupTypeList[] = 'STANOWISKO'; $groupTypeList[] = 'PODMIOT'; $groupTypeList[] = 'DZIAL'; if (in_array($record->TYPE, $groupTypeList)) { $rowFunc = new stdClass(); $rowFunc->ico = 'glyphicon glyphicon-retweet'; $rowFunc->href = "index.php?_route=Users&_task=syncGroup&idGroup={$id}"; $rowFunc->title = "Synchronizuj do LDAP"; $rowFunList[] = $rowFunc; } } if ('ADMIN_USERS' == $acl->getName()) {// TODO: mv to table gui xml if ($acl->canReadRecord($record) && $acl->canReadObjectField('ADM_ACCOUNT', $record)) { $rowFunc = new stdClass(); $rowFunc->ico = 'glyphicon glyphicon-user'; $rowFunc->href = 'index.php?_route=Users&_task=userGroups&usrLogin=' . $record->ADM_ACCOUNT; $rowFunc->title = "Ustal stanowisko"; $rowFunList[] = $rowFunc; $rowFunc = new stdClass(); $rowFunc->ico = 'glyphicon glyphicon-retweet'; $rowFunc->href = 'index.php?_route=Users&_task=syncUser&usrLogin=' . $record->ADM_ACCOUNT; $rowFunc->title = "Synchronizuj do LDAP"; $rowFunList[] = $rowFunc; $rowFunc = new stdClass(); $rowFunc->ico = 'glyphicon glyphicon-minus'; $rowFunc->href = 'index.php?MENU_INIT=USER_OCENA_PRACOWNIKA&usrLogin=' . $record->ADM_ACCOUNT; $rowFunc->title = "Ocena pracownika"; $rowFunList[] = $rowFunc; } } if ($urlFunctions = Route_UrlAction::getTableFunctions($acl->getID(), $id, $acl->getName(), User::getLogin())) { foreach ($urlFunctions as $urlFunction) { // TODO: is allowed to view - test by Router::getRoute('UrlAction')->isFunctionAllowedForRecord($routeName = $urlFunction['name'], $acl->getID(), $id); $rowFunction = array(); $rowFunction['href'] = $urlFunction['baseLink']; $rowFunction['ico'] = V::get('ico', 'glyphicon glyphicon-share', $urlFunction); $rowFunction['label'] = $urlFunction['label']; $rowFunction['title'] = V::get('title', $urlFunction['label'], $urlFunction); if (!empty($urlFunction['link_target'])) $rowFunction['target'] = $urlFunction['link_target']; if (!empty($urlFunction['cell_id_params'])) { $urlParams = array();// [ "{$urlParamName}={$paramValue}" ] foreach ($urlFunction['cell_id_params'] as $idField => $urlParamName) { $paramValue = ''; $fld = $acl->getField($idField); if ($fld) { $fldName = $fld['name']; $paramValue = V::get($fldName, '', $record); $urlParams[] = "{$urlParamName}={$paramValue}"; } } if (!empty($urlParams)) $rowFunction['href'] .= "&" . implode("&", $urlParams); } $rowFunList[] = $rowFunction; } } return $rowFunList; } public static function getAclList() {// @usage Core_AclHelper::getAclList();// @returns array [ $typeName , ... ] $aclList = array(); // Schema_AccessGroupStorageAcl, load by User::getAcl()->getObjectAcl('objects', $objName); // $objClassName = "Schema_{$objName}StorageAcl"; // if (!Lib::tryLoadClass($objClassName)) throw new HttpException("Not implemented", 501); // $ grep -r 'class ' SE/se-lib/Schema/*Acl.php // SE/se-lib/Schema/AccessGroupStorageAcl.php:class Schema_AccessGroupStorageAcl extends Core_AclBase {// Read only class // SE/se-lib/Schema/AccessOwnerStorageAcl.php:class Schema_AccessOwnerStorageAcl extends Core_AclBase { // SE/se-lib/Schema/FileStorageAcl.php:class Schema_FileStorageAcl extends Core_AclBase { // SE/se-lib/Schema/KorespondencjaStorageAcl.php:class Schema_KorespondencjaStorageAcl extends Core_AclBase { // SE/se-lib/Schema/TestPermsStorageAcl.php:class Schema_TestPermsStorageAcl extends Core_AclBase { $aclList[] = 'default_objects:AccessGroupRead'; $aclList[] = 'default_objects:AccessGroupWrite'; $aclList[] = 'default_objects:AccessOwner'; $aclList[] = 'default_objects:File'; $aclList[] = 'default_objects:Korespondencja'; $aclList[] = 'default_objects:TestPerms'; // TODO: read from Database // $aclList[] = 'default_db__x3A__TEST_PERMS:TEST_PERMS';// uproszczona wersja: default_db:TEST_PERMS $cleanHostName = str_replace(array(".", "-"), '_', $_SERVER['SERVER_NAME']); $objList = include APP_PATH_SCHEMA . "/gui/company/{$cleanHostName}/get_object_list.php"; if (!empty($objList) && is_array($objList)) { foreach ($objList as $objectName) { if (!in_array($objectName, $aclList)) $aclList[] = $objectName; } } return $aclList; } }