/** * 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; }
/** * Upgrade this module if necessary * @param string $old_vers * @param string $new_vers * @return boolean */ public function upgrade($old_vers, $new_vers) { /* * In 3.2.3 we moved some lists from entry to magicdata storage so we need to get the * old data from entry and save them to the new form storage. */ if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.3')) { $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_course_competency_evaluation", array("competency_evaluation" => "competency_evaluation", "competency" => "competency"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("training_course", array("competency" => "competency"), $migrate_path, $user)) { return false; } // If everything migrated correctly, then remove the unused fields. unset($class_config->iHRIS_Training_Course_Competency_Evaluation->fields->competency_type); } if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.6')) { $evals = array('not_evaluated' => 'Not Evaluated'); if (!I2CE_Module_Lists::remapFields('competency_evaluation', $evals, 'training_course_competency_evaluation')) { return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.7')) { // if (!I2CE_Module_Lists::deleteMappedValues('training_course_evaluation', $evals)) { // return false; // } } return parent::upgrade($old_vers, $new_vers); }
/** * Perform the migrate actions for this module * This is for going from pre 3.2 versions where benefit data has * been saved to the database. * @return boolean */ protected function migrate() { $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("employment", array("start_wage" => "currency", "end_wage" => "currency"), $migrate_path, $user)) { return false; } return true; }
/** * Perform the migrate actions for this module. * @return boolean; */ protected function migrate() { $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::migrateForm("id_type", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (!I2CE_FormStorage::migrateField("person_id", array("id_type" => "id_type"), $migrate_path, $user)) { return false; } return true; }
/** * Perform the migrate actions for this module * This is for going from pre 3.2 versions where benefit data has * been saved to the database. * @return boolean */ protected function migrate() { $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::migrateForm("competency_evaluation", "entry", $user, $migrate_path, "name", array("type"), array(), true)) { return false; } if (!I2CE_FormStorage::migrateField("person_competency", array("competency_evaluation" => "competency_evaluation", "competency" => "competency"), $migrate_path, $user)) { return false; } unset($class_config->iHRIS_PersonCompetency->fields->competency_type); return true; }
/** * Perform the migrate actions for this module. * @return boolean */ protected function migrate() { $user = new I2CE_User(1, false, false, false); $class_config = I2CE::getConfig()->modules->forms->formClasses; $migrate_path = "/I2CE/formsData/migrate_data/4.1.8"; if (!I2CE_FormStorage::migrateForm("training_classification", "entry", $user, $migrate_path)) { return false; } if (I2CE_ModuleFactory::instance()->isEnabled("CachedForms")) { $cachedForm = new I2CE_CachedForm("training_classification"); $cachedForm->dropTable(); } if (!I2CE_FormStorage::migrateField("training", array("training_classification" => "training_classification"), $migrate_path, $user)) { return false; } return true; }
/** * Perform the migrate actions for this module. * @return boolean */ protected function migrate() { $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::migrateForm("edu_type", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (!I2CE_FormStorage::migrateForm("degree", "entry", $user, $migrate_path, false, array("type"), array("edu_type" => "edu_type"))) { return false; } if (!I2CE_FormStorage::migrateField("education", array("degree" => "degree"), $migrate_path, $user)) { return false; } unset($class_config->iHRIS_Degree->fields->type); unset($class_config->iHRIS_Education->fields->edu_type); return true; }
/** * Perform the migrate actions for this module * This is for going from pre 3.2 versions where benefit data has * been saved to the database. * @return boolean */ protected function migrate() { $user = new I2CE_User(1, false, false, false); $class_config = I2CE::getConfig()->modules->forms->formClasses; $migrate_path = "/I2CE/formsData/migrate_data/3.2.3"; $migrate_node = I2CE::getConfig()->traverse($migrate_path, true, false); $constant_prof = array(1 => 'language_proficiency|elementary', 2 => 'language_proficiency|limited', 3 => 'language_proficiency|professional', 4 => 'language_proficiency|full_professional', 5 => 'language_proficiency|fluent'); foreach ($constant_prof as $old_id => $new_id) { $migrate_node->forms->language_proficiency->{$old_id} = $new_id; } if (!I2CE_FormStorage::migrateForm("language", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (!I2CE_FormStorage::migrateField("person_language", array("language" => "language", "speaking" => "language_proficiency", "reading" => "language_proficiency", "writing" => "language_proficiency"), $migrate_path, $user)) { return false; } return true; }
/** * Perform the migrate actions for this module. * @return boolean */ protected function migrate() { $user = new I2CE_User(1, false, false, false); $class_config = I2CE::getConfig()->modules->forms->formClasses; $migrate_path = "/I2CE/formsData/migrate_data/3.2.3"; $migrate_node = I2CE::getConfig()->traverse($migrate_path, true, false); $constant_gender = array(1 => 'gender|F', 2 => 'gender|M'); foreach ($constant_gender as $old_id => $new_id) { $migrate_node->forms->gender->{$old_id} = $new_id; } if (!I2CE_FormStorage::migrateForm("marital_status", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (!I2CE_FormStorage::migrateField("demographic", array("gender" => "gender", "marital_status" => "marital_status"), $migrate_path, $user)) { return false; } return true; }
/** * Upgrade this module if necessary * @param string $old_vers * @param string $new_vers * @return boolean */ public function upgrade($old_vers, $new_vers) { /* * In 3.2.3 we moved some lists from entry to magicdata storage so we need to get the * old data from entry and save them to the new form storage. */ if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.3')) { $user = new I2CE_User(1, false, false, false); //$class_config = I2CE::getConfig()->modules->forms->formClasses; $migrate_path = "/I2CE/formsData/migrate_data/3.2.3"; $migrate_node = I2CE::getConfig()->traverse($migrate_path, true, false); foreach (self::$constant_migrate as $old_id => $new_id) { $migrate_node->forms->contact_type->{$old_id} = $new_id; } if (!I2CE_FormStorage::migrateField("contact", array("contact_type" => "contact_type"), $migrate_path, $user)) { return false; } } return true; }
/** * Run the upgrade function for this module. * @param string $old_vers * @param string $new_vers * @return boolean */ public function upgrade($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.22')) { I2CE::getConfig()->__unset("/I2CE/page/position"); } if (!$this->do_migrate && I2CE_Validate::checkVersion($old_vers, '<', '3.2.24')) { $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("position", array("facility" => "facility"), $migrate_path, $user)) { return false; } } return parent::upgrade($old_vers, $new_vers); }
protected function postUpdateAccidentTypeFields() { $migrate_path = "/I2CE/formsData/migrate_data/4.0"; $user = new I2CE_User(1, false, false, false); $class_config = I2CE::getConfig()->modules->forms->formClasses; if (!I2CE_FormStorage::migrateField("accident", array("accident_type" => "accident_type"), $migrate_path, $user)) { return false; } return true; }
/** * Upgrade this module if necessary based on the previous and new * versions of the module. * @param string $old_vers * @param string $new_vers * @return boolean */ public function upgrade($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '3.0.1000')) { if (!$this->updateContactTypes()) { return false; } if (!$this->ensureFormsAndPages()) { return false; } } if (I2CE_Validate::checkVersion($old_vers, "<", "3.3.3")) { $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("person", array("home" => array("home_county" => "county", "home_district" => "district", "home_country" => "country")), $migrate_path, $user)) { return false; } unset($class_config->iHRIS_PersonQualify->fields->home_country); unset($class_config->iHRIS_PersonQualify->fields->home_district); unset($class_config->iHRIS_PersonQualify->fields->home_county); } if (I2CE_Validate::checkVersion($old_vers, "<", "3.3.5")) { $user = new I2CE_User(1, false, false, false); $class_config = I2CE::getConfig()->modules->forms->formClasses; $migrate_path = "/I2CE/formsData/migrate_data/3.2.3"; $facilityObj = I2CE_FormFactory::instance()->createContainer("health_facility"); if (!$facilityObj instanceof iHRIS_HealthFacility) { I2CE::raiseError("Bad health facility form"); return false; } $childForms = $facilityObj->getChildForms(); if (in_array("contact", $childForms)) { I2CE::raiseError("Changing contact child forms of health facility to facility_contact"); if (!iHRIS_Module_Contact::changeContactForm("health_facility", "contact_type|facility", "facility_contact", true)) { return false; } } if (!I2CE_FormStorage::migrateField("health_facility", array("location" => array("county" => "county", "district" => "district", "country" => "country"), "facility_type" => "facility_type", "facility_agent" => "facility_agent", "facility_status" => "facility_status"), $migrate_path, $user)) { return false; } unset($class_config->iHRIS_HealthFacility->fields->country); unset($class_config->iHRIS_HealthFacility->fields->district); unset($class_config->iHRIS_HealthFacility->fields->county); unset($class_config->iHRIS_HealthFacility->fields->type); } if (I2CE_Validate::checkVersion($old_vers, "<", "3.3.6")) { $user = new I2CE_User(1, false, false, false); $class_config = I2CE::getConfig()->modules->forms->formClasses; $migrate_path = "/I2CE/formsData/migrate_data/3.2.3"; $migrate_node = I2CE::getConfig()->traverse($migrate_path, true, false); $constant_try = array(1 => 'exam_try|first', 2 => 'exam_try|retry', 3 => 'exam_try|final'); foreach ($constant_try as $old_id => $new_id) { $migrate_node->forms->exam_try->{$old_id} = $new_id; } $constant_result = array(1 => 'exam_result|pass', 2 => 'exam_result|fail', 3 => 'exam_result|notake'); foreach ($constant_result as $old_id => $new_id) { $migrate_node->forms->exam_result->{$old_id} = $new_id; } $constant_reg_type = array(1 => 'registration_type|permanent', 2 => 'registration_type|temporary'); foreach ($constant_reg_type as $old_id => $new_id) { $migrate_node->forms->registration_type->{$old_id} = $new_id; } if (!I2CE_FormStorage::migrateField("cadre", array("qualification" => "qualification"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("certificate", array("academic_level" => "academic_level"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("deployment", array("health_facility" => "health_facility"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("training_disruption_reason", array("training_disruption_category" => "training_disruption_category"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("training_disrupt", array("disruption_reason" => "training_disruption_reason"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("disciplinary_action_reason", array("disciplinary_action_category" => "disciplinary_action_category"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("disciplinary_action", array("disciplinary_action_reason" => "disciplinary_action_reason"), $migrate_path, $user)) { return false; } $traininstObj = I2CE_FormFactory::instance()->createContainer("training_institution"); if (!$traininstObj instanceof iHRIS_QualifyTrainingInstitution) { I2CE::raiseError("Bad training institution form"); return false; } $childForms = $traininstObj->getChildForms(); if (in_array("contact", $childForms)) { I2CE::raiseError("Changing contact child forms of training institution to facility_contact"); if (!iHRIS_Module_Contact::changeContactForm("training_institution", "contact_type|facility", "facility_contact", true)) { return false; } } if (!I2CE_FormStorage::migrateField("training_institution", array("location" => array("county" => "county", "district" => "district", "country" => "country"), "facility_agent" => "facility_agent", "facility_status" => "facility_status"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("training_program", array("cadre" => "cadre"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("facility_institution", array("health_facility" => "health_facility", "training_institution" => "training_institution"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("demographic", array("birth_location" => array("birth_county" => "county", "birth_district" => "district", "birth_country" => "country")), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("education", array("certificate" => "certificate"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("training", array("cadre" => "cadre", "training_institution" => "training_institution", "out_country" => "country"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("exam", array("try" => "exam_try", "results" => "exam_result"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("registration", array("practice_type" => "registration_type"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("out_migration", array("country" => "country", "out_migration_reason" => "out_migration_reason"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("private_practice", array("health_facility" => "health_facility"), $migrate_path, $user)) { return false; } unset($class_config->iHRIS_DisciplinaryAction->fields->disciplinary_action_category); unset($class_config->iHRIS_Education->fields->academic_level); unset($class_config->iHRIS_QualifyDemographic->fields->birth_country); unset($class_config->iHRIS_QualifyDemographic->fields->birth_district); unset($class_config->iHRIS_QualifyDemographic->fields->birth_county); unset($class_config->iHRIS_Search); unset($class_config->iHRIS_TrainingDisrupt->fields->disruption_category); unset($class_config->iHRIS_Cadre->fields->type); unset($class_config->iHRIS_Certificate->fields->type); unset($class_config->iHRIS_DisciplinaryActionReason->fields->type); unset($class_config->iHRIS_HealthFacility->fields->type); unset($class_config->iHRIS_TrainingDisruptionReason->fields->type); } if (I2CE_Validate::checkVersion($old_vers, "<", "3.3.15")) { $user = new I2CE_User(1, false, false, false); $factory = I2CE_FormFactory::instance(); $training_programs = $factory->getRecords("training_program"); I2CE::raiseError("Training programs are: " . print_r($training_programs, true)); foreach ($training_programs as $id) { $program = $factory->createContainer("training_program|" . $id); $program->populate(); $program->getField("training_institution")->setFromDB($program->getParent()); I2CE::raiseError("Saving training_program {$id} to have institution " . $program->getParent()); $program->setParent(""); $program->save($user); $program->cleanup(); unset($program); } } return true; }
/** * Upgrade this module if necessary * @param string $old_vers * @param string $new_vers * @return boolean */ public function upgrade($old_vers, $new_vers) { /* * In 3.2.3 we moved some lists from entry to magicdata storage so we need to get the * old data from entry and save them to the new form storage. */ if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.3')) { $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::migrateForm("training_course_status", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (!I2CE_FormStorage::migrateForm("training_course_category", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (!I2CE_FormStorage::migrateForm("training_course_evaluation", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (!I2CE_FormStorage::migrateForm("training_course_requestor", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (!I2CE_FormStorage::migrateField("training_course", array("training_institution" => "training_institution", "training_funder" => "training_funder", "continuing_education_course" => "continuing_education_course", "training_course_status" => "training_course_status", "training_course_category" => "training_course_category"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("person_scheduled_training_course", array("training_course_evaluation" => "training_course_evaluation", "training_course_requestor" => "training_course_requestor", "scheduled_training_course" => "scheduled_training_course"), $migrate_path, $user)) { return false; } if (!I2CE_FormStorage::migrateField("scheduled_training_course", array("location" => array("county" => "county", "district" => "district", "country" => "country")), $migrate_path, $user)) { return false; } unset($class_config->iHRIS_Person_Scheduled_Training_Course->fields->training_course); unset($class_config->iHRIS_Scheduled_Training_Course->fields->country); unset($class_config->iHRIS_Scheduled_Training_Course->fields->district); unset($class_config->iHRIS_Scheduled_Training_Course->fields->county); } elseif (I2CE_Validate::checkVersion($old_vers, '<', '3.2.35')) { $user = new I2CE_User(1, false, false, false); $migrate_path = "/I2CE/formsData/migrate_data/3.2.3"; if (!I2CE_FormStorage::migrateField("person_scheduled_training_course", array("scheduled_training_course" => "scheduled_training_course"), $migrate_path, $user)) { return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.18')) { $evals = array('pass' => 'Pass', 'fail' => 'Fail', 'incomplete' => 'Incomplete'); if (!I2CE_Module_Lists::remapFields('training_course_evaluation', $evals, 'person_scheduled_training_course')) { return false; } if (!I2CE_Module_Lists::deleteMappedValues('training_course_evaluation', $evals)) { return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.30')) { $evals = array('open' => 'Open', 'closed' => 'Closed'); if (!I2CE_Module_Lists::remapFields('training_course_status', $evals, 'training_course')) { return false; } if (!I2CE_Module_Lists::deleteMappedValues('training_course_status', $evals)) { return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.32')) { $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("scheduled_training_course", array("location" => array("county" => "county", "district" => "district", "country" => "country")), $migrate_path, $user)) { return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.63')) { if (!$this->moveScheduledTrainingCourseToMap()) { return false; } } return parent::upgrade($old_vers, $new_vers); }
/** * Upgrade this module if necessary * @param string $old_vers * @param string $new_vers * @return boolean */ public function upgrade($old_vers, $new_vers) { /* * In 3.2.3 we moved some lists from entry to magicdata storage so we need to get the * old data from entry and save them to the new form storage. */ if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.3')) { $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("person", array("nationality" => "country", "residence" => array("residence_county" => "county", "county" => "county", "residence_district" => "district", "district" => "district", "residence_country" => "country", "country" => "country")), $migrate_path, $user)) { return false; } unset($class_config->iHRIS_Person->fields->residence_country); unset($class_config->iHRIS_Person->fields->residence_district); unset($class_config->iHRIS_Person->fields->residence_county); } return parent::upgrade($old_vers, $new_vers); }