PFAHandler:

- add $this->order_by to allow ordering by any field(s)
  (defaults to $this->id_field)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1730 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 10 years ago
parent 6bfe6706ba
commit b76511628d

@ -29,6 +29,11 @@ abstract class PFAHandler {
# defaults to $id_field if not set
protected $label_field = null;
# field(s) to use in the ORDER BY clause
# can contain multiple comma-separated fields
# defaults to $id_field if not set
protected $order_by = null;
# column containing the domain
# if a table does not contain a domain column, leave empty and override no_domain_field())
protected $domain_field = "";
@ -124,6 +129,11 @@ abstract class PFAHandler {
$this->label_field = $this->id_field;
}
# set order_by if not explicitely set
if (empty($this->order_by)) {
$this->order_by = $this->id_field;
}
if ($new) $this->new = 1;
if ($is_admin) {
@ -582,8 +592,7 @@ abstract class PFAHandler {
if ( (!$this->is_admin) && $this->user_field != '') {
$where .= " AND " . $this->user_field . " = '" . escape_string($this->username) . "' ";
}
$query = "SELECT $cols FROM $table $extrafrom $where ORDER BY " . $this->id_field;
$query = "SELECT $cols FROM $table $extrafrom $where ORDER BY " . $this->order_by;
$limit = (int) $limit; # make sure $limit and $offset are really integers
$offset = (int) $offset;

Loading…
Cancel
Save