Code

Backports from 2.7
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 Sep 2011 08:19:07 +0000 (08:19 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 Sep 2011 08:19:07 +0000 (08:19 +0000)
-Added option which allows to edit a username proposal when creating users from template.

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

gosa-core/plugins/admin/users/class_userManagement.inc
gosa-core/plugins/admin/users/template.tpl

index a51a5c21fbdecd1264d9dc1635f9f42ef1d4f863..67f6021bca54dadf832fb7c1d0b6b85b90a954c1 100644 (file)
@@ -340,7 +340,7 @@ class userManagement extends management
 
 
 
-                // Change cassword 
+                // Change password 
                 if(isset($this->force_hash_type[$this->dn])){
                     if(!change_password ($this->dn, $new_password,0,$this->force_hash_type[$this->dn],'', $message)){
                         msg_dialog::displayChecks(array($message));
@@ -481,6 +481,7 @@ class userManagement extends management
             $smarty->assign("template",  array_pop($target));
             $smarty->assign("templates", $templates);
             $smarty->assign("edit_uid", "");
+            $smarty->assign("allowUidProposalModification", $this->config->get_cfg_value("core","allowUidProposalModification"));
             return($smarty->fetch(get_template_path('template.tpl', TRUE)));
 
             // -> See 'templateContinue' for further handling!
@@ -517,6 +518,7 @@ class userManagement extends management
             $smarty->assign("template", "none");
             $smarty->assign("templates", $templates);
             $smarty->assign("edit_uid", "");
+            $smarty->assign("allowUidProposalModification", $this->config->get_cfg_value("core","allowUidProposalModification"));
             return($smarty->fetch(get_template_path('template.tpl', TRUE)));
 
             // -> See 'templateContinue' for further handling!
@@ -570,6 +572,7 @@ class userManagement extends management
             $smarty->assign("templates",$templates);
             $smarty->assign("got_uid", $this->got_uid);
             $smarty->assign("edit_uid",false);
+            $smarty->assign("allowUidProposalModification", $this->config->get_cfg_value("core","allowUidProposalModification"));
             return($smarty->fetch(get_template_path('template.tpl', TRUE)));
         }
 
@@ -592,16 +595,23 @@ class userManagement extends management
 
             if ($ldap->count () != 0){
                 msg_dialog::displayChecks(array(msgPool::duplicated(_("Name"))));
+                $smarty->assign("edit_uid", "");
             }else{
 
                 // Preset uid field by using the idGenerator 
                 $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName);
                 if ($this->config->get_cfg_value("core","idGenerator") != ""){
-                    $uids= gen_uids ($this->config->get_cfg_value("core","idGenerator"), $attributes);
-                    if (count($uids)){
-                        $smarty->assign("edit_uid", "false");
-                        $smarty->assign("uids", $uids);
-                        $this->uid= current($uids);
+                    $genStr = $this->config->get_cfg_value("core","idGenerator");
+                    $smarty->assign("edit_uid", "");
+                    if(!empty($genStr)){
+                        $uids= gen_uids($genStr, $attributes);
+                        if (count($uids)){
+                            $smarty->assign("edit_uid", "false");
+                            $smarty->assign("uids", $uids);
+                            $this->uid= current($uids);
+                        }else{
+                            msg_dialog::displayChecks(array(_("Cannot generate a unique id, please specify it manually!")));
+                        }
                     }
                 } else {
                     $smarty->assign("edit_uid", "");
@@ -618,6 +628,7 @@ class userManagement extends management
                 $smarty->assign("template", get_post('template'));
             }
             $smarty->assign("templates",$templates); 
+            $smarty->assign("allowUidProposalModification", $this->config->get_cfg_value("core","allowUidProposalModification"));
             return($smarty->fetch(get_template_path('template.tpl', TRUE)));
         }
 
index ce9fee3953bcee937a30a2619b1f79d8ddc02037..2f7e25dbbe0b6a1407ea2f2f391dcd4d8de754b0 100644 (file)
     <td><b>{t}Login{/t}</b></td>
     <td>
       {if $edit_uid eq "false"}
-      <select size="1" name="uid">
-        {html_options output=$uids values=$uids selected=$uid}
-      </select>
-      {else}
-      <input type='text' name="uid" size="30" maxlength="40" value="{$uid}">
+        {if $allowUidProposalModification == "true"}
+           <select size="1" name="uidSelect" id='uidSelect' onChange="
+                document.getElementById('uid').value = document.getElementById('uidSelect').value;">
+            {html_options output=$uids values=$uids selected=$uid}
+          </select>
+          <input type='text' id="uid" name="uid" size="30" maxlength="40" value="{$uid}" 
+                style="display: none;">
+          <img src="images/lists/edit.png" onClick="$('uid').toggle();" 
+                title="{t}Modify the uid proposal{/t}">
+        {else}
+           <select size="1" name="uid">
+            {html_options output=$uids values=$uids selected=$uid}
+          </select>
+        {/if}
+      {else}                    
+          <input type='text' id="uid" name="uid" size="30" maxlength="40" value="{$uid}">
       {/if}
     </td>
   </tr>