+ if (!empty($req['core_person_settings'])) {
+ $this->updateSettings($req['core_person_settings'], $roo);
+ }
+ }
+
+ function onUpdate($old, $req,$roo, $event)
+ {
+ if (!empty($req['core_person_settings'])) {
+ $this->updateSettings($req['core_person_settings'], $roo);
+ }
+ }
+
+ // there should really be a registry of valid scope values!?
+ function updateSettings($ar, $roo)
+ {
+ //DB_DataObject::debugLevel(1);
+ $old = array();
+ foreach($this->settings(true) as $o) {
+ $old[$o->scope] = $o;
+ }
+ foreach($ar as $k=>$v) {
+ if (isset($old[$k])) {
+ $oo = clone($old[$k]);
+ $old[$k]->data = $v;
+ $old[$k]->update($oo);
+ continue;
+ }
+ $cs = DB_DataObject::Factory('core_person_settings');
+ $cs->setFrom(array(
+ 'person_id' =>$this->id,
+ 'scope' => $k,
+ 'data' => $v
+ ));
+ $cs->insert();
+ }
+ // we dont delete old stuff....