Commit 4cc7838a authored by gloas's avatar gloas

Boite login: ajout champ select profil: permet de rediriger les actions de mon…

Boite login: ajout champ select profil: permet de rediriger les actions de mon compte ou de login sur un profil choisi
parent a35a3db2
......@@ -23,4 +23,4 @@ userfiles/image/*
userfiles/js/*
userfiles/photoBib/*
userfiles/photobib/*
userfiles/web_thumbnails/*
\ No newline at end of file
userfiles/web_thumbnails/*
......@@ -141,6 +141,11 @@ class Admin_AccueilController extends Zend_Controller_Action {
public function loginAction() {
$this->view->getHelper('ComboProfils')
->setTagId('profil_redirect')
->setTagName('profil_redirect')
->addEmptyOption();
$this->_simpleAction();
}
......
......@@ -72,3 +72,10 @@
<td class="gauche"><input type="text" name="lien_creer_compte" size="50" value="<?php print($this->preferences["lien_creer_compte"]); ?>"></td>
</tr>
<tr>
<td class="droite">Basculer automatiquement sur le profil:&nbsp;</td>
<td class="gauche">
<?php echo $this->ComboProfils('ALL', 'ALL', $this->preferences['profil_redirect']);
?>
</td>
</tr>
......@@ -125,7 +125,6 @@ class AuthController extends ZendAfi_Controller_Action {
function boiteLoginAction() {
$this->view->preferences = Class_Profil::getCurrentProfil()->getModuleAccueilPreferencesByType('auth');
$strategy = Auth_Strategy_Abstract::strategyForController($this);
$strategy->setDefaultUrl($this->_request->getServer('HTTP_REFERER'));
$strategy->processLogin();
......
......@@ -22,7 +22,7 @@ function submit() {
<?php
if($user = Class_Users::getLoader()->getIdentity()) {
echo sprintf("<div class='welcome'>%s %s </div>", $this->_($this->preferences['message_connecte']), $user->getNomAff());
echo sprintf('<a href="%s/abonne/fiche" target="_parent">&raquo;&nbsp;%s</a>', $this->url(['controller'=>'abonne','action'=>'fiche']), $this->_($this->preferences['lien_compte']));
echo sprintf('<a href="%s/abonne/fiche" target="_parent">&raquo;&nbsp;%s</a>', $this->url(['controller'=>'abonne','action'=>'fiche'],null,true), $this->_($this->preferences['lien_compte']));
if ($user->hasIdabon())
echo $this->ficheAbonneLinks($user->getNbEmprunts(), $user->getNbEmpruntsRetard(), $user->getNbReservations());
echo sprintf('<a href="%s" target="_parent">&raquo;&nbsp;%s</a>', $this->url(['controller'=>'auth','action'=>'logout']), $this->_($this->preferences['lien_deconnection']));
......
<div class="form">
<?php
if($user = Class_Users::getLoader()->getIdentity()) {
echo sprintf("<div class='welcome'>%s %s </div>", $this->_($this->preferences['message_connecte']), $user->getNomAff());
echo sprintf('<a href="%s" target="_parent">%s</a>', $this->url(['controller'=>'abonne',
'action'=>'fiche']), $this->_($this->preferences['lien_compte']));
if ($user->hasIdabon())
echo $this->ficheAbonneLinks($user->getNbEmprunts(), $user->getNbEmpruntsRetard(), $user->getNbReservations());
echo sprintf('<a href="%s" target="_parent">%s</a>', $this->url(['controller'=>'auth',
'action'=>'logout']), $this->_($this->preferences['lien_deconnection']));
} else {
$form = ZendAfi_Form_Login::newWithOptions(['data' => array_merge(
$this->preferences,
['redirect_url' => $this->redirect,
'service' => $this->service,
'id_notice' => $this->id_notice]),
'action' => $this->url(['controller' => 'auth',
'action' => 'boite-login',
'id_module' => $this->id_module])]);
echo $this->renderForm($form);
}
?>
</div>
\ No newline at end of file
<?php
if($user = Class_Users::getLoader()->getIdentity()) {
echo sprintf("<div class='welcome'>%s %s </div>", $this->_($this->preferences['message_connecte']), $user->getNomAff());
echo sprintf('<a href="%s" target="_parent">%s</a>', $this->url(['controller'=>'abonne',
'action'=>'fiche',
'id_profil'=>$this->preferences['profil_redirect'] > 0 ? $this->preferences['profil_redirect'] : Class_Profil::getCurrentProfil()->getId()],null,true), $this->_($this->preferences['lien_compte']));
if ($user->hasIdabon())
echo $this->ficheAbonneLinks($user->getNbEmprunts(), $user->getNbEmpruntsRetard(), $user->getNbReservations());
echo sprintf('<a href="%s" target="_parent">%s</a>', $this->url(['controller'=>'auth',
'action'=>'logout',
'id_profil'=>$this->preferences['profil_redirect'] > 0 ? $this->preferences['profil_redirect'] : Class_Profil::getCurrentProfil()->getId()],null,true), $this->_($this->preferences['lien_deconnection']));
} else {
$form = ZendAfi_Form_Login::newWithOptions(['data' => array_merge(
$this->preferences,
['redirect_url' => $this->redirect,
'service' => $this->service,
'id_notice' => $this->id_notice]),
'action' => $this->url(['controller' => 'auth',
'action' => 'boite-login',
'id_module' => $this->id_module])]);
echo $this->renderForm($form);
}
?>
</div>
......@@ -1780,7 +1780,6 @@ class Class_Notice extends Storm_Model_Abstract {
public function getPaniersLibelles() {
xdebug_break();
$list_panier = $this->getPaniers();
if(($nb_paniers = count($list_panier)) < 1)
return '';
......
......@@ -54,7 +54,8 @@ class Class_Systeme_ModulesAccueil_Login extends Class_Systeme_ModulesAccueil_Nu
'message_connecte' => 'Bienvenue',
'lien_compte' => '» Mon compte',
'lien_deconnection' => '» Se déconnecter',
'autocomplete_off' => 1 // si == 1, rajoute autocomplete="off" au formulaire
'autocomplete_off' => 1 ,// si == 1, rajoute autocomplete="off" au formulaire
'profil_redirect' => '0'
];
}
?>
\ No newline at end of file
......@@ -204,7 +204,6 @@ class ZendAfi_Form_Album extends ZendAfi_Form {
}
public function addAffichageFor($album) {
xdebug_break();
return $this
->addElement('cochesSuggestion', 'bibliotheques',
['label' => 'Bibliotheques',
......
......@@ -25,7 +25,6 @@ class ZendAfi_Form_Decorator_CochesSuggestion extends Zend_Form_Decorator_Abstra
*/
public function render($content) {
$helper = $this->_element->getView()->getHelper('tagListeCoches');
xdebug_break();
$helper->setSelectedAllMeansNothing($this->_element->getSelectedAllMeansNothing());
return $content
.$this->_element->getView()->tagListeCoches(
......
......@@ -472,15 +472,22 @@ class AccueilControllerConfigBoiteLoginTest extends Admin_AbstractControllerTest
public function setUp() {
parent::setUp();
Class_Profil::getCurrentProfil()
->updateModuleConfigAccueil(25,
array('type_module' => 'LOGIN',
'division' => 4,
'id_module' => 32,
'preferences' => array()));
->updateModuleConfigAccueil(32,
['type_module' => 'LOGIN',
'division' => 4,
'id_module' => 32,
'preferences' => ['profil_redirect'=>'1',
'mot_de_pass_exemple' => 'dd/mm/aaaa']]);
$this->dispatch('/admin/accueil/login?config=accueil&type_module=LOGIN&id_module=32', true);
}
/** @test */
public function selectProfilRedirectShouldContainsProfil1() {
$this->assertXPathContentContains('//select[@id="profil_redirect"][@name="profil_redirect"]/optgroup/option[@value="1"][@selected="selected"]', 'portail: Accueil', $this->_response->getBody());
}
/** @test */
public function inputTitreShouldBeSeConnecter() {
$this->assertXPath('//input[@name="titre"][@value="Se connecter"]');
......@@ -533,6 +540,18 @@ class AccueilControllerConfigBoiteLoginTest extends Admin_AbstractControllerTest
public function profilShouldBeValid() {
$this->assertTrue(Class_Profil::getCurrentProfil()->isValid());
}
/** @test **/
public function configShouldContainsSelectProfil() {
$this->assertXPath('//td/select[@name="profil_redirect"][@id="profil_redirect"]');
}
/** @test **/
public function selectProfilShloudBeEmptyValue() {
$this->assertXPath('//td/select[@id="profil_redirect"]/option');
}
}
......
......@@ -38,7 +38,8 @@ abstract class PortailWithOneLoginModuleTestCase extends AbstractControllerTestC
'mot_de_passe_exemple' => '1983',
'titre_connecte' => 'Vous êtes connecté(e)',
'lien_connexion' => 'please, log me',
'lien_mot_de_passe_oublie' => 'me rappelle plus']]],
'lien_mot_de_passe_oublie' => 'me rappelle plus',
'profil_redirect' => 1]]],
'options' => []];
Class_Profil::getCurrentProfil()
......@@ -113,6 +114,13 @@ class AuthControllerAbonneSIGBLoggedTest extends PortailWithOneLoginModuleTestCa
}
/** @test */
public function redirectProfilShouldBeProfil1(){
$this->assertXPath('//a[contains(@href,"abonne/fiche/id_profil/1")]',$this->_response->getBody());
}
/** @test */
public function linkPretsShouldBePresent() {
$this->assertXPathContentContains('//div[@id="boite_login"]//a[contains(@href, "prets")]', '3');
......@@ -228,6 +236,7 @@ class AuthControllerNobodyLoggedAndRegistrationAllowedBoiteLoginTest extends Aut
$this->assertXPathContentContains('//h1','Se connecter');
}
public function testLinkSeConnecter() {
$this->assertXPath('//div[@id="boite_login"]//a[contains(@onclick,"submit")]');
$this->assertXPathContentContains('//div[@id="boite_login"]//a[contains(@onclick, "submit")]',
......@@ -954,4 +963,71 @@ class AuthControllerNobodyLoggedAndRegistrationAllowedRegisterTest extends AuthC
}
}
class portailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_IntBib')
->whenCalled('findAllBy')
->answers([]);
$cfg_accueil = ['modules' => [4 => ['division' => '4',
'id_module' => 4,
'type_module' => 'LOGIN',
'preferences' => [
'identifiant' => 'Numéro de carte',
'mot_de_passe'=> 'Année de naissance',
'identifiant_exemple' => 'jj-mm-aaaa',
'mot_de_passe_exemple' => '1983',
'titre_connecte' => 'Vous êtes connecté(e)',
'lien_connexion' => 'please, log me',
'lien_mot_de_passe_oublie' => 'me rappelle plus',
'profil_redirect' => 0]]],
'options' => []];
Class_Profil::getCurrentProfil()
->setBrowser('opac')
->setCfgAccueil(ZendAfi_Filters_Serialize::serialize($cfg_accueil));
ZendAfi_Auth::getInstance()->logUser(
Class_Users::newInstanceWithId(5,
['login' => 'Pioup',
'idabon' => 48,
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'id_site' => 1,
'fiche_sigb' => []]));
$this->dispatch('/opac/');
}
/** @test */
public function redirectProfilForLoginShouldBeProfil2(){
$this->assertXPath('//a[contains(@href,"abonne/fiche/id_profil/2")]',$this->_response->getBody());
}
/** @test */
public function redirectProfilForLoginShouldNotBeProfil0(){
$this->assertNotXPath('//a[contains(@href,"abonne/fiche/id_profil/0")]',$this->_response->getBody());
}
/** @test */
public function redirectProfilForLogoutShouldNotBeProfil2(){
$this->assertXPath('//a[contains(@href,"auth/logout/id_profil/2")]',$this->_response->getBody());
}
/** @test */
public function redirectProfilForLogoutShouldNotBeProfil0(){
$this->assertNotXPath('//a[contains(@href,"abonne/logout/id_profil/0")]',$this->_response->getBody());
}
}
?>
\ No newline at end of file
......@@ -168,7 +168,6 @@ class ModulesMenuTest extends Storm_Test_ModelTestCase {
public function vodeclicUrlWithAbonnementInvalidShouldBeJSAlertAbonnementInvalid() {
$this->_logUserGaston();
$vodeclic= new Class_Systeme_ModulesMenu_Vodeclic();
xdebug_break();
$url = $vodeclic->getDynamiqueUrl();
$this->assertContains('Votre abonnement est terminé', $vodeclic->getMessage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment