2010-11-22 12:50:12 +00:00
|
|
|
<?php
|
2011-04-13 12:15:43 +00:00
|
|
|
require_once 'Web/Forms/Login.php';
|
2010-11-22 12:50:12 +00:00
|
|
|
require_once 'Web/WebAuthAdapter.php';
|
|
|
|
|
|
|
|
class UserController extends Zend_Controller_Action {
|
|
|
|
|
2011-01-05 09:59:49 +00:00
|
|
|
public function init()
|
|
|
|
{
|
2011-01-07 17:16:07 +00:00
|
|
|
|
2011-01-05 09:59:49 +00:00
|
|
|
}
|
2010-11-22 12:50:12 +00:00
|
|
|
|
|
|
|
public function indexAction()
|
|
|
|
{
|
2011-04-18 14:36:06 +00:00
|
|
|
$this->view->headLink()->appendStylesheet('/themes/default/styles/form.css', 'all');
|
|
|
|
|
2011-04-01 12:14:40 +00:00
|
|
|
require_once 'Scores/WsScores.php';
|
|
|
|
$ws = new WsScores();
|
|
|
|
//Liste de tous les droits
|
|
|
|
$listeDroits = $ws->getListeDroits();
|
|
|
|
$droitsLib = array();
|
|
|
|
foreach($listeDroits->item as $droit) {
|
|
|
|
$droitsLib[$droit->code] = $droit->desc;
|
|
|
|
}
|
|
|
|
$this->view->assign('droitsLib', $droitsLib);
|
2011-02-21 08:45:13 +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) {
|
|
|
|
$prefsLib[$pref->code] = $pref->desc;
|
|
|
|
}
|
|
|
|
$this->view->assign('prefsLib', $prefsLib);
|
2011-02-21 08:45:13 +00:00
|
|
|
|
2011-04-01 12:14:40 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$identity = $auth->getIdentity();
|
2011-02-21 08:45:13 +00:00
|
|
|
$isAdmin = false;
|
2011-04-01 12:14:40 +00:00
|
|
|
if ($identity->profil == 'Administrateur'
|
|
|
|
|| $identity->profil == 'SuperAdministrateur') {
|
2011-02-21 08:45:13 +00:00
|
|
|
$isAdmin = true;
|
|
|
|
}
|
2011-04-01 12:14:40 +00:00
|
|
|
$this->view->assign('options', $identity);
|
2011-02-21 08:45:13 +00:00
|
|
|
$this->view->assign('isAdmin', $isAdmin);
|
2011-04-01 12:14:40 +00:00
|
|
|
$this->view->assign('loginVu', $identity->username);
|
|
|
|
if (!isset($_REQUEST['action']) || $_REQUEST['action']!='new') {
|
|
|
|
$this->view->assign('loginNew', '');
|
|
|
|
$this->view->assign('droits', explode(' ', $identity->droits));
|
|
|
|
$this->view->assign('droitsClients', explode(' ', $identity->droitsClients));
|
|
|
|
$this->view->assign('action', 'edit');
|
|
|
|
$this->view->assign('pref', explode(' ',$identity->pref));
|
|
|
|
} else {
|
|
|
|
$reponse = $ws->getNextLogin($loginVu);
|
|
|
|
$this->view->assign('loginNew', $reponse->result->racine);
|
|
|
|
$this->view->assign('droitsClients', explode(' ', $reponse->result->droitsClients));
|
|
|
|
$this->view->assign('action', 'new');
|
|
|
|
$this->view->assign('pref', array());
|
|
|
|
}
|
2011-02-21 08:45:13 +00:00
|
|
|
|
|
|
|
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
|
|
|
|
2011-04-01 12:14:40 +00:00
|
|
|
public function saveAction()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function changepwdAction()
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-11-22 12:50:12 +00:00
|
|
|
public function loginAction()
|
|
|
|
{
|
2011-02-21 08:45:13 +00:00
|
|
|
//@todo : gestion des affichages particuliers pour les clients
|
2011-01-07 17:16:07 +00:00
|
|
|
$activeNav = $this->view->navigation();
|
|
|
|
$activeNav->removePages();
|
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();
|
2011-01-06 11:22:26 +00:00
|
|
|
$authAdapter = new WebAuthAdapter($login, $pass);
|
2010-11-22 12:50:12 +00:00
|
|
|
$result = $auth->authenticate($authAdapter);
|
|
|
|
if (!$result->isValid()){
|
|
|
|
$this->view->message = '';
|
|
|
|
foreach ($result->getMessages() as $message) {
|
|
|
|
$this->view->message.= $message."<br/>";
|
|
|
|
}
|
|
|
|
} else {
|
2011-01-06 11:22:26 +00:00
|
|
|
$timeout = $auth->getIdentity()->timeout;
|
|
|
|
$storage = new Zend_Auth_Storage_Session();
|
|
|
|
$sessionNamespace = new Zend_Session_Namespace($storage->getNamespace());
|
|
|
|
$sessionNamespace->setExpirationSeconds($timeout);
|
|
|
|
$auth->setStorage($storage);
|
2011-02-04 16:27:03 +00:00
|
|
|
$url = '';
|
|
|
|
if (Zend_Registry::isRegistered('URL')){
|
|
|
|
$url = Zend_Registry::get('URL');
|
|
|
|
}
|
2011-01-11 09:15:11 +00:00
|
|
|
if (!empty($url)){
|
|
|
|
$this->_redirect($url);
|
|
|
|
}
|
2010-11-22 12:50:12 +00:00
|
|
|
$this->_redirect('/');
|
|
|
|
}
|
2011-01-07 17:16:07 +00:00
|
|
|
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-06 11:22:26 +00:00
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$this->render('login');
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
2011-02-21 08:45:13 +00:00
|
|
|
|
|
|
|
public function logoutAction()
|
|
|
|
{
|
2011-01-07 17:16:07 +00:00
|
|
|
$activeNav = $this->view->navigation();
|
|
|
|
$activeNav->removePages();
|
2010-11-22 12:50:12 +00:00
|
|
|
Zend_Auth::getInstance()->clearIdentity();
|
2011-02-04 16:27:03 +00:00
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$this->render('logout');
|
2010-11-22 12:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|