/**
  * 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");
     }
 }
 /**
  * Checks to see if the current value for this is set and valid.
  * @return boolean
  */
 public function isValid()
 {
     if ($this->issetValue()) {
         return I2CE_Validate::checkString($this->getValue());
     }
     return false;
 }
 /**
  * Validate the email field for contact forms.
  * @param I2CE_FormField $formfield
  */
 public function validate_form_contact_field_email($formfield)
 {
     $value = $formfield->getValue();
     if (I2CE_Validate::checkString($value) && !I2CE_Validate::checkEmail($value)) {
         $formfield->setInvalidMessage('invalid_email');
     }
 }
 /**
  * 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);
 }
 /**
  * Checks to make sure all the required fields are valid for the application.
  * @param I2CE_Form $form
  */
 public function validate_form_application($form)
 {
     if ($form->felony == 1 && !I2CE_Validate::checkString($form->felony_circumstance)) {
         $form->setInvalidMessage('felony_circumstance', 'required');
     }
     if ($form->full_time == 0 && !I2CE_Validate::checkString($form->hours)) {
         $form->setInvalidMessage('hours', 'required');
     }
 }
 /**
  * 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());
         }
     }
 }
 /**
  * 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;
 }
 /**
  * Perform extra validation for the person form.
  * A new person record needs to verify there aren't any existing 
  * records with the same name.
  * @param I2CE_Form $form
  */
 public function validate_form_person($form)
 {
     $search = array();
     $surname_ignore = false;
     if (isset($form->surname_ignore)) {
         $surname_ignore = $form->surname_ignore;
     }
     if (I2CE_ModuleFactory::instance()->isEnabled('forms-storage') && $form->getId() == '0' && !$surname_ignore && I2CE_Validate::checkString($form->surname) && I2CE_Validate::checkString($form->firstname)) {
         $where = array('operator' => 'AND', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'surname', 'style' => 'lowerequals', 'data' => array('value' => strtolower($form->surname))), 1 => array('operator' => 'FIELD_LIMIT', 'field' => 'firstname', 'style' => 'lowerequals', 'data' => array('value' => strtolower($form->firstname)))));
         $results = I2CE_FormStorage::listFields('person', array('surname', 'firstname'), false, $where, array('surname', 'firstname'));
         if (count($results) > 0) {
             foreach ($results as $id => &$data) {
                 $data = implode(', ', $data);
             }
             $form->setInvalidMessage('surname', 'unique', array("view?id=" => $results));
         }
     }
 }
Esempio n. 9
0
 /**
  * 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.");
     }
 }
 /**
  * Perform extra validation for the trainingprovider form.
  * A new trainingprovider record needs to verify there aren't any existing 
  * records with the same name.
  * @param I2CE_Form $form
  */
 public function validate_form_trainingprovider($form)
 {
     $search = array();
     $name_ignore = false;
     if (isset($form->name_ignore)) {
         $name_ignore = $form->name_ignore;
     }
     if (I2CE_ModuleFactory::instance()->isEnabled('forms-storage') && $form->getId() == 0 && !$name_ignore && I2CE_Validate::checkString($form->name)) {
         $where = array('operator' => 'AND', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'name', 'style' => 'lowerequals', 'data' => array('value' => strtolower($form->name)))));
         $results = I2CE_FormStorage::listFields('trainingprovider', array('name'), false, $where, array('name'));
         if (count($results) > 0) {
             foreach ($results as $id => &$data) {
                 $data = implode(', ', $data);
             }
             $form->getField('name')->setInvalid("Duplicate records match this record's name:", array("viewprovider?id=" => $results));
         }
     }
     $value = $form->getField('email')->getValue();
     if (I2CE_Validate::checkString($value) && !I2CE_Validate::checkEmail($value)) {
         $form->getField('email')->setInvalid('invalid_email');
     }
 }
 /**
  * Checks to see if the current value for this is set and valid.
  * @return boolean
  */
 public function isValid()
 {
     $value = $this->getValue();
     $curr_value = parent::getFromDB($value[0]);
     return count($this->value) == 2 && I2CE_Validate::checkCurrency($value[1]) && I2CE_Validate::checkString($curr_value[1]) && in_array($curr_value[0], $this->getSelectableForms());
 }
Esempio n. 12
0
 /**
  * The month name text to be displayed for the given month number.
  * @param integer $mon
  * @return string
  */
 public function getMonthName($mon)
 {
     if ($mon === 0 && I2CE_Validate::checkString($this->blank_text)) {
         return $this->blank_text;
     } else {
         return self::$months[$mon];
     }
 }
 /**
  * Checks to see if the current value for this is set and valid.
  * @return boolean
  */
 public function isValid()
 {
     if (!$this->isSetValue()) {
         return false;
     }
     if ($this->canSelectAnyForm()) {
         foreach ($this->value as $value) {
             if (count($value) != 2 || !I2CE_Validate::checkString($value[1])) {
                 return false;
             }
         }
         return true;
     } else {
         $forms = $this->getSelectableForms();
         foreach ($this->value as $value) {
             if (count($value) != 2 || !I2CE_Validate::checkString($value[1]) || !in_array($value[0], $forms)) {
                 return false;
             }
         }
         return true;
     }
 }
 /**
  * Checks to see if the current value for this is set and valid.
  * @return boolean
  */
 public function isValid()
 {
     if (!$this->isSetValue()) {
         return false;
     }
     return count($this->value) == 2 && I2CE_Validate::checkString($this->value[1]) && ($this->canSelectAnyForm() || in_array($this->value[0], $this->getSelectableForms()));
 }
 /**
  * Checks to see if the current value for this is set and valid.
  * @return boolean
  */
 public function isValid()
 {
     return I2CE_Validate::checkString($this->getValue());
 }