Code

Updated registrtation process
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Nov 2010 15:29:54 +0000 (15:29 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Nov 2010 15:29:54 +0000 (15:29 +0000)
-Added several error messages

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

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

index 9fdc23a238fc9341ff9db51d4ff766cf2a09c0cc..81ea9ae6aeb875f8a844f07070d65eb48782b30b 100644 (file)
@@ -12,144 +12,67 @@ class RegistrationDialog extends plugin
     protected $isRegistered = FALSE; 
     protected $step = 0;
 
-    public $attrs = array(
-            
-            // User table
-            'uid','password','password_repeated','restoreQuestion','restoreAnswer',
-            'mailAddress','surname','givenName','newsletter',
-
-            // Contact table
-            'phone','contact','contact_mail','company','street',
-            'postal_code','city','trade','employees','description');
-
-
     protected $values = array();
+    public $attrs = array('username','password');
 
     function __construct(&$config)
     {
         $this->config = $config;    
 
+        // Use empty values initially.
         foreach($this->attrs as $attr) $this->values[$attr] = "";
-
-        // Try to establish a rpc connection.
-        $this->rpcConfigured = FALSE;
-        if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
-            $this->rpcConfigured = TRUE;
-            $this->rpcHandle = $this->config->getRpcHandle(
-                    "http://10.3.64.59:4000",
-                    "65717fe6-9e3e-11df-b010-5452005f1250",
-                    "WyukwauWoid2",
-                    TRUE);
-        }
-    }
-
-
-    function registerNow()
-    {
-        if($this->selectedRegistrationType == "registered"){
-
-            // Register user 
-            print_a($this->rpcHandle->registerUser($this->values['uid'], $this->values));
-
-            // Register Instance with User.
-        }
-
-        #$this->step = 200; // Awaiting verification
     }
 
 
-    function check()
-    {
-        $message  = array();
-        if($this->step == 1){
-
-            // Checking for a valid 'uid'.
-            if(empty($this->values['uid'])) {
-                $message[] = msgPool::required(_("Account-ID"));
-            }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);
-    }
-
-   
     function execute()
     {
+        $smarty = get_smarty();
+        $smarty->assign("error", "");
+
         // 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();
+                if($this->selectedRegistrationType == "registered"){
+
+                    // Try to login with the given username / password
+                    $rpcHandle = $this->config->getRpcHandle(                                                   
+                            "http://10.3.64.59:4000",                                                                 
+                            $this->values['username'],
+                            $this->values['password'],
+                            TRUE, FALSE);         
+
+                    // Register instance 
+                    $rpcHandle->registerInstance($this->config->getInstanceUuid());
+
+                    // Check if we're able to connect. 
+                    if(!$rpcHandle->success()){
+            
+                        $code =  $rpcHandle->getHTTPstatusCode();
+                        if($code == 0){
+                            $smarty->assign("error", _("Communciation with the backend failed! Please check your internet connection!"));
+                        }elseif($code == 401){
+                            $smarty->assign("error", _("Authentication failed, please check combination of username and password!"));
+                        }elseif($code == 403){
+                            $smarty->assign("error", _("Internal server error, please try again later. If the problem persists contact the GOsa-Team!"));
+                        }
+                    }
+                } 
             }
         }
 
-
-        $smarty = get_smarty();
         $smarty->assign("default", $this->selectedRegistrationType);
         $smarty->assign("step", $this->step);
-
         foreach($this->attrs as $attr) $smarty->assign($attr, set_post($this->values[$attr]));
-
-
         return($smarty->fetch(get_template_path("Register/register.tpl", TRUE))); 
     } 
 
 
     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);
         }
@@ -157,7 +80,6 @@ class RegistrationDialog extends plugin
         if(isset($_POST['registrationType']))  $this->selectedRegistrationType = get_post('registrationType');
         if(isset($_POST['startRegistration'])) $this->step = 1;
         if(isset($_POST['stepBack'])) $this->step -= 1;
-
     }
 }
 ?>
index e3c4c4e714e15c85d62503f0060ba3f406a4a02b..24a6813f7a43053142abd4c779c27bc65990f982 100644 (file)
@@ -2,7 +2,6 @@
 
 <h3>{t}GOsa registration{/t}</h3>
 
-
 {if $step == 0}
 
     {t}Do you want to register GOsa and benefit from the features it brings?{/t}
             <!-- Add a descritive text later -->
         </p>
 
-        <!--
-        <input type='radio' name='registrationType' value='annonym' id="registrationType_annonym"
-            {if $default == "annonym"} checked {/if}><b><LABEL for="registrationType_annonym">{t}Annonym access{/t}</LABEL></b>
-        <p style='padding-left:20px;'>
-        <ul>
-            <li>{t}Access to the 'Open-Channels' to easily install or remove plugins within the GOsa user interface{/t}</li>
-            <li>{t}Use the inbuild bugtracker and keep track of their status on the dash-board.{/t}</li>
-        </ul>
-        </p>
-
-        <p style='padding-left:20px;'>
-        {t}What information will be transmitted to the backend and maybe stored:{/t}
-        <ul>
-            <li>{t}Information about the installed plugins and their version.{/t}</li>
-            <li>{t}The GOsa-UUID (will be generated during the registration) and a password, to authenticate.{/t}</li>
-            <li>{t}The bugs you will report and the corresponding trace. You can select what information you want to send in.{/t}</li>
-        </ul>
-        </p>
-        -->
         <input type='radio' name='registrationType' value='registered' id="registrationType_registered"
             {if $default == "registered"} checked {/if}><b><LABEL for="registrationType_registered">{t}Register{/t}</LABEL></b>
         <p style='padding-left:20px;'>
 
 {/if}
 
-{if $step == 1}
-
-    {if $default == ""}
-        <b>{t}Selected registration type:{/t} {$default}</b>
-    {elseif $default == "annonym"}
-        <b>{t}Selected registration type:{/t} {$default}</b>
-    {elseif $default == "registered"}
-        
-        <h3>{t}Account settings{/t}</h3>
-        <table style='width:100%;'>
-            <tr> 
-                <td style='width:220px;'><LABEL for="uid">{t}Login-ID{/t}{$must}</LABEL></td>
-                <td>
-                    <input type='text' name="uid" value="{$uid}" id="uid">
-                </td>
-            </tr>
-            <tr> 
-                <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>
-            </tr>
-        </table>
-
-        <hr>
-
-        <h3>{t}Password{/t}</h3>
-        <table style='width:100%;'>
-            <tr> 
-                <td style='width:220px;'><LABEL for="password">{t}Password{/t}{$must}</LABEL></td>
-                <td>
-                    {factory type='password' name='password' id='password' value={$password}
-                          onkeyup="testPasswordCss(\$('password').value)"}
-                </td>
-            </tr>
-            <tr>
-                <td></td>
-                <td>
-                    <div style='width:200px'>
-                    <span id="meterEmpty" style="padding:0;margin:0;width:100%;
-                            background-color:#DC143C;display:block;height:7px;">
-                    <span id="meterFull" style="padding:0;margin:0;z-index:100;
-                            width:0;background-color:#006400;display:block;height:7px;"></span></span>
-                    </div>
-                </td>
-            </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' value={$password_repeated}}
-                </td>
-            </tr>
-            <tr> 
-                <td style='width:220px;'><LABEL for="restoreQuestion">{t}Password restore question{/t}{$must}</LABEL></td>
-                <td>
-                    <input type='text' style='width:400px' name="restoreQuestion" value="{$restoreQuestion}" id="restoreQuestion">
-                </td>
-            </tr>
-            <tr> 
-                <td style='width:220px;'><LABEL for="restoreAnswer">{t}Password restore answer{/t}{$must}</LABEL></td>
-                <td>
-                    <input type='text' name="restoreAnswer" value="{$restoreAnswer}" id="restoreAnswer">
-                </td>
-            </tr>
-        </table>
-        <hr>
-       
-        <h3>{t}Personal information{/t}</h3>
-        <table style='width:100%;'>
-            <tr> 
-                <td style='width:220px;'><LABEL for="surname">{t}Surname{/t}{$must}</LABEL></td>
-                <td>
-                    <input type='text' name="surname" value="{$surname}" id="surname">
-                </td>
-            </tr>
-            <tr> 
-                <td style='width:220px;'><LABEL for="givenName">{t}Given name{/t}{$must}</LABEL></td>
-                <td>
-                    <input type='text' name="givenName" value="{$givenName}" id="givenName">
-                </td>
-            </tr>
-        </table>
-
-        <hr>
-        <h3>{t}Newsletter{/t}</h3>
-        <table style='width:100%;'>
-            <tr> 
-                <td style='width:220px;'><LABEL for="newsletter">{t}Newsletter{/t}</LABEL></td>
-                <td>
-                    <input type='checkbox' name="newsletter" value="1" {if $newsletter} checked {/if}id="newsletter">
-                </td>
-            </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='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>
+{if $step == 1 || $step == -1}
+    <table>
+        <tr>
+            <td><LABEL for="username">{t}Login{/t}</LABEL></td>
+            <td><input type='text' id='username' name='username' value="{$username}"></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>
+            <td><LABEL for="password">{t}Password{/t}</LABEL></td>
+            <td>{factory type='password' name='password' id='password' value={$password}}</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>
+            <td>&nbsp;</td>
+            <td><div style="color: red; font-size: small;"><i>{$error}</i></div></td>
         </tr>
     </table>
-
     <hr>
     <div class="plugin-actions">
-        <button name='stepBack'>{msgPool type=backButton}</button>
-        <button name='registerPage3'>{msgPool type=okButton}</button>
+        <button name='stepBack'>{msgPool type=backButton}</button>        
+        <button name='registerPage2'>{msgPool type=okButton}</button>        
     </div>
 {/if}
 
-{if $step == 200}
-   <h3>VERIFY TEXTS!!!</h3> You have receifed a mail, bafasel, please click link and so on.
 
-{/if}