|
@@ -15,12 +15,19 @@ class Schema_AccessOwnerStorageAcl extends Core_AclBase {
|
|
|
public function getVisibleFieldListByIdZasob() { return $this->getRealFieldListByIdZasob(); }
|
|
public function getVisibleFieldListByIdZasob() { return $this->getRealFieldListByIdZasob(); }
|
|
|
public function getVirtualFieldListByIdZasob() { return array(); }
|
|
public function getVirtualFieldListByIdZasob() { return array(); }
|
|
|
public function getRealFieldListByIdZasob($force = false) {
|
|
public function getRealFieldListByIdZasob($force = false) {
|
|
|
|
|
+ $cols = array();
|
|
|
$cols[100000] = 'id';// ADMIN_USERS.ID
|
|
$cols[100000] = 'id';// ADMIN_USERS.ID
|
|
|
$cols[100001] = 'login';// ADMIN_USERS.ADM_ACCOUNT
|
|
$cols[100001] = 'login';// ADMIN_USERS.ADM_ACCOUNT
|
|
|
$cols[100002] = 'name';// ADMIN_USERS.ADM_NAME
|
|
$cols[100002] = 'name';// ADMIN_USERS.ADM_NAME
|
|
|
return $cols;
|
|
return $cols;
|
|
|
}
|
|
}
|
|
|
- public function getFields() { return array_values($this->getRealFieldListByIdZasob()); }
|
|
|
|
|
|
|
+ public function getFields() {
|
|
|
|
|
+ $fields = array();
|
|
|
|
|
+ $fields[100000] = ['name'=>'id', 'perms'=>'R', 'opis'=>'', 'label'=>'', 'sort_prio'=>100];
|
|
|
|
|
+ $fields[100001] = ['name'=>'login', 'perms'=>'R', 'opis'=>'', 'label'=>'', 'sort_prio'=>101];
|
|
|
|
|
+ $fields[100002] = ['name'=>'name', 'perms'=>'R', 'opis'=>'', 'label'=>'', 'sort_prio'=>102];
|
|
|
|
|
+ return $fields;
|
|
|
|
|
+ }
|
|
|
public function getFieldType($fieldName) { return null; }
|
|
public function getFieldType($fieldName) { return null; }
|
|
|
|
|
|
|
|
// TODO: replace legacy functions: isAllowed, hasFieldPerm, getFieldIdByName
|
|
// TODO: replace legacy functions: isAllowed, hasFieldPerm, getFieldIdByName
|
|
@@ -60,6 +67,58 @@ class Schema_AccessOwnerStorageAcl extends Core_AclBase {
|
|
|
$items = array_filter($items, array($queryWhereBuilder, 'filterRawArray'));
|
|
$items = array_filter($items, array($queryWhereBuilder, 'filterRawArray'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $filterId = trim(V::get('f_id', '', $params));
|
|
|
|
|
+ if (strlen($filterId)) {// allow '0'
|
|
|
|
|
+ $queryWhereBuilder = new SqlQueryWhereBuilder();
|
|
|
|
|
+ if (is_numeric($filterId)) {
|
|
|
|
|
+ $queryWhereBuilder->addComparisonFieldToValue('id', '=', $filterId);
|
|
|
|
|
+ } else if (false !== strpos($filterId, '%') && is_numeric(trim($filterId, '%'))) {
|
|
|
|
|
+ $queryWhereBuilder->addComparisonFieldToValue('id', 'like', $filterId);
|
|
|
|
|
+ } else if ('>=' == substr($filterId, 0, 2) && is_numeric(substr($filterId, 2))) {
|
|
|
|
|
+ $queryWhereBuilder->addComparisonFieldToValue('id', 'GreaterThenOrEqualTo', substr($filterId, 2));
|
|
|
|
|
+ } else if ('<=' == substr($filterId, 0, 2) && is_numeric(substr($filterId, 2))) {
|
|
|
|
|
+ $queryWhereBuilder->addComparisonFieldToValue('id', 'LessThenOrEqualTo', substr($filterId, 2));
|
|
|
|
|
+ } else if ('>' == substr($filterId, 0, 1) && is_numeric(substr($filterId, 1))) {
|
|
|
|
|
+ $queryWhereBuilder->addComparisonFieldToValue('id', 'GreaterThen', substr($filterId, 1));
|
|
|
|
|
+ } else if ('<' == substr($filterId, 0, 1) && is_numeric(substr($filterId, 1))) {
|
|
|
|
|
+ $queryWhereBuilder->addComparisonFieldToValue('id', 'LessThen', substr($filterId, 1));
|
|
|
|
|
+ } else if ('=' == substr($filterId, 0, 1) && is_numeric(substr($filterId, 1))) {
|
|
|
|
|
+ $queryWhereBuilder->addComparisonFieldToValue('id', '=', substr($filterId, 1));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $filterId = null;// TODO: BUG uniimplemented comparison sign
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($filterId) $items = array_filter($items, array($queryWhereBuilder, 'filterRawArray'));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ foreach (['login', 'name'] as $fieldName) {
|
|
|
|
|
+ $filterValue = trim(V::get("f_{$fieldName}", '', $params));
|
|
|
|
|
+ if (strlen($filterValue)) {// allow '0'
|
|
|
|
|
+ $queryWhereBuilder = new SqlQueryWhereBuilder();
|
|
|
|
|
+ if (!is_scalar($filterValue)) {
|
|
|
|
|
+ } else if ('=' == substr($filterValue, 0, 1)) {
|
|
|
|
|
+ $queryWhereBuilder->addComparisonFieldToValue($fieldName, '=', substr($filterValue, 1));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if ('%' != substr($filterValue, 0, 1)) $filterValue = "%{$filterValue}";
|
|
|
|
|
+ if ('%' != substr($filterValue, -1)) $filterValue = "{$filterValue}%";
|
|
|
|
|
+ $queryWhereBuilder->addComparisonFieldToValue($fieldName, 'like', $filterValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ $items = array_filter($items, array($queryWhereBuilder, 'filterRawArray'));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $orderBy = strtolower(V::get('order_by', 'id', $params));
|
|
|
|
|
+ $orderDir = strtolower(V::get('order_dir', 'desc', $params));
|
|
|
|
|
+ if (!in_array($orderBy, ['id', 'login', 'name'])) throw new HttpException("Bad Request - wrong or missing order by", 400);
|
|
|
|
|
+ if (!in_array($orderDir, ['desc', 'asc'])) throw new HttpException("Bad Request - wrong or missing order dir", 400);
|
|
|
|
|
+ usort($items, function ($a, $b) use ($orderBy, $orderDir) {
|
|
|
|
|
+ if ('desc' == $orderDir) {
|
|
|
|
|
+ return (V::geti($orderBy, '', $a) > V::geti($orderBy, '', $b)) ? -1 : 1;
|
|
|
|
|
+ } else if ('asc' == $orderDir) {
|
|
|
|
|
+ return (V::geti($orderBy, '', $a) > V::geti($orderBy, '', $b)) ? 1 : -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
if($DBG>2){echo 'C.'.get_class($this).' L.' . __LINE__ . " getItems \$items:";print_r($items);echo "\n";}
|
|
if($DBG>2){echo 'C.'.get_class($this).' L.' . __LINE__ . " getItems \$items:";print_r($items);echo "\n";}
|
|
|
return $items;
|
|
return $items;
|
|
|
}
|
|
}
|