Code

Added additional check for selected values on template selection dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Sep 2006 04:04:55 +0000 (04:04 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Sep 2006 04:04:55 +0000 (04:04 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4610 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/users/class_userManagement.inc

index cc6fc5f060558c7967ca0eb34c259cdb16e9dd7d..d2aea37b4d6e90762e6f5a3336e2f7d7b8325014 100644 (file)
@@ -79,6 +79,7 @@ class userManagement extends plugin
       foreach(array("del"       => "user_del",    "edit"      => "user_edit",
                     "new"       => "user_new",
                     "new_tpl"   => "user_tplnew",
+                    "create_user_from_tpl"          => "userfrom_tpl",
                     "change_pw" => "user_chgpw", 
                     "editPaste" => "editPaste",   "copy"      => "copy",
                     "cut"       => "cut") as $act => $name){
@@ -459,6 +460,38 @@ class userManagement extends plugin
       Create a new user,template, user from template 
      ********************/
 
+    /* Check selected options for template */
+    if (isset($_POST['template_continue'])){
+      if(!isset($_POST['template']) || (empty($_POST['template']))){
+        $message[] = _("Please select a valid template.");
+      }
+      if(!isset($_POST['sn']) || (empty($_POST['sn']))){
+        $message[]= _("The required field 'Name' is not set.");
+      }
+      if(!isset($_POST['givenName']) || (empty($_POST['givenName']))){
+        $message[]= _("The required field 'Given name' is not set.");
+      }
+    
+      /* Show error message / continue editing */
+      if (count($message) > 0){
+        show_errors ($message);
+
+        foreach(array("sn", "givenName", "uid", "template") as $attr){
+          if(isset($_POST[$attr])){
+            $smarty->assign("$attr", $_POST[$attr]);
+          }else{
+            $smarty->assign("$attr", "");
+          }
+        }
+        $smarty->assign("templates",$this->templates);
+        $smarty->assign("got_uid",$this->got_uid);
+        $smarty->assign("edit_uid",false);
+
+        return($smarty->fetch(get_template_path('template.tpl', TRUE)));
+
+      }
+    }
+
     /* New user/template request */
     if (($s_action=="create_user_from_tpl")||($s_action=="new") || ($s_action=="new_tpl")){
       /* By default we set 'dn' to 'new', all relevant plugins will
@@ -504,7 +537,8 @@ class userManagement extends plugin
      ********************/
 
     /* Continue template editing */
-    if ((isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid']))){
+    if ((isset($_POST['template_continue'])) && ($_POST['template'] != 'none') && (!isset($_POST['uid']))){
+
       $this->sn             = $_POST['sn'];
       $this->givenName      = $_POST['givenName'];
 
@@ -555,7 +589,6 @@ class userManagement extends plugin
       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
     }
 
-
     /********************
       No template selected continue edit
      ********************/