function processView() { $GLOBALS['system']->setFriendlyErrors(TRUE); $this->_person =& $GLOBALS['system']->getDBObject('person', (int) $_REQUEST['personid']); if (!empty($_REQUEST['move_to'])) { if ($_REQUEST['move_to'] == 'new') { $family =& $GLOBALS['system']->getDBObject('family', (int) $this->_person->getValue('familyid')); $family->id = 0; $family->create(); $this->_person->setValue('familyid', $family->id); $this->_person->save(); add_message('New family created with same details as old family. You should update the new family\'s details as required'); redirect('_edit_family', array('familyid' => $family->id)); // exits } else { if (empty($_REQUEST['familyid'])) { trigger_error("You must select a new family to move to, or choose to create a new family"); return false; } $family =& $GLOBALS['system']->getDBObject('family', (int) $_REQUEST['familyid']); if ($family) { $old_familyid = $this->_person->getValue('familyid'); $this->_person->setValue('familyid', (int) $_REQUEST['familyid']); if ($this->_person->save()) { add_message('Person moved to family "' . $family->toString() . '"'); $remaining_members = $GLOBALS['system']->getDBObjectData('person', array('familyid' => $old_familyid)); if (empty($remaining_members)) { $old_family =& $GLOBALS['system']->getDBObject('family', $old_familyid); if ($GLOBALS['user_system']->havePerm(PERM_EDITNOTE)) { // add a note $GLOBALS['system']->includeDBClass('family_note'); $note = new Family_Note(); $note->setValue('familyid', $old_familyid); $note->setValue('subject', 'Archived by System'); $note->setValue('details', 'The system is archiving this family because its last member (' . $this->_person->toString() . ' #' . $this->_person->id . ') has been moved to another family (' . $family->toString() . ' #' . $family->id . ')'); $note->create(); } // archive the family record $old_family->setValue('status', 'archived'); $old_family->save(); } redirect('persons', array('personid' => $this->_person->id)); // exits } } } } }