PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
- $tab = array_shift(explode('/', $tab));
+ $explode_tab = explode('/', $tab);
+ $tab = array_shift($explode_tab);
$x = $this->dataObject($tab);
'exclude' => empty($_REQUEST['_exclude_columns']) ? false: explode(',', $_REQUEST['_exclude_columns'])
));
- exit;
+
$this->setFilters($x,$_REQUEST);
if (!$this->checkPerm($x,'S', $_REQUEST)) {
// filter results, and add any data that is needed...
if (method_exists($x,'postListFilter')) {
- $ret = $x->postListFilter($ret, $this->getAuthUser(), $_REQUEST);
+ $ret = $x->postListFilter($ret, $this->authUser, $_REQUEST);
}
$sorted = false;
if (method_exists($x, 'applySort')) {
$sorted = $x->applySort(
- $this->getAuthUser(),
+ $this->authUser,
$sort,
$dir,
array_keys($this->cols),
$cols = $x->table();
$excols = array_keys($this->cols);
+ //print_R($excols);
if (isset($x->_extra_cols)) {
$excols = array_merge($excols, $x->_extra_cols);
$cols = array_keys($data[0]);
$options = &PEAR::getStaticProperty('DB_DataObject','options');
- $reader = $options["ini_{$x->_database}"] .'.reader';
+ $reader = $options["ini_{$x->databaseNickname()}"] .'.reader';
if (!file_exists( $reader )) {
return;
}
}
+
+ function multiSort($x)
+ {
+ $ms = json_decode($_REQUEST['_multisort']);
+ if (!isset($ms->order) || !is_array($ms->order)) {
+ return;
+ }
+ $sort_str = array();
+
+ $cols = $x->table();
+
+ foreach($ms->order as $col) {
+ if (!isset($ms->sort->{$col})) {
+ continue; // no direction..
+ }
+ $ms->sort->{$col} = $ms->sort->{$col} == 'ASC' ? 'ASC' : 'DESC';
+
+ if (strlen($col) && isset($cols[$col]) ) {
+ $sort_str[] = $x->tableName() .'.'.$col . ' ' . $ms->sort->{$col};
+ continue;
+ }
+
+ if (in_array($col, array_keys($this->cols))) {
+ $sort_str[] = $col. ' ' . $ms->sort->{$col};
+ continue;
+ }
+ if (isset($x->_extra_cols) && in_array($col, $x->_extra_cols)) {
+ $sort_str[] = $col. ' ' . $ms->sort->{$col};
+ }
+ }
+
+ if ($sort_str) {
+ $x->orderBy(implode(', ', $sort_str ));
+ }
+ }
}