clean code and fix bugs (to cont.)
This commit is contained in:
parent
abf81ef36d
commit
5b1b92fe61
@ -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();
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -1,4 +1,18 @@
|
||||
<?php
|
||||
if(isset($_POST['formLoginButtonSubmit'])){
|
||||
$user = $oUser->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;
|
||||
|
@ -37,8 +37,9 @@
|
||||
<div class="card col s12 l9">
|
||||
<div class="card-content">
|
||||
<span class="card-title">My Profile</span>
|
||||
<p>Email/Login: <?php echo $user[0]['email']; ?></p>
|
||||
<p>Company: <?php echo $user[0]['company_id'][1]; ?></p>
|
||||
<p>Email: <?php echo $_SESSION['user']['email']; ?></p>
|
||||
<p>Firstname: <?php echo $_SESSION['user']['firstname']; ?></p>
|
||||
<p>Lastname: <?php echo $_SESSION['user']['lastname']; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -6,7 +6,7 @@ if(isset($message)){
|
||||
<div class="section">
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<?php if($user == true){ ?>
|
||||
<?php if($res == "success_creation_user"){ ?>
|
||||
<div class="card-panel green">
|
||||
<span class="white-text">Your profile has been created with success.</span>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user