mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
PFAHandler:
- add $this->label_field and $this->label (defaults to $this->id_field and $this->id) to allow nicer messages - use $this->label in various messages git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1729 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
parent
ca76b0fb6e
commit
6bfe6706ba
@ -25,6 +25,10 @@ abstract class PFAHandler {
|
||||
# field containing the ID
|
||||
protected $id_field = null;
|
||||
|
||||
# field containing the label
|
||||
# defaults to $id_field if not set
|
||||
protected $label_field = null;
|
||||
|
||||
# column containing the domain
|
||||
# if a table does not contain a domain column, leave empty and override no_domain_field())
|
||||
protected $domain_field = "";
|
||||
@ -66,6 +70,10 @@ abstract class PFAHandler {
|
||||
# filled in domain_from_id() via init()
|
||||
protected $domain = null;
|
||||
|
||||
# the label of the current item (for usage in error/info messages)
|
||||
# filled in init() (only contains the "real" label in edit mode - in new mode, it will be the same as $id)
|
||||
protected $label = null;
|
||||
|
||||
# can this item be edited?
|
||||
# filled in init() (only in edit mode)
|
||||
protected $can_edit = 1;
|
||||
@ -111,6 +119,11 @@ abstract class PFAHandler {
|
||||
* @param integer - 0 if logged in as user, 1 if logged in as admin or superadmin
|
||||
*/
|
||||
public function __construct($new = 0, $username = "", $is_admin = 1) {
|
||||
# set label_field if not explicitely set
|
||||
if (empty($this->label_field)) {
|
||||
$this->label_field = $this->id_field;
|
||||
}
|
||||
|
||||
if ($new) $this->new = 1;
|
||||
|
||||
if ($is_admin) {
|
||||
@ -251,6 +264,7 @@ abstract class PFAHandler {
|
||||
*/
|
||||
public function init($id) {
|
||||
$this->id = strtolower($id);
|
||||
$this->label = $this->id;
|
||||
|
||||
$exists = $this->view(false);
|
||||
|
||||
@ -271,6 +285,7 @@ abstract class PFAHandler {
|
||||
} else {
|
||||
$this->can_edit = $this->result['_can_edit'];
|
||||
$this->can_delete = $this->result['_can_delete'];
|
||||
$this->label = $this->result[$this->label_field];
|
||||
# return true;
|
||||
}
|
||||
}
|
||||
@ -326,7 +341,7 @@ abstract class PFAHandler {
|
||||
*/
|
||||
public function set($values) {
|
||||
if ( !$this->can_edit ) {
|
||||
$this->errormsg[] = Config::Lang_f('edit_not_allowed', $this->id);
|
||||
$this->errormsg[] = Config::Lang_f('edit_not_allowed', $this->label);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -463,7 +478,7 @@ abstract class PFAHandler {
|
||||
$result = db_update($this->db_table, $this->id_field, $this->id, $db_values);
|
||||
}
|
||||
if ($result != 1) {
|
||||
$this->errormsg[] = Config::lang_f($this->msg['store_error'], $this->id);
|
||||
$this->errormsg[] = Config::lang_f($this->msg['store_error'], $this->label);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -475,7 +490,7 @@ abstract class PFAHandler {
|
||||
if ($result) {
|
||||
# return success message
|
||||
# TODO: add option to override the success message (for example to include autogenerated passwords)
|
||||
$this->infomsg['success'] = Config::lang_f($this->msg['successmessage'], $this->id);
|
||||
$this->infomsg['success'] = Config::lang_f($this->msg['successmessage'], $this->label);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
Loading…
Reference in New Issue
Block a user