X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=RooGetTrait.php;h=162ebce1d0e998dc6863e32dbb7e31b2835e16de;hp=97db393682ec7afde7b94704873786ac40f66e62;hb=refs%2Fheads%2Fwip_edward_T5851_download_old_offer_sheet;hpb=ede3412d45303145367c82ac55c4de7039eb841a diff --git a/RooGetTrait.php b/RooGetTrait.php index 97db3936..162ebce1 100644 --- a/RooGetTrait.php +++ b/RooGetTrait.php @@ -107,7 +107,8 @@ trait Pman_Core_RooGetTrait { 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); @@ -236,7 +237,7 @@ trait Pman_Core_RooGetTrait { // 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); } @@ -286,7 +287,7 @@ trait Pman_Core_RooGetTrait { $sorted = false; if (method_exists($x, 'applySort')) { $sorted = $x->applySort( - $this->getAuthUser(), + $this->authUser, $sort, $dir, array_keys($this->cols), @@ -301,6 +302,7 @@ trait Pman_Core_RooGetTrait { $cols = $x->table(); $excols = array_keys($this->cols); + //print_R($excols); if (isset($x->_extra_cols)) { $excols = array_merge($excols, $x->_extra_cols); @@ -433,7 +435,7 @@ trait Pman_Core_RooGetTrait { $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; } @@ -464,4 +466,39 @@ trait Pman_Core_RooGetTrait { } + + 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 )); + } + } }