Code

Updated setup
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 14 Feb 2008 13:39:06 +0000 (13:39 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 14 Feb 2008 13:39:06 +0000 (13:39 +0000)
-Mail methods are listed correctly again.
-Added mail indentification attribute.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8915 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/setup/class_setupStep_Config2.inc
gosa-core/setup/setup_config2.tpl

index 9389964118d9f12e478385deb8920ea0e2ce18ca..ecf986f830f501abb14701c273bc40db3542b3dc 100644 (file)
@@ -27,7 +27,8 @@ class Step_Config2 extends setup_step
   var $header_image = "images/ldapserver.png";
 
   var $cyrusunixstyle = FALSE;
-  var $mail       = "none";
+  var $mail           = "none";
+  var $mail_attrib    = "";
   var $mail_methods   = array();
   var $mail_settings = array("vacationdir"        => "/etc/gosa/vacation",
                              "vacationdir_active" => FALSE);
@@ -57,16 +58,13 @@ class Step_Config2 extends setup_step
   var $timezone       = "Europe/Berlin";
   var $timezones      = array();
 
-  var $attributes = array("governmentmode","sambaidmapping","cyrusunixstyle","mail","use_netatalk","enableFAI_management","timezone","enableMimeType");
+  var $attributes = array("mail_attrib","governmentmode","sambaidmapping","cyrusunixstyle","mail","use_netatalk","enableFAI_management","timezone","enableMimeType");
   var $called = FALSE;
 
   function Step_Config2()
   {
     $this->update_strings();
-    $tmp = $this->get_available_mail_classes();
-    foreach($tmp['name'] as $name){
-      $this->mail_methods[$name] = $name;
-    }
+    $this->mail_methods = $this->get_available_mail_classes();
 
     /* Look for samba password generation method */
     if(file_exists("/usr/bin/mkntpasswd")){
@@ -92,6 +90,7 @@ class Step_Config2 extends setup_step
  
   function execute()
   {
+    $this->mail_methods = $this->get_available_mail_classes();
     /* On first call check for rid/sid base */
     $cv = $this->parent->captured_values;
     $ldap = new LDAP($cv['admin'],
@@ -159,7 +158,7 @@ class Step_Config2 extends setup_step
     $smarty->assign("mail_methods",$this->mail_methods);
     $smarty->assign("samba_settings",$this->samba_settings);
     $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
-        foreach($this->attributes as $attr){
+    foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
     }
     $smarty->assign("timezone"     ,$this->timezone);
@@ -175,6 +174,8 @@ class Step_Config2 extends setup_step
         $this->timezone = $_POST['timezone'];
       }
 
+      $old_mail = $this->mail;
+
       /* Get attributes */
       foreach($this->attributes as $attr){
         if(isset($_POST[$attr])){
@@ -254,6 +255,11 @@ class Step_Config2 extends setup_step
         $this->samba_settings['samba_sid_active'] = TRUE;
         $this->samba_settings['samba_rid_active'] = TRUE;
       }
+
+      /* Reload mail naming attribute */
+      if($old_mail != $this->mail && isset($this->mail_methods[$this->mail]['uattrib'])){
+        $this->mail_attrib = $this->mail_methods[$this->mail]['uattrib'];
+      }
     }
 
     $tmp = $this->check();
@@ -282,30 +288,34 @@ class Step_Config2 extends setup_step
     return($tmp);
   }
 
-/* Returns the classnames auf the mail classes */
+
+  /* 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++;
+    global $class_mapping;
+
+    $default_uattrib = "";
+    $m_class_vars = get_class_vars("mailMethod");
+    if(isset($m_class_vars['uattrib'])){
+      $default_uattrib = $m_class_vars['uattrib'];
+    }
+
+    foreach($class_mapping as $name => $file){
+      if(preg_match("/^mailMethod[a-z]*$/i",$name)){
+        $name = preg_replace("/^mailMethod/","",$name);
+        if(!empty($name)){
+          $methods[$name]['name'] = $name;
+          $m_class_vars = get_class_vars("mailMethod".$methods[$name]['name']);
+          if(isset($m_class_vars['uattrib'])){
+            $methods[$name]['uattrib'] = $m_class_vars['uattrib'];
+          }else{
+            $methods[$name]['uattrib'] = $default_uattrib;
+          }
+        }
       }
     }
     return($methods);
   }
-
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 80c5cf6aac5666e2d4412c51e4e9e035f6ba5903..e5000dead61b8c423d4e27645df4ac1240388bca 100644 (file)
         <div class='step4_name'>
             {t}Mail method{/t}
         </div>
-        <div class='step4_value'>
-            <select name="mail" size="1" title="">
+               <div class='step4_value'>
+            <select name="mail" size="1" title="" onChange="document.mainform.submit();">
                 <option  value="disabled">{t}disabled{/t}</option>
-                {html_options options=$mail_methods selected=$mail}
+                {foreach from=$mail_methods item=item}
+                    <option value="{$item.name}" {if $mail == $item.name} selected {/if}>{$item.name}&nbsp;({$item.uattrib})</option>
+                {/foreach}
+            </select>
+        </div>
+        <div class='step4_status'>
+        </div>
+    </div>
+
+    <div class='step4_container'>
+        <div class='step4_name'>
+            {t}Account identification attribute{/t}
+        </div>
+        <div class='step4_value'>
+            <select name="mail_attrib" size="1" {if $mail == "disabled"} disabled {/if}>
+                <option value="mail" {if $mail_attrib == "mail"} selected {/if} >mail</option>
+                <option value="uid" {if $mail_attrib == "uid"} selected {/if} >uid</option>
             </select>
         </div>
         <div class='step4_status'>