function applyFilters($q, $au)
{
- print_r($q);exit;
+
// DB_DataObject::debugLevel(1);
if (!empty($q['query']['empty_etype'])) {
$this->whereAdd("etype = ''");
");
}
-// print_r($this);
- if(!empty($q['id'])){
- $this->id = $q['id'];
+ }
+
+ function checkPerm($lvl, $au, $req=null)
+ {
+ if (!$au) {
+ return false;
}
-
+ return true;
}
+
function autoJoinCmsTranslate($lang)
{
$l = $this->escape($lang);
function beforeUpdate($old, $request,$roo)
{
+ if(!empty($request['_merge_id'])){
+ $this->merge($request['_merge_id'], $roo);
+ }
+
$tn = $this->tableName();
$x = $this->factory($tn);
if(!($old->etype == $request['etype'] && $old->name == $request['name'])){
return 0;
}
+ function lookupCreate($etype,$name, $display_name=false) {
+
+ // check
+ $ce = DB_DataObject::Factory('core_enum');
+ $ce->setFrom(array(
+ 'etype' => '',
+ 'name' => $etype
+ ));
+ if (!$ce->find(true)) {
+ $ce->display_name = $etype;
+ $ce->insert();
+ }
+
+ $ce = DB_DataObject::Factory('core_enum');
+ $ce->etype = $etype;
+ $ce->name = $name;
+ if ($ce->find(true)) {
+ return $ce->id;
+ }
+ $ce->active = 1;
+ $ce->display_name = $display_name === false ? $ce->name : $display_name;
+ return $ce->insert();
+
+ }
function lookupById($id) {
$ce = DB_DataObject::Factory('core_enum');
function initEnums($data, $base = array())
{
- die('here');
// base only contains etype...
//print_r($data);
$seq_id = 0;
}
+ function merge($to, $roo)
+ {
+ $affects = array();
+
+ $all_links = $GLOBALS['_DB_DATAOBJECT']['LINKS'][$this->_database];
+
+ foreach($all_links as $tbl => $links) {
+ foreach($links as $col => $totbl_col) {
+ $to = explode(':', $totbl_col);
+ if ($to[0] != $this->tableName()) {
+ continue;
+ }
+
+ $affects[$tbl .'.' . $col] = true;
+ }
+ }
+
+ foreach($affects as $k => $true) {
+ $ka = explode('.', $k);
+
+ $chk = DB_DataObject::factory($ka[0]);
+
+ if (!is_a($chk,'DB_DataObject')) {
+ $roo->jerr('Unable to load referenced table, check the links config: ' .$ka[0]);
+ }
+
+ $chk->{$ka[1]} = $this->id;
+
+ foreach ($chk->fetchAll() as $c){
+ $cc = clone ($c);
+ $c->{$ka[1]} = $to;
+ $c->update($cc);
+ }
+ }
+
+ $this->delete();
+
+ $roo->jok('Merged');
+
+ }
+
}