prepare($sql); $execSQL->execute(array()); $rows = $execSQL->fetchAll(PDO::FETCH_ASSOC); foreach($rows as $k=>$v){ $erpConfig[$rows[$k]['k']] = $rows[$k]['v']; } return $erpConfig; } public function createClient($data, $ext_id){ $this->_data = $data; $this->_extId = $ext_id; $config = ClassConfig::getConfig(); $oPDOLink = ClassConfig::foreignDatabaseConnect($_SESSION['globsi_clients']['db_server'], $_SESSION['globsi_clients']['db_name'], $_SESSION['globsi_clients']['db_user'], $_SESSION['globsi_clients']['db_password']); //IF password and confirmPassword are not identical, displaying an error message if($this->_data['formCreateClientFieldPassword'] != $this->_data['formCreateClientFieldConfirmPassword']){ $message['state']='failed'; $message['css_class']='failed'; $message['translation_code'] = 'checkRegisterForm_notSamePassword'; return $message; } else { $activation_code = rand(); $sql=" INSERT INTO user_user(email, password, activation_code, firstname, lastname, core_lang_id, core_country_id, core_currency_id, core_theme_id, is_active, comment )VALUES( :email, :password, :activation_code, :firstname, :lastname, 12, 44, 4, 1, true, 'user created during installation process') "; $execSQL = $oPDOLink->prepare($sql); if($execSQL->execute(array( ':email'=>$this->_data['formCreateClientFieldEmail'], ':password'=>sha1($this->_data['formCreateClientFieldPassword'].'-k3P[8x&'), ':activation_code'=>$activation_code, ':firstname'=>$this->_data['formCreateClientFieldFirstname'], ':lastname'=>$this->_data['formCreateClientFieldLastname'] ))){ $newUserId = $oPDOLink->lastInsertId('user_user_id_seq'); //$isVipOfferActive = $this->_checkIfVipOfferActive(); //$isEverythingForFreeActive = $this->_checkIfEverythingForFreeActive(); // core user detail $sql=" INSERT INTO user_detail(user_id, ext_id) VALUES (:user_id, :ext_id) "; $execSQL = $oPDOLink->prepare($sql); $execSQL->execute(array(':user_id'=>$newUserId, ':ext_id'=>$this->_extId)); // features for user $sql=" INSERT INTO useruser_corefeature_rel(user_id, core_feature_id) VALUES ( (SELECT id FROM user_user WHERE email=:email LIMIT 1), (SELECT id FROM core_feature WHERE code=:core_feature_code LIMIT 1) ); "; $execSQL = $oPDOLink->prepare($sql); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'home')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'list-tasks')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'edit-task')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'create-task')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'list-partners')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'edit-partner')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'create-partner')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'list-projects')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'edit-project')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'create-project')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'my-profile')); $execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'logout')); $message['user_id'] = $newUserId; $message['activation_code'] = $activation_code; $message['status'] = "green"; $message['content'] = 'User created with success'; //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['status']='red'; $message['content'] = 'User has not been created'; //$message['translation_code'] = 'register_form_failed'; return $message; } } } public function getClient($user_id){ $this->_userId = $user_id; $config = ClassConfig::getConfig(); $oPDOLink = ClassConfig::foreignDatabaseConnect($_SESSION['globsi_clients']['db_server'], $_SESSION['globsi_clients']['db_name'], $_SESSION['globsi_clients']['db_user'], $_SESSION['globsi_clients']['db_password']); $sql=" SELECT ud.ext_id, uu.* FROM user_user uu LEFT JOIN user_detail ud ON uu.id=ud.user_id WHERE uu.id=:user_id; "; $execSQL = $oPDOLink->prepare($sql); $execSQL->execute(array(':user_id'=>$this->_userId)); $row = $execSQL->fetch(PDO::FETCH_ASSOC); return $row; } }