Commit 8e08b44f authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #74786 : fix big bang with patrons

parent 0c4770d7
Pipeline #4544 failed with stage
in 51 minutes and 16 seconds
...@@ -611,24 +611,26 @@ class AbonneController extends ZendAfi_Controller_Action { ...@@ -611,24 +611,26 @@ class AbonneController extends ZendAfi_Controller_Action {
Class_Newsletter::findAllBy(['id' => $subscriptions]) : Class_Newsletter::findAllBy(['id' => $subscriptions]) :
[]; [];
try { $password = $this->_request->getParam('password');
$password = $this->_request->getParam('password'); if (empty($password))
if (empty($password)) $password = $this->_user->getPassword();
$password = $this->_user->getPassword();
$this->_user->updateSIGBOnSave(); $fields_to_save = Class_AdminVar::getChampsFicheUtilisateur();
$attributes = [];
foreach($fields_to_save as $field)
$attributes[$field] = $this->_request->getParam($field);
$fields_to_save = Class_AdminVar::getChampsFicheUtilisateur(); $this->_user
$attributes = []; ->updateAttributes($attributes)
foreach($fields_to_save as $field) ->setPassword($password)
$attributes[$field] = $this->_request->getParam($field); ->setNewsletters($newsletters);
$this->_user $patron = $this->_user->getEmprunteur();
->updateAttributes($attributes) $patron->updateFromUser($this->_user);
->setPassword($password)
->setNewsletters($newsletters);
try {
if ($this->_user->save()) { if ($this->_user->save()) {
$patron->ensureService($this->_user)->save();
$this->_helper->notify($this->_('Vos modifications ont bien été enregistrées')); $this->_helper->notify($this->_('Vos modifications ont bien été enregistrées'));
$this->_redirect('/abonne/fiche'); $this->_redirect('/abonne/fiche');
} }
......
...@@ -343,11 +343,18 @@ class AuthController extends ZendAfi_Controller_Action { ...@@ -343,11 +343,18 @@ class AuthController extends ZendAfi_Controller_Action {
|| !$form->isValid($this->_request->getPost())) || !$form->isValid($this->_request->getPost()))
return; return;
$user->setPassword($form->getValue('new_pass')) $user->setPassword($form->getValue('new_pass'));
->save(); $patron = $user->getEmprunteur();
$patron->updateFromUser($user);
try {
if ($user->save())
$patron->ensureService($user)->save();
} catch(Exception $e) {
$this->_helper->notify($e->getMessage());
return $this->_redirect('/auth/login');
}
$this->_helper->notify($this->_('Votre mot de passe a été réinitialisé, vous pouvez vous connecter.')); $this->_helper->notify($this->_('Votre mot de passe a été réinitialisé, vous pouvez vous connecter.'));
$this->_redirect('/auth/login'); $this->_redirect('/auth/login');
} }
......
...@@ -1333,12 +1333,6 @@ class Class_Users extends Storm_Model_Abstract { ...@@ -1333,12 +1333,6 @@ class Class_Users extends Storm_Model_Abstract {
} }
public function updateSIGBOnSave() {
$this->getFicheSigb();
return $this;
}
public function setFicheSIGB($fiche) { public function setFicheSIGB($fiche) {
$this->_fiche_sigb = $fiche; $this->_fiche_sigb = $fiche;
return $this; return $this;
...@@ -1364,30 +1358,10 @@ class Class_Users extends Storm_Model_Abstract { ...@@ -1364,30 +1358,10 @@ class Class_Users extends Storm_Model_Abstract {
} }
/**
* Hook AbstractModel::save
* Sauvegarde des données compte lecteur sur le SIGB
*/
public function afterSave() {
$this->getEmprunteur()->ensureService($this)->save($this);
}
public function beforeSave() { public function beforeSave() {
$this->setDateMaj(Class_Multimedia_Utils_DateTimeFormat::getInstance() $this->setDateMaj(Class_Multimedia_Utils_DateTimeFormat::getInstance()
->getCurrentDateFormatInYmdHMS()); ->getCurrentDateFormatInYmdHMS());
$this->getEmprunteur()
->setNom($this->getNom())
->setPrenom($this->getPrenom())
->setEMail($this->getMail())
->setPassword($this->getPassword())
->setTelephone($this->getTelephone())
->setIsContactSms($this->getIsContactSms())
->setIsContactEmail($this->getIsContactMail())
->setLogin($this->getLogin())
;
$this->setPassword((new Class_User_Password($this))->format()); $this->setPassword((new Class_User_Password($this))->format());
} }
......
...@@ -744,6 +744,22 @@ class Class_WebService_SIGB_Emprunteur { ...@@ -744,6 +744,22 @@ class Class_WebService_SIGB_Emprunteur {
} }
public function updateFromUser($user) {
$this
->setNom($user->getNom())
->setPrenom($user->getPrenom())
->setEMail($user->getMail())
->setPassword($user->getPassword())
->setTelephone($user->getTelephone())
->setIsContactSms($user->getIsContactSms())
->setIsContactEmail($user->getIsContactMail())
->setLogin($user->getLogin())
;
return $this;
}
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return string * @return string
......
...@@ -98,10 +98,20 @@ class ZendAfi_Controller_Plugin_Manager_User extends ZendAfi_Controller_Plugin_M ...@@ -98,10 +98,20 @@ class ZendAfi_Controller_Plugin_Manager_User extends ZendAfi_Controller_Plugin_M
} }
protected function _setupFormAndSave($model) { protected function _doBeforeSave($model) {
if ($this->_request->isPost()) parent::_doBeforeSave($model);
$model->updateSIGBOnSave(); $model->getEmprunteur()->updateFromUser($model);
return $this;
}
protected function _doAfterSave($model) {
$model->getEmprunteur()->ensureService($model)->save();
return parent::_doAfterSave($model);
}
protected function _setupFormAndSave($model) {
try { try {
return parent::_setupFormAndSave($model); return parent::_setupFormAndSave($model);
} catch (Exception $e) { } catch (Exception $e) {
......
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