projects
/
Pman.Base
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed locked
[Pman.Base]
/
Pman
/
Roo.php
diff --git
a/Pman/Roo.php
b/Pman/Roo.php
index
20d04be
..
ee0e571
100644
(file)
--- a/
Pman/Roo.php
+++ b/
Pman/Roo.php
@@
-42,7
+42,14
@@
require_once 'Pman.php';
class Pman_Roo extends Pman
{
class Pman_Roo extends Pman
{
- /**
+
+ /* EVENTUALLY - move this stuff here..
+ * use Pman_Core_RooTrait,
+ Pman_Core_RooGetTrait,
+ Pman_Core_RooPostTrait,
+ Pman_Core_RooJsonOutputTrait;
+ */
+ /**
* if set to an array (when extending this, then you can restrict which tables are available
*/
var $validTables = false;
* if set to an array (when extending this, then you can restrict which tables are available
*/
var $validTables = false;
@@
-56,16
+63,21
@@
class Pman_Roo extends Pman
var $do = false; // the dataobject being worked on..
var $do = false; // the dataobject being worked on..
+
+ var $countWhat; // set in loadMap
+ var $colsJname;
+ var $old;
+
function getAuth()
{
parent::getAuth(); // load company!
$au = $this->getAuthUser();
if (!$au) {
function getAuth()
{
parent::getAuth(); // load company!
$au = $this->getAuthUser();
if (!$au) {
- $this->jerr
(
"Not authenticated", array('authFailure' => true));
+ $this->jerr
or("LOGIN-NOAUTH",
"Not authenticated", array('authFailure' => true));
}
if (!$au->pid() ) { // not set up yet..
}
if (!$au->pid() ) { // not set up yet..
- $this->jerr
(
"Not authenticated", array('authFailure' => true));
+ $this->jerr
or("LOGIN-NOAUTH",
"Not authenticated", array('authFailure' => true));
}
}
@@
-85,6
+97,9
@@
class Pman_Roo extends Pman
* lookup[key]=value single fetch based on a single key value lookup.
* multiple key/value can be used. eg. ontable+onid..
* _columns what to return.
* lookup[key]=value single fetch based on a single key value lookup.
* multiple key/value can be used. eg. ontable+onid..
* _columns what to return.
+ *
+ * _no_count skip the default count query.
+ * use the number of records in the query result as the total
*
*
* JOINS:
*
*
* JOINS:
@@
-141,9
+156,9
@@
class Pman_Roo extends Pman
* -- apply any query filters on data. and hide stuff not to be seen.
* -- can exit by calling $roo->jerr()
* postListExtra($_REQUEST, $roo, $array_data) : array(extra_name => data)
* -- apply any query filters on data. and hide stuff not to be seen.
* -- can exit by calling $roo->jerr()
* postListExtra($_REQUEST, $roo, $array_data) : array(extra_name => data)
- * - add extra column
data on the results (like new messages etc.)
+ * - add extra column
to the jdata return key/value info.
* postListFilter($data, $authUser, $request) return $data
* postListFilter($data, $authUser, $request) return $data
- * -
add extra data to an object
+ * -
modify the returned array of data (either add stuff to the data, or remove lines etc)
*
*
* toRooSingleArray($authUser, $request) : array
*
*
* toRooSingleArray($authUser, $request) : array
@@
-173,13
+188,9
@@
class Pman_Roo extends Pman
$this->init(); // from pman.
//DB_DataObject::debuglevel(1);
HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev && !empty($_REQUEST['isDev']));
$this->init(); // from pman.
//DB_DataObject::debuglevel(1);
HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev && !empty($_REQUEST['isDev']));
-
-
-
+
// debugging...
// debugging...
-
-
-
+
if ( $this->checkDebugPost()) {
if ( $this->checkDebugPost()) {
@@
-196,7
+207,8
@@
class Pman_Roo extends Pman
$tab = array_shift($tt);
$x = $this->dataObject($tab);
$tab = array_shift($tt);
$x = $this->dataObject($tab);
- $_columns = !empty($_REQUEST['_columns']) ? explode(',', $_REQUEST['_columns']) : false;
+ $_columns = !empty($_REQUEST['_columns']) && is_string($_REQUEST['_columns']) ? explode(',', $_REQUEST['_columns']) : false;
+
if (isset( $_REQUEST['lookup'] ) && is_array($_REQUEST['lookup'] )) { // single fetch based on key/value pairs
$this->selectSingle($x, $_REQUEST['lookup'],$_REQUEST);
if (isset( $_REQUEST['lookup'] ) && is_array($_REQUEST['lookup'] )) { // single fetch based on key/value pairs
$this->selectSingle($x, $_REQUEST['lookup'],$_REQUEST);
@@
-250,7
+262,7
@@
class Pman_Roo extends Pman
$this->setFilters($x,$_REQUEST);
if (!$this->checkPerm($x,'S', $_REQUEST)) {
$this->setFilters($x,$_REQUEST);
if (!$this->checkPerm($x,'S', $_REQUEST)) {
- $this->jerr
(
"PERMISSION DENIED (g)");
+ $this->jerr
or("NOTICE-NOPERM",
"PERMISSION DENIED (g)");
}
//print_r($x);
}
//print_r($x);
@@
-266,16
+278,21
@@
class Pman_Roo extends Pman
$xx=clone($x);
}
$xx=clone($x);
}
-
- $total = $xx->count($this->countWhat);
+ $total = false;
+ if (!isset($_REQUEST['_no_count'])) {
+ $total = $xx->count($this->countWhat);
+ }
+ if (isset($xx->_real_total)) { // this is used when we subquery the search.
+ $total = $xx->_real_total;
+ }
// sorting..
//
// sorting..
//
- //var_dump($total);exit;
+ //
var_dump($total);exit;
$this->applySort($x);
$fake_limit = false;
$this->applySort($x);
$fake_limit = false;
- if (!empty($_REQUEST['_distinct']) && $total < 400) {
+ if (!empty($_REQUEST['_distinct']) && $total
!== false && $total
< 400) {
$fake_limit = true;
}
$fake_limit = true;
}
@@
-307,7
+324,7
@@
class Pman_Roo extends Pman
if (!empty($_REQUEST['query']['add_blank'])) {
$ret[] = array( 'id' => 0, 'name' => '----');
if (!empty($_REQUEST['query']['add_blank'])) {
$ret[] = array( 'id' => 0, 'name' => '----');
- $total
+=
1;
+ $total
=== false ? false : $total+
1;
}
$rooar = method_exists($x, 'toRooArray');
}
$rooar = method_exists($x, 'toRooArray');
@@
-338,7
+355,7
@@
class Pman_Roo extends Pman
// filter results, and add any data that is needed...
if (method_exists($x,'postListFilter')) {
// 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->authUser, $_REQUEST
, $this
);
}
}
@@
-357,13
+374,14
@@
class Pman_Roo extends Pman
if (!empty($_REQUEST['_requestMeta']) && count($ret)) {
$meta = $this->meta($x, $ret);
if ($meta) {
if (!empty($_REQUEST['_requestMeta']) && count($ret)) {
$meta = $this->meta($x, $ret);
if ($meta) {
+ $extra = $extra ? $extra: array();
$extra['metaData'] = $meta;
}
}
// this make take some time...
$this->sessionState(0);
// echo "<PRE>"; print_r($ret);
$extra['metaData'] = $meta;
}
}
// this make take some time...
$this->sessionState(0);
// echo "<PRE>"; print_r($ret);
- $this->jdata($ret, max(count($ret), $total), $extra );
+ $this->jdata($ret, max(count($ret), $total
=== false ? 0 : $total
), $extra );
}
}
@@
-538,7
+556,7
@@
class Pman_Roo extends Pman
// 'fillBlank' => 'gray', // set
);
//die('here');
// 'fillBlank' => 'gray', // set
);
//die('here');
- if (method_exists($this->do, 'toSimpleExcelColumn')) {
+ if (
!empty($this->do) &&
method_exists($this->do, 'toSimpleExcelColumn')) {
$add = $this->do->toSimpleExcelColumn($add);
}
$add = $this->do->toSimpleExcelColumn($add);
}
@@
-745,11
+763,11
@@
class Pman_Roo extends Pman
{
// Db_DataObject::debugLevel(1);
{
// Db_DataObject::debugLevel(1);
- $sort = empty($_REQUEST['sort']) ? $sort : $_REQUEST['sort'];
- $dir = empty($_REQUEST['dir']) ? $dir : $_REQUEST['dir'];
+ $sort = empty($_REQUEST['sort'])
|| !is_string($_REQUEST['sort'])
? $sort : $_REQUEST['sort'];
+ $dir = empty($_REQUEST['dir'])
|| !is_string($_REQUEST['dir'])
? $dir : $_REQUEST['dir'];
$dir = $dir == 'ASC' ? 'ASC' : 'DESC';
$dir = $dir == 'ASC' ? 'ASC' : 'DESC';
- $ms = empty($_REQUEST['_multisort']) ? false : $_REQUEST['_multisort'];
+ $ms = empty($_REQUEST['_multisort'])
|| !is_string($_REQUEST['_multisort'])
? false : $_REQUEST['_multisort'];
//var_Dump($ms);exit;
$sorted = false;
if (method_exists($x, 'applySort')) {
//var_Dump($ms);exit;
$sorted = false;
if (method_exists($x, 'applySort')) {
@@
-915,18
+933,17
@@
class Pman_Roo extends Pman
function insert($x, $req, $with_perm_check = true)
{
function insert($x, $req, $with_perm_check = true)
{
-
- if (method_exists($x, 'setFromRoo')) {
+ if (method_exists($x, 'setFromRoo')) {
$res = $x->setFromRoo($req, $this);
if (is_string($res)) {
$res = $x->setFromRoo($req, $this);
if (is_string($res)) {
- $this->jerr
(
$res);
+ $this->jerr
or("NOTICE-INSERT",
$res);
}
} else {
$x->setFrom($req);
}
if ( $with_perm_check && !$this->checkPerm($x,'A', $req)) {
}
} else {
$x->setFrom($req);
}
if ( $with_perm_check && !$this->checkPerm($x,'A', $req)) {
- $this->jerr("PERMISSION DENIED
(i
)");
+ $this->jerr("PERMISSION DENIED
{$x->tableName()}:checkPerm(A
)");
}
$cols = $x->tableColumns();
}
$cols = $x->tableColumns();
@@
-1194,7
+1211,7
@@
class Pman_Roo extends Pman
$x->whereAdd($this->key .' IN ('. implode(',', $bits) .')');
if (!$x->find()) {
$x->whereAdd($this->key .' IN ('. implode(',', $bits) .')');
if (!$x->find()) {
- $this->jerr
(
"Nothing found to delete");
+ $this->jerr
or("NOTICE-DELETE",
"Nothing found to delete");
}
$errs = array();
while ($x->fetch()) {
}
$errs = array();
while ($x->fetch()) {
@@
-1273,7
+1290,7
@@
class Pman_Roo extends Pman
if (method_exists($chk, 'toEventString')) {
$desc .= ' : ' . $o[0]->toEventString();
}
if (method_exists($chk, 'toEventString')) {
$desc .= ' : ' . $o[0]->toEventString();
}
- $this->jerr
(
"Delete Dependant records ($match_total found), " .
+ $this->jerr
or("NOTICE-DELETE-DEP",
"Delete Dependant records ($match_total found), " .
"first is ( $desc )");
}
"first is ( $desc )");
}
@@
-1322,8
+1339,7
@@
class Pman_Roo extends Pman
function loadMap($do, $cfg =array()) //$onlycolumns=false, $distinct = false)
{
function loadMap($do, $cfg =array()) //$onlycolumns=false, $distinct = false)
{
-
- //DB_DataObject::debugLevel(5);
+ //DB_DataObject::debugLevel(5);
$onlycolumns = !empty($cfg['columns']) ? $cfg['columns'] : false;
$distinct = !empty($cfg['distinct']) ? $cfg['distinct'] : false;
$excludecolumns = !empty($cfg['exclude']) ? $cfg['exclude'] : array();
$onlycolumns = !empty($cfg['columns']) ? $cfg['columns'] : false;
$distinct = !empty($cfg['distinct']) ? $cfg['distinct'] : false;
$excludecolumns = !empty($cfg['exclude']) ? $cfg['exclude'] : array();
@@
-1579,7
+1595,8
@@
class Pman_Roo extends Pman
}
$tab = str_replace('/', '',$tab); // basic protection??
}
$tab = str_replace('/', '',$tab); // basic protection??
- $pm = HTML_FlexyFramework::get()->Pman;
+ $ff = HTML_FlexyFramework::get();
+ $pm = isset($ff->Pman) ? $ff->Pman : array();
if (isset($pm['roo_alias'])) {
$map = array_flip($pm['roo_alias']);
if (isset($pm['roo_alias'])) {
$map = array_flip($pm['roo_alias']);