function applyFilters($q, $au)
{
- //DB_DataObject::debugLevel(1);
+// 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 autoJoinCmsTranslate($lang)
+ {
+ $l = $this->escape($lang);
+
+ $this->_join .= "
+ LEFT JOIN
+ cms_templatestr
+ ON
+ cms_templatestr.lang = '$l'
+ AND
+ cms_templatestr.on_table = 'core_enum'
+ AND
+ cms_templatestr.on_id = core_enum.id
+ AND
+ cms_templatestr.on_col = 'display_name'
+ ";
+
+ $this->selectAdd("
+ CASE WHEN
+ '$l' = 'en' THEN display_name
+ ELSE
+ CASE WHEN cms_templatestr.txt IS NOT NULL AND cms_templatestr.txt != '' THEN
+ cms_templatestr.txt
+ ELSE
+ display_name
+ END
+ END as display_name_tr
+ ");
+
}
function postListFilter($data, $authUser, $q) {
function onInsert($req)
{
$x = $this->factory($this->tableName());
- $x->query("SELECT core_enum_seqmax_update('". $this->escape($this->etype) ."')");
+ $x->query("SELECT core_enum_seqmax_update('". $this->escape($this->etype) ."')"); // no idea why need to do this!!??
}
function onUpdate($old, $req)
{
$x = $this->factory($this->tableName());
- $x->query("SELECT core_enum_seqmax_update('". $this->escape($this->etype) ."')");
+ $x->query("SELECT core_enum_seqmax_update('". $this->escape($this->etype) ."')"); // no idea why need to do this!!??
if ($old->etype != $this->etype) {
$x->query("SELECT core_enum_seqmax_update('". $this->escape($old->etype) ."')");
}
return 0;
}
+
+ function lookupById($id) {
+ $ce = DB_DataObject::Factory('core_enum');
+ $ce->get($id);
+ return $ce;
+ }
+
/**
*
*
$x = DB_DataObject::factory('core_enum');
$x->etype = $etype;
$x->active = 1;
+ $x->orderBy('seqid ASC');
return $x->fetchAll($fetchArg1, $fetchArg2, $fetchArg3);
}
function initEnums($data, $base = array())
{
- // base only contains etype...
+ // base only contains etype...
+ //print_r($data);
$seq_id = 0;
if (!empty($base['etype'])) {
$seq_id = 1;
if (empty($t->name)) {
print_R($data);
- die("invalid name used for core_enum");
+ die("ERROR: invalid name used for core_enum\n\n");
}
if (!$t->count()) {
-
+ // base already gave it the etype..
$t->setFrom($row);
-
//$t->is_system_enum = 1; // this should be on the caller..
if (!empty($row['seqid'])) {
$t->insert();
}else{
+ $t->find(true); // fetch it..
if ( isset($row['is_system_enum'])) {
$t->is_system_enum = isset($row['is_system_enum']) ? $row['is_system_enum'] : $t->is_system_enum;