Code

Removed getkiosk.php.
[gosa.git] / gosa-core / include / functions.inc
index 314a0d05fd9a689d588bd344e7512e2dd555bdf1..80552801c241c7b3c38f267c17194c73c0cbc725 100644 (file)
@@ -93,14 +93,35 @@ $REWRITE= array( "รค" => "ae",
 /* Class autoloader */
 function __autoload($class_name) {
     global $class_mapping, $BASE_DIR;
+
+    if ($class_mapping === NULL){
+           echo sprintf(_("Fatal error: no class locations defined - please run '%s' to fix this"), "<b>update-gosa rescan-classes</b>");
+           exit;
+    }
+
     if (isset($class_mapping[$class_name])){
       require_once($BASE_DIR."/".$class_mapping[$class_name]);
     } else {
-      echo _("Fatal: cannot load class \"$class_name\" - execution aborted");
+      echo sprintf(_("Fatal error: cannot instantiate class '%s' - execution aborted"), $class_name);
+      print_a(debug_backtrace());
+      exit;
     }
 }
 
 
+/* Check if plugin is avaliable */
+function plugin_available($plugin)
+{
+       global $class_mapping, $BASE_DIR;
+
+       if (!isset($class_mapping[$plugin])){
+               return false;
+       } else {
+               return is_readable($BASE_DIR."/".$class_mapping[$plugin]);
+       }
+}
+
+
 /* Create seed with microseconds */
 function make_seed() {
   list($usec, $sec) = explode(' ', microtime());
@@ -1274,7 +1295,7 @@ function show_ldap_error($message, $addon= "")
       msg_dialog::display(_("LDAP error:"), $message, ERROR_DIALOG);
     } else {
       if(!preg_match("/No such object/i",$message)){
-        msg_dialog::display(sprintf(_("LDAP error in plugin '%s':"),"<i>".$addon."</i>"),$message,ERROR_DIALOG);
+        msg_dialog::display(_("LDAP error"), sprintf(_("Plugin '%s':%s"),"<i>".$addon."</i>", "<br><br>$message"),ERROR_DIALOG);
       }
     }
     return TRUE;
@@ -2555,6 +2576,63 @@ function getEntryCSN($dn)
 }
 
 
+/* Add a given objectClass to an attrs entry */
+function add_objectClass($classes, &$attrs)
+{
+  if (is_array($classes)){
+    $list= $classes;
+  } else {
+    $list= array($classes);
+  }
+
+  foreach ($list as $class){
+    $attrs['objectClass'][]= $class;
+  }
+}
+
+
+/* Removes a given objectClass from the attrs entry */
+function remove_objectClass($classes, &$attrs)
+{
+  if (isset($attrs['objectClass'])){
+    /* Array? */
+    if (is_array($classes)){
+      $list= $classes;
+    } else {
+      $list= array($classes);
+    }
+
+    $tmp= array();
+    foreach ($attrs['objectClass'] as $oc) {
+      foreach ($list as $class){
+        if ($oc != $class){
+          $tmp[]= $oc;
+        }
+      }
+    }
+    $attrs['objectClass']= $tmp;
+  }
+}
+
+/*! \brief  Initialize a file download with given content, name and data type. 
+ *  @param  data  String The content to send.
+ *  @param  name  String The name of the file.
+ *  @param  type  String The content identifier, default value is "application/octet-stream";
+ */
+function send_binary_content($data,$name,$type = "application/octet-stream")
+{
+  header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+  header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
+  header("Cache-Control: no-cache");
+  header("Pragma: no-cache");
+  header("Cache-Control: post-check=0, pre-check=0");
+  header("Content-type: ".$type."");
+  header("Content-Disposition: attachment; filename=".$name);
+  echo $data;
+  exit();
+}
+
+
 function display_error_page()
 {
   $smarty= get_smarty();