[Fusionforge-commits] r9698 - trunk/plugins/coclico/hudson/include

Mélanie Le Bail melanelebail at libremir.placard.fr.eu.org
Mon May 10 11:26:58 CEST 2010


Author: melanelebail
Date: 2010-05-10 11:26:58 +0200 (Mon, 10 May 2010)
New Revision: 9698

Modified:
   trunk/plugins/coclico/hudson/include/HudsonJobWidget.class.php
   trunk/plugins/coclico/hudson/include/HudsonWidget.class.php
   trunk/plugins/coclico/hudson/include/PluginHudsonJobDao.class.php
   trunk/plugins/coclico/hudson/include/hudsonPlugin.class.php
   trunk/plugins/coclico/hudson/include/hudsonViews.class.php
   trunk/plugins/coclico/hudson/include/hudson_Widget_JobBuildHistory.class.php
   trunk/plugins/coclico/hudson/include/hudson_Widget_JobLastArtifacts.class.php
   trunk/plugins/coclico/hudson/include/hudson_Widget_JobLastBuilds.class.php
   trunk/plugins/coclico/hudson/include/hudson_Widget_JobTestResults.class.php
   trunk/plugins/coclico/hudson/include/hudson_Widget_JobTestTrend.class.php
   trunk/plugins/coclico/hudson/include/hudson_Widget_MyMonitoredJobs.class.php
   trunk/plugins/coclico/hudson/include/hudson_Widget_ProjectJobsOverview.class.php
Log:
Modify plugin hudson widgets 


Modified: trunk/plugins/coclico/hudson/include/HudsonJobWidget.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/HudsonJobWidget.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/HudsonJobWidget.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -41,27 +41,40 @@
         $vId->required();
         if ($request->valid($vId)) {
             $job_id = $request->get('job_id');
-            $sql = 'INSERT INTO plugin_hudson_widget (widget_name, owner_id, owner_type, job_id) VALUES ("' . $this->id . '", '. $this->owner_id .", '". $this->owner_type ."', " . db_escape_int($job_id) ." )";
-            $res = db_query($sql);
-            $content_id = db_insertid($res);
+            $sql = 'INSERT INTO plugin_hudson_widget (widget_name, owner_id, owner_type, job_id) VALUES ($1,$2,$3,$4)';
+            $res = db_query_params($sql,array($this->id,$this->owner_id,$this->owner_type,$job_id));
+            $content_id = db_insertid($res,'plugin_hudson_widget','id');
         }
         return $content_id;
     }
     
     function destroy($id) {
-        $sql = 'DELETE FROM plugin_hudson_widget WHERE id = '. $id .' AND owner_id = '. $this->owner_id ." AND owner_type = '". $this->owner_type ."'";
-        db_query($sql);
+        $sql = 'DELETE FROM plugin_hudson_widget WHERE id = $1 AND owner_id = $2 AND owner_type = $3';
+        db_query_params($sql,array($id,$this->owner_id,$this->owner_type));
     }
     
     function getInstallPreferences() {
         $prefs  = '';
         $prefs .= '<strong>'._("Monitored job:").'</strong><br />';
-        
+       /* 
         $jobs = $this->getAvailableJobs();
         
         foreach ($jobs as $job_id => $job) {
             $prefs .= '<input type="radio" name="job_id" value="'.$job_id.'"> '.$job->getName().'<br />';
         }
+        return $prefs;*/
+	$selected_jobs_id = $this->getSelectedJobsId();
+        $jobs = $this->getAvailableJobs();
+
+        $only_one_job = (count($jobs) == 1);
+            foreach ($jobs as $job_id => $job) {
+                $selected = ($only_one_job)?'checked="checked"':'';
+                $prefs .= '<input type="radio" name="' . $this->widget_id . '_job_id" value="'.$job_id.'" ' . $selected . '> ' . $job->getName() ;
+                if (in_array($job_id, $selected_jobs_id)) {
+                        $prefs .= ' <em>('._('Already used') .')</em>';
+                }
+                $prefs .= '<br />';
+            }
         return $prefs;
     }
     function hasPreferences() {
@@ -84,12 +97,26 @@
         $request->valid(new Valid_String('cancel'));
         if (!$request->exist('cancel')) {
             $job_id = $request->get($this->id);
-            $sql = "UPDATE plugin_hudson_widget SET job_id=". $job_id ." WHERE owner_id = ". $this->owner_id ." AND owner_type = '". $this->owner_type ."' AND id = ". (int)$request->get('content_id');
-            $res = db_query($sql); 
+            $sql = "UPDATE plugin_hudson_widget SET job_id=$1 WHERE owner_id = $2 AND owner_type = $3 AND id = $4";
+            $res = db_query_params($sql,array($job_id,$this->owner_id,$this->owner_type,(int)$request->get('content_id'))); 
         }
         return true;
     }
+/**
+     * Returns the jobs selected for this widget
+     */
+    function getSelectedJobsId() {
+        $sql = "SELECT * FROM plugin_hudson_widget WHERE widget_name='" . $this->widget_id . "' AND owner_id = ". $this->owner_id ." AND owner_type = '". $this->owner_type ."'";
+        $res = db_query($sql);
+
+        $selected_jobs_id = array();
+        while ($data = db_fetch_array($res)) {
+                $selected_jobs_id[] = $data['job_id'];
+        }
+        return $selected_jobs_id;
+    }
+
     
 }
 
-?>
\ No newline at end of file
+?>

Modified: trunk/plugins/coclico/hudson/include/HudsonWidget.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/HudsonWidget.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/HudsonWidget.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -24,7 +24,7 @@
 abstract class HudsonWidget extends Widget {
     
     function getCategory() {
-        return 'ci';
+        return _('Hudson');
     }
     
     protected function getAvailableJobs() {
@@ -77,4 +77,4 @@
     
 }
 
-?>
\ No newline at end of file
+?>

Modified: trunk/plugins/coclico/hudson/include/PluginHudsonJobDao.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/PluginHudsonJobDao.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/PluginHudsonJobDao.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -83,7 +83,7 @@
 	 */
 	function & searchByUserID($user_id) {
 		$sql = "SELECT j.*  
-			FROM plugin_hudson_job j, user u, user_group ug
+			FROM plugin_hudson_job j, users u, user_group ug
 			WHERE ug.group_id = j.group_id AND
 			u.user_id = ug.user_id AND 
 			u.user_id = $1";

Modified: trunk/plugins/coclico/hudson/include/hudsonPlugin.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudsonPlugin.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/hudsonPlugin.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -59,7 +59,7 @@
 				return;
 			}
 			if ( $project->usesPlugin ( $this->name ) ) {
-				$params['TITLES'][]='<nobr>'.$this->text.'</nobr>';
+				$params['TITLES'][]=$this->text;
 				$params['DIRS'][]='/plugins/hudson/index.php?group_id=' . $group_id . "&pluginname=" . $this->name; // we indicate the part we�re calling is the project one
 			} 
 			(($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
@@ -167,13 +167,17 @@
 	function jsFile($params) {
 		// Only include the js files if we're actually in the IM pages.
 		// This stops styles inadvertently clashing with the main site.
-		//if (strpos($_SERVER['REQUEST_URI'], $this->getPluginPath()) === 0) {
 			echo '<script type="text/javascript" src="/scripts/prototype/prototype.js"></script>'."\n";
 			echo '<script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>'."\n";
 			echo '<script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>'."\n";
-			echo '<script type="text/javascript" src="/scripts/codendi/cross_references.js"></script>'."\n";
+			echo '<script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>'."\n";
+			echo '<script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>'."\n";
+			echo '<script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>'."\n";
 			echo '<script type="text/javascript" src="hudson_tab.js"></script>'."\n";
-		//}
+		if (strpos($_SERVER['REQUEST_URI'], $this->getPluginPath()) === 0) {
+		//	echo '<script type="text/javascript" src="/scripts/codendi/cross_references.js"></script>'."\n";
+			echo '<script type="text/javascript" src="hudson_tab.js"></script>'."\n";
+		}
 	}
 
 	/**

Modified: trunk/plugins/coclico/hudson/include/hudsonViews.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudsonViews.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/hudsonViews.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -89,13 +89,13 @@
 		}
 		if ($dar->valid()) {
 			$row = $dar->current();
-			fwrite($myfile,"appel de Cross REf Factory avec :".$row['name']);
+			/*fwrite($myfile,"appel de Cross REf Factory avec :".$row['name']);
 			$crossref_fact= new CrossReferenceFactory($row['name'], 'hudson_job', $group_id);
 			$crossref_fact->fetchDatas();
 			if ($crossref_fact->getNbReferences() > 0) {
 				echo '<b> '._('References').'</b>';
 				$crossref_fact->DisplayCrossRefs();
-			}
+			}*/
 			$this->_display_iframe($row['job_url']);
 			fwrite($myfile,"display iframe de ".$row['job_url']);
 		} else {

Modified: trunk/plugins/coclico/hudson/include/hudson_Widget_JobBuildHistory.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudson_Widget_JobBuildHistory.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/hudson_Widget_JobBuildHistory.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -20,7 +20,6 @@
 
 
 require_once('HudsonJobWidget.class.php');
-require_once('common/user/UserManager.class.php');
 require_once('common/include/HTTPRequest.class.php');
 require_once('PluginHudsonJobDao.class.php');
 require_once('HudsonJob.class.php');
@@ -44,9 +43,9 @@
     function getTitle() {
         $title = '';
         if ($this->job) {
-            $title .= vsprintf(_("%s Builds History"),  array($this->job->getName()));
+            $title .= vsprintf(_("%s Builds History"),  $this->job->getName());
         } else {
-            $title .= _("%s Builds History");
+            $title .= _("Builds History");
         }
         return  $title;
     }
@@ -56,8 +55,8 @@
     }
     
     function loadContent($id) {
-        $sql = "SELECT * FROM plugin_hudson_widget WHERE widget_name='" . $this->widget_id . "' AND owner_id = ". $this->owner_id ." AND owner_type = '". $this->owner_type ."' AND id = ". $id;
-        $res = db_query($sql);
+        $sql = "SELECT * FROM plugin_hudson_widget WHERE widget_name=$1 AND owner_id = $2 AND owner_type = $3 AND id = $4";
+        $res = db_query_params($sql,array($this->widget_id,$this->owner_id,$this->owner_type,$id));
         if ($res && db_numrows($res)) {
             $data = db_fetch_array($res);
             $this->job_id    = $data['job_id'];

Modified: trunk/plugins/coclico/hudson/include/hudson_Widget_JobLastArtifacts.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudson_Widget_JobLastArtifacts.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/hudson_Widget_JobLastArtifacts.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -20,7 +20,6 @@
 
 
 require_once('HudsonJobWidget.class.php');
-require_once('common/user/UserManager.class.php');
 require_once('common/include/HTTPRequest.class.php');
 require_once('PluginHudsonJobDao.class.php');
 require_once('HudsonBuild.class.php');

Modified: trunk/plugins/coclico/hudson/include/hudson_Widget_JobLastBuilds.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudson_Widget_JobLastBuilds.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/hudson_Widget_JobLastBuilds.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -20,7 +20,6 @@
 
 
 require_once('HudsonJobWidget.class.php');
-require_once('common/user/UserManager.class.php');
 require_once('common/include/HTTPRequest.class.php');
 require_once('PluginHudsonJobDao.class.php');
 require_once('HudsonJob.class.php');
@@ -46,7 +45,7 @@
         if ($this->job) {
             $title .= vsprintf(_("%s Last Builds"),  array($this->job->getName()));
         } else {
-            $title .= _("%s Last Builds");
+            $title .= _("Last Builds");
         }
         return  $title;
     }

Modified: trunk/plugins/coclico/hudson/include/hudson_Widget_JobTestResults.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudson_Widget_JobTestResults.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/hudson_Widget_JobTestResults.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -20,7 +20,6 @@
 
 
 require_once('HudsonJobWidget.class.php');
-require_once('common/user/UserManager.class.php');
 require_once('common/include/HTTPRequest.class.php');
 require_once('PluginHudsonJobDao.class.php');
 require_once('HudsonJob.class.php');

Modified: trunk/plugins/coclico/hudson/include/hudson_Widget_JobTestTrend.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudson_Widget_JobTestTrend.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/hudson_Widget_JobTestTrend.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -20,7 +20,6 @@
 
 
 require_once('HudsonJobWidget.class.php');
-require_once('common/user/UserManager.class.php');
 require_once('common/include/HTTPRequest.class.php');
 require_once('PluginHudsonJobDao.class.php');
 require_once('HudsonJob.class.php');

Modified: trunk/plugins/coclico/hudson/include/hudson_Widget_MyMonitoredJobs.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudson_Widget_MyMonitoredJobs.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/hudson_Widget_MyMonitoredJobs.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -20,7 +20,7 @@
 
 
 require_once('HudsonOverviewWidget.class.php');
-require_once('common/user/UserManager.class.php');
+//require_once('common/user/UserManager.class.php');
 require_once('common/include/HTTPRequest.class.php');
 require_once('PluginHudsonJobDao.class.php');
 require_once('HudsonJob.class.php');
@@ -38,18 +38,19 @@
     function hudson_Widget_MyMonitoredJobs($plugin) {
         $this->Widget('plugin_hudson_my_jobs');
         $this->plugin = $plugin;
+	$user=UserManager::instance()->getCurrentUser();
         
-        $this->_not_monitored_jobs = user_get_preference('plugin_hudson_my_not_monitored_jobs');
+        $this->_not_monitored_jobs = $user->getPreference('plugin_hudson_my_not_monitored_jobs');
         if ($this->_not_monitored_jobs === false) {
             $this->_not_monitored_jobs = array();
         } else {
             $this->_not_monitored_jobs = explode(",", $this->_not_monitored_jobs);
         }
         
-        $this->_use_global_status = user_get_preference('plugin_hudson_use_global_status');
+        $this->_use_global_status = $user->getPreference('plugin_hudson_use_global_status');
         if ($this->_use_global_status === false) {
             $this->_use_global_status = "false";
-            user_set_preference('plugin_hudson_use_global_status', $this->_use_global_status);
+            $user->setPreference('plugin_hudson_use_global_status', $this->_use_global_status);
         }
         
         if ($this->_use_global_status == "true") {
@@ -124,11 +125,11 @@
             
             $this->_not_monitored_jobs = $not_monitored_jobs; 
             
-            user_set_preference('plugin_hudson_my_not_monitored_jobs', implode(",", $this->_not_monitored_jobs));
+            $user->setPreference('plugin_hudson_my_not_monitored_jobs', implode(",", $this->_not_monitored_jobs));
             
             $use_global_status = $request->get('use_global_status');
             $this->_use_global_status = ($use_global_status !== false)?"true":"false";
-            user_set_preference('plugin_hudson_use_global_status', $this->_use_global_status);
+            $user->setPreference('plugin_hudson_use_global_status', $this->_use_global_status);
         }
         return true;
     }
@@ -177,8 +178,13 @@
                         $job_id = $row['job_id'];
                         $group_id = $row['group_id'];
                         $job = new HudsonJob($job_url);
-                        
-                        $html .= '<tr class="'. util_get_alt_row_color($cpt) .'">';
+                        if ($cpt % 2 == 0) {
+					$class="boxitemalt bgcolor-white";
+				} else {
+					$class="boxitem bgcolor-grey";
+				}
+
+                        $html .= '<tr class="'. $class .'">';
                         $html .= ' <td>';
                         $html .= ' <img src="'.$job->getStatusIcon().'" title="'.$job->getStatus().'" >';
                         $html .= ' </td>';
@@ -214,4 +220,4 @@
     }
 }
 
-?>
\ No newline at end of file
+?>

Modified: trunk/plugins/coclico/hudson/include/hudson_Widget_ProjectJobsOverview.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudson_Widget_ProjectJobsOverview.class.php	2010-05-10 08:25:48 UTC (rev 9697)
+++ trunk/plugins/coclico/hudson/include/hudson_Widget_ProjectJobsOverview.class.php	2010-05-10 09:26:58 UTC (rev 9698)
@@ -20,7 +20,6 @@
 
 
 require_once('HudsonOverviewWidget.class.php');
-require_once('common/user/UserManager.class.php');
 require_once('common/include/HTTPRequest.class.php');
 require_once('PluginHudsonJobDao.class.php');
 require_once('HudsonJob.class.php');
@@ -116,4 +115,4 @@
     }
 }
 
-?>
\ No newline at end of file
+?>




More information about the Fusionforge-commits mailing list