Code

Added warning to package request method of Daemon class.
[gosa.git] / gosa-core / update-gosa
index de343937cd9aa74e1a39fdcfa2dfc2e90e383213..616817d12eeec87b3f9fb5bde381405a22dc6e99 100755 (executable)
@@ -1,5 +1,25 @@
 #!/usr/bin/php5
 <?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: main.php 9254 2008-03-03 15:57:49Z cajus $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 
 define ("GOSA_HOME", dirname(__FILE__));
 define ("LOCALE_DIR", GOSA_HOME."/locale");
@@ -48,7 +68,11 @@ function get_classes($folder= ".")
   static $result= array();
 
   if ($base_dir == ""){
-    $base_dir= getcwd();
+    if ($folder == "."){
+      $base_dir= getcwd();
+    } else {
+      $base_dir= $folder;
+    }
   }
 
   $currdir=getcwd();
@@ -167,6 +191,56 @@ function rescan_i18n()
 }
 
 
+function rescan_guide()
+{
+       $master_guide= "doc/guide.xml";
+       echo "Updating Online Help Index...\n";
+       $master_guide_content="<?xml version=\"1.0\"?>\n".
+               "<!--\n".
+               "\tWARNING:\n".
+               "\tThis file is automatically generated by update-online-help.\n".
+               "\tIf you want to add entries, use doc/core/guide.xml or doc/plugins/\"Appropriate Plugin Directory\"/guide.xml.\n".
+               "\tThen execute update-online-help to merge them into this file.\n".
+               "-->\n\n".
+               "<!--\n".
+               "\tThis xml file specifies which class is documented in which help file.\n".
+               "\tIf isset ( \$_SESSION['current_class_for_help'] ) then open the helpfile which is\n".
+               "\tspecified for this class below.\n".
+               "-->\n\n".
+               "<!--\n".
+               "\t<ENTRY NAME='class name' VALUE='displayed text' PATH='path to helpfiles' FILE='path to htmlfile' />\n".
+               "\tLeave blank to display message \"There is no helpfile specified for this class.\"\n".
+               "-->\n".
+               "<ENTRIES>\n";
+
+       $guide= 'doc/core/guide.xml';
+       if(file_exists($guide) && is_readable($guide)) {
+               $master_guide_content.= file_get_contents($guide);
+       }
+       
+       $plugins= scandir('doc/plugins');
+       foreach($plugins as $key => $plugin) {
+               if($plugin != '.' && $plugin != '..') {
+                       if(is_dir('doc/plugins/'.$plugin)) {
+                               $guide= 'doc/plugins/'.$plugin.'/guide.xml';
+                               if(file_exists($guide) && is_readable($guide)) {
+                                       $master_guide_content.= file_get_contents($guide);
+                               }
+                       }
+               }
+       }
+
+       $master_guide_content.= "</ENTRIES>";
+       
+       $master_guide_content= preg_replace("/[ \t][ \t]*/", " ", $master_guide_content);
+
+       if(is_writable($master_guide)) {
+               file_put_contents($master_guide, $master_guide_content);
+       }
+
+}
+
+
 function parse_ini($file)
 {
        global $description, $provides, $depends, $versions, $conflicts;
@@ -290,7 +364,14 @@ function install_plugin($file)
 
                                /* Check if dependencies are fullfilled */
                                foreach ($depends as $dep){
-                                       if (!in_array($dep, $provides)){
+                                       $found= false;
+                                       foreach ($provides as $provide => $dummy){
+                                               if ($dep == $provide){
+                                                       $found= true;
+                                                       break;
+                                               }
+                                       }
+                                       if (!$found){
                                                echo "! Error: plugin depends on '$dep', but this is not installed\n\n";
                                                exit (3);
                                        }
@@ -370,12 +451,13 @@ function install_plugin($file)
        /* Update caches */
        rescan_classes();
        rescan_i18n();
+       rescan_guide();
 }
 
 
 function remove_plugin($name)
 {
-       global $description;
+       global $description, $depends;
 
        /* Load plugin list */
        load_plugins();
@@ -386,6 +468,14 @@ function remove_plugin($name)
                exit (1);
        }
 
+       /* Depends? */
+       foreach ($depends as $sname => $pl_depends){
+               if (in_array($name, $pl_depends)){
+                       echo "! Error: plugin '$sname' depends on '$name' - cannot remove it\n\n";
+                       exit (1);
+               }
+       }
+
        /* Load information */
        if (!file_exists(PLUGSTATE_DIR."/$name/plugin.lst")){
                echo "! Error: cannot remove plugin '$name' - no install history found\n\n";
@@ -419,6 +509,7 @@ function remove_plugin($name)
        /* Update caches */
        rescan_classes();
        rescan_i18n();
+       rescan_guide();
 }
 
 
@@ -430,6 +521,7 @@ $description= $provides= $depends= $versions= $conflicts= array();
 if ($argc < 2){
        rescan_classes();
        rescan_i18n();
+       rescan_guide();
         exit (0);
 }