fixed page sorting

This commit is contained in:
Roland Gruber 2011-09-23 09:44:38 +00:00
parent bc66f62f07
commit f1288b3e54
1 changed files with 17 additions and 10 deletions

View File

@ -687,8 +687,8 @@ class accountContainer {
/** Name of accountContainer variable in session */ /** Name of accountContainer variable in session */
private $base; private $base;
/** This variable stores the name of the currently displayed page */ /** This variable stores the page number of the currently displayed page */
private $current_page; private $current_page = 0;
/** This variable is set to the pagename of a subpage if it should be displayed */ /** This variable is set to the pagename of a subpage if it should be displayed */
private $subpage; private $subpage;
@ -1558,29 +1558,29 @@ class accountContainer {
} }
// Complete dn with RDN attribute // Complete dn with RDN attribute
$search = $this->rdn; $search = $this->rdn;
$added = false; $DNChanged = false;
foreach ($attributes as $DN) { foreach ($attributes as $DN) {
if (isset($DN['modify'][$search][0]) && !$added) { if (isset($DN['modify'][$search][0]) && !$DNChanged) {
$attributes[$search.'='.$DN['modify'][$search][0].','.$this->finalDN] = $attributes[$this->finalDN]; $attributes[$search.'='.$DN['modify'][$search][0].','.$this->finalDN] = $attributes[$this->finalDN];
unset ($attributes[$this->finalDN]); unset ($attributes[$this->finalDN]);
$this->finalDN = $search.'='.$DN['modify'][$search][0].','.$this->finalDN; $this->finalDN = $search.'='.$DN['modify'][$search][0].','.$this->finalDN;
$added = true; $DNChanged = true;
} }
if (isset($DN['add'][$search][0]) && !$added) { if (isset($DN['add'][$search][0]) && !$DNChanged) {
$attributes[$search.'='.$DN['add'][$search][0].','.$this->finalDN] = $attributes[$this->finalDN]; $attributes[$search.'='.$DN['add'][$search][0].','.$this->finalDN] = $attributes[$this->finalDN];
unset ($attributes[$this->finalDN]); unset ($attributes[$this->finalDN]);
$this->finalDN = $search.'='.$DN['add'][$search][0].','.$this->finalDN; $this->finalDN = $search.'='.$DN['add'][$search][0].','.$this->finalDN;
$added = true; $DNChanged = true;
} }
if (isset($DN['notchanged'][$search][0]) && !$added) { if (isset($DN['notchanged'][$search][0]) && !$DNChanged) {
$attributes[$search.'='.$DN['notchanged'][$search][0].','.$this->finalDN] = $attributes[$this->finalDN]; $attributes[$search.'='.$DN['notchanged'][$search][0].','.$this->finalDN] = $attributes[$this->finalDN];
unset ($attributes[$this->finalDN]); unset ($attributes[$this->finalDN]);
$this->finalDN = $search.'='.$DN['notchanged'][$search][0].','.$this->finalDN; $this->finalDN = $search.'='.$DN['notchanged'][$search][0].','.$this->finalDN;
$added = true; $DNChanged = true;
} }
} }
// Add old dn if dn hasn't changed // Add old dn if dn hasn't changed
if (!$added) { if (!$DNChanged) {
$attributes[$this->dn_orig] = $attributes[$this->finalDN]; $attributes[$this->dn_orig] = $attributes[$this->finalDN];
unset ($attributes[$this->finalDN]); unset ($attributes[$this->finalDN]);
$this->finalDN = $this->dn_orig; $this->finalDN = $this->dn_orig;
@ -1746,6 +1746,9 @@ class accountContainer {
$order = array(); $order = array();
$modules = array_keys($this->module); $modules = array_keys($this->module);
$depModules = array(); $depModules = array();
if (isset($this->order)) {
$currentPage = $this->order[$this->current_page];
}
for ($i = 0; $i < sizeof($modules); $i++) { for ($i = 0; $i < sizeof($modules); $i++) {
// insert waiting modules // insert waiting modules
for ($w = 0; $w < sizeof($depModules); $w++) { for ($w = 0; $w < sizeof($depModules); $w++) {
@ -1808,6 +1811,10 @@ class accountContainer {
} }
} }
$this->order = array_merge($activeModules, $passiveModules); $this->order = array_merge($activeModules, $passiveModules);
// check if ordering changed and current page number must be updated
if (isset($currentPage) && ($currentPage != $this->order[$this->current_page])) {
$this->current_page = array_search($currentPage, $this->order);
}
} }
/** /**