[Fusionforge-commits] r11719 - in branches/Branch_5_1: src/common/include src/db src/plugins/cvstracker/db src/www/admin tests/func/Testing

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Tue Dec 7 20:52:50 CET 2010


Author: aljeux
Date: 2010-12-07 20:52:50 +0100 (Tue, 07 Dec 2010)
New Revision: 11719

Added:
   branches/Branch_5_1/src/common/include/DatabaseInstaller.class.php
Modified:
   branches/Branch_5_1/src/common/include/Error.class.php
   branches/Branch_5_1/src/common/include/Plugin.class.php
   branches/Branch_5_1/src/db/upgrade-db.php
   branches/Branch_5_1/src/plugins/cvstracker/db/20050305.sql
   branches/Branch_5_1/src/www/admin/pluginman.php
   branches/Branch_5_1/tests/func/Testing/SeleniumGforge.php
Log:
Add support for plugin upgrade & pluginman improvement:
* Removed confusing init checkbox, now auto detected.
* Improved upgrade-db.php to manage plugins also.
* Hack to allow conditional SQL in db upgrade file.
* Add return false in setError() to allow cleaner code.

Added: branches/Branch_5_1/src/common/include/DatabaseInstaller.class.php
===================================================================
--- branches/Branch_5_1/src/common/include/DatabaseInstaller.class.php	                        (rev 0)
+++ branches/Branch_5_1/src/common/include/DatabaseInstaller.class.php	2010-12-07 19:52:50 UTC (rev 11719)
@@ -0,0 +1,128 @@
+<?php
+
+class DatabaseInstaller extends Error {
+	
+	function DatabaseInstaller($name='', $path='') {
+		$this->name = $name;
+		$this->path	= $path;	
+	}
+
+	function install() {
+		$name = $this->name;
+		$path = $this->path;
+
+		$init = "$path/$name-init.sql";
+		if (is_file($init)) {
+			$ret = $this->runScript($init);
+			if (!$ret) {
+				return false;
+			}
+			return $this->upgrade($name, $path);
+		}
+		return $this->setError(_('No database installation scripts found.'));
+	}
+	
+	function upgrade() {
+		$name = $this->name;
+		$path = $this->path;
+
+		if ($name) {
+			$prefix = $name.':';
+			$date   = -1;
+		} else {
+			$prefix = '';
+			$date   = $this->getDatabaseDate();
+		}
+
+		$scripts = $this->getScripts($path);
+		$output  = '';
+		foreach ($scripts as $script) {
+			if ((int) $script['date'] > $date) {
+				$res = db_query_params ('SELECT * FROM database_changes WHERE filename=$1',
+					array ($prefix.$script['filename'])) ;
+				if (!$res) {
+					return $this->setError("ERROR-2: ".db_error());
+				} else if (db_numrows($res) == 0) {
+					$output .= "Running script: {$script['filename']}\n";
+					$result = $this->runScript($path.'/'.$script['filename']);
+					if ($result) {
+						$res = db_query_params ('INSERT INTO database_changes (filename) VALUES ($1)',
+							array ($prefix.$script['filename'])) ;
+						if (!$res) {
+							return $this->setError("ERROR-3: ".db_error());
+						}
+					} else {
+						return false;
+					}
+				} else {
+//					$output .= "Skipping script: $prefix{$script['filename']}\n";
+				}
+			}
+		}
+		return $output;
+	}
+	
+	private static function getDatabaseDate() {
+		// Check if table 'database_startpoint' has proper values
+		$res = db_query_params ('SELECT * FROM database_startpoint', array()) ;
+		if (!$res) { // db error
+			return $this->setError("DB-ERROR-3: ".db_error()."\n");
+		} else if (db_numrows($res) == 0) { // table 'database_startpoint' is empty
+			return $this->setError("Table 'database_startpoint' is empty, run startpoint.php first.");
+		} else { // get the start date from the db
+			return (int) db_result($res, 0, 'db_start_date');
+		}
+		return false;
+	}
+
+	private function runScript($file) {
+		// If a condition statement if found, then run the script only if true.
+		$content = file($file);
+		if (preg_match('/^-- TRUE\? (.+)/', $content[0], $match)) {
+			$res = db_query_params($match[1], array());
+			if (db_result($res,0,0) == 'f') {
+				return true;
+			}
+		}
+		$res = db_query_from_file($file);
+		if ($res) {
+			while ($res) {
+				db_free_result($res);
+				$res = db_next_result();
+			}
+		} else {
+			return $this->setError(_('Database initialisation error:').' '.db_error());
+		}
+		return true;
+	}
+
+	private static function getScripts($dir) {
+		$data = array();
+		if (is_dir($dir)) {
+			if ($dh = opendir($dir)) {
+				while (($file = readdir($dh)) !== false) {
+					$pos = strrpos($file, '.');
+					if ($pos !== false && $pos > 0) {
+						$name = substr($file, 0, $pos);
+						if (strlen($name) >= 8) {
+							$date_aux = substr($name, 0, 8);
+							$type_aux = substr($file, $pos + 1);
+							if ((int) $date_aux > 20000000 && ($type_aux=='sql' || $type_aux=='php') 
+								&& strpos($file, 'debian') === false) {
+								$data[] = array('date'=>$date_aux, 'filename'=>$file, 'ext'=>$type_aux);
+							}
+						}
+					}
+				}
+				closedir($dh);
+			}
+			usort($data, array('DatabaseInstaller', 'compare_scripts'));
+			reset($data);
+		}
+		return $data;
+	}
+
+	private static function compare_scripts($script1, $script2) {
+		return strcmp($script1['filename'], $script2['filename']);
+	}
+}

Modified: branches/Branch_5_1/src/common/include/Error.class.php
===================================================================
--- branches/Branch_5_1/src/common/include/Error.class.php	2010-12-07 19:40:22 UTC (rev 11718)
+++ branches/Branch_5_1/src/common/include/Error.class.php	2010-12-07 19:52:50 UTC (rev 11719)
@@ -76,6 +76,7 @@
 		$this->error_state=true;
 		$this->error_message=$string;
 		$this->error_code=$code;
+		return false;
 	}
 
 	/**

Modified: branches/Branch_5_1/src/common/include/Plugin.class.php
===================================================================
--- branches/Branch_5_1/src/common/include/Plugin.class.php	2010-12-07 19:40:22 UTC (rev 11718)
+++ branches/Branch_5_1/src/common/include/Plugin.class.php	2010-12-07 19:52:50 UTC (rev 11719)
@@ -137,7 +137,78 @@
 	function registerRoleValues(&$params, $values) {
 		$role =& $params['role'] ;
 	}
-		
+
+	function install() {
+		$this->installCode();
+		$this->installConfig();
+		$this->installDatabase();
+	}
+
+	function installCode() {
+		$name = $this->name;
+		$path = forge_get_config('plugins_path') . '/' . $name;
+		$installdir = $this->getInstallDir();
+
+		// Create a symbolic links to plugins/<plugin>/www (if directory exists).
+		if (is_dir($path . '/www')) { // if the plugin has a www dir make a link to it
+			// The apache group or user should have write perms the www/plugins folder...
+			if (!is_link('../'.$installdir)) {
+				$code = symlink($path . '/www', '../'.$installdir);
+				if (!$code) {
+					$this->setError('['.'../'.$installdir.'->'.$path . '/www]'.
+						'<br />Soft link to www couldn\'t be created. Check the write permissions for apache in gforge www/plugins dir or create the link manually.');
+				}
+			}
+		}
+
+		// Create a symbolic links to plugins/<plugin>/etc/plugins/<plugin> (if directory exists).
+		if (is_dir($path . '/etc/plugins/' . $name)) {
+			// The apache group or user should have write perms in /etc/gforge/plugins folder...
+			if (!is_link(forge_get_config('config_path'). '/plugins/'.$name) && !is_dir(forge_get_config('config_path'). '/plugins/'.$name)) {
+				$code = symlink($path . '/etc/plugins/' . $name, forge_get_config('config_path'). '/plugins/'.$name);
+				if (!$code) {
+					$this->setError('['.forge_get_config('config_path'). '/plugins/'.$name.'->'.$path . '/etc/plugins/' . $name . ']'.
+					_('<br />Config file could not be linked to etc/gforge/plugins/%1$s. Check the write permissions for apache in /etc/gforge/plugins or create the link manually.'), $name);
+				}
+			}
+		}
+	}
+
+	function installConfig() {
+		$name = $this->name;
+		$path = forge_get_config('plugins_path') . '/' . $name;
+
+		// Create a symbolic links to plugins/<plugin>/etc/plugins/<plugin> (if directory exists).
+		if (is_dir($path . '/etc/plugins/' . $name)) {
+			// The apache group or user should have write perms in /etc/gforge/plugins folder...
+			if (!is_link(forge_get_config('config_path'). '/plugins/'.$name) && !is_dir(forge_get_config('config_path'). '/plugins/'.$name)) {
+				$code = symlink($path . '/etc/plugins/' . $name, forge_get_config('config_path'). '/plugins/'.$name);
+				if (!$code) {
+					$this->setError('['.forge_get_config('config_path'). '/plugins/'.$name.'->'.$path . '/etc/plugins/' . $name . ']'.
+					_('<br />Config file could not be linked to etc/gforge/plugins/%1$s. Check the write permissions for apache in /etc/gforge/plugins or create the link manually.'), $name);
+				}
+			}
+		}
+	}
+
+	function installDatabase() {
+		$name = $this->name;
+		$path = forge_get_config('plugins_path') . '/' . $name . '/db';
+
+		require_once $GLOBALS['gfcommon'].'include/DatabaseInstaller.class.php';
+		$di = new DatabaseInstaller($name, $path);
+
+		// Search for database tables, if present then upgrade.
+		$res=db_query_params ('SELECT COUNT(*) FROM pg_class WHERE (relname=$1 OR relname like $2) AND relkind=$3',
+			array ('plugin_'.$name, 'plugin_'.$name.'_%', 'r'));
+		$count = db_result($res,0,0);
+		if ($count == 0) {
+			$di->install();
+		} else {
+			$di->upgrade();
+		}
+	}
+
 	function groupisactivecheckbox (&$params) {
 		//Check if the group is active
 		// this code creates the checkbox in the project edit public info page to activate/deactivate the plugin

Modified: branches/Branch_5_1/src/db/upgrade-db.php
===================================================================
--- branches/Branch_5_1/src/db/upgrade-db.php	2010-12-07 19:40:22 UTC (rev 11718)
+++ branches/Branch_5_1/src/db/upgrade-db.php	2010-12-07 19:52:50 UTC (rev 11719)
@@ -1,6 +1,10 @@
 #! /usr/bin/php
 <?php
 
+// upgrade-db.php          => Upgrade the main database.
+// upgrade-db.php all      => Upgrade the main database and active plugins.
+// upgrade-db.php <plugin> => Upgrade only the database of the given active plugin.
+
 require_once dirname(__FILE__).'/../www/env.inc.php';
 require_once $gfcommon.'include/pre.php';
 
@@ -72,37 +76,60 @@
 	exit();
 }
 
-$scripts = get_scripts($db_path);
-
-foreach ($scripts as $script) {
-	if ((int) $script['date'] > $date) {
-		$res = db_query_params ('SELECT * FROM database_changes WHERE filename=$1',
-					array ("{$script['filename']}")) ;
-		if (!$res) {
-			// error
-			show("ERROR-2: ".db_error()."\n");
-			exit();
-		} else if (db_numrows($res) == 0) {
-			show("Running script: {$script['filename']}\n");
-			$result = run_script($script);
-			if ($result) {
-				$res = db_query_params ('INSERT INTO database_changes (filename) VALUES ($1)',
-							array ("{$script['filename']}")) ;
-				if (!$res)
-				{
-					show("ERROR-3: ".db_error()."\n");
+// Upgrade main database if no argument or if all)
+if ($argc == 1 || $argv[1] == 'all') {
+	$scripts = get_scripts($db_path);
+	foreach ($scripts as $script) {
+		if ((int) $script['date'] > $date) {
+			$res = db_query_params ('SELECT * FROM database_changes WHERE filename=$1',
+						array ("{$script['filename']}")) ;
+			if (!$res) {
+				// error
+				show("ERROR-2: ".db_error()."\n");
+				exit();
+			} else if (db_numrows($res) == 0) {
+				show("Running script: {$script['filename']}\n");
+				$result = run_script($script);
+				if ($result) {
+					$res = db_query_params ('INSERT INTO database_changes (filename) VALUES ($1)',
+								array ("{$script['filename']}")) ;
+					if (!$res)
+					{
+						show("ERROR-3: ".db_error()."\n");
+						exit();
+					}
+				} else {
+					// error
 					exit();
 				}
 			} else {
-				// error
-				exit();
+	//			show("Skipping script: {$script['filename']}\n");
 			}
-		} else {	
-			show("Skipping script: {$script['filename']}\n");
 		}
 	}
 }
 
+// Upgrade activated plugins.
+if ($argc == 2) {
+	require_once $gfcommon.'include/DatabaseInstaller.class.php';
+	$plugins = get_installed_plugins();
+	foreach ($plugins as $plugin) {
+		if ($argv[1] == 'all' || $argv[1] == $plugin) {
+			$di = new DatabaseInstaller($plugin, dirname($db_path) . '/plugins/' . $plugin . '/db');
+			echo $di->upgrade();
+		}
+	}
+}
+
+function get_installed_plugins() {
+	$plugins = array();
+	$res = db_query_params ('SELECT plugin_name FROM plugins', array ());
+	while ($row = db_fetch_array($res)) {
+		$plugins[] = $row['plugin_name'];
+	}
+	return $plugins;
+}
+
 function get_scripts($dir) {
 	$data = array();
 	if (is_dir($dir)) {

Modified: branches/Branch_5_1/src/plugins/cvstracker/db/20050305.sql
===================================================================
--- branches/Branch_5_1/src/plugins/cvstracker/db/20050305.sql	2010-12-07 19:40:22 UTC (rev 11718)
+++ branches/Branch_5_1/src/plugins/cvstracker/db/20050305.sql	2010-12-07 19:52:50 UTC (rev 11719)
@@ -1,3 +1,5 @@
+-- TRUE? SELECT data_type = 'date' FROM information_schema.columns WHERE table_name = 'plugin_cvstracker_data_master' AND column_name='cvs_date';
+
 DROP INDEX plugin_cvstracker_group_artifact_id;
 
 ALTER TABLE plugin_cvstracker_data_master ADD COLUMN cvs_date2 int4;
@@ -11,4 +13,4 @@
 CREATE INDEX plugincvstrackerdataartifact_projecttaskid ON plugin_cvstracker_data_artifact(project_task_id);
 
 CREATE INDEX plugincvstrackerdatamaster_holderid ON plugin_cvstracker_data_master(holder_id);
-CREATE INDEX plugincvstrackerdatamaster_cvsdate ON plugin_cvstracker_data_master(cvs_date);
\ No newline at end of file
+CREATE INDEX plugincvstrackerdatamaster_cvsdate ON plugin_cvstracker_data_master(cvs_date);

Modified: branches/Branch_5_1/src/www/admin/pluginman.php
===================================================================
--- branches/Branch_5_1/src/www/admin/pluginman.php	2010-12-07 19:40:22 UTC (rev 11718)
+++ branches/Branch_5_1/src/www/admin/pluginman.php	2010-12-07 19:52:50 UTC (rev 11719)
@@ -36,26 +36,23 @@
 	$pluginname = getStringFromRequest('update');
 	
 	if ((getStringFromRequest('action')=='deactivate')) {
-		if (getStringFromRequest('delusers')) {
 
-			$res = db_query_params ('DELETE FROM user_plugin WHERE plugin_id = (SELECT plugin_id FROM plugins WHERE plugin_name = $1)',
+		$res = db_query_params ('DELETE FROM user_plugin WHERE plugin_id = (SELECT plugin_id FROM plugins WHERE plugin_name = $1)',
 			array($pluginname));
-			if (!$res) {
-				exit_error(db_error(),'admin');
-			} else {
-				$feedback .= sprintf(ngettext('%d user detached from plugin.', '%d users detached from plugin.', db_affected_rows($res)), db_affected_rows($res));
-			}
+		if (!$res) {
+			exit_error(db_error(),'admin');
+		} else {
+			$feedback .= sprintf(ngettext('%d user detached from plugin.', '%d users detached from plugin.', db_affected_rows($res)), db_affected_rows($res));
 		}
-		if (getStringFromRequest('delgroups')) {
 
-			$res = db_query_params ('DELETE FROM group_plugin WHERE plugin_id = (SELECT plugin_id FROM plugins WHERE plugin_name = $1)',
+		$res = db_query_params ('DELETE FROM group_plugin WHERE plugin_id = (SELECT plugin_id FROM plugins WHERE plugin_name = $1)',
 			array($pluginname));
-			if (!$res) {
-				exit_error(db_error(),'admin');
-			} else {
-				$feedback .= sprintf(ngettext('%d project detached from plugin.', '%d projects detached from plugin.', db_affected_rows($res)), db_affected_rows($res));
-			}
+		if (!$res) {
+			exit_error(db_error(),'admin');
+		} else {
+			$feedback .= sprintf(ngettext('%d project detached from plugin.', '%d projects detached from plugin.', db_affected_rows($res)), db_affected_rows($res));
 		}
+
 		$res = $pm->deactivate($pluginname);
 		if (!$res) {
 			exit_error(db_error(),'admin');
@@ -98,62 +95,11 @@
 			// Load the plugin and now get information from it.
 			$pm = plugin_manager_get_object();
 			$pm->LoadPlugin($pluginname);
-			$plugin = $pm->GetPluginObject($pluginname);
-			$installdir = $plugin->getInstallDir();
 
-			// Create a symbolic links to plugins/<plugin>/www (if directory exists).
-			if (is_dir(forge_get_config('plugins_path') . '/' . $pluginname . '/www')) { // if the plugin has a www dir make a link to it
-				// The apache group or user should have write perms the www/plugins folder...
-				if (!is_link('../'.$installdir)) {
-					$code = symlink(forge_get_config('plugins_path') . '/' . $pluginname . '/www', '../'.$installdir); 
-					if (!$code) {
-						$error_msg .= '<br />['.'../'.$installdir.'->'.forge_get_config('plugins_path') . '/' . $pluginname . '/www]';
-						$error_msg .= _('<br />Soft link to www couldn\'t be created. Check the write permissions for apache in gforge www/plugins dir or create the link manually.');
-					}
-				}
-			}
-				
-			// Create a symbolic links to plugins/<plugin>/etc/plugins/<plugin> (if directory exists).
-			if (is_dir(forge_get_config('plugins_path') . '/' . $pluginname . '/etc/plugins/' . $pluginname)) {
-				// The apache group or user should have write perms in /etc/gforge/plugins folder...
-				if (!is_link(forge_get_config('config_path'). '/plugins/'.$pluginname) && !is_dir(forge_get_config('config_path'). '/plugins/'.$pluginname)) {
-					$code = symlink(forge_get_config('plugins_path') . '/' . $pluginname . '/etc/plugins/' . $pluginname, forge_get_config('config_path'). '/plugins/'.$pluginname); 
-					if (!$code) {
-						$error_msg .= '<br />['.forge_get_config('config_path'). '/plugins/'.$pluginname.'->'.forge_get_config('plugins_path') . '/' . $pluginname . '/etc/plugins/' . $pluginname . ']';
-						$error_msg .= sprintf(_('<br />Config file could not be linked to etc/gforge/plugins/%1$s. Check the write permissions for apache in /etc/gforge/plugins or create the link manually.'), $pluginname);
-					}
-				}
-			}
-
-			if (getStringFromRequest('init')) {
-				// now we're going to check if there's a XX-init.sql file and run it
-				$db_init = forge_get_config('plugins_path') . '/' . $pluginname . '/db/' . $pluginname . '-init-pgsql.sql';
-				if (!is_file($db_init)) {
-					$db_init = forge_get_config('plugins_path') . '/' . $pluginname . '/db/' . $pluginname . '-init.sql';
-					if (!is_file($db_init)) {
-						$db_init = 0;
-					}
-				}
-					
-				if ($db_init) {
-					$res = db_query_from_file($db_init);
-					
-					if ($res) {
-						while ($res) {
-							db_free_result($res);
-							$res = db_next_result();
-						}
-					} else {
-						$error_msg .= _('Initialisation error<br />Database said: ').db_error();
-					}
-				}	
-				//we check for a php script	
-				if (is_file(forge_get_config('plugins_path') . '/' . $pluginname . '/script/' . $pluginname . '-init.php')) {
-					include(forge_get_config('plugins_path') . '/' . $pluginname . '/script/' . $pluginname . '-init.php');		
-				} else {
-					
-				}
-			}
+			$plugin = $pm->GetPluginObject($pluginname);
+			$plugin->installCode();
+			$plugin->installConfig();
+			$plugin->installDatabase();
 		}
 	}
 }
@@ -162,34 +108,18 @@
 echo '<h1>' . _('Plugin Manager') . '</h1>';
 
 ?>
-<script type="text/javascript">
-<!--
-	function change(url,plugin)
-	{
-		field = document.theform.elements[plugin];
-		if (field.checked) {
-			window.location=(url + "&init=yes");
-		} else {
-			window.location=(url);
-		}
-	}
-
-// -->
-</script>
-
 <form name="theform" action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="get">
 <?php
 echo '<p>';
 echo _('Here you can activate / deactivate site-wide plugins which are in the plugins/ folder. Then, you should activate them also per project, per user or whatever the plugin specifically applies to.');
 echo '</p>';
 echo '<p class="important">' . _('Be careful because some projects/users can be using the plugin. Deactivating it will remove the plugin from all users/projects.') . '</p>';
-echo '<p class="important">' . _('Be EXTRA careful running the SQL init script when a plugin has been deactivated prior use (and you want to re-activate) because some scripts have DROP TABLE statements.') . '</p>';
+
 $title_arr = array( _('Plugin Name'),
 		    _('Status'),
 		    _('Action'),
-		    _('Run Init Script?'),
 		    _('Users Using it'),
-				_('Projects Using it'),);
+			_('Projects Using it'),);
 echo $HTML->listTableTop($title_arr);
 
 // Get the activated plugins.
@@ -208,7 +138,6 @@
 //get the directories from the plugins dir
 
 $filelist = array();
-$has_init = array();
 if($handle = opendir(forge_get_config('plugins_path'))) {
 	while (($filename = readdir($handle)) !== false) {
 		if ($filename!='..' && $filename!='.' && $filename!=".svn" && $filename!="CVS" &&
@@ -216,7 +145,6 @@
 		    !in_array($filename, $plugins_disabled)) {
 
 			$filelist[] = $filename;
-			$has_init[$filename] = is_dir(forge_get_config('plugins_path').'/'.$filename.'/db');
 		}
 	}
 	closedir($handle);
@@ -226,25 +154,22 @@
 $j = 0;
 
 foreach ($filelist as $filename) {
-	$init = '<input type="hidden" id="'.$filename.'" name="script[]" value="'.$filename.'" />';
 	if ($pm->PluginIsInstalled($filename)) {
 		$msg = _('Active');
-		$status="active";
-		$link = "<a href=\"javascript:change('" . getStringFromServer('PHP_SELF') . "?update=$filename&amp;action=deactivate";
+		$status = "active";
+		$link = util_make_link("/admin/pluginman.php?update=$filename&amp;action=deactivate", _('Deactivate'));
 
-		$res = db_query_params ('SELECT  u.user_name FROM plugins p, user_plugin up, users u WHERE p.plugin_name = $1 and up.user_id = u.user_id and p.plugin_id = up.plugin_id',
+		$res = db_query_params ('SELECT u.user_name FROM plugins p, user_plugin up, users u WHERE p.plugin_name = $1 and up.user_id = u.user_id and p.plugin_id = up.plugin_id',
 			array($filename));
 		if ($res) {
 			if (db_numrows($res)>0) {
-				// tell the form to delete the users, so that we don't re-do the query
-				$link .= "&amp;delusers=1";
 				$users = " ";
 				for($i=0;$i<db_numrows($res);$i++) {
 					$users .= db_result($res,$i,0) . " | ";
 				}
 				$users = substr($users,0,strlen($users) - 3); //remove the last |
 			} else {
-				$users = _("none");
+				$users = _('None');
 			}
 		}
 
@@ -252,37 +177,27 @@
 			array($filename));
 		if ($res) {
 			if (db_numrows($res)>0) {
-				// tell the form to delete the groups, so that we don't re-do the query
-				$link .= "&amp;delgroups=1";
 				$groups = " ";
 				for($i=0;$i<db_numrows($res);$i++) {
 					$groups .= db_result($res,$i,0) . " | ";
 				}
 				$groups = substr($groups,0,strlen($groups) - 3); //remove the last |
 			} else {
-				$groups = _("none");
+				$groups = _('None');
 			}
 		}
-		$link .= "','$filename');" . '">' . _('Deactivate') . "</a>";
-		if ($has_init[$filename]) {
-			$init = '<input id="'.$filename.'" type="checkbox" disabled="disabled" name="script[]" value="'.$filename.'" />';
-		}
 	} else {
 		$msg = _('Inactive');
 		$status = "inactive";
-		$link = "<a href=\"javascript:change('" . getStringFromServer('PHP_SELF') . "?update=$filename&amp;action=activate','$filename');" . '">' . _('Activate') . "</a>";
-		if ($has_init[$filename]) {
-			$init = '<input id="'.$filename.'" type="checkbox" name="script[]" value="'.$filename.'" />';
-		}
-		$users = _("none");
-		$groups = _("none");
+		$link = util_make_link("/admin/pluginman.php?update=$filename&amp;action=activate", _('Activate'));
+		$users = _('None');
+		$groups = _('None');
 	}
 
 	echo '<tr '. $HTML->boxGetAltRowStyle($j+1) .'>'.
 		'<td>'. $filename.'</td>'.
 		'<td class="'.$status.'" style="text-align:center">'. $msg .'</td>'.
 		'<td style="text-align:center;">'. $link .'</td>'.
-		'<td style="text-align:center;">'. $init .'</td>'.
 		'<td style="text-align:left;">'. $users .'</td>'.
 		'<td style="text-align:left;">'. $groups .'</td></tr>'."\n";
 

Modified: branches/Branch_5_1/tests/func/Testing/SeleniumGforge.php
===================================================================
--- branches/Branch_5_1/tests/func/Testing/SeleniumGforge.php	2010-12-07 19:40:22 UTC (rev 11718)
+++ branches/Branch_5_1/tests/func/Testing/SeleniumGforge.php	2010-12-07 19:52:50 UTC (rev 11719)
@@ -203,16 +203,11 @@
 	}
 
 	protected function activatePlugin($pluginName) {
+		$this->switchUser('admin');
 		$this->open( ROOT . '/admin/pluginman.php?update='.$pluginName.'&action=deactivate');
 		$this->waitForPageToLoad("30000");
-		$this->open( ROOT );
+		$this->open( ROOT . '/admin/pluginman.php?update='.$pluginName.'&action=activate');
 		$this->waitForPageToLoad("30000");
-		$this->login('admin');
-		$this->clickAndWait("link=Site Admin");
-		$this->clickAndWait("link=Plugin Manager");
-		$this->click($pluginName);
-		$this->click("//a[contains(@href, \"javascript:change('".ROOT."/admin/pluginman.php?update=$pluginName&action=activate','$pluginName');\")]");
-		$this->waitForPageToLoad("30000");
 		$this->logout();
 	}
 




More information about the Fusionforge-commits mailing list