From a2024271a90fd73b6b26edb36b6892783d409526 Mon Sep 17 00:00:00 2001 From: cajus Date: Thu, 13 Aug 2009 09:46:31 +0000 Subject: [PATCH] Updaed listing handling git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14044 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_filter.inc | 5 ++ gosa-core/include/class_listing.inc | 90 +++++++++++++++++++++++++---- 2 files changed, 85 insertions(+), 10 deletions(-) diff --git a/gosa-core/include/class_filter.inc b/gosa-core/include/class_filter.inc index bde9b1726..d32499147 100644 --- a/gosa-core/include/class_filter.inc +++ b/gosa-core/include/class_filter.inc @@ -49,6 +49,11 @@ class filter { $entry= $this->xmlData['search']; $this->baseMode= $entry['base']; $this->scopeMode= $entry['scope']; + if ($entry['scope'] == "auto") { + $this->scope= "one"; + } else { + $this->scope= $entry['scope']; + } $this->query= $entry['query']; } else { return false; diff --git a/gosa-core/include/class_listing.inc b/gosa-core/include/class_listing.inc index e9085b045..0457005b5 100644 --- a/gosa-core/include/class_listing.inc +++ b/gosa-core/include/class_listing.inc @@ -13,6 +13,7 @@ class listing { var $header= array(); var $colprops= array(); var $filters= array(); + var $pid; static $objectTypes; @@ -26,6 +27,9 @@ class listing { $this->registerFilter("objectType", "listing::filterObjectType"); $this->registerFilter("link", "listing::filterLink"); $this->registerFilter("actions", "listing::filterActions"); + + // Initialize pid + $this->pid= preg_replace("/[^0-9]/", "", microtime(TRUE)); } @@ -91,10 +95,11 @@ class listing { function render() { -echo "Handle empty lists differently, alternating, sorting, post_id, bottom list info
"; +echo "action menu, sorting, department browsing, filter base handling, bottom list info, copy'n paste handler
"; // Initialize list - $result= "
"; + $result= ""; + $result.= "
"; $result.= "
"; $num_cols= count($this->colprops) + ($this->multiSelect?1:0); @@ -114,6 +119,11 @@ echo "Handle empty lists differently, alternating, sorting, post_id, bottom list // New table for the real list contents $result.= "
"; + // No results? Just take an empty colspanned row + if (count($this->entries) == 0) { + $result.= ""; + } + // Fill with contents foreach ($this->entries as $row => $entry){ $result.=""; @@ -174,11 +184,18 @@ echo "Handle empty lists differently, alternating, sorting, post_id, bottom list function setFilter($filter) { $this->filter= &$filter; + $this->entries= $this->filter->query(); } function update() { + // Do not do anything if this is not our PID + # DISABLED because the object is not in the session + #if(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->pid) { + # return; + #} + $this->entries= $this->filter->query(); } @@ -256,10 +273,9 @@ echo "Handle empty lists differently, alternating, sorting, post_id, bottom list $params[]= $row; } - // pid is replaced by the current post_id + // pid is replaced by the current PID if ($param == "pid") { - #TODO: get post_id - $params[]= "99"; + $params[]= $this->pid; } // Fixie with "" is passed directly @@ -280,7 +296,7 @@ echo "Handle empty lists differently, alternating, sorting, post_id, bottom list // Move dn if needed if ($param == "dn") { - $params[]= $config["dn"]; + $params[]= LDAP::fix($config["dn"]); } } @@ -300,13 +316,13 @@ echo "Handle empty lists differently, alternating, sorting, post_id, bottom list foreach ($classes as $objectClass) { if (isset(listing::$objectTypes[$objectClass])){ if (!isset(listing::$objectTypes[$objectClass]["priority"])){ - $result= ""; + $result= ""; return $result; } if (listing::$objectTypes[$objectClass]["priority"] < $prio){ $prio= listing::$objectTypes[$objectClass]["priority"]; - $result= ""; + $result= ""; } } } @@ -321,7 +337,7 @@ echo "Handle empty lists differently, alternating, sorting, post_id, bottom list $row= func_get_arg(0); $pid= func_get_arg(1); - $dn= func_get_arg(2); + $dn= LDAP::fix(func_get_arg(2)); $params= array(func_get_arg(3)); // Collect sprintf params @@ -337,7 +353,7 @@ echo "Handle empty lists differently, alternating, sorting, post_id, bottom list $result= " "; $trans= call_user_func_array("sprintf", $params); if ($trans != "") { - return("$trans"); + return("$trans"); } return $result; @@ -400,6 +416,60 @@ echo "Handle empty lists differently, alternating, sorting, post_id, bottom list } + function getAction() + { + // Do not do anything if this is not our PID + # DISABLED because the object is not in the session + #if(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->pid) { + # return; + #} + + $result= array("targets" => array(), "action" => ""); + + // Filter GET with "act" attributes + if (isset($_GET['act'])) { + $key= validate($_GET['act']); + $target= preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)$/', '$1', $key); + if (isset($this->entries[$target]['dn'])) { + $result['action']= preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+$/', '$1', $key); + $result['targets'][]= $this->entries[$target]['dn']; + } + return $result; + } + + // Filter POST with "listing_" attributes + foreach ($_POST as $key => $prop) { + + // Capture selections + if (preg_match('/^listing_selected_[0-9]+$/', $key)) { + $target= preg_replace('/^listing_selected_([0-9]+)$/', '$1', $key); + if (isset($this->entries[$target]['dn'])) { + $result['targets'][]= $this->entries[$target]['dn']; + } + continue; + } + + // Capture action with target - this is a one shot + if (preg_match('/^listing_[a-zA-Z_]+_[0-9]+(|_x)$/', $key)) { + $target= preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)(|_x)$/', '$1', $key); + if (isset($this->entries[$target]['dn'])) { + $result['action']= preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+(|_x)$/', '$1', $key); + $result['targets']= array($this->entries[$target]['dn']); + } + break; + } + + // Capture action without target + if (preg_match('/^listing_[a-zA-Z_]+(|_x)$/', $key)) { + $result['action']= preg_replace('/^listing_([a-zA-Z_]+)(|_x)$/', '$1', $key); + continue; + } + } + + return $result; + } + + static function filterActions() { return "TBD"; -- 2.30.2