Code

Fixed Problem with saving new ACL for a tagged department.
[gosa.git] / gosa-core / include / class_gosaSupportDaemon.inc
index 2e300bfe5bad7b85cca9ee88afb9a4afb477ac70..0d86efe43e9a3160f782c166089f5fc541571281 100644 (file)
@@ -134,7 +134,91 @@ class gosaSupportDaemon
   }
 
 
-  public function FAI_get_packages($release,$attrs, $package = array())
+  public function FAI_get_kernels($release)
+  {
+    $xml_msg = "<xml><header>gosa_get_available_kernel</header><source>GOSA</source><target>GOSA</target><release>halut</release></xml>";
+
+    if($this->connect()){
+      $this->o_sock->write($xml_msg);
+      $str = trim($this->o_sock->read());
+
+      /* Check if something went wrong while reading */
+      if($this->o_sock->is_error()){
+        $this->set_error($this->o_sock->get_error());
+        return($ret);
+      }
+
+      $entries = $this->xml_to_array($str);
+      if(isset($entries['XML']) && is_array($entries['XML'])){
+
+        /* Check if returned values represent a valid answer */
+        if(isset($entries['XML'])){
+          if(isset($entries['XML']['ERROR_STRING'])) {
+            $this->set_error($entries['XML']['ERROR_STRING']);
+            new log("debug","GOsa-si",
+                get_class($this)."::".__FUNCTION__, array(),
+                "FAILED error was ".$this->get_error());
+            return($ret);
+          }
+
+          /* Unset header tags */
+          $ret = $entries['XML'];
+          foreach($ret as $key => $entry){
+            if(!preg_match("/^answer/i",$key)){
+              unset($ret[$key]);
+            }
+          }
+        }
+      }
+    }
+    return($ret);
+  }
+
+
+  public function FAI_get_package_sections($release)
+  {
+    $xml_msg = "<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
+      "<select>distinct section</select>".
+      "<where><clause><phrase><distribution>".$release."</distribution></phrase></clause></where></xml>";
+
+    if($this->connect()){
+      $this->o_sock->write($xml_msg);
+      $str = trim($this->o_sock->read());
+
+      /* Check if something went wrong while reading */
+      if($this->o_sock->is_error()){
+        $this->set_error($this->o_sock->get_error());
+        return($ret);
+      }
+
+      $entries = $this->xml_to_array($str);
+      if(isset($entries['XML']) && is_array($entries['XML'])){
+
+        /* Check if returned values represent a valid answer */
+        if(isset($entries['XML'])){
+          if(isset($entries['XML']['ERROR_STRING'])) {
+            $this->set_error($entries['XML']['ERROR_STRING']);
+            new log("debug","GOsa-si",
+                get_class($this)."::".__FUNCTION__, array(),
+                "FAILED error was ".$this->get_error());
+            return($ret);
+          }
+
+          /* Unset header tags */
+          foreach(array("HEADER","SOURCE","TARGET","SESSION_ID") as $type){
+            if(isset($entries['XML'][$type])){
+              unset($entries['XML'][$type]);
+            }
+          }
+          $ret = $entries['XML'];
+        }
+      }
+    }
+    return($ret);
+  }
+
+
+  public function FAI_get_packages($release,$attrs,$package,$from=-1,$to=-1)
   {
     $this->reset_error();
     $ret = array();
@@ -157,40 +241,32 @@ class gosaSupportDaemon
       $attr.= "<select>".$at."</select>";
     }
 
+    /* If no package is given, search for all */
+    if(!count($package)) $package = array("%");
+
+    /* Create limit tag */
+    if($from == -1){
+      $limit =""; 
+    }else{
+      $limit = "<limit><from>".$from."</from><to>".$to."</to></limit>";
+    }
+
     /* Create list of attributes to fetch */
     $pkgs = ""; 
     foreach($package as $pkg){
-      $pkgs .="
-               <phrase>
-                <operator>like</operator>
-                <package>".$pkg."</package>
-               </phrase>
-             ";
-
+      $pkgs .="<phrase><operator>like</operator><package>".$pkg."</package></phrase>";
     }
 
-    /* Create Daemon query */
-    if(!count($package)){
-      $xml_msg = "<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
-        $attr.
-        "<where><clause><phrase><distribution>".$release."</distribution></phrase></clause></where>
-        </xml>";
-    }else{
-         $xml_msg = "<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
-        $attr.
-        "<where>
-            <clause>
-             <connector>AND</connector>
-             <phrase><distribution>".$release."</distribution></phrase>
-              <clause>
-              <connector>OR</connector>
-               ".$pkgs."
-             </clause>
-            </clause>
-         </where>
-         <limit><from>0</from><to>100</to></limit>
-        </xml>";
-    }
+    $xml_msg = "<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
+      $attr.
+      "<where>
+      <clause><phrase><distribution>".$release."</distribution></phrase></clause>
+      <clause><connector>OR</connector>
+      ".$pkgs."
+      </clause>
+      </where>".
+      $limit.
+      "</xml>";
 
     if($this->connect()){
       $this->o_sock->write($xml_msg);