public function user_exists(FormField $field) { if ($field->get_value()) { return PersistenceContext::get_querier()->row_exists(DB_TABLE_MEMBER, 'WHERE display_name=:display_name', array('display_name' => $field->get_value())); } return false; }
public function login_exists(FormField $field) { if (!empty($this->user_id)) { return PersistenceContext::get_querier()->row_exists(DB_TABLE_INTERNAL_AUTHENTICATION, 'WHERE login=:login AND user_id != :user_id', array('login' => $field->get_value(), 'user_id' => $this->user_id)); } else { if ($field->get_value()) { return PersistenceContext::get_querier()->row_exists(DB_TABLE_INTERNAL_AUTHENTICATION, 'WHERE login=:login', array('login' => $field->get_value())); } } return false; }
public function validate() { $first_value = $this->first_field->get_value(); $second_value = $this->second_field->get_value(); if ($first_value !== null && $second_value !== null) { if ($first_value == $second_value) { return true; } } return false; }
public function email_exists(FormField $field) { if (!empty($this->user_id)) { return PersistenceContext::get_querier()->row_exists(DB_TABLE_MEMBER, 'WHERE email=:email AND user_id != :user_id', array('email' => $field->get_value(), 'user_id' => $this->user_id)); } else { if ($field->get_value()) { return PersistenceContext::get_querier()->row_exists(DB_TABLE_MEMBER, 'WHERE email=:email', array('email' => $field->get_value())); } } return false; }
public function display_name_exists(FormField $field) { if (!empty($this->user_id)) { return PersistenceContext::get_querier()->row_exists(DB_TABLE_MEMBER, 'WHERE display_name=:display_name AND user_id != :user_id', array('display_name' => $field->get_value(), 'user_id' => $this->user_id)); } else { if ($field->get_value()) { return PersistenceContext::get_querier()->row_exists(DB_TABLE_MEMBER, 'WHERE display_name=:display_name', array('display_name' => $field->get_value())); } } return false; }
public function validate() { $first_value = $this->first_field->get_value(); $second_value = $this->second_field->get_value(); if ($first_value !== null && $second_value !== null) { if ($first_value instanceof Date && $second_value instanceof Date) { if ($second_value->get_timestamp() > $first_value->get_timestamp()) { return true; } } else { if ($second_value > $first_value) { return true; } } } return false; }
public function validate(FormField $field) { $value = strlen($field->get_value()); $is_required = $field->is_required(); if (!empty($value) || $is_required) { return $value >= $this->lower_bound && $value <= $this->upper_bound; } return true; }
public function url_is_valid(FormField $field) { $status = 200; $url = new Url($field->get_value()); $file_headers = get_headers($url->absolute(), true); if (is_array($file_headers)) { if (preg_match('/^HTTP\\/[12]\\.[01] (\\d\\d\\d)/', $file_headers[0], $matches)) { $status = (int) $matches[1]; } } return $status == 200; }
public function validate(FormField $field) { $value = $field->get_value(); $is_required = $field->is_required(); if ($value instanceof Date) { $value = $value->format(Date::FORMAT_ISO_DAY_MONTH_YEAR); } if (!empty($value) || $is_required) { return preg_match($this->php_regex, $value) > 0; } return true; }
public function validate(FormField $field) { $value = $field->get_value(); $this->set_validation_error_message(StringVars::replace_vars($this->error_message, array('name' => strtolower($field->get_label())))); if ($value instanceof FormFieldEnumOption) { return $value->get_raw_value() !== null && $value->get_raw_value() != ''; } if ($value instanceof Date) { return $value->format(Date::FORMAT_ISO_DAY_MONTH_YEAR) !== null && $value->format(Date::FORMAT_ISO_DAY_MONTH_YEAR) != ''; } return $value == 0 || $value !== null && $value != ''; }
public function validate(FormField $field) { $is_required = $field->is_required(); $value = $field->get_value(); if (!is_numeric($value)) { return false; } $value = (int) $value; if (!empty($value) || $is_required) { return $value <= $this->upper_bound; } return true; }
public function validate(FormField $field) { $value = $field->get_value(); if (empty($value)) { return false; } if (file_exists($value)) { $value = substr($value, -1) == '/' ? $value : $value . '/'; if (file_exists($value . 'wp-config.php')) { require_once $value . 'wp-config.php'; if (defined('DB_HOST')) { return true; } } } return false; }
public function validate(FormField $field) { $field_name = ContactField::rewrite_field_name($field->get_value()); $valid = true; if (!empty($this->field_id)) { foreach (ContactConfig::load()->get_fields() as $id => $f) { if ($id != $this->field_id && $f['field_name'] == $field_name) { $valid = false; } } } else { foreach (ContactConfig::load()->get_fields() as $id => $f) { if ($f['field_name'] == $field_name) { $valid = false; } } } return $valid; }
private function warning_if_not_equals(FormField $field, $message) { $tpl = new StringTemplate('var field = $FF(${escapejs(ID)}); var value = ${escapejs(VALUE)}; if (field.getValue()!=value && !confirm(${escapejs(MESSAGE)})){field.setValue(value);}'); $tpl->put('ID', $field->get_id()); $tpl->put('VALUE', $field->get_value()); $tpl->put('MESSAGE', $message); return $tpl->render(); }
protected function get_value() { return $this->field->get_value(); }
public function validate(FormField $field) { return !empty($this->bug_id) && $this->bug_status != $field->get_value()->get_raw_value(); }