[evolvis-commits] r18256: [#2964] small-fixes pending merges:↵ Thorsten Glaser 2012-04-07 re-do the reordering routine; optimise unneeded reorder calls away↵ Thorsten Glaser 2012-04-07 alphaorderValues does not take any arguments…

mirabilos at evolvis.org mirabilos at evolvis.org
Sat Apr 7 15:41:40 CEST 2012


Author: mirabilos
Date: 2012-04-07 15:41:40 +0200 (Sat, 07 Apr 2012)
New Revision: 18256

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactExtraField.class.php
   trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactType.class.php
   trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/updates.php
Log:
[#2964] small-fixes pending merges:
  Thorsten Glaser 2012-04-07 re-do the reordering routine; optimise unneeded reorder calls away
    Thorsten Glaser 2012-04-07 alphaorderValues does not take any arguments…


Modified: trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactExtraField.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactExtraField.class.php	2012-04-07 13:41:35 UTC (rev 18255)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactExtraField.class.php	2012-04-07 13:41:40 UTC (rev 18256)
@@ -565,25 +565,36 @@
 			$this->setError(_('Out of range value'));
 			return false;
 		}
-		$data = array();
-		$i = 1;
-		$j = 0;
-		while ($i <= $max) {
-			if ($i == $new_pos) {
-				$data[] = $element_id;
-				$i++;
+		$new_pos--;
+		$cur_pos = -1;
+		for ($i = 0; $i < $max; ++$i) {
+			if ($res[$i]['element_id'] == $element_id) {
+				$cur_pos = $i;
 			}
-			if ($res[$j]['element_id'] != $element_id) {
-				$data[] = $res[$j]['element_id'];
-				$i++;
+		}
+		if ($cur_pos == -1 || $cur_pos == $new_pos) {
+			/* element not found or already at right position */
+			return true;
+		}
+		$nd = array();
+		$nc = 0;
+		for ($i = 0; $i < $max; ++$i) {
+			if ($i == $cur_pos) {
+				$np = $new_pos;
+			} else {
+				if ($nc == $new_pos) {
+					$nc++;
+				}
+				$np = $nc++;
 			}
-			$j++;
+			$nd[$np] = array($i, $res[$i]['element_id']);
 		}
-		for ($i = 0; $i < count($data); $i++) {
-			if (! $this->updateOrder($data[$i], $i + 1))
+		for ($i = 0; $i < $max; ++$i) {
+			if ($nd[$i][0] != $i &&
+			    !$this->updateOrder($nd[$i][1], $i + 1)) {
 				return false;
+			}
 		}
-
 		return true;
 	}
 

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/updates.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/updates.php	2012-04-07 13:41:35 UTC (rev 18255)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/updates.php	2012-04-07 13:41:40 UTC (rev 18256)
@@ -425,7 +425,7 @@
 			} elseif ($ac->isError()) {
 				$error_msg .= $ac->getErrorMessage();
 			} else {
-				if (!$ac->alphaorderValues($id)) {
+				if (!$ac->alphaorderValues()) {
 					$error_msg .= _('Error updating a custom field').' : '.$ac->getErrorMessage();
 					$ac->clearError();
 				} else {



More information about the evolvis-commits mailing list