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

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Mon Jun 28 19:11:29 CEST 2010


Author: aljeux
Date: 2010-06-28 19:11:29 +0200 (Mon, 28 Jun 2010)
New Revision: 10145

Modified:
   trunk/plugins/coclico/hudson/include/HudsonJobWidget.class.php
Log:
Disable already used jobs (or current) for add/change.

Modified: trunk/plugins/coclico/hudson/include/HudsonJobWidget.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/HudsonJobWidget.class.php	2010-06-28 17:04:59 UTC (rev 10144)
+++ trunk/plugins/coclico/hudson/include/HudsonJobWidget.class.php	2010-06-28 17:11:29 UTC (rev 10145)
@@ -60,11 +60,15 @@
 	$selected_jobs_id = $this->getSelectedJobsId();
         
         foreach ($jobs as $job_id => $job) {
-            $prefs .= '<input type="radio" name="job_id" value="'.$job_id.'"> '.$job->getName();
-                if (in_array($job_id, $selected_jobs_id)) {
-                        $prefs .= ' <em>('._('Already used') .')</em>';
-                }
-                $prefs .= '<br />';
+            if (in_array($job_id, $selected_jobs_id)) {
+    			$options = ' disabled="disabled"';
+    			$comment = ' <em>('._('Already used') .')</em>';
+    		} else {
+    			$options = '';
+    			$comment = '';
+            }
+    		$prefs .= '<input type="radio" name="job_id" value="'.$job_id.'"'.$options.'/> '.$job->getName().$comment;
+            $prefs .= '<br />';
         }
         return $prefs;
     }
@@ -74,12 +78,22 @@
     function getPreferences() {
         $prefs  = '';
         $prefs .= '<strong>'._("Monitored job:").'</strong><br />';
-        
         $jobs = $this->getAvailableJobs();
+    	$selected_jobs_id = $this->getSelectedJobsId();
         
         foreach ($jobs as $job_id => $job) {
-            $selected = ($job_id == $this->job_id)?'checked="checked"':'';
-            $prefs .= '<input type="radio" name="' . $this->id . '" value="'.$job_id.'" ' . $selected . '> '.$job->getName().'<br />';
+    		if (in_array($job_id, $selected_jobs_id)) {
+    			$options = ' disabled="disabled"';
+    			$comment = ' <em>('._('Already used') .')</em>';
+    		} else {
+    			$options = '';
+    			$comment = '';
+    		}
+    		if ($job_id == $this->job_id) {
+    			$options = ' checked="checked"';
+    			$comment = ' <em>('._('Current used') .')</em>';
+    		}
+    		$prefs .= '<input type="radio" name="' . $this->id . '" value="'.$job_id.'"' . $options . '> '.$job->getName().$comment.'<br />';
         }
         return $prefs;
     }




More information about the Fusionforge-commits mailing list