Code

Added initial department migration step.
[gosa.git] / setup / class_setupStep_Config2.inc
index b572ff74d6a7de9eacaa9526c6de0cd89c294f82..8eab8885f68696eb644f538ff0bad3ff01c94abf 100644 (file)
 
 class Step_Config2 extends setup_step
 {
-  var $strict         = TRUE;
   var $governmentmode = FALSE;
   var $sambaidmapping = FALSE;
-  var $minid          = 100;       
-  var $account_expiration  =FALSE;
+  var $header_image = "images/ldapserver.png";
 
-  var $generic_settings  = array( "idgen"         => "{%sn}-{%givenName[2-4]}",
-                                  "idgen_active"  => FALSE,
-                                  "minid"         => "100",
-                                  "minid_active"  => FALSE,
+  var $cyrusunixstyle = FALSE;
+  var $mail       = "none";
+  var $mail_methods   = array();
+  var $mail_settings = array("vacationdir"        => "/etc/gosa/vacation",
+                             "vacationdir_active" => FALSE);
+
+  var $generic_settings  = array( "enableCopyPaste" => false,
                                   "wws_ou"        => "ou=winstations",
                                   "wws_ou_active" => FALSE,
                                   "snapshot_active"     => FALSE,
                                   "snapshot_base"       => "ou=snapshots,%base%",
-                                  "snapshot_ldap_base"  => "%base%",
                                   "snapshot_user"       => "cn=ldapadmin,%base%",
                                   "snapshot_password"   => "",
                                   "snapshot_server"     => "%connection%");
@@ -44,20 +44,37 @@ class Step_Config2 extends setup_step
   var $samba_settings    = array( "samba_sid"        => "0-815-4711",
                                   "samba_sid_active" => FALSE,
                                   "samba_rid"        => 1000,
+                                  "smbhash"          => 'SMBHASH',
                                   "samba_rid_active" => FALSE); 
-  var $attributes = array("strict","governmentmode","sambaidmapping","account_expiration");
+
+  var $attributes = array("governmentmode","sambaidmapping","cyrusunixstyle","mail");
 
   function Step_Config2()
   {
     $this->update_strings();
+    $tmp = $this->get_available_mail_classes();
+    foreach($tmp['name'] as $name){
+      $this->mail_methods[$name] = $name;
+    }
+
+    /* Look for samba password generation method */
+    if(file_exists("/usr/bin/mkntpasswd")){
+      $pwdhash  = "/usr/bin/mkntpasswd";
+    } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
+      $pwdhash= "mkntpwd";
+    } else {
+      $pwdhash= 'perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen \$ARGV[0]), $/;"';
+    }
+
+    $this->samba_settings['smbhash'] = $pwdhash;
   }
 
  
   function update_strings()
   {
     $this->s_title      = _("GOsa settings 2/3");
-    $this->s_title_long = _("GOsa generic settings, page 2/3");
-    $this->s_info       = _("This dialog allows you to setup GOsa behaviour");
+    $this->s_title_long = _("GOsa settings 2/3");
+    $this->s_info       = _("Customize special parameters");
   }
 
  
@@ -65,7 +82,7 @@ class Step_Config2 extends setup_step
   {
     /* Update snapshot values, with already collected values */
     foreach($this->generic_settings as $key => $value){
-      foreach(array("snapshot_ldap_base","snapshot_base","snapshot_user","snapshot_server") as $attr){
+      foreach(array("snapshot_base","snapshot_user","snapshot_server") as $attr){
         foreach($this->parent->captured_values as $replace_name => $replace_value){
           if(is_string($replace_value))  {
             $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]);
@@ -76,14 +93,14 @@ class Step_Config2 extends setup_step
 
     $smarty = get_smarty();
     $smarty->assign("generic_settings",$this->generic_settings);
+    $smarty->assign("mail_settings",$this->mail_settings);
+    $smarty->assign("mail_methods",$this->mail_methods);
     $smarty->assign("samba_settings",$this->samba_settings);
-    $smarty->assign("warnings" ,$this->check());
-    $smarty->assign("warnings_cnt" ,count($this->check()));
     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
         foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
     }
-    return($smarty -> fetch (get_template_path("../setup/setup_step6.tpl")));
+    return($smarty -> fetch (get_template_path("../setup/setup_config2.tpl")));
   }
 
   function save_object()
@@ -97,13 +114,18 @@ class Step_Config2 extends setup_step
         }
       }
 
-      if(isset($_POST['minid_active'])){
-        $this->generic_settings['minid_active'] = TRUE;
-        if(isset($_POST['minid'])){
-          $this->generic_settings['minid'] = $_POST['minid'];
+      /* Mail settings */
+      if(isset($_POST['vacationdir_active'])){
+        $this->mail_settings['vacationdir_active'] = TRUE;
+        if(isset($_POST['vacationdir'])){
+          $this->mail_settings['vacationdir'] = $_POST['vacationdir'];
         }
       }else{
-        $this->generic_settings['minid_active'] = FALSE;
+        $this->mail_settings['vacationdir_active'] = FALSE;
+      }
+
+      if(isset($_POST['enableCopyPaste'])){
+        $this->generic_settings['enableCopyPaste'] = $_POST['enableCopyPaste'];
       }
 
       if(isset($_POST['wws_ou_active'])){
@@ -115,15 +137,6 @@ class Step_Config2 extends setup_step
         $this->generic_settings['wws_ou_active'] = FALSE;
       }
 
-      /* Generic settings */
-      if(isset($_POST['idgen_active'])){
-        $this->generic_settings['idgen_active'] = TRUE;
-        if(isset($_POST['idgen'])){
-          $this->generic_settings['idgen'] = $_POST['idgen'];
-        }
-      }else{
-        $this->generic_settings['idgen_active'] = FALSE;
-      }
       if(isset($_POST['snapshot_active'])){
         $this->generic_settings['snapshot_active'] = TRUE;
         if(isset($_POST['snapshot_base'])){
@@ -138,9 +151,6 @@ class Step_Config2 extends setup_step
         if(isset($_POST['snapshot_server'])){
           $this->generic_settings['snapshot_server'] = $_POST['snapshot_server'];
         }
-        if(isset($_POST['snapshot_ldap_base'])){
-          $this->generic_settings['snapshot_ldap_base'] = $_POST['snapshot_ldap_base'];
-        }
       }else{
         $this->generic_settings['snapshot_active'] = FALSE;
       }
@@ -162,6 +172,9 @@ class Step_Config2 extends setup_step
       }else{
         $this->samba_settings['samba_rid_active'] = FALSE;
       }
+      if(isset($_POST['smbhash'])){
+        $this->samba_settings['smbhash'] = $_POST['smbhash'];
+      }
 
     }
 
@@ -177,11 +190,6 @@ class Step_Config2 extends setup_step
   function check()
   {
     $message = array();
-    
-    if(isset($this->generic_settings['minid_active']) && !is_numeric($this->generic_settings['minid'])){
-      $message[] = sprintf(_("The specified value for '%s' must be a numeric value"),_("GID / UID min id"));
-    }
-  
     return($message);
   }
   
@@ -190,12 +198,36 @@ class Step_Config2 extends setup_step
   function get_attributes()
   {
     $tmp = setup_step::get_attributes();
-    foreach(array("samba_settings","generic_settings") as $attr){
+    foreach(array("samba_settings","generic_settings","mail_settings") as $attr){
       $tmp[$attr]= $this->$attr;
     }
     return($tmp);
   }
 
+/* Returns the classnames auf the mail classes */
+  function get_available_mail_classes()
+  {
+    $dir = opendir( "../include");
+    $methods = array();
+    $suffix = "class_mail-methods-";
+    $lensuf = strlen($suffix);
+    $prefix = ".inc";
+    $lenpre = strlen($prefix);
+    $i = 0;
+    while (($file = readdir($dir)) !== false){
+
+      if(stristr($file,$suffix)) {
+        $lenfile = strlen($file);
+        $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
+        $methods['file'][$i] = $file;
+        $methods[$i]['file'] = $file;
+        $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
+        $i++;
+      }
+    }
+    return($methods);
+  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: