/** * Validate the email field for contact forms. * @param I2CE_FormField $formfield */ public function validate_form_user_request_field_email($formfield) { $value = $formfield->getValue(); if (I2CE_Validate::checkString($value) && !I2CE_Validate::checkEmail($value)) { $formfield->setInvalidMessage("invalid_email"); } }
/** * Validate this form. */ public function validate() { if (I2CE_Validate::checkNumber($this->count, 1)) { if (!$this->code_start || !I2CE_Validate::checkNumber($this->code_start, 0)) { $this->setInvalidMessage('code_start', 'required'); } if ($this->code_format != "") { if (preg_match('/%[\\d\\.]*d/', $this->code_format) == 0) { $this->code_format .= "%d"; } $storage = I2CE_ModuleFactory::instance()->getClass("forms-storage"); if ($storage instanceof I2CE_FormStorage) { $count = $this->count; $code_start = $this->code_start; while ($count--) { $this->code = sprintf($this->code_format, $code_start); $storage->validate_formfield($this->getField("code")); if ($this->getField("code")->hasInvalid()) { $this->setInvalidMessage("code_format", 'unique'); } $code_start++; } } } } parent::validate(); }
/** * Checks to see if the current value for this is set and valid. * @return boolean */ public function isValid() { if ($this->issetValue()) { return I2CE_Validate::checkNumber($this->getValue()); } return false; }
/** * 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("facility_type", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (I2CE_FormStorage::migrateForm("facility", "entry", $user, $migrate_path, false, array("type"), array("facility_type" => "facility_type", "location" => array("county" => "county", "district" => "district", "country" => "country")))) { unset($class_config->iHRIS_Facility->fields->country); unset($class_config->iHRIS_Facility->fields->district); unset($class_config->iHRIS_Facility->fields->county); unset($class_config->iHRIS_Facility->fields->type); } else { return false; } } elseif (I2CE_Validate::checkVersion($old_vers, '<', '3.2.4')) { $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("facility", "entry", $user, $migrate_path, false, array("type"))) { return false; } unset($class_config->iHRIS_Facility->fields->type); } return parent::upgrade($old_vers, $new_vers); }
/** * 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); }
/** * Extra validation for training disruptions to make sure the disruption date * is after the intake date of the training being disrupted. * */ protected function validate() { parent::validate(); if (I2CE_Validate::checkDate($this->getPrimary()->disruption_date) && $this->getPrimary()->disruption_date->before($this->getParent()->intake_date)) { $this->getPrimary()->setInvalidMessage("disruption_date", "bad_date"); } }
/** * Checks to see if the value has been set. * @return boolean */ public function issetValue() { if (!is_array($this->value) || count($this->value) != 2) { return false; } list($form, $id) = $this->value; return I2CE_Validate::checkString($form) && I2CE_Validate::checkString($id); }
/** * 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) { if (I2CE_Validate::checkVersion($old_vers, '<', '4.0.6.1')) { if (!$this->addLastModifiedColumn()) { return false; } } return true; }
public function upgrade($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '4.0.6')) { if (!$this->createTempUploadTable()) { return false; } } return true; }
/** * Perform the main actions of the page. * @global array */ protected function action() { $i2ce_config = I2CE::getConfig()->I2CE; parent::action(); $fields = array("Name" => false, "Company" => false, "Title" => false, "Industry" => false, "Address" => false, "City" => false, "State" => false, "Postal_Code" => false, "Country" => false, "Telephone" => false, "Fax" => false, "Email" => false, "Comments" => false, "referer" => false); $valid = true; $err_msg = ""; if ($this->isPost()) { $message = ""; foreach ($fields as $name => $required) { if ($required && !I2CE_Validate::checkString($this->post($name))) { $valid = false; $err_msg .= "<li>{$name} is blank.</li>\n"; } $message .= $name . ": " . $this->post($name) . "\n"; } $message .= "Username : "******"\n"; $message .= "User Role : " . $this->user->getRole() . "\n"; if ($valid) { $this->template->addFile("feedback_thanks.html"); $this->template->setDisplayData("return_link", 'home'); I2CE_Mailer::mail($i2ce_config->feedback->to, array('Subject' => $i2ce_config->feedback->subject, 'From' => $this->post('Email')), $message); return; } } $this->template->addFile("feedback_form.html"); if (array_key_exists('contact_address', $this->args) && $this->args['contact_address']) { if (($formNode = $this->template->getElementById('feedback_form')) instanceof DOMElement) { $formNode->setAttribute('action', 'mailto:' . $this->args['contact_address'] . '?Subject=iHRIS Feedback'); $formNode->setAttribute('enctype', 'text/plain'); } } if (!$valid && $err_msg != "") { $this->template->addText('<div id="error">There were some problems with your information:<ul>' . $err_msg . '</ul></div>'); } if ($this->isPost()) { foreach ($fields as $name => $required) { if ($name == "Comments") { $this->template->addText('<textarea name="Comments" rows="10" cols="45" id="Comments">' . $this->post($name) . '</textarea>', "textarea", $name); } else { $this->template->setAttribute("value", $this->post($name), $name, "."); } } } else { $this->template->setAttribute("value", $_SERVER['HTTP_REFERER'], "referer", "."); if (!array_key_exists('auto_populate', $this->args) || $this->args['auto_populate']) { //defaults to true foreach (array('email' => 'Email', 'phone' => 'Phone', 'fax' => 'Fax') as $detail => $data) { if (I2CE_User::hasDetail($detail)) { $this->template->setDisplayDataImmediate($data, $this->user->{$detail}); } } $this->template->setDisplayDataImmediate('Name', $this->user->displayName()); } } }
public function upgrade($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '4.1.12.3')) { //CHECK THAT THIS IS CORRECT VERSION if (!$this->resaveTrainings()) { return false; } } return true; }
public function post_update($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '=', '0')) { //this module is new to 3.2, we may need to update contacts from 3.1 //only fixup contact on a new installation if (!$this->updateContacts()) { return false; } } return true; }
function vers_compare($vers1, $vers2) { if (I2CE_Validate::checkVersion($vers1, '=', $vers2)) { return 0; } if (I2CE_Validate::checkVersion($vers1, "<", $vers2)) { return 1; } else { return -1; } }
public function upgrade($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '3.0.1000')) { if (!$this->updatePersonFormFields()) { return false; } if (!$this->ensureFormsAndPages()) { 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')) { $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) { if (I2CE_Validate::checkVersion($old_vers, '<', '4.1.12.0')) { if (!I2CE_Util::runSQLScript('initialize_user_statistics.sql')) { I2CE::raiseError("Could not initialize user statistics cache table."); return false; } if (!$this->cacheUserStatistics()) { I2CE::raiseError("Failed to cache user statistics so must be done manually."); } } return true; }
public function post_update($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '4.2.0.35')) { if (!$this->intialize_csd_cache_metadata()) { return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '4.2.0.35')) { if (!$this->intialize_csd_cache_metadata_health_facility()) { return false; } } return true; }
public function post_update($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '4.2.0.3')) { if (!$this->intialize_csd_cache_metadata()) { return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '4.2.0.12')) { if (!$this->update_uuids()) { return false; } } return true; }
/** * Upgrade module method * @param string $old_vers * @param string $new_vers */ public function upgrade($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '4.0.11.1')) { if (!I2CE_Util::runSQLScript('initialize_form_store.sql')) { I2CE::raiseError("Could not initialize I2CE form history storage tables"); return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '4.1.4.1') && !$this->upgradeFormStore()) { I2CE::raiseError("Could not upgrade I2CE form history storage tables"); return false; } return true; }
public function upgrade($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '<', '4.2.0.4')) { if (!$this->update_keys()) { return false; } } if (I2CE_Validate::checkVersion($old_vers, '<', '4.2.0.6')) { if (!$this->fixup_svs_oids()) { return false; } } return true; }
/** * post updates the modules * @param string $old_vers * @param string $new_vers * @returns boolean * @returns boolean */ public function post_update($old_vers, $new_vers) { if (I2CE_Validate::checkVersion($old_vers, '=', '0')) { //only fixup contact on a new installation if (!$this->fixupContact()) { return false; } // After fixing up the contact, we need to migrate // the data to magic data storage. if (!$this->migrate()) { return false; } } return true; }
/** * Method called before the module is enabled for the first time. * @param boolean -- returns true on success. false on error. */ public function action_initialize() { /* * This module was split off from Custom Reports. * If Custom Reports has been used previously then we should assume the methods * are defined there so they need to be turned off until CustomReports can be * upgraded when it is required. */ $cr_vers = null; I2CE::getConfig()->setIfIsSet($cr_vers, "/config/data/CustomReports/version"); if ($cr_vers !== null && I2CE_Validate::checkVersion($cr_vers, '<', '3.2')) { I2CE::raiseError("Removing hooks from CustomReports because they were moved to form-limits."); I2CE_ModuleFactory::instance()->removeHooks("CustomReports"); } return true; }
/** * Checks to see if the value has been set. * @return boolean */ public function issetValue() { if (!is_array($this->value) || count($this->value) == 0) { return false; } foreach ($this->value as $value) { if (!is_array($value) || count($value) != 2) { return false; } list($form, $id) = $value; if (!I2CE_Validate::checkString($form) || !I2CE_Validate::checkString($id)) { return false; } } return true; }
/** * Save the training object. * * Sets all the required fields for the training object based on the form data. * Since a training may be inside or outside the country certain fields may be required * depending on which case it is. * * @param I2CE_User &$user The user saving this object. * @param boolean $transact */ public function save(&$user, $transact = true) { if (I2CE_Validate::checkMap($this->training_program)) { $tp = I2CE_FormFactory::instance()->createContainer($this->getField("training_program")->getDBValue()); $tp->populate(); $this->in_cadre = $tp->cadre; $this->training_institution = $tp->training_institution; $this->trained_outside = false; $this->cadre = $this->in_cadre; unset($this->out_country); unset($this->out_institution); } else { $this->trained_outside = true; $this->cadre = $this->out_cadre; unset($this->training_institution); } parent::save($user, $transact); }
/** * Perform the main actions of the page. * @global array Get the home page from the global configuration */ protected function action() { parent::action(); if ($this->user->logged_in()) { $this->setRedirect('home'); return; } $access = I2CE::getUserAccess(); $has_email = $access instanceof I2CE_UserAccess_Mechanism && $access->canChangePassword() && I2CE_User::hasDetail('email'); $this->template->setBodyId("loginPage"); $this->template->setDisplayDataImmediate('has_email', $has_email); if (!$this->isPost() || !$has_email) { return; } if ($this->post('submit') == "Reset") { if (I2CE_Validate::checkString($this->post('username')) && I2CE_User::userExists($this->post('username'), true)) { $user = new I2CE_User($this->post('username'), true, false, true); $email = $user->email; $valid_email = I2CE_Validate::checkEmail($email); $pass = trim(I2CE_User::generatePassword()); if ($user->getRole() != 'guest' && $valid_email && $pass && $user->setPassword($pass)) { if ($this->mailPassword($email, $this->post('username'), $pass)) { $this->template->addTextNode("error_message", "Your password has been reset and mailed to you."); } else { $this->template->addTextNode("error_message", "Your password has been reset, but could not mailed to you. Please contact your system administrator"); } } else { $this->template->addTextNode("error_message", "Your password could not be reset. Please contact your system administrator to change your password."); } } else { $this->template->addTextNode("error_message", "Your username could not be found in the database. Please contact your System Administrator."); } } elseif ($this->post('submit') == "View") { $usernames = I2CE_User::findUsersByInfo(false, array('email' => $this->post('email'))); if (is_array($usernames) && count($usernames) == 1) { reset($usernames); $this->template->addText('<p id="error_message">Your username is: <b>' . current($usernames) . '</b><br />Enter it below to reset your password or return to the login page to login.</p>', 'p'); } else { $this->template->addTextNode("error_message", "That email address was not found in the system. Please contact your System Administrator."); } } else { $this->template->addTextNode("error_message", "Please click one of the submit buttons or only enter one text field."); } }
/** * 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; }
/** * 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.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"; if (!I2CE_FormStorage::migrateForm("competency_type", "entry", $user, $migrate_path, false, array("type"))) { return false; } if (!I2CE_FormStorage::migrateForm("competency", "entry", $user, $migrate_path, false, array("type"), array("competency_type" => "competency_type"))) { return false; } // If everything migrated correctly, then remove the unused fields. unset($class_config->iHRIS_Competency->fields->type); } 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); }