}
// trigger emails..
+ if (isset($req['uploads'])) {
+ $this->updateUploads(json_decode($req['uploads']),$roo);
+ }
+
+
+ }
+ function onInsert($req,$roo, $even)
+ {
+
+
+ if (!$ch) {
+ $ch = DB_DataObject::factory('mtrack_change');
+ $ch->beginChange($this, "Changed");
+ $this->_mtrack_change = $ch;
+ }
+ $ch->add($this, false);
+ if (isset($req['uploads'])) {
+ $this->updateUploads(json_decode($req['uploads']). $roo);
+ }
}
+ function updateUploads($uploads, $roo)
+ {
+ foreach($uploads as $up) {
+
+ if (empty($up->id) || $up->id < 0) {
+ if ($up->is_deleted) {
+ continue;
+ }
+
+
+ $i = DB_DAtaObject::factory('Images');
+ $i->object($this);
+ $i->setFrom(array(
+ 'mimetype' => $up->mimetype,
+ 'title' => $up->title,
+ 'filename' => $up->title,
+ 'created' => date('Y-m-d H:i:s')
+ ));
+ $i->createFromData($up->srcdata);
+ continue;
+ }
+ // edit..
+ $i = DB_DAtaObject::factory('Images');
+ $i->object($this);
+ if (!$i->get($up->id)) {
+ $roo->jerr("invalid update id for image {$up->id}");
+ }
+ if ($up->is_deleted) {
+
+ $i->beforeDelete(array(), $roo);
+ $i->delete();
+ }
+
+ // update???
+
+ }
+ }
function updated()
function toRooSingleArray($au, $req)
{
if ($this->id) {
- return $this->toArray();
+ $ret = $this->toArray();;
+ $ret['images'] = array();
+ foreach($this->images() as $i) {
+ $ret['images'][] = $i->toRooArray(array());
+ }
+
+ return $ret;
}
// empty!
$p = $this->factory('core_enum');
$ret = array_merge($ret, $c->toArray('classification_id_%s'));
$ret = array_merge($ret, $s->toArray('severity_id_%s'));
- return $ret;
+
+ return $ret;
}