/**
  * Run the upgrade 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.5')) {
         I2CE::raiseError("Disabling training module.");
         I2CE_ModuleFactory::instance()->disable(array("manage-training-simple-competency", "manage-training-institution", "manage-training-course", "training-simple-competency", "training-institution", "training-course"));
     }
     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')) {
         $class_config = I2CE::getConfig()->modules->forms->formClasses;
         unset($class_config->iHRIS_ContinuingEducationCourse->fields->type);
     }
     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 forms to magicdata so we need to get the old data from entry
      * and save it to the new form storage.
      */
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.6')) {
         if (!$this->migrate()) {
             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::migrateForm("currency", "entry", $user, $migrate_path, false, array("type"), array("country" => "country"))) {
             unset($class_config->iHRIS_Currency->fields->type);
         } else {
             return false;
         }
     }
     return parent::upgrade($old_vers, $new_vers);
 }
 /**
  * Run the upgrade 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, '<', '4.0.3.2')) {
         I2CE::raiseError("Upgrading sample data for license end_date");
         $db = MDB2::singleton();
         $updated = $db->exec("UPDATE last_entry SET date = NOW(), date_value = '2015-01-01 00:00:00' WHERE form_field = 75 AND date_value = '2010-01-01 00:00:00'");
         if (!I2CE::pearError($updated, "Unable to update license end_date for Qualify Sample Data.")) {
             I2CE::raiseError("Update {$updated} entries.");
             $last_mod = $db->exec("UPDATE record SET last_modified = NOW() WHERE form = 16");
             if (!I2CE::pearError($last_mod, "Unable to update license end_date for Qualify Sample Data record last modified.")) {
                 I2CE::raiseError("Updated {$last_mod} records.");
             } else {
                 return false;
             }
         } else {
             return false;
         }
         I2CE::getConfig()->modules->CachedForms->dirty->license = time();
     }
     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::migrateForm("country", "entry", $user, $migrate_path, "alpha_two", array("type"))) {
             return false;
         }
         if (!I2CE_FormStorage::migrateForm("region", "entry", $user, $migrate_path, false, array("type"), array("country" => "country"))) {
             return false;
         }
         if (!I2CE_FormStorage::migrateForm("district", "entry", $user, $migrate_path, false, array("type", "country"), array("region" => "region"))) {
             return false;
         }
         if (!I2CE_FormStorage::migrateForm("county", "entry", $user, $migrate_path, false, array("type", "region", "country"), array("district" => "district"))) {
             return false;
         }
         // If everything migrated correctly, then remove the unused fields.
         unset($class_config->iHRIS_Country->fields->type);
         unset($class_config->iHRIS_Region->fields->type);
         unset($class_config->iHRIS_District->fields->type);
         unset($class_config->iHRIS_District->fields->country);
         unset($class_config->iHRIS_County->fields->type);
         unset($class_config->iHRIS_County->fields->region);
         unset($class_config->iHRIS_County->fields->country);
         unset($class_config->iHRIS_ListByCountry->fields->type);
         unset($class_config->iHRIS_ListByCountry->fields->county);
         unset($class_config->iHRIS_ListByCountry->fields->district);
         unset($class_config->iHRIS_ListByCountry->fields->country);
     }
     return parent::upgrade($old_vers, $new_vers);
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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);
 }