public function validateController($htmlentities = true) { $this->cacheDatabaseRequiredFields(); $errors = array(); $databaseRequiredFields = isset(self::$_database_required_fields[get_class($this)]) ? self::$_database_required_fields[get_class($this)] : array(); $fields = JeproshopTools::getTableFields('#__jeproshop_address'); $input = JRequest::get('post'); foreach ($fields as $field => $data) { $value = isset($input[$data->Field]) ? $input[$data->Field] : $this->{$data->Field}; // Check if field is required by user if (in_array($data->Field, $databaseRequiredFields)) { $data->Null = true; } // Checking for required fields if (isset($data->Null) && $data->Null && empty($value) && $value !== '0') { if (!$this->customer_id || $data->Field != 'passwd') { $errors[$data->Field] = '<b>' . self::displayFieldName($field, get_class($this), $htmlentities) . '</b> ' . JText::_('COM_JEPROSHOP_IS_REQUIRED_LABEL'); } } // Checking for maximum fields sizes preg_match('#\\((.*)\\)#', $data->Type, $matches); if (isset($matches[1]) && !empty($value) && strlen($value) > $matches[1]) { $errors[$data->Field] = sprintf(Tools::displayError('%1$s is too long. Maximum length: %2$d'), self::displayFieldName($data->Field, get_class($this), $htmlentities), $matches[1]); } // Checking for fields validity // Hack for postcode required for country which does not have postcodes if (!empty($value) || $value === '0' || $data->Field == 'postcode' && $value == '0') { if (isset($data->validate) && !JeproshopTools::$data['validate']($value) && (!empty($value) || $data->Null)) { $errors[$field] = '<b>' . self::displayFieldName($field, get_class($this), $htmlentities) . '</b> ' . JText::_('COM_JEPROSHOP_IS_INVALID_LABEL'); } else { if (isset($data->copy_post) && !$data['copy_post']) { continue; } if ($data->Field == 'passwd') { if ($value = $input[$data->Field]) { $this->{$field} = JeproshopTools::encrypt($value); } } else { $this->{$field} = $value; } } } } return $errors; }
/** * Tokenize a string * * @param string $string string to encrypt * @return bool */ public static function getAdminToken($string) { return !empty($string) ? JeproshopTools::encrypt($string) : false; }
public function setWebServicePasswd($passwd) { if ($this->customer_id != 0) { if ($this->passwd != $passwd) { $this->passwd = JeproshopTools::encrypt($passwd); } } else { $this->passwd = JeproshopTools::encrypt($passwd); } return true; }