2010-11-22 12:50:12 +00:00
|
|
|
<?php
|
2011-05-03 12:49:43 +00:00
|
|
|
class UserController extends Zend_Controller_Action
|
|
|
|
{
|
2011-05-23 10:04:12 +00:00
|
|
|
/**
|
|
|
|
* Récupére les valeurs du profil depuis le webservice
|
|
|
|
* @param unknown_type $login
|
|
|
|
* @param unknown_type $password
|
|
|
|
*/
|
2011-05-03 12:49:43 +00:00
|
|
|
protected function updateProfil($login, $password)
|
2011-01-05 09:59:49 +00:00
|
|
|
{
|
2011-05-03 12:49:43 +00:00
|
|
|
Zend_Registry::get('firebug')->info('updateProfil');
|
|
|
|
$ws = new WsScores();
|
2012-05-10 06:06:04 +00:00
|
|
|
$InfosLogin = $ws->getInfosLogin($login, $_SERVER['REMOTE_ADDR']);
|
2011-05-03 12:49:43 +00:00
|
|
|
$identity = new stdClass;
|
|
|
|
$identity->username = $login;
|
2012-05-10 06:06:04 +00:00
|
|
|
$identity->password = $password;
|
2011-05-03 12:49:43 +00:00
|
|
|
$identity->email = $InfosLogin->result->email;
|
|
|
|
$identity->profil = $InfosLogin->result->profil;
|
|
|
|
$identity->pref = $InfosLogin->result->pref;
|
|
|
|
$identity->droits = $InfosLogin->result->droits;
|
|
|
|
$identity->droitsClients = $InfosLogin->result->droitsClients;
|
|
|
|
$identity->nom = $InfosLogin->result->nom;
|
|
|
|
$identity->prenom = $InfosLogin->result->prenom;
|
|
|
|
$identity->tel = $InfosLogin->result->tel;
|
|
|
|
$identity->fax = $InfosLogin->result->fax;
|
|
|
|
$identity->mobile = $InfosLogin->result->mobile;
|
|
|
|
$identity->id = $InfosLogin->result->id;
|
|
|
|
$identity->idClient = $InfosLogin->result->idClient;
|
|
|
|
$identity->reference = $InfosLogin->result->reference;
|
|
|
|
$identity->nbReponses = $InfosLogin->result->nbReponses;
|
|
|
|
$identity->typeScore = $InfosLogin->result->typeScore;
|
|
|
|
$identity->timeout = (!empty($InfosLogin->result->timeout)) ?
|
|
|
|
$InfosLogin->result->timeout : 1800;
|
2012-05-10 06:06:04 +00:00
|
|
|
$identity->time = time() + $identity->timeout;
|
2011-05-03 12:49:43 +00:00
|
|
|
$identity->modeEdition = false;
|
|
|
|
return $identity;
|
2011-01-05 09:59:49 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-03 15:58:48 +00:00
|
|
|
public function init()
|
|
|
|
{
|
2011-05-24 13:25:52 +00:00
|
|
|
require_once 'Scores/Utilisateur.php';
|
|
|
|
require_once 'Scores/WsScores.php';
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-23 10:04:12 +00:00
|
|
|
$this->view->headLink()->appendStylesheet('/themes/default/styles/user.css', 'all');
|
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()
|
|
|
|
{
|
2012-02-29 09:10:51 +00:00
|
|
|
$user = new Utilisateur();
|
|
|
|
if (!$user->checkPerm('MONPROFIL')){
|
|
|
|
$this->_forward('perms', 'error');
|
2012-05-10 06:06:04 +00:00
|
|
|
}
|
|
|
|
|
2011-05-23 06:45:29 +00:00
|
|
|
$this->view->headLink()->appendStylesheet('/themes/default/styles/form.css', 'all');
|
|
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/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-04-01 12:14:40 +00:00
|
|
|
$ws = new WsScores();
|
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
|
|
|
|
2011-05-03 12:49:43 +00:00
|
|
|
if ($request->isPost()) {
|
|
|
|
$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'))) {
|
|
|
|
$infos = new stdClass();
|
|
|
|
$infos->idClient = $options['idClient'];
|
|
|
|
$infos->nom = $options['nom'];
|
|
|
|
$infos->prenom = $options['prenom'];
|
|
|
|
$infos->reference = $options['reference'];
|
2011-11-22 09:32:13 +00:00
|
|
|
$infos->email = strtolower($options['email']);
|
2011-05-03 12:49:43 +00:00
|
|
|
$infos->tel_fix = $options['tel_fix'];
|
|
|
|
$infos->tel_fax = $options['tel_fax'];
|
|
|
|
$infos->tel_mob = $options['tel_mob'];
|
|
|
|
$infos->rech_nbrep = $options['rech_nbrep'];
|
|
|
|
$infos->formatMail = $options['formatMail'];
|
|
|
|
$infos->password = '';
|
|
|
|
if ($options['changepwd']==1){
|
|
|
|
$infos->password = $options['password'];
|
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
|
|
|
if ( in_array($options['profil'], array('Administrateur', 'SuperAdministrateur'))
|
2012-04-19 10:22:15 +00:00
|
|
|
&& !in_array('monprofil', $options['droits']) ) {
|
|
|
|
$options['droits'][] = 'monprofil';
|
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-03 12:49:43 +00:00
|
|
|
$infos->droits = $options['droits'];
|
|
|
|
$infos->pref = $options['pref'];
|
2011-08-08 11:53:11 +00:00
|
|
|
$infos->profil = isset($options['profil']) ? $options['profil'] : 'Utilisateur';
|
|
|
|
$infos = $ws->setInfosLogin($login, $action, $infos);
|
2011-05-03 12:49:43 +00:00
|
|
|
$isProfilUpdated = true;
|
|
|
|
$message = 'Erreur lors de la mise à jour du compte !';
|
|
|
|
if ($infos->result){
|
|
|
|
$updateResult = true;
|
|
|
|
$message = 'Compte mis à jour.';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-04-01 12:14:40 +00:00
|
|
|
//Liste de tous les droits
|
|
|
|
$listeDroits = $ws->getListeDroits();
|
|
|
|
$droitsLib = array();
|
|
|
|
foreach($listeDroits->item as $droit) {
|
2011-05-03 12:49:43 +00:00
|
|
|
$droitsLib[strtoupper($droit->code)] = $droit->desc;
|
2011-04-01 12:14:40 +00:00
|
|
|
}
|
|
|
|
$this->view->assign('droitsLib', $droitsLib);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-04-01 12:14:40 +00:00
|
|
|
//Liste de toutes les préférences
|
|
|
|
$listePrefs = $ws->getListePrefs();
|
|
|
|
$prefsLib = array();
|
|
|
|
foreach($listePrefs->item as $pref) {
|
2011-05-03 12:49:43 +00:00
|
|
|
$prefsLib[strtoupper($pref->code)] = $pref->desc;
|
2011-04-01 12:14:40 +00:00
|
|
|
}
|
|
|
|
$this->view->assign('prefsLib', $prefsLib);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-03 12:49:43 +00:00
|
|
|
//Récupération des informations de l'identité
|
2011-04-01 12:14:40 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
2012-04-23 14:43:34 +00:00
|
|
|
$identity = $auth->getIdentity();
|
2011-05-24 13:25:52 +00:00
|
|
|
if ($identity->idClient == $options['idClient'] && $identity->username == $login) {
|
2011-05-26 13:49:36 +00:00
|
|
|
//Modification lors du changement de mot de passe
|
|
|
|
if ($options['changepwd']==1 && $updateResult) {
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-09-09 08:28:42 +00:00
|
|
|
$identity->password = md5($login.'|'.$options['password']);
|
|
|
|
$auth->getStorage()->write($identity);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-26 13:49:36 +00:00
|
|
|
}
|
|
|
|
//Mise à jour du profil
|
2011-05-24 13:25:52 +00:00
|
|
|
if ($isProfilUpdated && $updateResult) {
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-24 13:25:52 +00:00
|
|
|
$identity = $this->updateProfil($identity->username, $identity->password);
|
2011-05-17 09:52:14 +00:00
|
|
|
$auth->getStorage()->write($identity);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-17 09:52:14 +00:00
|
|
|
}
|
2011-05-24 13:25:52 +00:00
|
|
|
//Gestion mode edition en SESSION
|
|
|
|
if ($action=='update') {
|
|
|
|
$modeEdition = $request->getParam('modeEdition', false);
|
2012-04-23 14:43:34 +00:00
|
|
|
if ( $modeEdition ) {
|
|
|
|
|
2011-05-24 13:25:52 +00:00
|
|
|
$identity->modeEdition = true;
|
|
|
|
$auth->getStorage()->write($identity);
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-24 13:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-17 09:52:14 +00:00
|
|
|
}
|
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
|
|
|
|
2011-09-09 08:28:42 +00:00
|
|
|
Zend_Registry::get('firebug')->info('action : '.$action);
|
2011-08-05 13:19:01 +00:00
|
|
|
if ($op=='new'){
|
|
|
|
Zend_Registry::get('firebug')->info('Gestion first user SD');
|
2012-01-26 11:25:05 +00:00
|
|
|
$idClient = $request->getParam('idClient', '');
|
|
|
|
if ($idClient == '') {
|
|
|
|
$idClient = $identity->idClient;
|
|
|
|
}
|
2011-08-05 13:19:01 +00:00
|
|
|
$reponse = $ws->getListeClients($idClient);
|
|
|
|
$InfosClient = $reponse->result->item[0];
|
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);
|
2011-08-05 13:19:01 +00:00
|
|
|
$this->view->assign('loginNew', $InfosClient->racineLogin);
|
2011-08-05 13:43:39 +00:00
|
|
|
$this->view->assign('droitsClients', explode(' ', strtolower($InfosClient->droits)));
|
2011-08-05 13:19:01 +00:00
|
|
|
$this->view->assign('action', 'new');
|
|
|
|
$this->view->assign('pref', array());
|
|
|
|
}elseif (!empty($action) || $action!='new') {
|
2011-08-05 14:01:27 +00:00
|
|
|
if ( !empty($login) && $identity->username != $login ) {
|
2011-06-30 14:25:23 +00:00
|
|
|
Zend_Registry::get('firebug')->info('getInfosLogin');
|
2012-05-10 06:06:04 +00:00
|
|
|
$reponse = $ws->getInfosLogin($login, $_SERVER['REMOTE_ADDR']);
|
2011-05-24 13:25:52 +00:00
|
|
|
$this->view->assign('options', $reponse->result);
|
|
|
|
$this->view->assign('loginVu', $reponse->result->login);
|
2011-08-05 13:43:39 +00:00
|
|
|
$this->view->assign('droits', explode(' ', strtolower($reponse->result->droits)));
|
2011-05-24 13:25:52 +00:00
|
|
|
$this->view->assign('droitsClients', explode(' ', $reponse->result->droitsClients));
|
|
|
|
} 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)));
|
2011-05-24 13:25:52 +00:00
|
|
|
$this->view->assign('droitsClients', explode(' ', $identity->droitsClients));
|
|
|
|
}
|
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));
|
|
|
|
} else {
|
2011-08-05 12:52:50 +00:00
|
|
|
$reponse = $ws->getNextLogin($identity->username);
|
2011-04-01 12:14:40 +00:00
|
|
|
$this->view->assign('loginNew', $reponse->result->racine);
|
2011-08-05 13:43:39 +00:00
|
|
|
$this->view->assign('droitsClients', explode(' ', strtolower($reponse->result->droitsClients)));
|
2011-04-01 12:14:40 +00:00
|
|
|
$this->view->assign('action', 'new');
|
|
|
|
$this->view->assign('pref', array());
|
|
|
|
}
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-06-27 12:56:19 +00:00
|
|
|
/**
|
|
|
|
* Renvoi vers le wiki
|
|
|
|
*/
|
|
|
|
public function documentationAction()
|
|
|
|
{
|
|
|
|
$user = new Utilisateur();
|
|
|
|
$login = $user->getLogin();
|
|
|
|
$password = $user->getPassword();
|
|
|
|
$url = 'http://infos.scores-decisions.com/?do=login&u='.$login.'&p='.$password;
|
|
|
|
$this->_redirect($url);
|
|
|
|
}
|
2012-05-10 06:06:04 +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()
|
|
|
|
{
|
|
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/conso.js', 'text/javascript');
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-05-23 10:04:12 +00:00
|
|
|
$user = new 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
|
|
|
|
*/
|
2011-05-03 15:58:48 +00:00
|
|
|
public function activateAction()
|
|
|
|
{
|
2011-05-24 13:25:52 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$login = $request->getParam('login');
|
|
|
|
$action = 'actif';
|
|
|
|
$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
|
|
|
|
*/
|
2011-05-03 15:58:48 +00:00
|
|
|
public function unactivateAction()
|
|
|
|
{
|
2011-05-24 13:25:52 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$login = $request->getParam('login');
|
|
|
|
$action = 'desactif';
|
|
|
|
$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
|
|
|
{
|
|
|
|
$user = new 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
|
|
|
{
|
2011-02-21 08:45:13 +00:00
|
|
|
//@todo : gestion des affichages particuliers pour les clients
|
2010-11-24 10:55:21 +00:00
|
|
|
$this->view->headTitle()->append('Connexion');
|
2010-11-22 12:50:12 +00:00
|
|
|
$form = new Form_Login();
|
|
|
|
$this->view->form = $form;
|
|
|
|
$request = $this->getRequest();
|
|
|
|
if ($request->isPost()) {
|
|
|
|
$formData = $request->getPost ();
|
|
|
|
if ($form->isValid($formData)) {
|
|
|
|
$login = $form->getValue('login');
|
|
|
|
$pass = $form->getValue('pass');
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
2012-04-04 12:40:44 +00:00
|
|
|
$authAdapter = new Scores_AuthAdapter($login, md5($login.'|'.$pass));
|
2010-11-22 12:50:12 +00:00
|
|
|
$result = $auth->authenticate($authAdapter);
|
|
|
|
if (!$result->isValid()){
|
|
|
|
$this->view->message = '';
|
2011-08-30 14:46:40 +00:00
|
|
|
Zend_Registry::get('firebug')->info($result);
|
2010-11-22 12:50:12 +00:00
|
|
|
foreach ($result->getMessages() as $message) {
|
|
|
|
$this->view->message.= $message."<br/>";
|
|
|
|
}
|
|
|
|
} else {
|
2011-02-04 16:27:03 +00:00
|
|
|
$url = '';
|
2011-05-18 07:44:43 +00:00
|
|
|
if (Zend_Session::namespaceIsset('login')){
|
|
|
|
$session = new Zend_Session_Namespace('login');
|
|
|
|
if (isset($session->url)) {
|
|
|
|
$url = $session->url;
|
|
|
|
}
|
2011-02-04 16:27:03 +00:00
|
|
|
}
|
2011-09-07 13:42:18 +00:00
|
|
|
if (!empty($url) && $url!='/user/login' && $url!='/localauth'){
|
2011-01-11 09:15:11 +00:00
|
|
|
$this->_redirect($url);
|
|
|
|
}
|
2010-11-22 12:50:12 +00:00
|
|
|
$this->_redirect('/');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-06 11:22:26 +00:00
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$this->render('login');
|
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()
|
|
|
|
{
|
2010-11-22 12:50:12 +00:00
|
|
|
Zend_Auth::getInstance()->clearIdentity();
|
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
|
|
|
|
2011-08-30 14:46:40 +00:00
|
|
|
$url = 'http://www.scores-decisions.com/';
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-08-30 14:46:40 +00:00
|
|
|
if (APPLICATION_ENV != 'production'){
|
|
|
|
$url = 'http://'.$_SERVER['SERVER_NAME'].$this->view->url(array(
|
|
|
|
'controller' => 'user',
|
|
|
|
'action' => 'login',
|
2012-05-10 06:06:04 +00:00
|
|
|
));
|
2011-09-09 08:28:42 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2011-09-09 08:28:42 +00:00
|
|
|
$this->view->assign('url', $url);
|
2012-05-10 06:06:04 +00:00
|
|
|
$this->view->headMeta()->appendHttpEquiv('refresh', '5; url='.$url);
|
2011-02-04 16:27:03 +00:00
|
|
|
$this->render('logout');
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
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
|
|
|
|
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
|
|
|
}
|
2012-05-10 06:06:04 +00:00
|
|
|
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|