mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-20 03:36:20 +02:00
95bf0161c6
create-domain.php - replace old $form_fields with $handler->getStruct() - rewrite handling POST data to make it easier to understand - move reading POST input to the section handling POST - remove condition on POST (we are in the POST block now) - check if editing of a field is allowed (use default value if not) - move validation of 'enum' fields to PFAHandler - allow changing the "active" state (instead of hardcoding it) model/PFAHandler.php: - add check for 'enum' fields model/DomainHandler.php: - change default for "active" and "default_aliases" to 1 templates/admin_edit-domain.tpl: - don't hide the "Active" checkbox on new git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1220 a1433add-5e2c-0410-b055-b7f2511e0802
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
class PFAHandler {
|
|
|
|
/**
|
|
* @return return value of previously called method
|
|
*/
|
|
public function result() {
|
|
return $this->return;
|
|
}
|
|
|
|
|
|
/**
|
|
* functions for basic input validation
|
|
*/
|
|
function _inp_num($field, $val) {
|
|
$valid = is_numeric($val);
|
|
if ($val < -1) $valid = false;
|
|
if (!$valid) $this->errormsg[] = "$field must be numeric";
|
|
return $valid;
|
|
# return (int)($val);
|
|
}
|
|
|
|
function _inp_bool($field, $val) {
|
|
if ($val == "0" || $val == "1") return true;
|
|
$this->errormsg[] = "$field must be boolean";
|
|
return false;
|
|
# return $val ? db_get_boolean(true): db_get_boolean(false);
|
|
}
|
|
|
|
function _inp_enum($field, $val) {
|
|
if(in_array($val, $this->struct[$field]['options'])) return true;
|
|
$this->errormsg[] = "Invalid parameter given for $field";
|
|
return false;
|
|
}
|
|
|
|
function _inp_password($field, $val){
|
|
# TODO: fetchmail specific. Not suited for mailbox/admin passwords.
|
|
$this->errormsg[] = "_inp_password not implemented yet";
|
|
return false;
|
|
# return base64_encode($val);
|
|
}
|
|
|
|
}
|
|
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|