[evolvis-commits] r18242: small-fixes pending merges:↵ Thorsten Glaser 2012-04-05 nuke all remnants of core/template_group config option↵ [#2966] Thorsten Glaser 2012-04-05 rewrite the Clone Tracker logic to take all template groups into account↵ Thorsten Glaser 2012-04-05 sort template groups by id, descending↵ Thorsten Glaser 2012-04-05 c'est ne pas français ici…

mirabilos at evolvis.org mirabilos at evolvis.org
Thu Apr 5 23:01:32 CEST 2012


Author: mirabilos
Date: 2012-04-05 23:01:31 +0200 (Thu, 05 Apr 2012)
New Revision: 18242

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/common/include/Group.class.php
   trunk/gforge_base/evolvisforge-5.1/src/common/include/config-vars.php
   trunk/gforge_base/evolvisforge-5.1/src/common/include/constants.php
   trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactType.class.php
   trunk/gforge_base/evolvisforge-5.1/src/deb-specific/install-chroot.sh
   trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/defaults.ini
   trunk/gforge_base/evolvisforge-5.1/src/etc/local.d/30homegroupother
   trunk/gforge_base/evolvisforge-5.1/src/etc/local.inc.example
   trunk/gforge_base/evolvisforge-5.1/src/utils/migrate-to-ini-files.sh
   trunk/gforge_base/evolvisforge-5.1/src/www/register/index.php
   trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/form-clonetracker.php
   trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/updates.php
Log:
small-fixes pending merges:
  Thorsten Glaser 2012-04-05 nuke all remnants of core/template_group config option
[#2966]    Thorsten Glaser 2012-04-05 rewrite the Clone Tracker logic to take all template groups into account
    Thorsten Glaser 2012-04-05 sort template groups by id, descending
    Thorsten Glaser 2012-04-05 c'est ne pas français ici…


Modified: trunk/gforge_base/evolvisforge-5.1/src/common/include/Group.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/include/Group.class.php	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/include/Group.class.php	2012-04-05 21:01:31 UTC (rev 18242)
@@ -2531,7 +2531,7 @@
 						$t = new ArtifactType ($this) ;
 						$t->create ($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->isPublic(),$o->allowsAnon(),$o->emailAll(),$o->getEmailAddress(),$o->getDuePeriod()/86400,0,$o->getSubmitInstructions(),$o->getBrowseInstructions()) ;
 						$id_mappings['tracker'][$o->getID()] = $t->getID() ;
-						$t->cloneFieldsFrom ($o->getID()) ;
+						$t->cloneFieldsFrom($template, $o->getID());
 					}
 				}
 			}
@@ -3243,36 +3243,36 @@
 
 class ProjectComparator {
 	var $criterion = 'name' ;
+	var $reverse = false ;
 
 	function Compare ($a, $b) {
 		switch ($this->criterion) {
 		case 'name':
 		default:
-			$namecmp = strcoll ($a->getPublicName(), $b->getPublicName()) ;
-			if ($namecmp != 0) {
-				return $namecmp ;
+			$res = strcoll ($a->getPublicName(), $b->getPublicName()) ;
+			if ($res != 0) {
+				break;
 			}
 			/* If several projects share a same public name */
-			return strcoll ($a->getUnixName(), $b->getUnixName()) ;
+			$res = strcoll ($a->getUnixName(), $b->getUnixName()) ;
 			break ;
 		case 'unixname':
-			return strcmp ($a->getUnixName(), $b->getUnixName()) ;
+			$res = strcmp ($a->getUnixName(), $b->getUnixName()) ;
 			break ;
 		case 'id':
 			$aid = $a->getID() ;
 			$bid = $b->getID() ;
-			if ($a == $b) {
-				return 0;
-			}
-			return ($a < $b) ? -1 : 1;
+			$res = ($a == $b) ? 0 : ($a < $b) ? -1 : 1;
 			break ;
 		}
+		return ($this->reverse ? -$res : $res);
 	}
 }
 
-function sortProjectList (&$list, $criterion='name') {
+function sortProjectList (&$list, $criterion='name', $reverse=false) {
 	$cmp = new ProjectComparator () ;
 	$cmp->criterion = $criterion ;
+	$cmp->reverse = $reverse ;
 
 	return usort ($list, array ($cmp, 'Compare')) ;
 }

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/include/config-vars.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/include/config-vars.php	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/include/config-vars.php	2012-04-05 21:01:31 UTC (rev 18242)
@@ -360,11 +360,6 @@
 } else {
 	forge_define_config_item ('peer_rating_group', 'core', 4) ;
 }
-if (isset ($GLOBALS['sys_template_group'])) {
-	forge_define_config_item ('template_group', 'core', $GLOBALS['sys_template_group']) ;
-} else {
-	forge_define_config_item ('template_group', 'core', 5) ;
-}
 if (isset ($GLOBALS['sys_sendmail_path'])) {
 	forge_define_config_item ('sendmail_path', 'core', $GLOBALS['sys_sendmail_path']) ;
 } else {

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/include/constants.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/include/constants.php	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/include/constants.php	2012-04-05 21:01:31 UTC (rev 18242)
@@ -68,7 +68,6 @@
 define('GROUP_IS_STATS', forge_get_config('stats_group'));
 define('GROUP_IS_NEWS', forge_get_config('news_group'));
 define('GROUP_IS_PEER_RATINGS', forge_get_config('peer_rating_group'));
-define('GROUP_IS_TEMPLATE', forge_get_config('template_group'));
 
 /* Admin */
 define('ADMIN_CRONMAN_ROWS', 30);

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactType.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactType.class.php	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/tracker/ArtifactType.class.php	2012-04-05 21:01:31 UTC (rev 18242)
@@ -645,16 +645,7 @@
 	 *
 	 *	@return	boolean	true/false on success
 	 */
-	function cloneFieldsFrom($clone_tracker_id) {
-
-		$g =& group_get_object(forge_get_config('template_group'));
-		if (!$g || !is_object($g)) {
-			$this->setError('Could Not Get Template Group');
-			return false;
-		} elseif ($g->isError()) {
-			$this->setError('Template Group Error '.$g->getErrorMessage());
-			return false;
-		}
+	function cloneFieldsFrom($g, $clone_tracker_id) {
 		$at = new ArtifactType($g,$clone_tracker_id);
 		if (!$at || !is_object($at)) {
 			$this->setError('Could Not Get Tracker To Clone');

Modified: trunk/gforge_base/evolvisforge-5.1/src/deb-specific/install-chroot.sh
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/deb-specific/install-chroot.sh	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/deb-specific/install-chroot.sh	2012-04-05 21:01:31 UTC (rev 18242)
@@ -16,7 +16,7 @@
 
 case $1 in
 configure)
-	echo "Installing chroot environnement at $CHROOTDIR"
+	echo "Installing chroot environment at $CHROOTDIR"
 	test -d "$CHROOTDIR" || install -d -m 755 "$CHROOTDIR"
 	test -d "$CHROOTDIR" || exit 1
 	for dir in \

Modified: trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/defaults.ini
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/defaults.ini	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/etc/config.ini.d/defaults.ini	2012-04-05 21:01:31 UTC (rev 18242)
@@ -48,7 +48,6 @@
 sendmail_path = "/usr/sbin/sendmail"
 show_source = no
 stats_group = 3
-template_group = 5
 unix_cipher = MD5
 url_prefix = "/"
 use_docman = yes

Modified: trunk/gforge_base/evolvisforge-5.1/src/etc/local.d/30homegroupother
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/etc/local.d/30homegroupother	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/etc/local.d/30homegroupother	2012-04-05 21:01:31 UTC (rev 18242)
@@ -77,7 +77,6 @@
 $sys_news_group={newsadmin_groupid};
 $sys_stats_group={statsadmin_groupid};
 $sys_peer_rating_group={peerrating_groupid};
-$sys_template_group={template_project};
 $default_trove_cat={default_trove_cat};
 
 // JPGRAPH Package

Modified: trunk/gforge_base/evolvisforge-5.1/src/etc/local.inc.example
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/etc/local.inc.example	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/etc/local.inc.example	2012-04-05 21:01:31 UTC (rev 18242)
@@ -282,7 +282,6 @@
 $sys_news_group=2;
 $sys_stats_group=3;
 $sys_peer_rating_group=4;
-$sys_template_group=5;
 $default_trove_cat=18;
 
 // JPGRAPH Package

Modified: trunk/gforge_base/evolvisforge-5.1/src/utils/migrate-to-ini-files.sh
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/utils/migrate-to-ini-files.sh	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/utils/migrate-to-ini-files.sh	2012-04-05 21:01:31 UTC (rev 18242)
@@ -82,7 +82,6 @@
 add_config core src_path >> $tmp
 add_config core stats_group >> $tmp
 add_config core sys_proxy >> $tmp
-add_config core template_group >> $tmp
 add_config core themes_root >> $tmp
 add_config core unix_cipher >> $tmp
 add_config core upload_dir >> $tmp

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/register/index.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/register/index.php	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/register/index.php	2012-04-05 21:01:31 UTC (rev 18242)
@@ -51,7 +51,7 @@
 }
 
 $template_projects = group_get_template_projects() ;
-sortProjectList ($template_projects) ;
+sortProjectList ($template_projects, 'id', true) ;
 
 if (getStringFromRequest('submit')) {
 	if (!form_key_is_valid(getStringFromRequest('form_key'))) {

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/form-clonetracker.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/form-clonetracker.php	2012-04-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/form-clonetracker.php	2012-04-05 21:01:31 UTC (rev 18242)
@@ -1,9 +1,10 @@
 <?php
-/**
- * FusionForge Tracker Cloning Form
+/*-
+ * FusionForge form for applying a template tracker ("cloning")
  *
- * Copyright 2010, FusionForge Team
- * http://fusionforge.org
+ * Copyright © 2012
+ *	Thorsten Glaser <t.glaser at tarent.de>
+ * All rights reserved.
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -21,46 +22,71 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-$g = group_get_object(forge_get_config('template_group'));
-if (!$g || !is_object($g)) {
-	exit_no_group();
-} elseif ($g->isError()) {
-	exit_error($g->getErrorMessage(),'tracker');
-} else {
-	$atf = new ArtifactTypeFactory($g);
-	if (!$atf || !is_object($atf)) {
-		exit_error(_('Unable to Create Template Group Object'),'tracker');
-	} elseif ($atf->isError()) {
-		exit_error($atf->getErrorMessage(),'tracker');
-	} else {
-		$ata = $atf->getArtifactTypes();
-		$ids = array();
-		$titles = array();
-		for ($i=0; $i<count($ata); $i++) {
-			if (!$ata[$i] || $ata[$i]->isError()) {
-//skip it
-			} else {
-				$ids[]=$ata[$i]->getID();
-				$titles[]=$g->getPublicName().'::'.$ata[$i]->getName();
-			}
-		}
+$tlist = group_get_template_projects();
+sortProjectList($tlist, 'id', true);
 
-		$ath->adminHeader(array ('title'=>_('Clone Tracker')));
+$ids = array();
+$names = array();
+$has_error = false;
 
-		if (empty($ata)) {
-			echo '<div class="warning_msg">'._('The site administrator must first set up template trackers in the template projet with default values and set permissions propertly so you can access them.').'</div>';
-		} else {
-		?>
-		<p><?php echo _('Choose the template tracker to clone.') ?></p>
-		<form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&atid='.$ath->getID(); ?>" method="post">
-		<input type="hidden" name="clone_tracker" value="y" />
-		<div class="warning" ><?php echo _('WARNING!!! Cloning this tracker will duplicate all the fields and all the elements from those fields into this tracker. There is nothing to prevent you from cloning multiple times or making a huge mess. You have been warned!') ?></div>
-		<p><?php echo html_build_select_box_from_arrays($ids,$titles,'clone_id','',false); ?></p>
-		<input type="submit" name="post_changes" value="<?php echo _('Submit') ?>" />
-		</form>
-<?php
+foreach ($tlist as $tp) {
+	if (!$tp || !is_object($tp) || $tp->isError()) {
+		/* skip it */
+		$has_error = true;
+		continue;
+	}
+	$atf = new ArtifactTypeFactory($tp);
+	if (!$atf || !is_object($atf) || $atf->isError()) {
+		$has_error = true;
+		continue;
+	}
+	$ats = $atf->getArtifactTypes();
+	$ata = array();
+	foreach ($ats as $at) {
+		if (!$at || !is_object($at) || $at->isError()) {
+			$has_error = true;
+			continue;
 		}
-		$ath->footer(array());
+		$ata[$at->getID()] = $at;
 	}
+	uasort($ata, create_function('$a, $b', '
+		$av = $a->getName();
+		$bv = $b->getName();
+
+		return strcoll($av, $bv);
+	    '));
+	foreach ($ata as $aid => $at) {
+		$ids[] = $aid;
+		$names[] = sprintf('%s::%s (%d::%d)',
+		    $tp->getPublicName(), $at->getName(),
+		    $tp->getID(), $aid);
+	}
 }
-?>
+
+if (!$ids) {
+	exit_error($has_error ? _('Error looking up template projects') :
+	    _('No template project found'), 'tracker');
+}
+
+if ($has_error) {
+	$warning_msg = _('Some errors occured during template project lookup');
+}
+
+$ath->adminHeader(array('title' => _('Apply Template Tracker')));
+
+echo "<p>" . _('Choose the template tracker to clone.') . "</p>\n";
+
+echo '<form action="' . getStringFromServer('PHP_SELF') .
+    '?group_id=' . $group_id . '&atid=' . $ath->getID() .
+    '" method="post">
+	<input type="hidden" name="clone_tracker" value="y" />
+	<div class="warning">' .
+    _('WARNING!!! Cloning this tracker will duplicate all the fields and all the elements from those fields into this tracker. There is nothing to prevent you from cloning multiple times or making a huge mess. You have been warned!') .
+    '</div>
+	<p>' . html_build_select_box_from_arrays($ids, $names,
+    'clone_id', '', false) . '</p>
+	<input type="submit" name="post_changes" value="' .
+    _('Submit') . '" />
+</form>';
+
+$ath->footer(array());

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-05 21:01:23 UTC (rev 18241)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/updates.php	2012-04-05 21:01:31 UTC (rev 18242)
@@ -274,7 +274,13 @@
 			if (!$clone_id) {
 				exit_missing_param('',array(_('Clone ID')),'tracker');
 			}
-			if (!$ath->cloneFieldsFrom($clone_id)) {
+			$clone_gid = artifacttype_get_groupid($clone_id);
+			$clone_group = $clone_gid ? group_get_object($clone_gid) : false;
+			if (!$clone_group || !is_object($clone_group) ||
+			    $clone_group->isError()) {
+				exit_error(_('Error looking up template project'), 'tracker');
+			}
+			if (!$ath->cloneFieldsFrom($clone_group, $clone_id)) {
 				exit_error(_('Error cloning fields: ').$ath->getErrorMessage(),'tracker');
 			} else {
 				$feedback .= _('Successfully Cloned Tracker Fields ');



More information about the evolvis-commits mailing list