4 require_once 'Pman.php';
8 * not really sure how save our factory method is....!!!
11 * Uses these methods of the dataobjects:
12 * - checkPerm('L'/'E'/'A', $authuser) - can we list the stuff
14 * - applySort($au, $sortcol, $direction, $array_of_columns, $multisort) -- does not support multisort at present..
15 * - applyFilters($_REQUEST, $authUser) -- apply any query filters on data. and hide stuff not to be seen.
16 * - postListExtra($_REQUEST) : array(extra_data) - add extra column data on the results (like new messages etc.)
17 * - postListFilter($data, $authUser, $request) return $data - add extra data to an object
19 * - toRooSingleArray($authUser, $request) // single fetch, add data..
20 * - toRooArray($request) /// toArray if you need to return different data.. for a list fetch.
23 * - beforeDelete($ar) -- return false for fail and set DO->err;
24 * Argument is an array of un-find/fetched dependant items.
25 * - onUpdate($old, $request,$roo) - after update // return value ignored
26 * - onInsert($request,$roo) - after insert
28 * - setFromRoo($ar) - values from post (deal with dates etc.) - return true|error string.
30 * - toEventString (for logging - this is generically prefixed to all database operations.)
33 class Pman_Roo extends Pman
37 parent::getAuth(); // load company!
38 $au = $this->getAuthUser();
40 $this->jerr("Not authenticated", array('authFailure' => true));
42 $this->authUser = $au;
46 * GET method Roo/TABLENAME.php
47 * -- defaults to listing data. with args.
50 * !colname=.... => colname != ....
51 * !colname[0]=... !colname[1]=... => colname NOT IN (.....) ** only supports main table at present..
52 * colname[0]=... colname[1]=... => colname IN (.....) ** only supports main table at present..
55 * _post = simulate a post with debuggin on.
56 * lookup = array( k=>v) single fetch based on a key/value pair
57 * _id = single fetch based on id.
58 * _delete = delete a list of ids element. (seperated by ,);
59 * _columns = comma seperated list of columns.
60 * _distinct = a distinct column lookup.
61 * _requestMeta = default behaviour of Roo stores.. on first query..
63 * csvCols[0] csvCols[1].... = .... column titles for CSV output
65 * csvTitles[0], csvTitles[1] .... = columns to use for CSV output
67 * sort = sort column (',' comma delimited)
68 * dir = sort direction ?? in future comma delimited...
69 * _multisort = JSON encoded { sort : { row : direction }, order : [ row, row, row ] }
71 * limit = limit number
73 * _toggleActive !:!:!:! - this hsould not really be here..
74 * query[add_blank] - add a line in with an empty option... - not really needed???
79 // $this->jerr("Not authenticated", array('authFailure' => true));
80 //echo '<PRE>';print_R($_GET);
81 //DB_DataObject::debuglevel(1);
83 $this->init(); // from pnan.
85 HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev);
87 if (!empty($_GET['_post'])) {
89 //DB_DAtaObject::debuglevel(1);
90 return $this->post($tab);
92 $tab = str_replace('/', '',$tab); // basic protection??
94 $x = DB_DataObject::factory($tab);
96 if (!is_a($x, 'DB_DataObject')) {
97 $this->jerr('invalid url');
99 $_columns = !empty($_REQUEST['_columns']) ? explode(',', $_REQUEST['_columns']) : false;
101 if (isset( $_REQUEST['lookup'] )) { // single fetch based on key/value pairs
102 if (method_exists($x, 'checkPerm') && !$x->checkPerm('S', $this->authUser)) {
103 $this->jerr("PERMISSION DENIED");
105 $this->loadMap($x, $_columns);
106 $x->setFrom($_REQUEST['lookup'] );
108 if (!$x->find(true)) {
111 $this->jok($x->toArray());
116 if (isset($_REQUEST['_id'])) { // single fetch
118 if (empty($_REQUEST['_id'])) {
119 $this->jok($x->toArray()); // return an empty array!
122 $this->loadMap($x, $_columns);
124 if (!$x->get($_REQUEST['_id'])) {
125 $this->jerr("no such record");
128 if (method_exists($x, 'checkPerm') && !$x->checkPerm('S', $this->authUser)) {
129 $this->jerr("PERMISSION DENIED");
132 $this->jok(method_exists($x, 'toRooSingleArray') ? $x->toRooSingleArray($this->authUser, $_REQUEST) : $x->toArray());
135 if (isset($_REQUEST['_delete'])) {
136 // do we really delete stuff!?!?!?
137 return $this->delete($x,$_REQUEST);
143 if (isset($_REQUEST['_toggleActive'])) {
144 // do we really delete stuff!?!?!?
145 if (!$this->hasPerm("Core.Staff", 'E')) {
146 $this->jerr("PERMISSION DENIED");
148 $clean = create_function('$v', 'return (int)$v;');
149 $bits = array_map($clean, explode(',', $_REQUEST['_toggleActive']));
150 if (in_array($this->authUser->id, $bits) && $this->authUser->active) {
151 $this->jerr("you can not disable yourself");
153 $x->query('UPDATE Person SET active = !active WHERE id IN (' .implode(',', $bits).')');
154 $this->addEvent("USERTOGGLE", false, implode(',', $bits));
155 $this->jok("Updated");
158 //DB_DataObject::debugLevel(1);
159 if (method_exists($x, 'checkPerm') && !$x->checkPerm('S', $this->authUser)) {
160 $this->jerr("PERMISSION DENIED");
163 // sets map and countWhat
164 $this->loadMap($x, $_columns, empty($_REQUEST['_distinct']) ? false: $_REQUEST['_distinct']);
166 $this->setFilters($x,$_REQUEST);
169 // build join if req.
170 //DB_DataObject::debugLevel(1);
171 $total = $x->count($this->countWhat);
174 //var_dump($total);exit;
175 $this->applySort($x);
180 empty($_REQUEST['start']) ? 0 : (int)$_REQUEST['start'],
181 min(empty($_REQUEST['limit']) ? 25 : (int)$_REQUEST['limit'], 5000)
184 $queryObj = clone($x);
185 //DB_DataObject::debuglevel(1);
189 if (!empty($_REQUEST['query']['add_blank'])) {
190 $ret[] = array( 'id' => 0, 'name' => '----');
195 //if (($tab == 'Groups') && ($_REQUEST['type'] != 0)) { // then it's a list of teams..
196 if ($tab == 'Groups') {
198 $ret[] = array( 'id' => 0, 'name' => 'EVERYONE');
199 $ret[] = array( 'id' => -1, 'name' => 'NOT_IN_GROUP');
200 //$ret[] = array( 'id' => 999999, 'name' => 'ADMINISTRATORS');
207 $rooar = method_exists($x, 'toRooArray');
209 while ($x->fetch()) {
211 $add = $rooar ? $x->toRooArray($_REQUEST) : $x->toArray();
213 $ret[] = !$_columns ? $add : array_intersect_key($add, array_flip($_columns));
216 if (method_exists($queryObj ,'postListExtra')) {
217 $extra = $queryObj->postListExtra($_REQUEST);
219 // filter results, and add any data that is needed...
220 if (method_exists($x,'postListFilter')) {
221 $ret = $x->postListFilter($ret, $this->authUser, $_REQUEST);
224 if (!empty($_REQUEST['csvCols']) && !empty($_REQUEST['csvTitles']) ) {
225 header('Content-type: text/csv');
227 header('Content-Disposition: attachment; filename="list-export-'.date('Y-m-d') . '.csv"');
228 //header('Content-type: text/plain');
229 $fh = fopen('php://output', 'w');
230 fputcsv($fh, $_REQUEST['csvTitles']);
233 foreach($ret as $x) {
234 //echo "<PRE>"; print_r(array($_REQUEST['csvCols'], $x->toArray())); exit;
236 foreach($_REQUEST['csvCols'] as $k) {
237 $line[] = isset($x[$k]) ? $x[$k] : '';
248 //if ($x->tableName() == 'Documents_Tracking') {
249 // $ret = $this->replaceSubject(&$ret, 'doc_id_subject');
254 if (!empty($_REQUEST['_requestMeta']) && count($ret)) {
255 $meta = $this->meta($x, $ret);
257 $extra['metaData'] = $meta;
261 // echo "<PRE>"; print_r($ret);
262 $this->jdata($ret,$total, $extra );
269 * apply REQUEST[sort] and [dir]
270 * sort may be an array of columsn..
272 * @arg DB_DataObject $x
275 function applySort($x, $sort = '', $dir ='')
278 // Db_DataObject::debugLevel(1);
279 $sort = empty($_REQUEST['sort']) ? $sort : $_REQUEST['sort'];
280 $dir = empty($_REQUEST['dir']) ? $dir : $_REQUEST['dir'];
281 $dir = $dir == 'ASC' ? 'ASC' : 'DESC';
283 $ms = empty($_REQUEST['_multisort']) ? false : $_REQUEST['_multisort'];
285 if (method_exists($x, 'applySort')) {
286 $sorted = $x->applySort(
290 array_keys($this->cols),
291 $ms ? json_decode($ms) : false
295 return $this->multiSort($x);
298 if ($sorted === false) {
301 $sort_ar = explode(',', $sort);
304 foreach($sort_ar as $sort) {
306 if (strlen($sort) && isset($cols[$sort]) ) {
307 $sort_str[] = $x->tableName() .'.'.$sort . ' ' . $dir ;
309 } else if (in_array($sort, array_keys($this->cols))) {
310 $sort_str[] = $sort . ' ' . $dir ;
315 $x->orderBy(implode(', ', $sort_str ));
320 function multiSort($x)
322 //DB_DataObject::debugLevel(1);
323 $ms = json_decode($_REQUEST['_multisort']);
328 foreach($ms->order as $col) {
329 if (!isset($ms->sort->{$col})) {
330 continue; // no direction..
332 $ms->sort->{$col} = $ms->sort->{$col} == 'ASC' ? 'ASC' : 'DESC';
334 if (strlen($col) && isset($cols[$col]) ) {
335 $sort_str[] = $x->tableName() .'.'.$col . ' ' . $ms->sort->{$col};
337 } else if (in_array($col, array_keys($this->cols))) {
338 $sort_str[] = $col. ' ' . $ms->sort->{$col};
343 $x->orderBy(implode(', ', $sort_str ));
353 * POST method Roo/TABLENAME.php
354 * -- updates the data..
357 * _debug - forces debugging on.
358 * _get - forces a get request
359 * _ids - multiple update of records.
360 * {colid} - forces fetching
363 function post($tab) // update / insert (?? dleete??)
365 //DB_DataObject::debugLevel(1);
366 if (!empty($_REQUEST['_debug'])) {
367 DB_DataObject::debugLevel(1);
370 if (!empty($_REQUEST['_get'])) {
371 return $this->get($tab);
374 $_columns = !empty($_REQUEST['_columns']) ? explode(',', $_REQUEST['_columns']) : false;
376 $tab = str_replace('/', '',$tab); // basic protection??
377 $x = DB_DataObject::factory($tab);
378 if (!is_a($x, 'DB_DataObject')) {
379 $this->jerr('invalid url');
381 // find the key and use that to get the thing..
384 $this->jerr('no key');
387 // delete should be here...
388 if (isset($_REQUEST['_delete'])) {
389 // do we really delete stuff!?!?!?
390 return $this->delete($x,$_REQUEST);
396 // not sure if this is a good idea here...
398 if (!empty($_REQUEST['_ids'])) {
399 $ids = explode(',',$_REQUEST['_ids']);
400 $x->whereAddIn($keys[0], $ids, 'int');
401 $ar = $x->fetchAll();
403 $this->update($x, $_REQUEST);
407 $this->jok("UPDATED");
413 if (!empty($_REQUEST[$keys[0]])) {
415 if (!$x->get($keys[0], $_REQUEST[$keys[0]])) {
416 $this->jerr("Invalid request");
418 $this->jok($this->update($x, $_REQUEST));
422 $this->jerr("No data recieved for inserting");
425 $this->jok($this->insert($x, $_REQUEST));
432 function insert($x, $req)
436 if (method_exists($x, 'checkPerm') && !$x->checkPerm('A', $this->authUser, $req)) {
437 $this->jerr("PERMISSION DENIED");
440 $_columns = !empty($req['_columns']) ? explode(',', $req['_columns']) : false;
442 if (method_exists($x, 'setFromRoo')) {
443 $res = $x->setFromRoo($req, $this);
444 if (is_string($res)) {
454 if (isset($cols['created'])) {
455 $x->created = date('Y-m-d H:i:s');
457 if (isset($cols['created_dt'])) {
458 $x->created_dt = date('Y-m-d H:i:s');
460 if (isset($cols['created_by'])) {
461 $x->created_by = $this->authUser->id;
465 if (isset($cols['modified'])) {
466 $x->modified = date('Y-m-d H:i:s');
468 if (isset($cols['modified_dt'])) {
469 $x->modified_dt = date('Y-m-d H:i:s');
471 if (isset($cols['modified_by'])) {
472 $x->modified_by = $this->authUser->id;
475 if (isset($cols['updated'])) {
476 $x->updated = date('Y-m-d H:i:s');
478 if (isset($cols['updated_dt'])) {
479 $x->updated_dt = date('Y-m-d H:i:s');
481 if (isset($cols['updated_by'])) {
482 $x->updated_by = $this->authUser->id;
490 if (method_exists($x, 'onInsert')) {
491 $x->onInsert($_REQUEST, $this);
493 $ev = $this->addEvent("ADD", $x);
498 // note setFrom might handle this before hand...!??!
499 if (!empty($_FILES) && method_exists($x, 'onUpload')) {
503 $r = DB_DataObject::factory($x->tableName());
505 // let's assume it has a key!!!
508 $this->loadMap($r, $_columns);
512 $rooar = method_exists($r, 'toRooArray');
513 //print_r(var_dump($rooar)); exit;
514 return $rooar ? $r->toRooArray($_REQUEST) : $r->toArray();
518 function update($x, $req)
520 if (method_exists($x, 'checkPerm') && !$x->checkPerm('E', $this->authUser, $_REQUEST)) {
521 $this->jerr("PERMISSION DENIED");
525 // only done if we recieve a lock_id.
526 // we are very trusing here.. that someone has not messed around with locks..
527 // the object might want to check in their checkPerm - if locking is essential..
528 $lock_warning = false;
529 $lock = DB_DataObjecT::factory('Core_locking');
530 if (is_a($lock,'DB_DataObject')) {
532 $lock->on_id = $x->id;
533 $lock->on_table= $x->tableName();
534 if (!empty($_REQUEST['_lock_id'])) {
535 $lock->whereAdd('id != ' . ((int)$_REQUEST['_lock_id']));
537 $lock->whereAdd('person_id !=' . $this->authUser->id);
541 if ($lock->find(true)) {
542 // it's locked by someone else..
543 $p = $lock->person();
544 $lock_warning = "Record was locked by " . $p->name . " at " .$lock->created.
545 " - Your changes have been saved - you may like to warn them if " .
546 " they are editing now";
548 // check the users lock.. - no point.. ??? - if there are no other locks and it's not the users, then they can
549 // edit it anyways...
558 $_columns = !empty($req['_columns']) ? explode(',', $req['_columns']) : false;
563 // this lot is generic.. needs moving
564 if (method_exists($x, 'setFromRoo')) {
565 $res = $x->setFromRoo($req, $this);
566 if (is_string($res)) {
572 $ev = $this->addEvent("EDIT", $x);
573 $ev->audit($x, $old);
579 if (isset($cols['modified'])) {
580 $x->modified = date('Y-m-d H:i:s');
582 if (isset($cols['modified_dt'])) {
583 $x->modified_dt = date('Y-m-d H:i:s');
585 if (isset($cols['modified_by'])) {
586 $x->modified_by = $this->authUser->id;
589 if (isset($cols['updated'])) {
590 $x->updated = date('Y-m-d H:i:s');
592 if (isset($cols['updated_dt'])) {
593 $x->updated_dt = date('Y-m-d H:i:s');
595 if (isset($cols['updated_by'])) {
596 $x->updated_by = $this->authUser->id;
601 if (method_exists($x, 'onUpdate')) {
602 $x->onUpdate($old, $req, $this);
607 $this->jerr($lock_warning);
611 $r = DB_DataObject::factory($x->tableName());
613 // let's assume it has a key!!!
616 $this->loadMap($r, $_columns);
619 $rooar = method_exists($r, 'toRooArray');
620 //print_r(var_dump($rooar)); exit;
621 return $rooar ? $r->toRooArray($_REQUEST) : $r->toArray();
624 * Delete a number of records.
625 * calls $delete_obj->beforeDelete($array_of_dependant_dataobjects)
629 function delete($x, $req)
631 // do we really delete stuff!?!?!?
632 if (empty($req['_delete'])) {
633 $this->jerr("Delete Requested with no value");
635 // build a list of tables to queriy for dependant data..
640 $all_links = $GLOBALS['_DB_DATAOBJECT']['LINKS'][$x->_database];
641 foreach($all_links as $tbl => $links) {
642 foreach($links as $col => $totbl_col) {
643 $to = explode(':', $totbl_col);
644 if ($to[0] != $x->tableName()) {
648 $affects[$tbl .'.' . $col] = true;
653 // echo '<PRE>';print_r($affects);exit;
654 //DB_Dataobject::debugLevel(1);
657 $clean = create_function('$v', 'return (int)$v;');
659 $bits = array_map($clean, explode(',', $req['_delete']));
661 // print_r($bits);exit;
663 // let's assume it has a key!!!
666 $x->whereAdd($pk .' IN ('. implode(',', $bits) .')');
668 $this->jerr("Nothing found to delete");
671 while ($x->fetch()) {
677 if (method_exists($x, 'checkPerm') && !$x->checkPerm('D', $this->authUser)) {
678 $this->jerr("PERMISSION DENIED");
682 foreach($affects as $k=> $true) {
683 $ka = explode('.', $k);
684 $chk = DB_DataObject::factory($ka[0]);
685 if (!is_a($chk,'DB_DataObject')) {
686 $this->jerr('Unable to load referenced table, check the links config: ' .$ka[0]);
688 $chk->{$ka[1]} = $xx->$pk;
689 $matches = $chk->count();
692 $match_ar[] = clone($chk);
697 $has_beforeDelete = method_exists($xx, 'beforeDelete');
698 // before delte = allows us to trash dependancies if needed..
701 if ( method_exists($xx, 'beforeDelete') ) {
702 if ($xx->beforeDelete($match_ar) === false) {
703 $errs[] = "Delete failed ({$xx->id})\n".
704 (isset($xx->err) ? $xx->err : '');
710 foreach($affects as $k=> $true) {
711 $ka = explode('.', $k);
712 $chk = DB_DataObject::factory($ka[0]);
713 if (!is_a($chk,'DB_DataObject')) {
714 $this->jerr('Unable to load referenced table, check the links config: ' .$ka[0]);
716 $chk->{$ka[1]} = $xx->$pk;
717 $matches = $chk->count();
718 $match_total += $matches;
720 $match_ar[] = clone($chk);
730 if (!empty($match_ar)) {
733 $o = $chk->fetchAll();
734 $key = array_shift($chk->keys());
735 $desc = $chk->tableName(). '.' . $key .'='.$xx->$key ;
736 if (method_exists($chk, 'toEventString')) {
737 $desc .= ' : ' . $o[0]->toEventString();
740 $this->jerr("Delete Dependant records ($match_total found), " .
741 "first is ( $desc )");
748 $this->addEvent("DELETE", $x);
753 $this->jerr(implode("\n<BR>", $errs));
755 $this->jok("Deleted");
763 function loadMap($do, $filter=false, $distinct = false)
765 //DB_DataObject::debugLevel(1);
767 $this->countWhat = false;
773 $mods = explode(',',$this->appModules);
775 $ff = HTML_FlexyFramework::get();
782 $tabdef = $do->table();
783 if (isset($tabdef['passwd'])) {
784 // prevent exposure of passwords..
785 unset($tabdef['passwd']);
788 $xx = array_keys($tabdef);
789 $do->selectAdd(); // we need thsi as normally it's only cleared by an empty selectAs call.
791 $selectAs = array(array( $xx , '%s', false));
793 $has_distinct = false;
794 if ($filter || $distinct) {
796 //echo '<PRE>' ;print_r($filter);exit;
798 if ($distinct && $distinct == $c) {
799 $has_distinct = 'DISTINCT( ' . $do->tableName() .'.'. $c .') as ' . $c;
800 $this->countWhat = 'DISTINCT ' . $do->tableName() .'.'. $c .'';
803 if (!$filter || in_array($c, $filter)) {
809 $selectAs = empty($cols) ? array() : array(array( $cols , '%s', false)) ;
815 $this->cols = array();
816 $this->colsJoinName =array();
818 $this->cols[$k] = $do->tableName(). '.' . $k;
826 foreach($map as $ocl=>$info) {
828 list($tab,$col) = explode(':', $info);
829 // what about multiple joins on the same table!!!
830 $xx = DB_DataObject::factory($tab);
831 if (!is_a($xx, 'DB_DataObject')) {
834 // this is borked ... for multiple jions..
835 $do->joinAdd($xx, 'LEFT', 'join_'.$ocl.'_'. $col, $ocl);
836 $tabdef = $xx->table();
837 $table = $xx->tableName();
838 if (isset($tabdef['passwd'])) {
840 unset($tabdef['passwd']);
843 $xx = array_keys($tabdef);
846 if ($filter || $distinct) {
849 $tn = sprintf($ocl.'_%s', $c);
850 // echo '<PRE>'; var_dump($tn);
851 if ($distinct && $tn == $distinct) {
852 $has_distinct = 'DISTINCT( ' . 'join_'.$ocl.'_'.$col.'.'.$k .') as ' . $tn ;
853 $this->countWhat = 'DISTINCT join_'.$ocl.'_'.$col.'.'.$k;
858 if (!$filter || in_array($tn, $filter)) {
863 $selectAs[] = array($cols, $ocl.'_%s', 'join_'.$ocl.'_'. $col);
868 $selectAs[] = array($xx, $ocl.'_%s', 'join_'.$ocl.'_'. $col);
874 $this->cols[sprintf($ocl.'_%s', $k)] = $tab.'.'.$k;
875 $this->colsJname[sprintf($ocl.'_%s', $k)] = 'join_'.$ocl.'_'.$col.'.'.$k;
882 $do->selectAdd($has_distinct);
885 // we do select as after everything else as we need to plop distinct at the beginning??
887 // echo '<PRE>';print_r($this->colsJname);exit;
888 foreach($selectAs as $ar) {
889 $do->selectAs($ar[0], $ar[1], $ar[2]);
895 * generate the meta data neede by queries.
898 function meta($x, $data)
900 // this is not going to work on queries where the data does not match the database def..
901 // for unknown columns we send them as stirngs..
903 $cols = array_keys($data[0]);
908 //echo '<PRE>';print_r($this->cols); exit;
909 $options = &PEAR::getStaticProperty('DB_DataObject','options');
910 $reader = $options["ini_{$x->_database}"] .'.reader';
911 if (!file_exists( $reader )) {
915 $rdata = unserialize(file_get_contents($reader));
917 // echo '<PRE>';print_r($rdata);exit;
920 foreach($cols as $c ) {
921 if (!isset($this->cols[$c]) || !isset($rdata[$this->cols[$c]]) || !is_array($rdata[$this->cols[$c]])) {
925 $add = $rdata[$this->cols[$c]];
930 'totalProperty' => 'total',
931 'successProperty' => 'success',
940 function setFilters($x, $q)
942 // if a column is type int, and we get ',' -> the it should be come an inc clause..
943 // DB_DataObject::debugLevel(1);
944 if (method_exists($x, 'applyFilters')) {
945 // DB_DataObject::debugLevel(1);
946 $x->applyFilters($q, $this->authUser);
948 $q_filtered = array();
950 foreach($q as $key=>$val) {
952 // value is an array..
953 if (is_array($val) ) {
957 if ($key[0] == '!') {
959 $key = substr($key,1);
962 if (!in_array( $key, array_keys($this->cols))) {
966 // support a[0] a[1] ..... => whereAddIn(
969 foreach($val as $k=>$v) {
970 if (!is_numeric($k)) {
974 // FIXME: note this is not typesafe for anything other than mysql..
976 if (!is_numeric($v) || !is_long($v)) {
985 $x->whereAddIn($pref . (
986 isset($this->colsJname[$key]) ?
987 $this->colsJname[$key] :
988 ($x->tableName(). '.'.$key)),
989 $ar, $quote ? 'string' : 'int');
997 if ($key[0] == '!' && in_array(substr($key, 1), array_keys($this->cols))) {
999 $key = substr($key, 1) ;
1002 isset($this->colsJname[$key]) ?
1003 $this->colsJname[$key] :
1004 $x->tableName(). '.'.$key ) . ' != ' .
1005 (is_numeric($val) ? $val : "'". $x->escape($val) . "'")
1015 // Events and remarks -- fixme - move to events/remarsk...
1016 case 'on_id': // where TF is this used...
1017 if (!empty($q['query']['original'])) {
1018 // DB_DataObject::debugLevel(1);
1019 $o = (int) $q['query']['original'];
1021 $x->whereAdd("(on_id = $oid OR
1022 on_id IN ( SELECT distinct(id) FROM Documents WHERE original = $o )
1032 $q_filtered[$key] = $val;
1035 // subjoined columns = check the values.
1036 // note this is not typesafe for anything other than mysql..
1038 if (isset($this->colsJname[$key])) {
1040 if (!is_numeric($val) || !is_long($val)) {
1043 $x->whereAdd( "{$this->colsJname[$key]} = " . ($quote ? "'". $x->escape($val) ."'" : $val));
1052 $x->setFrom($q_filtered);
1057 // nice generic -- let's get rid of it.. where is it used!!!!
1059 // Person / Group / most of my queries noww...
1060 if (!empty($q['query']['name'])) {
1061 $x->whereAdd($x->tableName().".name LIKE '". $x->escape($q['query']['name']) . "%'");
1064 // - projectdirectory staff list - persn queuy