function setObjectTypeIds($ids) { if (is_array($ids)) { if (!$this->isNew()) { //If needed, delete mappings first. $lf_a = new HierarchyObjectTypeListFactory(); $lf_a->getByHierarchyControlId($this->getId()); $tmp_ids = array(); foreach ($lf_a as $obj) { $id = $obj->getId(); Debug::text('Hierarchy Object Type ID: ' . $obj->getId() . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); //Delete users that are not selected. if (!in_array($id, $ids)) { Debug::text('Deleting: ' . $id, __FILE__, __LINE__, __METHOD__, 10); $obj->Delete(); } else { //Save ID's that need to be updated. Debug::text('NOT Deleting : ' . $id, __FILE__, __LINE__, __METHOD__, 10); $tmp_ids[] = $id; } } unset($id, $obj); } foreach ($ids as $id) { if (isset($ids) and !in_array($id, $tmp_ids)) { $f = new HierarchyObjectTypeFactory(); $f->setHierarchyControl($this->getId()); $f->setObjectType($id); if ($this->Validator->isTrue('object_type', $f->Validator->isValid(), TTi18n::gettext('Object type is already assigned to another hierarchy'))) { $f->save(); } } } return TRUE; } return FALSE; }