Code

Updated registration process
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 8 Nov 2010 13:41:58 +0000 (13:41 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 8 Nov 2010 13:41:58 +0000 (13:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20203 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc
gosa-core/plugins/generic/dashBoard/Register/register.tpl

index 72f0b4eaecbb3166538799070cc76cef985645f9..9fdc23a238fc9341ff9db51d4ff766cf2a09c0cc 100644 (file)
@@ -49,7 +49,7 @@ class RegistrationDialog extends plugin
         if($this->selectedRegistrationType == "registered"){
 
             // Register user 
-            print_a($this->rpcHandle->registerUser('cajus', $this->values));
+            print_a($this->rpcHandle->registerUser($this->values['uid'], $this->values));
 
             // Register Instance with User.
         }
@@ -66,9 +66,43 @@ class RegistrationDialog extends plugin
             // Checking for a valid 'uid'.
             if(empty($this->values['uid'])) {
                 $message[] = msgPool::required(_("Account-ID"));
-            }elseif(!preg_match("/^[a-z0-9_-]+$/", $this->values['uid'])){
+            }elseif(preg_match('/[^a-z0-9_\-]/', $this->values['uid'])){
                 $message[] = msgPool::invalid(_("Account-ID"), $this->values['uid'],'/[a-z0-9_-]/');
             }
+
+            // Checking for a valid 'mailAddress'.
+            if(empty($this->values['mailAddress'])) {
+                $message[] = msgPool::required(_("Mail address"));
+            }elseif(!tests::is_email($this->values['mailAddress'])){
+                $message[] = msgPool::invalid(_("Mail address"), $this->values['mailAddress']);
+            }
+
+            // Checking for a valid 'password'.
+            if(empty($this->values['password'])) {
+                $message[] = msgPool::required(_("Password"));
+            }elseif($this->values['password'] != $this->values['password_repeated']){
+                $message[] = _("The given password and repeated password do not match!");
+            }
+
+            // Checking for a valid password restore message.
+            if(empty($this->values['restoreQuestion'])) {
+                $message[] = msgPool::required(_("Password restore question"));
+            }
+
+            // Checking for a valid restore answer.
+            if(empty($this->values['restoreAnswer'])) {
+                $message[] = msgPool::required(_("Password restore answer"));
+            }
+
+            // Checking for a valid 'givenName'.
+            if(empty($this->values['givenName'])) {
+                $message[] = msgPool::required(_("Given name"));
+            }
+
+            // Checking for a valid surname.
+            if(empty($this->values['surname'])) {
+                $message[] = msgPool::required(_("Surname"));
+            }
         }
         
         return($message);
@@ -77,12 +111,23 @@ class RegistrationDialog extends plugin
    
     function execute()
     {
-        // Registration request.
-        if(isset($_POST['registerNow'])){
+        // Registration page one filled in, next step requested.
+        if(isset($_POST['registerPage2'])){
+            $msgs = $this->check();
+            if(count($msgs)){
+                msg_dialog::displayChecks($msgs); 
+            }else{
+                $this->step = 2;
+            }
+        }
+
+        // Registration page one filled in, next step requested.
+        if(isset($_POST['registerPage3'])){
             $msgs = $this->check();
             if(count($msgs)){
                 msg_dialog::displayChecks($msgs); 
             }else{
+                $this->step = 200;
                 $this->registerNow();
             }
         }
@@ -101,13 +146,18 @@ class RegistrationDialog extends plugin
 
     function save_object()
     {
+        // get Newsletter Checkbox value
+        if($this->step == 1){
+             $this->values['newsletter'] = isset($_POST['newsletter']);
+        }
+        foreach($this->attrs as $attr){
+            if(isset($_POST[$attr])) $this->values[$attr] = get_post($attr);
+        }
+
         if(isset($_POST['registrationType']))  $this->selectedRegistrationType = get_post('registrationType');
         if(isset($_POST['startRegistration'])) $this->step = 1;
         if(isset($_POST['stepBack'])) $this->step -= 1;
 
-        foreach($this->attrs as $attr){
-            if(isset($_POST[$attr])) $this->values[$attr] = get_post($attr);
-        }
     }
 }
 ?>
index 55e3d977fb50387f54df814d7bce595ef338d1f0..e3c4c4e714e15c85d62503f0060ba3f406a4a02b 100644 (file)
@@ -79,7 +79,7 @@
                 </td>
             </tr>
             <tr> 
-                <td style='width:220px;'><LABEL for="mailAddress">{t}Mail-address{/t}{$must}</LABEL></td>
+                <td style='width:220px;'><LABEL for="mailAddress">{t}Mail address{/t}{$must}</LABEL></td>
                 <td>
                     <input type='text' name="mailAddress" value="{$mailAddress}" id="mailAddress">
                 </td>
@@ -93,9 +93,8 @@
             <tr> 
                 <td style='width:220px;'><LABEL for="password">{t}Password{/t}{$must}</LABEL></td>
                 <td>
-                    {factory type='password' name='password' id='password'
+                    {factory type='password' name='password' id='password' value={$password}
                           onkeyup="testPasswordCss(\$('password').value)"}
-
                 </td>
             </tr>
             <tr>
             <tr> 
                 <td style='width:220px;'><LABEL for="password_repeated">{t}Password{/t} <i>({t}repeated{/t})</i>{$must}</LABEL></td>
                 <td>
-                    {factory type='password' name='password_repeated' id='password_repeated'}
+                    {factory type='password' name='password_repeated' id='password_repeated' value={$password_repeated}}
                 </td>
             </tr>
             <tr> 
         </table>
         <hr>
         <i>({$must} {t}Required fields{/t})</i>
-
-
     {/if}
 
     <hr>
     <div class="plugin-actions">
         <button name='stepBack'>{msgPool type=backButton}</button>
-        <button name='registerNow'>{msgPool type=okButton}</button>
+        <button name='registerPage2'>{msgPool type=okButton}</button>
     </div>
     <script type="text/javascript">
         focus_field('uid');
     </script>
 {/if}
 
+
 {if $step == 2}
 
+    <h3>{t}Company information{/t}</h3>
+    <table style='width:100%;'>
+        <tr> 
+            <td style='width:220px;'><LABEL for="company">{t}Company name{/t}</LABEL></td>
+            <td>
+                <input type='text' name="company" value="{$company}" id="company">
+            </td>
+        </tr>
+        <tr> 
+            <td style='width:220px;'><LABEL for="street">{t}Street{/t}</LABEL></td>
+            <td>
+                <input type='text' name="street" value="{$street}" id="street">
+            </td>
+        </tr>
+        <tr> 
+            <td style='width:220px;'><LABEL for="city">{t}City{/t}</LABEL></td>
+            <td>
+                <input type='text' name="city" value="{$city}" id="city">
+            </td>
+        </tr>
+        <tr> 
+            <td style='width:220px;'><LABEL for="postal_code">{t}Postal code{/t}</LABEL></td>
+            <td>
+                <input type='text' name="postal_code" value="{$postal_code}" id="postal_code">
+            </td>
+        </tr>
+    </table>
+    <hr>
+
+    <h3>{t}Contact information{/t}</h3>
+    <table style='width:100%;'>
+        <tr> 
+            <td style='width:220px;'><LABEL for="phone">{t}Contact phone number{/t}</LABEL></td>
+            <td>
+                <input type='text' name="phone" value="{$phone}" id="phone">
+            </td>
+        </tr>
+        <tr> 
+            <td style='width:220px;'><LABEL for="contact_mail">{t}Contact mail address{/t}</LABEL></td>
+            <td>
+                <input type='text' name="contact_mail" value="{$contact_mail}" id="contact_mail">
+            </td>
+        </tr>
+    </table>
+    <hr>
+
+    <h3>{t}Details{/t}</h3>
+    <table style='width:100%;'>
+        <tr> 
+            <td style='width:220px;'><LABEL for="employees">{t}Number of employees{/t}</LABEL></td>
+            <td>
+                <input type='text' name="employees" value="{$employees}" id="employees">
+            </td>
+        </tr>
+        <tr> 
+            <td style='width:220px;'><LABEL for="trade">{t}What does your company deal with?{/t}</LABEL></td>
+            <td>
+                <textarea style="width:240px;" rows=3 id='trade' name="trade">{$trade}</textarea>
+            </td>
+        </tr>
+        <tr> 
+            <td style='width:220px;'><LABEL for="description">{t}Additional information{/t}</LABEL></td>
+            <td>
+                <textarea style="width:240px;" rows=3 id='description' name="description">{$description}</textarea>
+            </td>
+        </tr>
+    </table>
+
     <hr>
     <div class="plugin-actions">
         <button name='stepBack'>{msgPool type=backButton}</button>
+        <button name='registerPage3'>{msgPool type=okButton}</button>
     </div>
 {/if}