@ -65,7 +65,7 @@ class DomainHandler extends PFAHandler {
$transports = Config::read('transport_options');
return $transports[$id-1];
}
public function add($values) {
# TODO: make this a generic function for add and edit
# TODO: move DB writes etc. to separate save() function (to allow on-the-fly validation before saving to DB)
@ -79,11 +79,11 @@ class DomainHandler extends PFAHandler {
# base validation
$checked = array();
foreach($this->struct as $key=>$row) {
if ($row['editable'] == 0){ # not editable
if ($row['editable'] == 0){ # not editable
if ($this->new == 1) {
$checked[$key] = $row['default'];
}
} else {
} else {
$func="_inp_".$row['type'];
# TODO: error out if an editable field is not set in $values (on $this->new) -or- skip if in edit mode
$val=$values[$key];
@ -131,10 +131,10 @@ class DomainHandler extends PFAHandler {
db_log ($this->username, 'create_domain', "");
return true;
}
public function view() {
public function view() {
$table_domain = table_by_key($this->db_table);
$E_domain = escape_string($this->username);
$result = db_query("SELECT domain, description, aliases, mailboxes, maxquota, quota, transport, backupmx, DATE_FORMAT(created, '%d.%m.%y') AS created, DATE_FORMAT(modified, '%d.%m.%y') AS modified, active FROM $table_domain WHERE domain='$E_domain'");
if ($result['rows'] != 0) {
@ -148,8 +148,8 @@ class DomainHandler extends PFAHandler {
/**
* @return true on success false on failure
*/
public function delete(){
if( ! $this->view() ) {
public function delete(){
if( ! $this->view() ) {
$this->errormsg[] = 'A domain with that name does not exist.'; # TODO: make translatable
return false;
}
@ -160,7 +160,7 @@ class DomainHandler extends PFAHandler {
# TODO: recursively delete mailboxes, aliases, alias_domains, fetchmail entries etc. before deleting the domain