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 {
Class_Newsletter::findAllBy(['id' => $subscriptions]) :
[];
try {
$password = $this->_request->getParam('password');
if (empty($password))
$password = $this->_user->getPassword();
$password = $this->_request->getParam('password');
if (empty($password))
$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();
$attributes = [];
foreach($fields_to_save as $field)
$attributes[$field] = $this->_request->getParam($field);
$this->_user
->updateAttributes($attributes)
->setPassword($password)
->setNewsletters($newsletters);
$this->_user
->updateAttributes($attributes)
->setPassword($password)
->setNewsletters($newsletters);
$patron = $this->_user->getEmprunteur();
$patron->updateFromUser($this->_user);
try {
if ($this->_user->save()) {
$patron->ensureService($this->_user)->save();
$this->_helper->notify($this->_('Vos modifications ont bien été enregistrées'));
$this->_redirect('/abonne/fiche');
}
......
......@@ -343,11 +343,18 @@ class AuthController extends ZendAfi_Controller_Action {
|| !$form->isValid($this->_request->getPost()))
return;
$user->setPassword($form->getValue('new_pass'))
->save();
$user->setPassword($form->getValue('new_pass'));
$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->_redirect('/auth/login');
}
......
......@@ -1333,12 +1333,6 @@ class Class_Users extends Storm_Model_Abstract {
}
public function updateSIGBOnSave() {
$this->getFicheSigb();
return $this;
}
public function setFicheSIGB($fiche) {
$this->_fiche_sigb = $fiche;
return $this;
......@@ -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() {
$this->setDateMaj(Class_Multimedia_Utils_DateTimeFormat::getInstance()
->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());
}
......
......@@ -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
* @return string
......
......@@ -98,10 +98,20 @@ class ZendAfi_Controller_Plugin_Manager_User extends ZendAfi_Controller_Plugin_M
}
protected function _setupFormAndSave($model) {
if ($this->_request->isPost())
$model->updateSIGBOnSave();
protected function _doBeforeSave($model) {
parent::_doBeforeSave($model);
$model->getEmprunteur()->updateFromUser($model);
return $this;
}
protected function _doAfterSave($model) {
$model->getEmprunteur()->ensureService($model)->save();
return parent::_doAfterSave($model);
}
protected function _setupFormAndSave($model) {
try {
return parent::_setupFormAndSave($model);
} 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