From: hickert
Date: Tue, 9 Nov 2010 15:29:54 +0000 (+0000)
Subject: Updated registrtation process
X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e84e39a6caba8e52750cf914f8a29005d3386d60;p=gosa.git
Updated registrtation process
-Added several error messages
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20207 594d385d-05f5-0310-b6e9-bd551577e9d8
---
diff --git a/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc b/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc
index 9fdc23a23..81ea9ae6a 100644
--- a/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc
+++ b/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc
@@ -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;
-
}
}
?>
diff --git a/gosa-core/plugins/generic/dashBoard/Register/register.tpl b/gosa-core/plugins/generic/dashBoard/Register/register.tpl
index e3c4c4e71..24a6813f7 100644
--- a/gosa-core/plugins/generic/dashBoard/Register/register.tpl
+++ b/gosa-core/plugins/generic/dashBoard/Register/register.tpl
@@ -2,7 +2,6 @@
{t}GOsa registration{/t}
-
{if $step == 0}
{t}Do you want to register GOsa and benefit from the features it brings?{/t}
@@ -13,25 +12,6 @@
-
@@ -62,192 +42,26 @@
{/if}
-{if $step == 1}
-
- {if $default == ""}
- {t}Selected registration type:{/t} {$default}
- {elseif $default == "annonym"}
- {t}Selected registration type:{/t} {$default}
- {elseif $default == "registered"}
-
-
{t}Account settings{/t}
-
-
-
-
- {t}Password{/t}
-
-
-
- {t}Personal information{/t}
-
-
-
- {t}Newsletter{/t}
-
-
- ({$must} {t}Required fields{/t})
- {/if}
-
-
-
-
-
-
-
-{/if}
-
-
-{if $step == 2}
-
- {t}Company information{/t}
-
-
-
- {t}Contact information{/t}
-
-
-
- {t}Details{/t}
-