/** * Upgrades the modules * @param string $old_vers * @param string $new_vers * @returns boolean */ public function upgrade($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.12')) { I2CE::raiseError("Changing contact child forms of training_institution to training_institution_contact"); if (!iHRIS_Module_Contact::changeContactForm('training_institution', 'contact_type|facility', 'training_institution_contact', true)) { I2CE::raiseError("Could not upgrade training instituion contacts"); return false; } } if (I2CE_Validate::checkVersion($old_vers, '=', '3.2.12')) { //the changeContactForm did not remvoe the contact form before if (!iHRIS_Module_Contact::removeContactForm('training_institution')) { return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.19')) { I2CE::raiseError("Changing contact child forms of training_funder to training_funder_contact"); if (!iHRIS_Module_Contact::changeContactForm('training_funder', 'contact_type|facility', 'training_funder_contact', true)) { I2CE::raiseError("Could not upgrade training funder contacts"); return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.20')) { $user = new I2CE_User(1, false, false, false); $class_config = I2CE::getConfig()->modules->forms->formClasses; $migrate_path = "/I2CE/formsData/migrate_data/3.2.3"; if (!I2CE_FormStorage::migrateField("training_institution", array("location" => array("county" => "county", "district" => "district", "country" => "country")), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("training_funder", array("location" => array("county" => "county", "district" => "district", "country" => "country")), $migrate_path, $user)) { return false; } } return true; }
protected function updateContacts() { foreach (self::$contacts as $contact) { I2CE::raiseError("Changing contact child form of type {$contact} of person to person_contact_{$contact}"); if (!iHRIS_Module_Contact::changeContactForm('person', "contact_type|{$contact}", "person_contact_{$contact}", true, false)) { I2CE::raiseError("Could not upgrade training funder contacts"); return false; } } iHRIS_Module_Contact::removeContactForm('person'); return true; }