Commit 5cfed973 authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'dev#99489_magasin_de_themes_bases_sur_bootstrap'

Conflicts:
	library/templates/Intonation/Library/View/Wrapper/Record.php
parents dadbbf2f 712e2a3e
Pipeline #9978 passed with stage
in 44 minutes and 54 seconds
......@@ -1819,46 +1819,6 @@ class AbonneController extends ZendAfi_Controller_Action {
}
public function modifierAction() {
$form = $this->_userForm($this->_user);
$form->setAction($this->view->url());
$this->view->form = $form;
if (!$this->_request->isPost())
return ;
if (!$form->isValid($this->_request->getPost()))
return;
$fields_to_save = Class_AdminVar::getChampsFicheUtilisateur();
$attributes = [];
foreach($fields_to_save as $field)
$attributes[$field] = $this->_request->getParam($field);
$this->_user
->updateAttributes($attributes);
$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->_redirectClose('/abonne/informations');
}
$form->addDecorator('Errors');
foreach($this->_user->getErrors() as $error)
$form->addError($error);
} catch(Exception $e) {
$form->addError($e->getMessage());
$form->addDecorator('Errors');
}
}
public function exporterLaSelectionAction() {
$this->view->titre = $this->_('Exporter la sélection');
......@@ -1953,4 +1913,28 @@ class AbonneController extends ZendAfi_Controller_Action {
return $this->_helper->ajax($callback);
}
public function modifierAction() {
if ((new Class_User_EditFormHelper($this->_user,
$this->view,
$this->_request))
->beEditUser()
->proceed()) {
$this->_helper->notify($this->_('Vos informations ont bien été modifiées.'), ['status' => 'success']);
$this->_redirectClose($this->view->absoluteUrl(['action' => 'informations']));
}
}
public function changerMonMotDePasseAction() {
if ((new Class_User_EditFormHelper($this->_user,
$this->view,
$this->_request))
->beChangePassword()
->proceed()) {
$this->_helper->notify($this->_('Votre mot de passe à bien été changé.'), ['status' => 'success']);
$this->_redirectClose($this->view->absoluteUrl(['action' => 'informations']));
}
}
}
\ No newline at end of file
......@@ -136,4 +136,9 @@ class IndexController extends ZendAfi_Controller_Action {
return $this->_helper->ajax($callback);
}
public function heartbeatAction() {
$this->getHelper('ViewRenderer')->setNoRender();
}
}
\ No newline at end of file
<?php
echo $this->abonne_EditPassword($this->user, $this->form);
<?php
echo $this->abonne_Edit($this->user, $this->form);
?>
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_User_EditFormHelper {
use Trait_Translator;
protected
$_user,
$_view,
$_web_request,
$_form,
$_old_password,
$_callback;
public function __construct($user, $view, $request) {
$this->_user = $user;
$this->_view = $view;
$this->_web_request = $request;
}
public function beChangePassword() {
$this->_form = new ZendAfi_Form;
$this->_form
->addElement('password',
'current_password',
['label' => $this->_('Mot de passe actuel'),
'required' => true,
'allowEmpty' => false,
'validators' => [(new Zend_Validate_Identical($this->_user->getPassword()))
->setMessages(['missingToken' => $this->_('Vous devez confirmer votre mot de passe actuel'),
'notSame' => $this->_('Le mot de passe ne correspondent pas à votre mot de passe actuel')])]])
->addElement('password',
'new_password',
['label' => $this->_('Nouveau mot de passe'),
'required' => true,
'allowEmpty' => false,
'validators' => [(new Zend_Validate_StringLength(4, 24))]])
->addElement('password',
'confirm_new_password',
['label' => $this->_('Confirmer le nouveau mot de passe'),
'required' => true,
'allowEmpty' => false,
'validators' => [(new Zend_Validate_Identical($this->_web_request->getParam('new_password')))
->setMessages(['missingToken' => $this->_('Veuillez confirmer le nouveau mot de passe '),
'notSame' => $this->_('Les mots de passe ne sont pas identifique')])]]);
$this->_form->addUniqDisplayGroup('change-password');
$this->_callback = function() {
$this->_old_password = $this->_user->getPassword();
$this->_user->setPassword($this->_web_request->getParam('new_password'));
};
return $this;
}
public function beEditUser() {
$this->_form = new ZendAfi_Form;
$textfields = ['nom' => $this->_('Nom'),
'prenom' => $this->_('Prénom'),
'pseudo' => $this->_('Pseudo'),
'adresse' => $this->_('Adresse'),
'code_postal' => $this->_('Code postal'),
'ville' => $this->_('Ville'),
'mail' => $this->_('E-Mail'),
'telephone' => $this->_('Téléphone'),
'mobile' => $this->_('Téléphone mobile')];
foreach($textfields as $field => $label) {
$element = $this->_form
->createElement('text', $field)
->setLabel($label)
->setAttrib('size', 30);
$this->_form->addElement($element);
}
if ($mail_element = $this->_form->getElement('mail'))
$mail_element->addValidator(new ZendAfi_Validate_EmailAddress());
if ($phone_element = $this->_form->getElement('telephone'))
$phone_element->addValidator(new ZendAfi_Validate_PhoneNumber());
if ($mobile_element = $this->_form->getElement('mobile'))
$mobile_element->addValidator(new ZendAfi_Validate_PhoneNumber());
$this->_form->addDisplayGroup(['nom', 'prenom', 'pseudo'],
'identification',
['legend' => 'Identification']);
$this->_form->addDisplayGroup(['adresse', 'code_postal', 'ville'],
'coordonnees',
['legend' => 'Coordonnées']);
$this->_form->addDisplayGroup(['mail', 'telephone', 'mobile'],
'contact',
['legend' => 'Contact']);
$fields_to_show = Class_AdminVar::getChampsFicheUtilisateur();
if (in_array('mode_contact', $fields_to_show)) {
$this->_form->addElement('radio',
'mode_contact',
['label' => '',
'multiOptions' => [Class_Users::MODE_CONTACT_LETTER => $this->_(' par courrier postal'),
Class_Users::MODE_CONTACT_MAIL => $this->_(' par E-Mail'),
Class_Users::MODE_CONTACT_SMS => $this->_(' par SMS')],
'value' => $user->getModeContact()]);
$this->_form->addDisplayGroup(['mode_contact'], 'mode_de_contact', ['legend' => 'Recevoir mes notificactions de réservation et de rappel']);
}
$this->_form
->populate($this->_user->toArray());
$this->_callback = function () {
$password = $this->_user->getPassword();
$this->_user
->updateAttributes($this->_web_request->getPost())
->setPassword($password);
};
return $this;
}
public function proceed() {
$this->_form
->setAction($this->_view->url())
->setMethod('POST')
->setAttrib('autocomplete', 'off');
$this->_view->form = $this->_form;
if ( ! $this->_web_request->isPost())
return false;
if ( ! $this->_form->isValid($this->_web_request->getPost()))
return false;
$callback = $this->_callback;
$callback();
if (!$this->_user->isValid()) {
$this->_form->addDecorator('Errors');
foreach($this->_user->getErrors() as $error)
$this->_form->addError($error);
return false;
}
return $this->_updateUser();
}
protected function _updateUser() {
$patron = $this->_user->getEmprunteur();
$patron->updateFromUser($this->_user);
$patron->setPreviousPassword($this->_old_password);
try {
$patron
->ensureService($this->_user)
->save();
} catch(Exception $e) {
$this->_form->addError($e->getMessage());
$this->_form->addDecorator('Errors');
return false;
}
return $this->_user->save();
}
}
\ No newline at end of file
......@@ -95,36 +95,7 @@ class ZendAfi_View_Helper_Accueil_News extends ZendAfi_View_Helper_Accueil_Base
protected function addNewsAddButton() {
if (!$this->_articles || !Class_Users::isCurrentUserCanAccesBackend())
return '';
$category = $this->getFirstArticleCategorie($this->_articles);
if (!$category
|| !Class_Users::getIdentity()
->hasAnyPermissionOn($category, [Class_Permission::createArticle(),
Class_Permission::createArticleCategory()]))
return '';
return $this->view
->tagAnchor($this->view->url(['module' => 'admin',
'controller' => 'cms',
'action' => 'add',
'id_module' => $this->id_module,
'id_cat' => $category->getId()]),
Class_Admin_Skin::current()
->renderActionIconOn('add', $this->view,
['title' => $this->_('Ajouter un nouvel article')]),
['data-popup' => 'true']);
}
protected function getFirstArticleCategorie($articles) {
if (!$articles || !is_array($articles)) return '';
foreach($articles as $article) {
if($category = $article->getCategorie())
return $category;
}
return $this->view->Admin_TagAddNewArticle($this->id_module, $this->_articles);
}
......
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_Admin_TagAddNewArticle extends ZendAfi_View_Helper_BaseHelper {
public function Admin_TagAddNewArticle($id_module, $articles) {
if (!$articles)
return '';
$articles = array_filter($articles);
if (empty($articles))
return '';
if (!Class_Users::isCurrentUserCanAccesBackend())
return '';
if (!$category = $this->getFirstArticleCategorie($articles))
return '';
if (!Class_Users::getIdentity()->hasAnyPermissionOn($category, [Class_Permission::createArticle(),
Class_Permission::createArticleCategory()]))
return '';
return
$this->view
->tagAnchor($this->view->url(['module' => 'admin',
'controller' => 'cms',
'action' => 'add',
'id_module' => $id_module,
'id_cat' => $category->getId()]),
Class_Admin_Skin::current()
->renderActionIconOn('add', $this->view,
['title' => $this->_('Ajouter un nouvel article')]),
['data-popup' => 'true']);
}
protected function getFirstArticleCategorie($articles) {
foreach($articles as $article) {
if($category = $article->getCategorie())
return $category;
}
}
}
......@@ -58,7 +58,7 @@ class ZendAfi_View_Helper_TagEditArticle extends ZendAfi_View_Helper_BaseHelper
protected function _renderEdit() {
return $this
->_renderActionLink('edit', $this->_('Modifier l\'article'),
->_renderActionLink('edit', $this->_('Modifier l\'article %s', $this->_article->getTitre()),
['module' => 'admin',
'controller' => 'cms',
'action' => 'edit',
......
......@@ -781,4 +781,18 @@ input[id^="select_record"] + * {
.dropdown-menu select {
min-width: 1px;
}
.only_visible_in_viewnotice {
display: none;
}
.recherche_viewnotice .only_visible_in_viewnotice {
display: block;
}
.badge.only_visible_in_viewnotice .text-truncate {
width: auto;
max-width: none;
white-space: normal;
}
\ No newline at end of file
......@@ -148,7 +148,7 @@ class Intonation_Library_AjaxPaginatedListHelper {
$element
->setView($this->_view)
->inJsSearch();
return false !== strpos($element->getContentForJSSearch(), $term);
return false !== strpos(strtolower($element->getContentForJSSearch()), $term);
});
}
......
......@@ -118,7 +118,7 @@ class Intonation_Library_FormCustomizer_Abstract {
->addElement('select',
$this->_template->withNameSpace('width_medium'),
['label' => $this->_('Largeur à partir de la taille moyennne ( entre 768px et 991px )'),
['label' => $this->_('Largeur à partir de la taille moyenne ( entre 768px et 991px )'),
'value' => Intonation_Library_Constants::WIDTH_AUTO,
'multiOptions' => $this->_getWidthsOptions()])
......@@ -148,7 +148,7 @@ class Intonation_Library_FormCustomizer_Abstract {
->addElement('select',
$this->_template->withNameSpace('order_medium'),
['label' => $this->_('Ordre à partir de la taille moyennne ( entre 768px et 991px )'),
['label' => $this->_('Ordre à partir de la taille moyenne ( entre 768px et 991px )'),
'value' => Intonation_Library_Constants::WIDTH_AUTO,
'multiOptions' => $this->_getWidthsOptions()])
......@@ -178,7 +178,7 @@ class Intonation_Library_FormCustomizer_Abstract {
->addElement('select',
$this->_template->withNameSpace('offset_medium'),
['label' => $this->_('Décalage à droite à partir de la taille moyennne ( entre 768px et 991px )'),
['label' => $this->_('Décalage à droite à partir de la taille moyenne ( entre 768px et 991px )'),
'value' => Intonation_Library_Constants::WIDTH_AUTO,
'multiOptions' => $this->_getOffsetOptions()])
......
......@@ -169,13 +169,14 @@ class Intonation_Library_Settings extends Intonation_System_Abstract {
'like' => 'class fas fa-heart text-danger',
'dislike' => 'class far fa-heart',
'suggest' => 'class fas fa-hand-holding-heart',
'subscription' => 'class fas fa-euro-sign',
'subscription' => 'class fas fa-receipt',
'card-number' => 'class fas fa-barcode',
'read-document' => 'class far fa-arrow-alt-circle-right',
'read-review' => 'class far fa-comment-dots',
'team' => 'class fas fa-users',
'agenda' => 'class fas fa-calendar-alt',
'ical' => 'class far fa-calendar-plus',
'novelty' => 'class far fa-sun',
],
......@@ -201,6 +202,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract {
'rename' => 'class fas fa-edit',
'more' => 'class fas fa-ellipsis-h',
'refresh' => 'class fas fa-sync-alt',
'lock' => 'class fas fa-unlock-alt',
'email' => 'class fas fa-at',
'phone' => 'class fas fa-phone',
......
......@@ -217,11 +217,11 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr
'Title' => $this->_('Ajouter l\'événement %s dans mon calendrier',
$this->_model->getLibelle())]);
$actions [] = $this->_view->div(['class' => 'print'],
$this->_view->tagPrintLink((new Class_Entity())
->setController('cms')
->setModels([$this->_model])
->setStrategy('Article_List')));
if ($print_link = $this->_view->tagPrintLink((new Class_Entity())
->setController('cms')
->setModels([$this->_model])
->setStrategy('Article_List')))
$actions [] = $this->_view->div(['class' => 'print'], $print_link);
$actions [] = $this->_view->reseauxSociaux($this->_model);
......
......@@ -217,12 +217,12 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp
if ($this->_record)
return $this->_record;
if (!$this->_model->getNoticeOPAC())
if (!$db_record = $this->_model->getNoticeOPAC())
return $this->_record = null;
return $this->_record = $wrapper = (new Intonation_Library_View_Wrapper_Record)
return $this->_record = (new Intonation_Library_View_Wrapper_Record)
->setView($this->_view)
->setModel($this->_model->getNoticeOPAC());
->setModel($db_record);
}
......
......@@ -101,15 +101,12 @@ class Intonation_Library_View_Wrapper_PNBLoan extends Intonation_Library_View_Wr
}
protected function _getRecord() {
if ($this->_record)
return $this->_record;
if (!$this->_model->getNoticeOPAC())
return $this->_record = null;
return $this->_record = $wrapper = (new Intonation_Library_View_Wrapper_Record)
->setView($this->_view)
->setModel($this->_model->getNoticeOPAC());
public function getContentForJSSearch() {
return $this->_in_js_search
? $this->_view->dNone(implode(' ', [$this->getMainTitle(),
$this->getSecondaryTitle(),
$this->getDescription(),
'%s']))
: '';
}
}
......@@ -129,7 +129,13 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra
public function getBadges() {
$badges = [
$badges = [((new Intonation_Library_Badge)
->setTag('div')
->setClass(' pb-1 mb-1 px-0 card-title only_visible_in_viewnotice')
->setText($this->_getFullTitle())
->setTitle($this->_('Compléments de titre pour le document %s',
$this->_model->getTitrePrincipal(' ')))),
((new Intonation_Library_Badge)
->setTag('a')
->setClass('warning fs_1em record_doctype')
......@@ -166,6 +172,18 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra
$this->_model->getTitrePrincipal(' '),
$this->_model->getAnnee())));
$badges [] = ((new Intonation_Library_Badge)
->setClass('secondary record_novelty')
->setImage(($this->_model->isNouveaute()
? (Class_Template::current()
->getIco($this->_view,
'novelty',
'library'))
: ''))
->setText($this->_model->isNouveaute() ? $this->_('Nouveauté') : '')
->setTitle($this->_('Le document %s est nouveau dans votre bibliotèque',
$this->_model->getTitrePrincipal(' '))));
$badges = $this->_injectReviewsBadgesInto($badges);
$codif = Class_Codification::getInstance();
......@@ -180,20 +198,81 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra
->setTitle($facet->getTitle())
->setUrl($facet->getUrlForLink()));
if ($this->_model->hasSerie()) {
$serie = $this->_model->getClefChapeau() . '-' . $this->_model->getTypeDoc();
$badges = $this->_addSerieBadges($badges);
$label = Class_Codification::getLibelleForSerie($this->_model);
$badges [] = (new Intonation_Library_Badge)
->setTag('a')
->setUrl($this->_view->url((new Class_CriteresRecherche)->getNewUrlCriteresSerie($serie), null, true))
->setClass('white record_serie')
->setText($label)
->setTitle($this->_view->_('Lancer une recherche pour %s', lcfirst($label)));
}
return $this->_view->renderBadges($badges);
}
return $this->_view->renderBadges($badges);
protected function _addSerieBadges($badges) {
if ( ! $this->_model->hasSerie())
return $badges;
$serie = $this->_model->getClefChapeau() . '-' . $this->_model->getTypeDoc();
$label = Class_Codification::getLibelleForSerie($this->_model);
$badges [] = (new Intonation_Library_Badge)
->setTag('a')
->setUrl($this->_view->url((new Class_CriteresRecherche)->getNewUrlCriteresSerie($serie), null, true))
->setClass('white record_serie')
->setText($label)
->setTitle($this->_view->_('%s dans la recherche.', $label));
if ( ! $user = Class_Users::getIdentity())
return $badges;
if ( ! $same_serie_records = $this->_model->getNoticesMemeSeries())
return $badges;
if ( ! $readed_selection = Class_PanierNotice::findFirstBy(['libelle' => 'Déjà lu',
'id_user' => $user->getId()]))
return $badges;
if ( ! $readed_records = $readed_selection->getNoticesAsArray())
return $badges;
$readed_records_in_series =
array_filter($readed_records, function ($record)
{
return $record->hasSerie();
});
if ( ! $readed_records_in_series)
return $badges;
$readed_in_serie = array_uintersect($readed_records_in_series,
$same_serie_records,
function($record_1, $record_2)
{
if ($record_1->getId() == $record_2->getId())
return 0;
if ($record_1->getId() > $record_2->getId())
return 1;
return -1;
});
if ( ! $readed_in_serie)
return $badges;
$total_readed_in_serie = count($readed_in_serie);
$total_to_read = count($same_serie_records);
$badges [] = (new Intonation_Library_Badge)
->setClass('white record_serie')
->setImage(Class_Template::current()->getIco($this->_view,
'readed',
'library'))
->setText($this->_('%d sur %d',
$total_readed_in_serie,
$total_to_read))
->setTitle($this->_view->_('Vous avez lu %d sur %d des tômes de la série %s',
$total_readed_in_serie,
$total_to_read,
ucfirst(strtolower($this->_model->getClefChapeau()))));
return $badges;
}
......@@ -397,6 +476,19 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra
}