$this->whereAdd("etype = ''");
}
+ // this should be handled by roo... using '!name[0]' ....
if(!empty($q['!name'])){
- $names = explode(',', $q['!name']);
+ $names = is_array($q['!name']) ? $q['!name'] : explode(',', $q['!name']);
foreach($names as $name){
$name = $this->escape($name);
$this->whereAdd("
");
}
}
- if(!empty($q['search']['display_name')){
+ if(!empty($q['search']['display_name'])) {
+ $name = $this->escape($q['search']['display_name']);
+ // ilike on postgres?!?
+ $this->whereAdd("
+ core_enum.display_name LIKE '{$name}%'
+ ");
- foreach($names as $name){
- $this->whereAdd("
- core_enum.name NOT IN ('$name')
- ");
- }
}
}
}
- function onUpdate($old, $req)
- {
- $x = $this->factory($this->tableName());
- $x->query("SELECT core_enum_seqmax_update('". $this->escape($this->etype) ."')");
- if ($old->etype != $this->etype) {
- $x->query("SELECT core_enum_seqmax_update('". $this->escape($old->etype) ."')");
- }
-
- }
+
function beforeUpdate($old, $request,$roo)
{
$tn = $this->tableName();
}
}
}
+
function onInsert($req)
{
$x = $this->factory($this->tableName());
$x->query("SELECT core_enum_seqmax_update('". $this->escape($this->etype) ."')");
}
+ function onUpdate($old, $req)
+ {
+ $x = $this->factory($this->tableName());
+ $x->query("SELECT core_enum_seqmax_update('". $this->escape($this->etype) ."')");
+ if ($old->etype != $this->etype) {
+ $x->query("SELECT core_enum_seqmax_update('". $this->escape($old->etype) ."')");
+ }
+ }
+
function lookup($etype,$name) {
$ce = DB_DataObject::Factory('core_enum');
return $ce->id;
}
return 0;
+ }
+
+ /**
+ *
+ *
+ *
+ * @param string $etype
+ * @param array $name array of name
+ * @return array ID of core_enum
+ */
+
+ function lookupAllByName($etype,$name) {
+ $ce = DB_DataObject::Factory('core_enum');
+ $ce->etype = $etype;
+ $ce->whereAddIn('name', $name, 'string');
+ if ($ce->count() > 0) {
+ return $ce->fetchAll('id');
+ }
+ return array();
}
function fetchAllByType($etype, $fetchArg1=false, $fetchArg2=false, $fetchArg3=false)
$t->setFrom($row);
$t->setFrom($base);
+
unset($t->seqid); // these might have been changed
unset($t->display_name); // these might have been changed
-
if (!$t->find(true))
{
$t->setFrom($row);
$t->setFrom($base);
-
+ $t->is_system_enum = 1;
if (!empty($base['etype']) && empty($row['seqid'])) {
$t->seqid = $seq_id;
$seq_id++;
}
$t->insert();
+ }else{
+ $t->is_system_enum = 1;
+ $t->update();
}
if (!empty($row['cn'])) {
$this->initEnums($row['cn'], array('etype' => $t->name));