if (isset($_REQUEST['_delete'])) {
$this->jerr("DELETE by GET has been removed - update the code to use POST");
- /*
-
- $keys = $x->keys();
- if (empty($keys) ) {
- $this->jerr('no key');
- }
-
- $this->key = $keys[0];
-
-
- // do we really delete stuff!?!?!?
- return $this->delete($x,$_REQUEST);
- */
}
// sets map and countWhat
$this->loadMap($x, array(
- 'columns' => $_columns,
- 'distinct' => empty($_REQUEST['_distinct']) ? false: $_REQUEST['_distinct'],
- 'exclude' => empty($_REQUEST['_exclude_columns']) ? false: explode(',', $_REQUEST['_exclude_columns'])
- ));
+ 'columns' => $_columns,
+ 'distinct' => empty($_REQUEST['_distinct']) ? false: $_REQUEST['_distinct'],
+ 'exclude' => empty($_REQUEST['_exclude_columns']) ? false: explode(',', $_REQUEST['_exclude_columns'])
+ ));
$this->setFilters($x,$_REQUEST);
$this->jerr("PERMISSION DENIED (g)");
}
- //print_r($x);
- // build join if req.
- //DB_DataObject::debugLevel(1);
- // var_dump($this->countWhat);
$total = $x->count($this->countWhat);
// sorting..
//
if (false === $res) {
$this->jerr($x->_lastError->toString());
-
}
-
-
$ret = array();
// ---------------- THESE ARE DEPRICATED.. they should be moved to the model...
// filter results, and add any data that is needed...
if (method_exists($x,'postListFilter')) {
- $ret = $x->postListFilter($ret, $this->authUser, $_REQUEST);
+ $ret = $x->postListFilter($ret, $this->getAuthUser(), $_REQUEST);
}
}
// different symantics on all these calls??
if (method_exists($x, 'toRooSingleArray')) {
- $this->jok($x->toRooSingleArray($this->authUser, $req));
+ $this->jok($x->toRooSingleArray($this->getAuthUser(), $req));
}
if (method_exists($x, 'toRooArray')) {
$this->jok($x->toRooArray($req));
continue;
}
-
-
-
+
switch($key) {
// Events and remarks -- fixme - move to events/remarsk...
}
}
if (!empty($q_filtered)) {
- //var_dump($q_filtered);
-
-
-
$x->setFrom($q_filtered);
}
-
-
-
- // nice generic -- let's get rid of it.. where is it used!!!!
- // used by:
- // Person / Group / Comapnies.... most of my queries noww...
if (!empty($q['query']['name'])) {
-
-
if (in_array( 'name', array_keys($x->table()))) {
$x->whereAdd($x->tableName().".name LIKE '". $x->escape($q['query']['name']) . "%'");
}
}
- // - projectdirectory staff list - persn queuy
-
+ }
+
+ function applySort($x, $sort = '', $dir ='')
+ {
+ $sort = empty($_REQUEST['sort']) ? $sort : $_REQUEST['sort'];
+ $dir = empty($_REQUEST['dir']) ? $dir : $_REQUEST['dir'];
+ $dir = $dir == 'ASC' ? 'ASC' : 'DESC';
+
+ $ms = empty($_REQUEST['_multisort']) ? false : $_REQUEST['_multisort'];
+ //var_Dump($ms);exit;
+ $sorted = false;
+ if (method_exists($x, 'applySort')) {
+ $sorted = $x->applySort(
+ $this->getAuthUser(),
+ $sort,
+ $dir,
+ array_keys($this->cols),
+ $ms ? json_decode($ms) : false
+ );
+ }
+ if ($ms !== false) {
+ return $this->multiSort($x);
+ }
+ if ($sorted === false) {
+
+ $cols = $x->table();
+ $excols = array_keys($this->cols);
+
+ if (isset($x->_extra_cols)) {
+ $excols = array_merge($excols, $x->_extra_cols);
+ }
+ $sort_ar = explode(',', $sort);
+ $sort_str = array();
+
+ foreach($sort_ar as $sort) {
+
+ if (strlen($sort) && isset($cols[$sort]) ) {
+ $sort_str[] = $x->tableName() .'.'.$sort . ' ' . $dir ;
+
+ } else if (in_array($sort, $excols)) {
+ $sort_str[] = $sort . ' ' . $dir ;
+ }
+ }
+
+ if ($sort_str) {
+ $x->orderBy(implode(', ', $sort_str ));
+ }
+ }
}
}