Code

Updated listing class to support 'singleSelect'.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 19 Apr 2010 06:29:20 +0000 (06:29 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 19 Apr 2010 06:29:20 +0000 (06:29 +0000)
-Displays 'radio buttons' instead of the 'checkboxes'
-This allows us to select a single element, e.g. for the manager attribute.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17681 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_listing.inc

index 8b32798177430cd6ccb8940de0e4f19dc4d9f6ad..6ca5c31ae9db4990472894146897bbc2fa60b7d7 100644 (file)
@@ -28,6 +28,7 @@ class listing {
   var $departmentBrowser= false;
   var $departmentRootVisible= false;
   var $multiSelect= false;
+  var $singleSelect= false;
   var $template;
   var $headline;
   var $base;
@@ -160,7 +161,7 @@ class listing {
     $this->xmlData= $this->xmlData["list"];
 
     // Load some definition values
-    foreach (array("departmentBrowser", "departmentRootVisible", "multiSelect", "baseMode") as $token) {
+    foreach (array("departmentBrowser", "departmentRootVisible", "multiSelect","singleSelect", "baseMode") as $token) {
       if (isset($this->xmlData['definition'][$token]) &&
           $this->xmlData['definition'][$token] == "true"){
         $this->$token= true;
@@ -294,11 +295,11 @@ class listing {
     
     $result.= "<div class='listContainer' id='d_scrollbody' style='min-height:".($height+25)."px;'>\n";
     $result.= "<table summary='$this->headline' style='width:100%;table-layout:fixed' cellspacing='0' cellpadding='0' id='t_scrolltable'>\n";
-    $this->numColumns= count($this->colprops) + ($this->multiSelect?1:0);
+    $this->numColumns= count($this->colprops) + (($this->multiSelect|$this->singleSelect)?1:0);
 
     // Build list header
     $result.= "<thead class='fixedListHeader listHeaderFormat'><tr>\n";
-    if ($this->multiSelect) {
+    if ($this->multiSelect || $this->singleSelect) {
       $width= "24px";
       if (preg_match('/Konqueror/i', $_SERVER['HTTP_USER_AGENT'])){
         $width= "28px";
@@ -331,7 +332,7 @@ class listing {
         $result.="<tr>";
 
         // Render multi select if needed
-        if ($this->multiSelect) {
+        if ($this->multiSelect || $this->singleSelect) {
           $result.="<td style='text-align:center;padding:0;' class='list1'>&nbsp;</td>";
         }
 
@@ -368,6 +369,10 @@ class listing {
         $trow.="<td style='text-align:center;width:20px;' class='list0'><input type='checkbox' id='listing_selected_$row' name='listing_selected_$row'></td>\n";
       }
 
+      if ($this->singleSelect) {
+        $trow.="<td style='text-align:center;width:20px;' class='list0'><input type='radio' id='listing_radio_selected_$row' name='listing_radio_selected' value='{$row}'></td>\n";
+      }
+
       foreach ($this->xmlData['table']['column'] as $index => $config) {
         $renderedCell= $this->renderCell($config['value'], $entry, $row);
         $trow.="<td ".$this->colprops[$index]." class='list0'>".$renderedCell."</td>\n";
@@ -1064,6 +1069,12 @@ class listing {
       return $result;
     }
 
+    // Get single selection (radio box)
+    if($this->singleSelect && isset($_POST['listing_radio_selected'])){
+        $entry = $_POST['listing_radio_selected'];
+        $result['targets']= array($this->entries[$entry]['dn']);
+    }
+
     // Filter POST with "listing_" attributes
     foreach ($_POST as $key => $prop) {