Code

Added step8, configuration file handing. Not working yet.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 3 Apr 2007 08:11:11 +0000 (08:11 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 3 Apr 2007 08:11:11 +0000 (08:11 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5956 594d385d-05f5-0310-b6e9-bd551577e9d8

setup/class_setupStep5.inc
setup/class_setupStep8.inc [new file with mode: 0644]
setup/setup_step5.tpl
setup/setup_step8.tpl [new file with mode: 0644]

index 98fe7e694b11cf3b80c9e9db53da86731558a31f..7cad07cc03b8ad73ed26ca5ecdd46c42156e2388 100644 (file)
@@ -158,6 +158,8 @@ class setup_step_5 extends setup_step
       }else{
         $this->pwd_rules['pwdiffer_active'] = FALSE;
       }
+
+      /* Get password minimum length posts */
       if(isset($_POST['pwminlen_active'])){
         $this->pwd_rules['pwminlen_active'] = TRUE;
         if(isset($_POST['pwminlen'])){
@@ -176,6 +178,16 @@ class setup_step_5 extends setup_step
       }else{
         $this->mail_settings['vacationdir_active'] = FALSE;
       }
+
+      /* Mail settings */
+      if(isset($_POST['externalpwdhook_active'])){
+        $this->pwd_rules['externalpwdhook_active'] = TRUE;
+        if(isset($_POST['externalpwdhook'])){
+          $this->pwd_rules['externalpwdhook'] = $_POST['externalpwdhook'];
+        }
+      }else{
+        $this->pwd_rules['externalpwdhook_active'] = FALSE;
+      }
     }
 
     $tmp = $this->check(); 
diff --git a/setup/class_setupStep8.inc b/setup/class_setupStep8.inc
new file mode 100644 (file)
index 0000000..f7dc508
--- /dev/null
@@ -0,0 +1,111 @@
+<?php
+
+/*
+   This code is part of GOsa (https://gosa.gonicus.de)
+   Copyright (C) 2007 Fabian Hickert
+
+   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
+ */
+
+
+class setup_step_8 extends setup_step
+{
+  var $create_backup = TRUE;
+  var $gosa_conf_name = "/gosa.conf";
+
+  function setup_step_8()
+  {
+    $this->s_title      = _("Configuration file");
+    $this->s_title_long = _("In this step the configuration file will be created.");
+    $this->s_info       = _("Saving configuration file");
+  }
+
+
+  function execute()
+  {
+
+    /* Check if there is currently an active gosa.conf 
+     */
+    $exists = file_exists(CONFIG_DIR.$this->gosa_conf_name); 
+
+    /* Check if existing config file is writeable */
+    if($exists){
+      $writeable = is_writeable(CONFIG_DIR.$this->gosa_conf_name);
+    }else{
+      $writeable = is_writeable(CONFIG_DIR);
+    }
+
+    $smarty = get_smarty();
+  
+    $info= posix_getgrgid(posix_getgid());
+    $smarty->assign("webgroup", $info['name']);
+
+    $smarty->assign("gosa_conf_name" , $this->gosa_conf_name);
+    $smarty->assign("create_backup" , $this->create_backup);
+    $smarty->assign("CONFIG_DIR",CONFIG_DIR);
+  
+    $smarty->assign("msg_permissions",sprintf(_("The following file(s), folders(s) must be writeable for the web-user '%s'."),$info['name']));
+    $smarty->assign("exists",$exists);
+    $smarty->assign("writeable",$writeable);
+    $smarty->assign("cv",$this->parent->captured_values);
+    return($smarty -> fetch (get_template_path("../setup/setup_step8.tpl")));
+  }
+
+
+  /* Create a backup of the currently existing configuration file. 
+   */
+  function create_backup()
+  {
+    if(is_writeable(CONFIG_DIR) && is_writeable(CONFIG_DIR.$this->gosa_conf_name)){
+      $src = CONFIG_DIR.$this->gosa_conf_name;
+      $dst = CONFIG_DIR.$this->gosa_conf_name."_".date("Ymd");
+      $dst_backup= $dst;
+      $i = 1;
+      while(file_exists($dst)){
+        $dst = $dst_backup."-".$i;
+        $i ++;
+      }
+      return(rename($src,$dst));
+    }else{
+      return(FALSE);
+    }
+  }
+
+
+  function save_object()
+  {
+    if(isset($_POST['step8_posted'])){
+
+      /* Get attributes */
+      foreach($this->attributes as $attr){
+        if(isset($_POST[$attr])){
+          $this->$attr = validate($_POST[$attr]);
+        }
+      }
+
+      /* Backup toggle */
+      if(isset($_POST['create_backup'])){
+        $this->create_backup = TRUE;
+      }else{
+        $this->create_backup = FALSE;
+      }
+    }
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index ff9814552dcf50f520bac221fad12c019640c44d..ee93b8f90dd31644786ffa4499ba79720badc21a 100644 (file)
                                {t}Different characters from old password{/t}
                                <input id='pwdiffer' name='pwdiffer' type='text' value='{$pwd_rules.pwdiffer}' size=3 disabled>
                        {else}
-                               <input type='checkbox' value='1' name='pwminlen_active' checked>
+                               <input type='checkbox' value='1' name='pwdiffer_active' checked>
                                {t}Different characters from old password{/t}
                                <input id='pwdiffer' name='pwdiffer' type='text' value='{$pwd_rules.pwdiffer}' size=3 >
                        {/if}
diff --git a/setup/setup_step8.tpl b/setup/setup_step8.tpl
new file mode 100644 (file)
index 0000000..70cfee6
--- /dev/null
@@ -0,0 +1,49 @@
+<div style='float:left;width:690px;'>
+
+<h2>{t}Configuration File{/t}</h2>
+       <p>
+               {t}GOsa setup has collected all data needed to create an initial configuration file.{/t}
+       </p>
+       <p>
+               {t}If you want the setup routine to write the configuration file, use the 'Save configuration' button below. If you prefer to copy the 'gosa.conf' manually to '/etc/gosa/' you can download the configuration file by using the 'Download configuration' button.{/t}
+       </p>
+       <p>
+               <b>{t}Automatically write configuration{/t}</b>
+       </p>
+       <p>     
+               {if $writeable}
+                       {t}Write configuration file{/t}&nbsp;
+                       <input type='submit' name='saveconf' value='{t}Save configuration{/t}'>
+                       <br>
+                       <input {if $create_backup} checked {/if} type='checkbox' value='1' name='create_backup'>&nbsp;
+                       {t}Create a backup from existing configuration file{/t}
+               {else}          
+                       <div style='font-weight: bold; color: red;'>{t}Can't write configuration file, please check permissions.{/t}</div>
+                       <pre>
+{$msg_permissions}
+       {$CONFIG_DIR} 
+       {$CONFIG_DIR}{$gosa_conf_name}
+                       </pre>
+               {/if}
+       </p>
+       <br>
+       <p>
+               <b>{t}Manually create configuration file{/t}</b>
+       </p>
+       <p>     
+               {t}Download the configuration file{/t}&nbsp;
+               <input type='submit' name='getconf' value='{t}Download configuration{/t}'>
+       </p>
+       <p>     
+               {t}After placing the file under /etc/gosa, place make sure that the webserver user is able to read gosa.conf, while other users shouldn't. You may want to execute these commands to achieve this requirement:{/t}
+       </p>
+       <pre>
+       # chown root.{$webgroup} /etc/gosa/gosa.conf
+       # chmod 640 /etc/gosa/gosa.conf
+       </pre>
+</p>
+
+
+
+</div>
+<input type='hidden' value='1' name='step8_posted'>