2010-11-22 12:50:12 +00:00
|
|
|
<?php
|
2011-05-03 12:49:43 +00:00
|
|
|
class UserController extends Zend_Controller_Action
|
|
|
|
{
|
2015-07-08 13:48:28 +00:00
|
|
|
protected $theme;
|
|
|
|
|
2014-09-04 12:58:12 +00:00
|
|
|
/**
|
|
|
|
* Return a ramdom password
|
|
|
|
* @param int $length
|
|
|
|
* Length of the string
|
|
|
|
* @param int $strength
|
|
|
|
* $strength = 1:- 0-9
|
|
|
|
* $strength = 2:- A-Z0-9
|
|
|
|
* $strength = 3:- A-Za-z0-9
|
|
|
|
* $strength = 4:- A-Za-z0-9 and # $ % &
|
|
|
|
* $strength = 5:- A-Za-z0-9 and # $ % & = > ? @
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function randomPassword($length,$strength)
|
|
|
|
{
|
|
|
|
$char_sets=array('48-57','65-90','97-122','35-38','61-64');
|
|
|
|
$new_password='';
|
|
|
|
srand(microtime()*10000000);
|
|
|
|
for($i=0;$i<$length;$i++){
|
|
|
|
$random=rand(0,$strength-1);
|
|
|
|
list($start,$end)=explode('-',$char_sets[$random]);
|
|
|
|
$new_password.=chr(rand($start,$end));
|
|
|
|
}
|
|
|
|
return $new_password;
|
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-03 15:58:48 +00:00
|
|
|
public function init()
|
|
|
|
{
|
2015-07-08 20:38:22 +00:00
|
|
|
// --- Theme
|
|
|
|
$this->theme = Zend_Registry::get('theme');
|
|
|
|
|
2011-05-24 13:25:52 +00:00
|
|
|
require_once 'Scores/WsScores.php';
|
2011-05-03 15:58:48 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-03 12:49:43 +00:00
|
|
|
/**
|
|
|
|
* Affiche le fomulaire d'edition des paramètres utilisateur
|
|
|
|
*/
|
2010-11-22 12:50:12 +00:00
|
|
|
public function indexAction()
|
|
|
|
{
|
2015-07-16 15:48:12 +00:00
|
|
|
$this->view->headLink()->appendStylesheet($this->theme->pathStyle.'/user.css', 'all');
|
2014-04-24 10:46:36 +00:00
|
|
|
|
|
|
|
$user = new Scores_Utilisateur();
|
2013-05-27 15:22:43 +00:00
|
|
|
|
2012-02-29 09:10:51 +00:00
|
|
|
if (!$user->checkPerm('MONPROFIL')){
|
2016-09-20 16:37:56 +02:00
|
|
|
$this->forward('perms', 'error');
|
2012-05-10 06:06:04 +00:00
|
|
|
}
|
|
|
|
|
2013-05-14 09:32:08 +00:00
|
|
|
$this->view->assign('device_type', $user->getBrowserInfo()->mobile);
|
|
|
|
$this->view->assign('browser_info', $user->getBrowserInfo()->name.' '.$user->getBrowserInfo()->version);
|
|
|
|
|
2015-07-10 14:14:55 +00:00
|
|
|
$this->view->headScript()->appendFile($this->theme->pathScript.'/user.js', 'text/javascript');
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-03 12:49:43 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
$messages = '';
|
2011-05-06 08:23:36 +00:00
|
|
|
$isProfilUpdated = false;
|
|
|
|
$isPasswordUpdated = false;
|
2011-05-03 12:49:43 +00:00
|
|
|
$updateResult = false;
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-06-30 14:25:23 +00:00
|
|
|
$login = $request->getParam('login', '');
|
2011-08-05 12:52:50 +00:00
|
|
|
$op = $request->getParam('op');
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2013-05-27 15:22:43 +00:00
|
|
|
//Récupération des informations de l'identité
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$identity = $auth->getIdentity();
|
|
|
|
|
2013-05-14 09:32:08 +00:00
|
|
|
//Save data
|
|
|
|
if ( $request->isPost() ) {
|
2011-05-03 12:49:43 +00:00
|
|
|
$options = $request->getParam('frmOptions', '');
|
|
|
|
$action = $options['action'];
|
2011-08-05 14:40:21 +00:00
|
|
|
|
|
|
|
if ($login=='') $login = $options['login'];
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-03 12:49:43 +00:00
|
|
|
//Enregistrement des données new & update
|
|
|
|
if (in_array($action, array('new','update'))) {
|
2012-06-17 13:38:59 +00:00
|
|
|
|
2015-01-13 13:05:26 +00:00
|
|
|
if ( $options['changepwd'] != 1 ) {
|
2012-07-16 13:25:23 +00:00
|
|
|
$options['password'] = '';
|
2011-05-03 12:49:43 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
|
|
|
if ( in_array($options['profil'], array('Administrateur', 'SuperAdministrateur'))
|
2013-06-15 08:25:30 +00:00
|
|
|
&& !in_array('monprofil', $options['droits']) ) {
|
2012-04-19 10:22:15 +00:00
|
|
|
$options['droits'][] = 'monprofil';
|
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-07-16 13:25:23 +00:00
|
|
|
if( !isset($options['profil']) ) {
|
|
|
|
$options['profil'] = 'Utilisateur';
|
|
|
|
}
|
2015-01-13 13:05:26 +00:00
|
|
|
$ws = new WsScores();
|
2016-12-02 15:35:08 +01:00
|
|
|
Zend_Registry::get('firebug')->info('setInfosLogin');
|
|
|
|
Zend_Registry::get('firebug')->info($options);
|
2012-07-16 13:25:23 +00:00
|
|
|
$reponse = $ws->setInfosLogin($login, $action, $options);
|
2016-12-02 15:35:08 +01:00
|
|
|
Zend_Registry::get('firebug')->info($response);
|
2013-02-18 16:41:40 +00:00
|
|
|
|
2011-05-03 12:49:43 +00:00
|
|
|
$isProfilUpdated = true;
|
|
|
|
$message = 'Erreur lors de la mise à jour du compte !';
|
2013-02-18 16:41:40 +00:00
|
|
|
if (is_string($reponse)) {
|
|
|
|
$message = $reponse;
|
|
|
|
} elseif ($reponse){
|
2011-05-03 12:49:43 +00:00
|
|
|
$updateResult = true;
|
|
|
|
$message = 'Compte mis à jour.';
|
|
|
|
}
|
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2015-01-13 13:05:26 +00:00
|
|
|
// --- Write change in session
|
2013-05-27 15:22:43 +00:00
|
|
|
if ($identity->idClient == $options['idClient'] && $identity->username == $login) {
|
2015-01-13 13:05:26 +00:00
|
|
|
// --- Modification lors du changement de mot de passe
|
2013-05-27 15:22:43 +00:00
|
|
|
if ($options['changepwd']==1 && $updateResult) {
|
|
|
|
$identity->password = md5($login.'|'.$options['password']);
|
|
|
|
$auth->getStorage()->write($identity);
|
|
|
|
}
|
2015-01-13 13:05:26 +00:00
|
|
|
// --- Mise à jour du profil
|
2013-05-27 15:22:43 +00:00
|
|
|
if ($isProfilUpdated && $updateResult) {
|
2015-08-31 12:18:19 +00:00
|
|
|
$ws = new Scores_Ws_Client('gestion', '0.3');
|
|
|
|
$adressIp = $_SERVER['REMOTE_ADDR'];
|
|
|
|
$parameters = new stdClass();
|
|
|
|
$parameters->login = $identity->username;
|
|
|
|
$parameters->ipUtilisateur = $adressIp;
|
|
|
|
$parameters->from = null;
|
|
|
|
$InfosLogin = $ws->getInfosLogin($parameters);
|
2013-07-30 08:52:33 +00:00
|
|
|
$identity = $user->updateProfil($InfosLogin);
|
2013-05-27 15:22:43 +00:00
|
|
|
$auth->getStorage()->write($identity);
|
|
|
|
}
|
2015-01-13 13:05:26 +00:00
|
|
|
// --- Gestion mode edition en SESSION
|
2013-05-27 15:22:43 +00:00
|
|
|
if ($action=='update') {
|
|
|
|
$modeEdition = $request->getParam('modeEdition', false);
|
|
|
|
if ( $modeEdition ) {
|
|
|
|
$identity->modeEdition = true;
|
|
|
|
$auth->getStorage()->write($identity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-04-23 14:43:34 +00:00
|
|
|
if ( $isProfilUpdated || $isPasswordUpdated ) {
|
2011-05-03 12:49:43 +00:00
|
|
|
$this->view->assign('message', $message);
|
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-02-21 08:45:13 +00:00
|
|
|
$isAdmin = false;
|
2012-04-23 14:43:34 +00:00
|
|
|
if ( $identity->profil == 'Administrateur'
|
|
|
|
|| $identity->profil == 'SuperAdministrateur' ) {
|
2011-02-21 08:45:13 +00:00
|
|
|
$isAdmin = true;
|
|
|
|
}
|
|
|
|
$this->view->assign('isAdmin', $isAdmin);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-08-08 09:24:05 +00:00
|
|
|
$isSuperAdmin = false;
|
|
|
|
if ($identity->profil == 'SuperAdministrateur') {
|
|
|
|
$isSuperAdmin = true;
|
|
|
|
}
|
|
|
|
$this->view->assign('isSuperAdmin', $isSuperAdmin);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-08-07 10:21:12 +00:00
|
|
|
if ($op=='new')
|
|
|
|
{
|
2014-09-04 12:58:12 +00:00
|
|
|
$idClient = $request->getParam('idClient', '');
|
2012-01-26 11:25:05 +00:00
|
|
|
if ($idClient == '') {
|
|
|
|
$idClient = $identity->idClient;
|
|
|
|
}
|
2015-01-13 13:05:26 +00:00
|
|
|
$ws = new WsScores();
|
2012-08-16 11:37:59 +00:00
|
|
|
$reponse = $ws->getNextLogin($idClient);
|
2011-08-05 14:40:21 +00:00
|
|
|
$options->idClient = $idClient;
|
2012-05-10 06:06:04 +00:00
|
|
|
if ($identity->idClient!=1 && $identity->profil!='SuperAdministrateur') {
|
2012-01-26 11:25:05 +00:00
|
|
|
$options->profil = 'Utilisateur';
|
|
|
|
}
|
2011-08-05 14:40:21 +00:00
|
|
|
$this->view->assign('options', $options);
|
2012-08-07 10:21:12 +00:00
|
|
|
|
2014-09-04 12:58:12 +00:00
|
|
|
$this->view->assign('password', $this->randomPassword(10, 3));
|
2012-11-19 15:53:10 +00:00
|
|
|
$this->view->assign('loginNew', $reponse->result->racine);
|
2012-08-07 10:21:12 +00:00
|
|
|
$this->view->assign('droitsClients', explode(' ', strtolower($reponse->result->droitsClients)));
|
2011-08-05 13:19:01 +00:00
|
|
|
$this->view->assign('action', 'new');
|
|
|
|
$this->view->assign('pref', array());
|
2012-08-07 10:21:12 +00:00
|
|
|
}
|
|
|
|
elseif (!empty($op) || $op!='new')
|
|
|
|
{
|
2011-08-05 14:01:27 +00:00
|
|
|
if ( !empty($login) && $identity->username != $login ) {
|
2015-08-31 12:18:19 +00:00
|
|
|
$ws = new Scores_Ws_Client('gestion', '0.3');
|
|
|
|
$adressIp = $_SERVER['REMOTE_ADDR'];
|
|
|
|
$parameters = new stdClass();
|
|
|
|
$parameters->login = $login;
|
|
|
|
$parameters->ipUtilisateur = $adressIp;
|
|
|
|
$parameters->from = null;
|
2016-07-08 15:28:42 +02:00
|
|
|
try {
|
|
|
|
$reponse = $ws->getInfosLogin($parameters);
|
|
|
|
if ($reponse === false) {
|
|
|
|
$this->view->message = "Impossible d'afficher l'utilisateur.";
|
|
|
|
} else {
|
|
|
|
$this->view->assign('options', $reponse->result);
|
|
|
|
$this->view->assign('loginVu', $reponse->result->login);
|
|
|
|
$this->view->assign('droits', explode(' ', strtolower($reponse->result->droits)));
|
|
|
|
$this->view->assign('droitsClients', explode(' ', strtolower($reponse->result->droitsClients)));
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$this->view->message = $e->getMessage();
|
|
|
|
}
|
2011-05-24 13:25:52 +00:00
|
|
|
} else {
|
|
|
|
$this->view->assign('options', $identity);
|
|
|
|
$this->view->assign('loginVu', $identity->username);
|
2011-08-05 13:43:39 +00:00
|
|
|
$this->view->assign('droits', explode(' ', strtolower($identity->droits)));
|
2012-12-26 10:36:47 +00:00
|
|
|
$this->view->assign('droitsClients', explode(' ', strtolower($identity->droitsClients)));
|
2011-05-24 13:25:52 +00:00
|
|
|
}
|
2011-04-01 12:14:40 +00:00
|
|
|
$this->view->assign('loginNew', '');
|
2011-05-03 12:49:43 +00:00
|
|
|
$this->view->assign('action', 'update');
|
2011-04-01 12:14:40 +00:00
|
|
|
$this->view->assign('pref', explode(' ',$identity->pref));
|
|
|
|
}
|
2013-05-27 15:22:43 +00:00
|
|
|
|
2015-01-13 13:05:26 +00:00
|
|
|
$ws = new WsScores();
|
2013-05-27 15:22:43 +00:00
|
|
|
//Liste des catégories des accès
|
|
|
|
$reponse = $ws->getCategory();
|
|
|
|
$wscategory = $reponse->item;
|
|
|
|
$this->view->assign('wscategory', $wscategory);
|
|
|
|
|
|
|
|
//Liste de tous les droits
|
|
|
|
$listeDroits = $ws->getListeDroits();
|
|
|
|
$droitsLib = array();
|
|
|
|
foreach($listeDroits->item as $droit) {
|
|
|
|
$droitsLib[strtoupper($droit->code)] = $droit->desc;
|
|
|
|
}
|
|
|
|
$this->view->assign('droitsLib', $droitsLib);
|
|
|
|
|
|
|
|
//Liste de toutes les préférences
|
|
|
|
$listePrefs = $ws->getListePrefs();
|
|
|
|
$prefsLib = array();
|
|
|
|
foreach($listePrefs->item as $pref) {
|
|
|
|
$prefsLib[strtoupper($pref->code)] = $pref->desc;
|
|
|
|
}
|
|
|
|
$this->view->assign('prefsLib', $prefsLib);
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2013-06-15 08:25:30 +00:00
|
|
|
/**
|
|
|
|
* Display box to enter emails
|
|
|
|
* One main email and two secondary
|
|
|
|
* Email length 80 * 3 = 240
|
|
|
|
* 255 chars is the length to store emails (email1;email2;email3)
|
|
|
|
*/
|
2014-04-24 10:46:36 +00:00
|
|
|
public function emailAction()
|
2013-06-15 08:25:30 +00:00
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
2014-04-24 10:46:36 +00:00
|
|
|
|
|
|
|
$check = $request->getParam('check');
|
|
|
|
$email = $request->getParam('q');
|
|
|
|
|
|
|
|
if ( $check == 1) {
|
|
|
|
|
|
|
|
$this->view->assign('checkemail', true);
|
|
|
|
|
|
|
|
$valid = false;
|
|
|
|
|
|
|
|
$this->view->assign('msg', 'Email invalide !');
|
|
|
|
|
|
|
|
if (null !== $email) {
|
|
|
|
$validateur = new Zend_Validate_EmailAddress();
|
|
|
|
$valid = $validateur->isValid($email);
|
|
|
|
|
|
|
|
if ( $valid ) {
|
|
|
|
$this->view->assign('msg', 'Modification effectué.');
|
|
|
|
$this->view->assign('email', $email);
|
2013-06-15 08:25:30 +00:00
|
|
|
}
|
2014-04-24 10:46:36 +00:00
|
|
|
|
2013-06-15 08:25:30 +00:00
|
|
|
}
|
2014-04-24 10:46:36 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->view->assign('email', $email);
|
|
|
|
|
2013-06-15 08:25:30 +00:00
|
|
|
}
|
2014-04-24 10:46:36 +00:00
|
|
|
|
2013-06-15 08:25:30 +00:00
|
|
|
}
|
|
|
|
|
2014-04-24 10:46:36 +00:00
|
|
|
public function emailsecondaryAction()
|
2013-06-15 08:25:30 +00:00
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
2014-04-24 10:46:36 +00:00
|
|
|
$user = new Scores_Utilisateur();
|
2013-06-15 08:25:30 +00:00
|
|
|
|
2014-04-24 10:46:36 +00:00
|
|
|
$mode = $request->getParam('mode');
|
|
|
|
$this->view->assign('mode', $mode);
|
|
|
|
$email = $request->getParam('email');
|
|
|
|
$login = $request->getParam('login', $user->getLogin());
|
|
|
|
$this->view->assign('login', $login);
|
|
|
|
|
|
|
|
$idClient = $request->getParam('client', $user->getIdClient());
|
|
|
|
|
|
|
|
if ( $mode === null ) {
|
2013-06-15 08:25:30 +00:00
|
|
|
|
2014-04-24 10:46:36 +00:00
|
|
|
$ws = new WsScores();
|
|
|
|
$result = $ws->getGestionEmail($login);
|
|
|
|
$emails = array();
|
|
|
|
if (count($result->item)>0) {
|
|
|
|
$emails = $result->item;
|
|
|
|
}
|
|
|
|
$this->view->assign('emails', $emails);
|
|
|
|
|
|
|
|
} elseif ( $mode == 'set' ) {
|
|
|
|
|
|
|
|
$this->view->assign('msg', 'Email invalide !');
|
|
|
|
|
|
|
|
if (null !== $email) {
|
|
|
|
$validateur = new Zend_Validate_EmailAddress();
|
|
|
|
$valid = $validateur->isValid($email);
|
|
|
|
|
|
|
|
if ( $valid ) {
|
|
|
|
$ws = new WsScores();
|
|
|
|
$result = $ws->setGestionEmail($email, $login);
|
|
|
|
if ( $result ) {
|
|
|
|
$this->view->assign('msg', 'Modification effectué.');
|
|
|
|
$this->view->assign('email', $email);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} elseif ( $mode == 'del' ) {
|
|
|
|
|
|
|
|
$this->view->assign('msg', 'Erreur lors de la suppression !');
|
|
|
|
|
2014-05-24 09:22:50 +00:00
|
|
|
$id = $request->getParam('id');
|
|
|
|
|
2014-04-24 10:46:36 +00:00
|
|
|
$ws = new WsScores();
|
|
|
|
$result = $ws->setGestionEmail($email, $login, $id, $mode);
|
|
|
|
if ( $result ) {
|
|
|
|
$this->view->assign('msg', 'Adresse email supprimé.');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-06-15 08:25:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-23 10:04:12 +00:00
|
|
|
/**
|
|
|
|
* Téléchargement de la consommation au format CSV
|
|
|
|
*/
|
2011-05-23 06:45:29 +00:00
|
|
|
public function consoAction()
|
|
|
|
{
|
2015-07-10 14:14:55 +00:00
|
|
|
$this->view->headScript()->appendFile($this->theme->pathScript.'/conso.js', 'text/javascript');
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-05-20 16:31:28 +00:00
|
|
|
$user = new Scores_Utilisateur();
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-08-25 16:13:53 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$idClient = $request->getParam('idClient', $user->getIdClient());
|
|
|
|
$login = $request->getParam('login', '');
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-08-25 16:13:53 +00:00
|
|
|
$this->view->assign('idClient', $idClient);
|
|
|
|
$this->view->assign('login', $login);
|
2011-05-23 10:04:12 +00:00
|
|
|
$this->view->assign('profil', $user->getProfil());
|
2011-05-23 06:45:29 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-24 13:25:52 +00:00
|
|
|
/**
|
|
|
|
* Renvoi vers le formulaire utilisateur avec les paramètres de la requete
|
|
|
|
*/
|
2011-05-03 15:58:48 +00:00
|
|
|
public function editAction()
|
|
|
|
{
|
2011-05-24 13:25:52 +00:00
|
|
|
$params = $this->getRequest()->getParams();
|
|
|
|
$this->_forward('index', 'user', null, $params);
|
2011-05-03 15:58:48 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-24 13:25:52 +00:00
|
|
|
/**
|
|
|
|
* Suppression d'un utilisateur
|
|
|
|
*/
|
2011-05-03 15:58:48 +00:00
|
|
|
public function deleteAction()
|
|
|
|
{
|
2011-05-24 13:25:52 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$login = $request->getParam('login');
|
|
|
|
$action = 'delete';
|
|
|
|
$ws = new WsScores();
|
|
|
|
$ws->setInfosLogin($login, $action);
|
|
|
|
//Redirect
|
|
|
|
$this->_forward('liste');
|
2011-05-03 15:58:48 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-24 13:25:52 +00:00
|
|
|
/**
|
|
|
|
* Activation d'un utilisateur
|
|
|
|
*/
|
2012-09-03 10:12:16 +00:00
|
|
|
public function enableAction()
|
2011-05-03 15:58:48 +00:00
|
|
|
{
|
2011-05-24 13:25:52 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$login = $request->getParam('login');
|
2012-09-03 10:12:16 +00:00
|
|
|
$action = 'enable';
|
2011-05-24 13:25:52 +00:00
|
|
|
$ws = new WsScores();
|
|
|
|
$ws->setInfosLogin($login, $action);
|
2011-05-04 13:24:26 +00:00
|
|
|
//Redirect
|
2011-05-24 13:25:52 +00:00
|
|
|
$this->_forward('liste');
|
2011-05-03 15:58:48 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-24 13:25:52 +00:00
|
|
|
/**
|
|
|
|
* Désactivation d'un utilisateur
|
|
|
|
*/
|
2012-09-03 10:12:16 +00:00
|
|
|
public function disableAction()
|
2011-05-03 15:58:48 +00:00
|
|
|
{
|
2011-05-24 13:25:52 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$login = $request->getParam('login');
|
2012-09-03 10:12:16 +00:00
|
|
|
$action = 'disable';
|
2011-05-24 13:25:52 +00:00
|
|
|
$ws = new WsScores();
|
|
|
|
$ws->setInfosLogin($login, $action);
|
2011-05-04 13:24:26 +00:00
|
|
|
//Redirect
|
2011-05-24 13:25:52 +00:00
|
|
|
$this->_forward('liste');
|
2011-05-03 15:58:48 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-24 13:25:52 +00:00
|
|
|
/**
|
|
|
|
* Méthode AJAX pour modifier le password d'un utilisateur
|
|
|
|
*/
|
2011-04-01 12:14:40 +00:00
|
|
|
public function changepwdAction()
|
|
|
|
{
|
2011-05-04 13:24:26 +00:00
|
|
|
//Redirect
|
2011-04-01 12:14:40 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-23 10:04:12 +00:00
|
|
|
/**
|
|
|
|
* Affiche la liste des utiliateurs
|
|
|
|
*/
|
|
|
|
public function listeAction()
|
2011-05-03 15:58:48 +00:00
|
|
|
{
|
2012-05-20 16:31:28 +00:00
|
|
|
$user = new Scores_Utilisateur();
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-08-25 16:13:53 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$idClient = $request->getParam('idClient', $user->getIdClient());
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-03 15:58:48 +00:00
|
|
|
if (!$user->isSuperAdmin() && !$user->isAdmin()) {
|
2011-09-06 09:12:50 +00:00
|
|
|
$this->renderScript('error/perms.phtml');
|
2011-05-03 15:58:48 +00:00
|
|
|
}
|
2011-08-25 16:13:53 +00:00
|
|
|
if ($user->isAdmin()){
|
|
|
|
$idClient = $user->getIdClient();
|
|
|
|
}
|
2011-05-03 15:58:48 +00:00
|
|
|
$ws = new WsScores();
|
2011-05-24 13:25:52 +00:00
|
|
|
$infos = $ws->getListeUtilisateurs($user->getLogin(), $idClient);
|
2011-05-03 15:58:48 +00:00
|
|
|
$utilisateurs = $infos->result->item;
|
|
|
|
$this->view->assign('utilisateurs', $utilisateurs);
|
2011-08-25 16:13:53 +00:00
|
|
|
$this->view->assign('idClient', $idClient);
|
2011-05-03 15:58:48 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-23 10:04:12 +00:00
|
|
|
/**
|
|
|
|
* Gestion de l'authentification
|
|
|
|
*/
|
2011-05-03 15:58:48 +00:00
|
|
|
public function loginAction()
|
2010-11-22 12:50:12 +00:00
|
|
|
{
|
2014-04-24 10:46:36 +00:00
|
|
|
$this->_helper->layout()->disableLayout();
|
2010-11-24 10:55:21 +00:00
|
|
|
$this->view->headTitle()->append('Connexion');
|
2013-05-17 07:06:21 +00:00
|
|
|
$form = new Application_Form_Login();
|
2010-11-22 12:50:12 +00:00
|
|
|
$this->view->form = $form;
|
|
|
|
$request = $this->getRequest();
|
2013-05-14 09:32:08 +00:00
|
|
|
if ( $request->isPost() ) {
|
2013-10-25 14:30:46 +00:00
|
|
|
$formData = $request->getPost();
|
2010-11-22 12:50:12 +00:00
|
|
|
if ($form->isValid($formData)) {
|
|
|
|
$login = $form->getValue('login');
|
|
|
|
$pass = $form->getValue('pass');
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
2015-06-19 14:02:41 +00:00
|
|
|
$authAdapter = new Scores_Auth_Adapter_Ws($login, $pass);
|
2010-11-22 12:50:12 +00:00
|
|
|
$result = $auth->authenticate($authAdapter);
|
2013-05-14 09:32:08 +00:00
|
|
|
|
|
|
|
//Auth is valid
|
|
|
|
if ( $result->isValid() ) {
|
|
|
|
|
|
|
|
//Save browser information
|
|
|
|
$screenSize = $request->getParam('screenSize', 'unknow');
|
|
|
|
$user = new Scores_Utilisateur();
|
|
|
|
$info = get_browser();
|
|
|
|
$isMobile = ($info->ismobiledevice==1) ? 1 : 0;
|
|
|
|
$user->setBrowserInfo($info->platform, $info->browser, $info->version, $isMobile, $screenSize);
|
|
|
|
|
|
|
|
//Get previous url if user has been disconnected
|
|
|
|
$url = '';
|
|
|
|
if (Zend_Session::namespaceIsset('login')){
|
|
|
|
$session = new Zend_Session_Namespace('login');
|
|
|
|
if (isset($session->url)) {
|
|
|
|
$url = $session->url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($url) && $url!='/user/login' && $url!='/user/logout' && $url!='/localauth'){
|
2016-09-14 13:33:37 +02:00
|
|
|
$this->redirect($url);
|
2013-05-14 09:32:08 +00:00
|
|
|
}
|
2016-09-14 13:33:37 +02:00
|
|
|
$this->redirect('/');
|
2013-05-14 09:32:08 +00:00
|
|
|
}
|
|
|
|
//Auth error
|
|
|
|
else {
|
|
|
|
$this->view->message = '';
|
|
|
|
Zend_Registry::get('firebug')->info($result);
|
|
|
|
foreach ($result->getMessages() as $message) {
|
|
|
|
$this->view->message.= $message."<br/>";
|
|
|
|
}
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 13:33:37 +02:00
|
|
|
// Pas de validation du formulaire
|
|
|
|
else {
|
|
|
|
Zend_Registry::get('firebug')->info('DISPLAY');
|
|
|
|
}
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-23 10:04:12 +00:00
|
|
|
/**
|
|
|
|
* Gestion de la déconnexion
|
|
|
|
*/
|
2011-02-21 08:45:13 +00:00
|
|
|
public function logoutAction()
|
|
|
|
{
|
2012-08-23 08:04:46 +00:00
|
|
|
Zend_Auth::getInstance()->clearIdentity();
|
2013-09-16 15:41:31 +00:00
|
|
|
$session = new Zend_Session_Namespace('wcheck');
|
|
|
|
$session->unsetAll();
|
2011-02-04 16:27:03 +00:00
|
|
|
$this->_helper->layout()->disableLayout();
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-03-06 10:15:24 +00:00
|
|
|
$request = $this->getRequest();
|
2012-05-10 06:06:04 +00:00
|
|
|
$message = $request->getParam('message');
|
2012-03-06 10:15:24 +00:00
|
|
|
$this->view->assign('message', $message);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-11-20 14:12:54 +00:00
|
|
|
$ajax = $request->getParam('ajax', 0);
|
|
|
|
$this->view->assign('ajax', $ajax);
|
2012-12-26 10:36:47 +00:00
|
|
|
|
2012-08-23 08:04:46 +00:00
|
|
|
$refresh = 5;
|
2012-12-26 10:36:47 +00:00
|
|
|
|
2012-08-23 08:04:46 +00:00
|
|
|
$url = 'http://'.$_SERVER['SERVER_NAME'].$this->view->url(array(
|
2012-06-21 07:11:58 +00:00
|
|
|
'controller' => 'user',
|
|
|
|
'action' => 'login',
|
2014-08-11 12:11:23 +00:00
|
|
|
), 'default', true);
|
2012-08-23 08:04:46 +00:00
|
|
|
|
2011-09-09 08:28:42 +00:00
|
|
|
$this->view->assign('url', $url);
|
2012-12-26 10:36:47 +00:00
|
|
|
|
2014-04-24 10:46:36 +00:00
|
|
|
if ( $ajax == 0 ) {
|
2012-11-20 14:12:54 +00:00
|
|
|
$this->view->assign('refresh', $refresh);
|
|
|
|
$this->view->headMeta()->appendHttpEquiv('refresh', $refresh.'; url='.$url);
|
|
|
|
}
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2016-09-14 13:33:37 +02:00
|
|
|
/**
|
|
|
|
* Erreur pour les connexions en ipOnly
|
|
|
|
*/
|
|
|
|
public function iponlyAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$message = $request->getParam('message');
|
|
|
|
$this->view->assign('message', $message);
|
|
|
|
}
|
|
|
|
|
2011-11-22 17:00:53 +00:00
|
|
|
/**
|
|
|
|
* Mettre à jour le mode edition en session sans refresh de la page
|
|
|
|
*/
|
|
|
|
public function editionsessionAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
2012-05-10 06:06:04 +00:00
|
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
2011-11-22 17:00:53 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$mode = $request->getParam('mode', 'false');
|
|
|
|
$auth = Zend_Auth::getInstance();
|
2012-05-10 06:06:04 +00:00
|
|
|
$identity = $auth->getIdentity();
|
|
|
|
if ($identity->idClient == 1) {
|
2011-11-22 17:00:53 +00:00
|
|
|
if ($mode == 'false') {
|
|
|
|
$identity->modeEdition = false;
|
|
|
|
echo 0;
|
|
|
|
} else {
|
|
|
|
$identity->modeEdition = true;
|
|
|
|
echo 1;
|
|
|
|
}
|
|
|
|
$auth->getStorage()->write($identity);
|
|
|
|
} else {
|
2012-05-10 06:06:04 +00:00
|
|
|
echo 0;
|
2011-11-22 17:00:53 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2013-05-14 09:32:08 +00:00
|
|
|
/**
|
|
|
|
* Override email in surveillance portfolio
|
|
|
|
*/
|
|
|
|
public function emailsurveillanceAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
$user = new Scores_Utilisateur();
|
|
|
|
|
|
|
|
//Execute webservice operation
|
|
|
|
if ( $request->isPost() ) {
|
|
|
|
$email = trim($request->getParam('email'));
|
|
|
|
if ($user->isAdmin() || $user->isSuperAdmin()) {
|
|
|
|
$login = $request->getParam('login');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($email)) {
|
|
|
|
$result = "Aucun email défini!";
|
|
|
|
} else if (empty($login)) {
|
|
|
|
$result = "Aucun utilisateur défini!";
|
|
|
|
} else {
|
|
|
|
$ws = new WsScores();
|
|
|
|
$result = $ws->setSurveillancesMail($login, $email);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->view->assign('result', $result);
|
|
|
|
}
|
|
|
|
//Display form in dialog
|
|
|
|
else {
|
|
|
|
if ($user->isAdmin() || $user->isSuperAdmin()) {
|
|
|
|
$login = $request->getParam('login');
|
|
|
|
} else {
|
|
|
|
$login = $user->getLogin();
|
|
|
|
}
|
|
|
|
$this->view->assign('login', $login);
|
|
|
|
$this->view->assign('dialog',true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-27 15:22:43 +00:00
|
|
|
/**
|
|
|
|
* Changer la langue de l'utilisateur
|
|
|
|
*/
|
|
|
|
public function langAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
|
|
|
|
$lang = $this->getRequest()->getParam('lang', null);
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$identity = $auth->getIdentity();
|
|
|
|
|
|
|
|
$identity->langtmp = $lang;
|
|
|
|
|
|
|
|
$auth->getStorage()->write($identity);
|
|
|
|
}
|
2013-05-14 09:32:08 +00:00
|
|
|
|
2012-02-29 09:05:19 +00:00
|
|
|
/**
|
|
|
|
* Changer le theme de l'utilisateur
|
|
|
|
*/
|
|
|
|
public function changethemeAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-02-29 09:05:19 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$nom = $request->getParam('nom', 'default');
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-02-29 09:05:19 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$identity = $auth->getIdentity();
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-02-29 09:05:19 +00:00
|
|
|
$identity->theme = $nom;
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-02-29 09:05:19 +00:00
|
|
|
$auth->getStorage()->write($identity);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-02-29 09:05:19 +00:00
|
|
|
//Rediriger vers l'écran de recherche
|
|
|
|
$this->_redirect('/');
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2012-02-29 09:05:19 +00:00
|
|
|
}
|
2013-05-14 09:32:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Display browser informations on a simple page
|
|
|
|
*/
|
|
|
|
public function browserAction()
|
|
|
|
{
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
|
|
|
|
//Load bootstrap
|
|
|
|
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
|
|
|
|
|
|
|
|
//Get useragent and device informations
|
|
|
|
$userAgent = $bootstrap->getResource('useragent');
|
|
|
|
$device = $userAgent->getDevice();
|
|
|
|
|
|
|
|
//Display
|
|
|
|
echo "<pre>";
|
|
|
|
print_r(get_browser());
|
|
|
|
print_r($device->getAllFeatures());
|
|
|
|
echo "</pre>";
|
|
|
|
}
|
2013-06-15 08:25:30 +00:00
|
|
|
|
2013-06-14 16:00:22 +00:00
|
|
|
/**
|
|
|
|
* Sends email to the specific client, who requests for forgotten password
|
|
|
|
*/
|
|
|
|
public function motpasseAction()
|
|
|
|
{
|
|
|
|
$request = $this->getRequest();
|
2013-06-15 08:25:30 +00:00
|
|
|
$name = 'Identifiants oubliés ?';
|
2013-06-14 16:00:22 +00:00
|
|
|
$params = array(
|
|
|
|
'identifiant' => '',
|
|
|
|
'telephone' => '',
|
|
|
|
'email' => '',
|
|
|
|
'nom' => '',
|
|
|
|
'prenom' => '',
|
2013-06-20 15:15:39 +00:00
|
|
|
'fonction' => '',
|
|
|
|
'service' => '',
|
2013-06-14 16:00:22 +00:00
|
|
|
'rsociale' => '',
|
|
|
|
);
|
2013-06-15 08:25:30 +00:00
|
|
|
|
2013-06-25 10:05:46 +00:00
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
if ( $request->isPost() ) {
|
|
|
|
$params = $request->getParams();
|
|
|
|
$message = '';
|
2013-06-15 08:25:30 +00:00
|
|
|
|
2013-06-25 10:05:46 +00:00
|
|
|
$paramlist = array(
|
|
|
|
'telephone' => 'Numéro de téléphone direct',
|
|
|
|
'email' => 'Adresse email',
|
|
|
|
'nom' => 'Nom',
|
|
|
|
'prenom' => 'Prénom',
|
|
|
|
'fonction' => 'Fonction',
|
|
|
|
'service' => 'Service',
|
|
|
|
'rsociale' => 'Sociale',
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($paramlist as $item => $val) {
|
|
|
|
if (!isset($params[$item])) {
|
|
|
|
$message .= "Champs $val vide !<br/>";
|
|
|
|
}
|
|
|
|
}
|
2013-06-15 08:25:30 +00:00
|
|
|
|
2013-06-25 10:05:46 +00:00
|
|
|
$validator = new Zend_Validate_EmailAddress();
|
|
|
|
if (isset($params['email'])){
|
|
|
|
if (!$validator->isValid($params['email'])) {
|
|
|
|
$message .="Adresse email invalide ! <br/>";
|
|
|
|
}
|
|
|
|
}
|
2013-06-20 15:15:39 +00:00
|
|
|
|
2013-06-25 10:05:46 +00:00
|
|
|
if ($message == '') {
|
|
|
|
|
|
|
|
$mailbody = '<style type="text/css">table {font-family:Arial, Helvetica, sans-serif; font-size: 12px; width: 550px; border: none;}table td{padding: 4px 8px;}</style>';
|
2013-07-30 08:52:33 +00:00
|
|
|
$mailbody .= "Demande d'envoi des identifiants.<br /><br />";
|
|
|
|
$mailbody .= "L'un de nos clients a égaré son(ses) identifiant(s).<br />";
|
|
|
|
$mailbody .= "Via notre lien -identifiants oubliés- il a effectué une demande de transmission de ces codes.<br />";
|
|
|
|
$mailbody .= "<p>A l'aide des informations ci-dessous, merci de retrouver ces codes et les lui envoyer par email.</p>";
|
2013-06-25 10:05:46 +00:00
|
|
|
$mailbody .= "<table><tr bgcolor='#eeeeee'><td width='200px'><strong>Identifiant :</strong></td><td>".$params['identifiant']."</td></tr>";
|
|
|
|
$mailbody .= "<tr><td><strong>Adresse email:</strong></td><td>".$params['email']."</td></tr>";
|
|
|
|
$mailbody .= "<tr bgcolor='#eeeeee'><td><strong>Numéro de téléphone direct:</strong></td><td>".$params['telephone']."</td></tr>";
|
|
|
|
$mailbody .= "<tr><td><strong>Nom:</strong></td><td>".$params['nom']."</td></tr>";
|
|
|
|
$mailbody .= "<tr bgcolor='#eeeeee'><td><strong>Prénom:</strong></td><td>".$params['prenom']."</td></tr>";
|
|
|
|
$mailbody .= "<tr><td><strong>Fonction:</strong></td><td>".$params['fonction']."</td></tr>";
|
|
|
|
$mailbody .= "<tr bgcolor='#eeeeee'><td><strong>Service:</strong></td><td>".$params['service']."</td></tr>";
|
2013-12-26 14:42:44 +00:00
|
|
|
$mailbody .= "<tr><td><strong>Dénomination Sociale:</strong></td><td>".$params['rsociale']."</td></tr></table>";
|
2013-07-30 08:52:33 +00:00
|
|
|
$mailbody .= "<p>Si les informations fournies ne permettent pas d'identifier correctement l'utilisateur, ";
|
|
|
|
$mailbody .= "merci d'émettre un message sur le mail communiquer en précisant que \"Les éléments confiés ne permettent pas d'identifier l'utilisateur ";
|
|
|
|
$mailbody .= "et par conséquence de vous délivrer les codes d'accès demandés\".<br />";
|
|
|
|
$mailbody .= "Aussi nous vous invitons à vous rapprocher de votre interlocuteur commercial habituel ";
|
|
|
|
$mailbody .= "ou de votre responsable suivi relations Scores & Décisions au sein de votre société.</p>";
|
2013-06-25 10:05:46 +00:00
|
|
|
|
2015-06-10 14:52:05 +00:00
|
|
|
$mail = new Scores_Mail_Method();
|
2013-07-30 08:52:33 +00:00
|
|
|
$mail->setSubject("Demande d'envoi des identifiants");
|
2015-06-16 09:24:43 +00:00
|
|
|
$mail->setBodyHtmlC($mailbody);
|
2017-02-10 16:38:46 +01:00
|
|
|
$mail->setFromKey('supportdev');
|
2013-06-25 10:05:46 +00:00
|
|
|
$mail->addToKey('support');
|
|
|
|
$mail->setReplyTo($params['email']);
|
|
|
|
try {
|
2015-06-11 15:29:14 +00:00
|
|
|
$mail->execute();
|
2013-07-30 08:52:33 +00:00
|
|
|
$this->view->assign('sendEmail' , true);
|
2013-06-25 10:05:46 +00:00
|
|
|
}
|
|
|
|
catch ( Zend_Mail_Transport_Exception $e ){
|
|
|
|
$message = $e->getMessage();
|
2013-10-25 14:30:46 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 10:05:46 +00:00
|
|
|
}
|
|
|
|
$this->view->assign('message', $message);
|
2014-02-13 14:41:39 +00:00
|
|
|
}
|
2013-06-14 16:00:22 +00:00
|
|
|
}
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|