if (!empty($q['query']['empty_etype'])) {
$this->whereAdd("etype = ''");
}
+
+
+
}
function onUpdate($old, $req)
return false;
}
+ /**
+ * The base enums that the system always needs,
+ * If we need to add modular enums, then this can be extended, and the two
+ * base data applied.
+ *
+ * This might be moved to an external file later? - eg json...
+ *
+ */
+ function baseEnums()
+ {
+ //
+ return array(
+ array(
+ 'etype' => '',
+ 'name' => 'COMPTYPE',
+ 'display_name' => 'Company Types',
+ 'cn' => array(
+ array(
+ 'name' => 'OWNER',
+ 'display_name' => 'Owner',
+ 'seqid' => 999, // last...
+ )
+
+ )
+ )
+ );
+
+
+
+ }
+
+ function initEnums($data = false, $base = array())
+ {
+
+ if ($data === false) {
+ $this->initEnums($this->baseEnums());
+ return;
+ }
+ $seq_id = 0;
+ if (!empty($base['etype'])) {
+ $seq_id = 1;
+ $t = DB_DAtaObject::Factory('core_enum');
+ $t->etype = $base['etype'];
+ $t->selectAdD();
+ $t->selectAdD('max(seqid) as seqid');
+ if ($t->find(true)) {
+ $seq_id = $t->seqid+1;
+ }
+ }
+ foreach($data as $row) {
+ $t = DB_DAtaObject::Factory('core_enum');
+
+ $t->setFrom($row);
+ $t->setFrom($base);
+
+ if (!$t->find(true)) {
+ if (!empty($base['etype']) && empty($row['seqid'])) {
+ $t->seqid = $seq_id;
+ $seq_id++;
+ }
+ $t->insert();
+ }
+ if (!empty($row['cn'])) {
+ $this->initEnums($row['cn'], array('etype' => $t->name));
+ }
+ }
+
+ }
+
}