diff --git a/models/my-profile.php b/models/my-profile.php index b7d7c9e..a8e57b9 100644 --- a/models/my-profile.php +++ b/models/my-profile.php @@ -2,10 +2,3 @@ $oConf = new ClassConfig(); if(!isset($_SESSION['user'])){ header("location:".$oConf->getURLRoot()); } -$oUser = new ClassUser(); -$oCountry = new ClassCountry(); -$oCurrency = new ClassCurrency(); -$oLang = new ClassLang(); -$oERP = new ClassERP(); - - diff --git a/models/register.php b/models/register.php index a08ef7f..e01cae2 100644 --- a/models/register.php +++ b/models/register.php @@ -22,7 +22,6 @@ if(isset($_POST['formRegisterButtonSubmit'])){ //create user in Wefra and link the user to ERP $res = $oUser->createUser($_POST); - print_r($res); } // .. // ENDOF creating user in ERP and in WeFra diff --git a/modules/ClassUser.php b/modules/ClassUser.php index 1176646..863e460 100644 --- a/modules/ClassUser.php +++ b/modules/ClassUser.php @@ -165,93 +165,6 @@ class ClassUser extends ClassConfig { } //ENDOF createUser() -// public function createUser($data){ -// $this->_data = $data; -// $config = ClassConfig::getConfig(); -// $oPDOLink = ClassConfig::databaseConnect(); -// -// -// //IF password and confirmPassword are not identical, displaying an error message -// if($this->_data['formRegisterFieldPassword'] != $this->_data['formRegisterFieldConfirmPassword']){ -// $message['state']='failed'; -// $message['css_class']='failed'; -// $message['translation_code'] = 'checkRegisterForm_notSamePassword'; -// return $message; -// } -// -// $activation_code = rand(); -// $sql=" -// INSERT INTO user_user(email, password, activation_code -// core_lang_id, core_country_id, core_currency_id, core_theme_id, -// comment -// ) VALUES ( -// :email, :password, :activation_code, -// (SELECT id FROM core_lang WHERE code='en_gb'), -// (SELECT id FROM core_country WHERE code='ch'), -// (SELECT id FROM core_currency WHERE code='chf'), -// (SELECT id FROM core_theme WHERE code='materialize'), -// 'user registered online via Wefra frontend' -// ) -// "; -// -// $execSQL = $oPDOLink->prepare($sql); -// if($execSQL->execute(array( -// ':email'=>$this->_data['formRegisterFieldEmail'], -// ':password'=>sha1($this->_data['formRegisterFieldPassword'].'-k3P[8x&'), -// ':activation_code'=>$activation_code, -// ))){ -// $newUserId = $oPDOLink->lastInsertId('user_user_id_seq'); -// -// //$isVipOfferActive = $this->_checkIfVipOfferActive(); -// //$isEverythingForFreeActive = $this->_checkIfEverythingForFreeActive(); -// // core user detail -// $sql=" -// INSERT INTO user_detail(user_id) -// VALUES (:user_id) -// "; -// $execSQL = $oPDOLink->prepare($sql); -// $execSQL->execute(array(':user_id'=>$newUserId)); -// -// // get features for user -// $sql="SELECT id FROM core_feature WHERE is_user_feature=TRUE;"; -// $getFeatures = $oPDOLink->prepare($sql); -// $getFeatures->execute(array()); -// $features = $getFeatures->fetchAll(PDO::FETCH_ASSOC); -// -// $sql=" -// INSERT INTO useruser_corefeature_rel(user_id, core_feature_id) -// VALUES ( -// (SELECT id FROM user_user WHERE email=:email LIMIT 1), -// :feature_id -// ); -// "; -// $execSQL = $oPDOLink->prepare($sql); -// -// //set features to user -// foreach($features as $feature){ -// $execSQL->execute(array(':email'=>$this->_data['formRegisterFieldEmail'], ':feature_id'=>$feature['id'])); -// } -// -// $message['user_id'] = $newUserId; -// $message['activation_code'] = $activation_code; -// $message['status'] = "success"; -// $message['css_class'] = 'success-message'; -// //TODO change confirmation_registration by register_form_success when registrations will need an activation by clic on link in an email -// //$message['translation_code'] = 'register_form_success'; //'confirmation_registration'; -// -// //TODO send an email to admin to indicate that there is a new registration -// return $message; -// } else { -// $message['user_id'] = "null"; -// $message['activation_code'] = "null"; -// $message['status']='error'; -// $message['css_class'] = 'failed-message'; -// //$message['translation_code'] = 'register_form_failed'; -// return $message; -// } -// } - - public function activateUser($activation_code){ $this->_activationCode = (string) $activation_code; $oPDOLink = ClassConfig::databaseConnect(); @@ -286,6 +199,7 @@ class ClassUser extends ClassConfig { return $message; } + //ENDOF activateUser() public function login($post_datas=array()){ $this->_postDatas = $post_datas; diff --git a/themes/materialize/index.php b/themes/materialize/index.php index 7c5716f..fad8faa 100644 --- a/themes/materialize/index.php +++ b/themes/materialize/index.php @@ -1,4 +1,18 @@ login($_POST); + + if(isset($user['email'])){ + $_SESSION['translations'] = $oTrans->listTranslations($user['lang_code']); + $_SESSION['user'] = $user; + $_SESSION['features'] = $oFeat->getFeaturesOfUser($user['id'], $user['lang_code']); + header("Location:".$oConf->getURLRoot()); + } else { + $_SESSION['message'] = $user; + } +} + + if(isset($_POST['submit_change_password'])){ // Open connection with Globsi Backend $url = $_SESSION['erp']['url']; @@ -24,28 +38,6 @@ if(isset($_POST['submit_change_password'])){ -if(isset($_POST['formLoginButtonSubmit'])){ - $url = $_SESSION['erp']['url']; - $db = $_SESSION['erp']['db']; - $username = $_POST['formLoginFieldEmail']; - $user = $oUser->login($_POST); - - if(isset($user['email']) && $user['email'] == $username){ - $password = $user['password']; - $common = ripcord::client($url."xmlrpc/2/common"); - $user['ext_id'] = $common->authenticate($db, $username, $password, array()); - $models = ripcord::client($url."xmlrpc/2/object"); - $user['erp'] = $models->execute_kw($db, $user['ext_id'], $password, 'res.users', 'search_read', array(array(array('id', '=', (integer) $user['ext_id']))), array('fields'=>array())); //, 'limit'=>5 - - $_SESSION['translations'] = $oTrans->listTranslations($user['lang_code']); - $_SESSION['user'] = $user; - $_SESSION['features'] = $oFeat->getFeaturesOfUser($user['id'], $user['lang_code']); - header("Location:".$oConf->getURLRoot()); - } else { - $_SESSION['message'] = $user; - } -} - $session_lifetime = 60*60*8; diff --git a/themes/materialize/views/my-profile.php b/themes/materialize/views/my-profile.php index 7668eaf..e2fbf5b 100644 --- a/themes/materialize/views/my-profile.php +++ b/themes/materialize/views/my-profile.php @@ -37,8 +37,9 @@
My Profile -

Email/Login:

-

Company:

+

Email:

+

Firstname:

+

Lastname:

diff --git a/themes/materialize/views/register.php b/themes/materialize/views/register.php index f4bb02e..d2d363d 100644 --- a/themes/materialize/views/register.php +++ b/themes/materialize/views/register.php @@ -6,7 +6,7 @@ if(isset($message)){
- +
Your profile has been created with success.