Commit c783576e authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #64573 templating mon compte

parent 7e7ca8fd
Pipeline #6851 passed with stage
in 36 minutes and 45 seconds
......@@ -34,7 +34,7 @@ class AbonneController extends ZendAfi_Controller_Action {
if ('authenticate' == $this->getRequest()->getActionName())
return;
$this->_user = Class_Users::getIdentity();
$this->_user = $this->view->user = Class_Users::getIdentity();
$this->clearEmprunteurCache();
......@@ -364,7 +364,6 @@ class AbonneController extends ZendAfi_Controller_Action {
public function ficheAction() {
$fiche_sigb = $this->_user->getFicheSigb();
$this->view->error = isset($fiche_sigb['erreur']) ? $fiche_sigb["erreur"] : '';
......@@ -460,10 +459,6 @@ class AbonneController extends ZendAfi_Controller_Action {
if ($delete = $this->_getParam('consultation_id_delete'))
Class_CommSigb::getInstance()->onPlaceConsultationCancelBooking(Class_Users::getIdentity(), $delete);
$this->view->consultations_reservations = $this->_user->getConsultations();
$this->view->fiche = $this->_user->getFicheSigb();
$this->view->user = $this->_user;
}
......@@ -1404,4 +1399,51 @@ class AbonneController extends ZendAfi_Controller_Action {
$this->view->titre = $this->_('Mes Rendez-vous');
$this->view->user_rendez_vous = new Class_User_RendezVous($this->_user);
}
public function changeImageAction() {
$this->view->user = $this->_user;
}
public function pickImageAction() {
Class_FileManager::beOpenBar();
if (!$image = Class_FileManager::find($this->_getParam('id'))) {
$this->_helper->notify($this->_('Une erreur c\'est produite. Votre image de profil n\'a pas été modifiée.'));
return $this->_redirectClose($this->_getReferer());
}
$allowed_paths = explode(';', Class_AdminVar::getValueOrDefault('USER_PROFILE_IMAGES'));
if (!in_array($image->getPath(), $allowed_paths)) {
$this->_helper->notify($this->_('Une erreur c\'est produite. Votre image de profil n\'a pas été modifiée.'));
return $this->_redirectClose($this->_getReferer());
}
(new Class_User_Settings($this->_user))->setProfileImage($image->getPath());
$this->_user->save();
$this->_helper->notify($this->_('Votre image de profil a bien été modifiée.'));
return $this->_redirectClose($this->_getReferer());
}
public function informationsAction() {
}
public function selectionsAction() {
}
public function mesAvisAction() {
}
public function configurationsAction() {
}
public function donnerDesAvisAction() {
}
}
\ No newline at end of file
<?php
echo $this->abonne_ChangeImage($this->user);
\ No newline at end of file
<?php
echo $this->abonne_ConfigurationsBoard($this->user);
<?php
echo $this->abonne_RateRecords($this->user);
<?php
echo $this->abonne_Informations($this->user);
\ No newline at end of file
<?php
echo $this->abonne_ReviewsBoard($this->user);
<?php
$this->openBoite($this->_('Prêts en cours'));
echo $this->abonne_LoansBoard($this->config);
$this->closeBoite();
echo $this->abonne_RetourFiche();
<?php
Class_ScriptLoader::getInstance()->loadTableSorter();
$this->openBoite($this->_('Réservations en cours'));
echo $this->tag('div', $this->user->getNomAff(), ['class' => 'abonneTitre']);
$cards = new Class_User_Cards($this->user);
echo $this->abonne_ReservationsTable($cards->getHolds(), $this->fiche);
$this->closeBoite();
if (!empty($this->consultations_reservations)) {
$this->openBoite($this->_('Réservations pour la consultation sur place'));
echo $this->abonne_OnPlaceConsultationReservationsTable($this->consultations_reservations,
$this->fiche);
$this->closeBoite();
}
echo $this->abonne_RetourFiche();
?>
echo $this->abonne_HoldsBoard($this->user);
<?php
echo $this->abonne_SelectionsBoard($this->user);
\ No newline at end of file
......@@ -234,7 +234,10 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
Class_AdminVar_UserDoubleDetectOn::KEY => Class_AdminVar_Meta::newMultiInput($this->_('Champs servant à la détection des doublons. Champs possibles : %s', (new Class_AdminVar_UserDoubleDetectOn)->knownAsList()),
['validate' => 'ZendAfi_Validate_UserDoubleDetectOn']),
'SEARCH_RECORD_BEFORE_SUGGEST' => Class_AdminVar_Meta::newOnOff($this->_('Permet à l\'utilisateur de vérifier si la suggestion existe déjà dans le catalogue.'))
'SEARCH_RECORD_BEFORE_SUGGEST' => Class_AdminVar_Meta::newOnOff($this->_('Permet à l\'utilisateur de vérifier si la suggestion existe déjà dans le catalogue.')),
'USER_PROFILE_IMAGES' => Class_AdminVar_Meta::newMultiInput($this->_('Liste des images des utilisateurs'),
['value' => 'public/opac/images/abonnes/read_black.png;public/opac/images/abonnes/read_blue.png;public/opac/images/abonnes/read_green.png;public/opac/images/abonnes/read_grey.png;public/opac/images/abonnes/read_white.png;public/opac/images/abonnes/read_yellow.png;'])
];
}
......
......@@ -2037,6 +2037,9 @@ class Class_Profil extends Storm_Model_Abstract {
$cfg_accueil = $this->getCfgAccueilAsArray();
$i = 0;
foreach($cfg_accueil['modules'] as $existing_id => $config) {
if (!isset($config['division']))
continue;
if ($config['division'] != $div)
continue;
......
......@@ -110,6 +110,7 @@ class Class_Template {
return null;
$try_profile = $this->_findOrCreateTryProfileFrom($profile);
$try_profile->save();
$try_profile = $this->_patchProfile($try_profile);
$try_profile->save();
return $try_profile->getId();
......
......@@ -27,8 +27,8 @@ class Class_User_Settings {
ADMIN_SKIN = 'admin_skin',
ADMIN_SKIN_COLOR = 'admin_skin_color',
CHECKED_FEATURE = 'checked_features',
BOOKMARKED_SEARCHES = 'bookmarked_searches',
POPUP_FEATURES = 'popup_features';
POPUP_FEATURES = 'popup_features',
PROFILE_IMAGE = 'profile_image';
protected $_user, $_user_settings;
......@@ -291,7 +291,30 @@ class Class_User_Settings {
}
public function setProfileImage($path) {
$this->set(self::PROFILE_IMAGE, $path);
return $this->_user;
}
public function getProfileImage() {
return '';
$path = ($path = $this->get(self::PROFILE_IMAGE))
? $path
: $this->_initDefaultProfileImage();
$this->setProfileImage($path);
Class_FileManager::beOpenBar();
return Class_FileManager::find($path);
}
protected function _initDefaultProfileImage() {
$paths = explode(';', Class_AdminVar::getValueOrDefault('USER_PROFILE_IMAGES'));
if (!$paths || empty($paths))
return '';
return $paths[0];
}
}
\ No newline at end of file
......@@ -1006,11 +1006,13 @@ class Class_Users extends Storm_Model_Abstract {
public function getFirstAvisByIdNotice($id_notice) {
$notice = Class_Notice::find($id_notice);
if (!$notice = Class_Notice::find($id_notice))
return null;
$avis = $notice->getAvisByUser($this);
if (count($avis) > 0)
return $avis[0];
return null;
return count($avis) > 0
? $avis[0]
: null;
}
......
<?php
/**
* Copyright (c) 2012-2019, 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_Abonne_HoldsBoard extends ZendAfi_View_Helper_BaseHelper {
public function abonne_HoldsBoard($user) {
Class_ScriptLoader::getInstance()->loadTableSorter();
$cards = new Class_User_Cards($user);
$fiche = $user->getFicheSigb();
$consultations_reservations = $user->getConsultations();
$html = [$this->view->openBoiteContent($this->_('Réservations en cours')),
$this->view->div(['class' => 'abonneTitre'],
$user->getNomAff()),
$this->view->abonne_ReservationsTable($cards->getHolds(), $fiche),
$this->view->closeBoiteContent()];
if (!empty($consultations_reservations)) {
$html [] = $this->view->openBoiteContent($this->_('Réservations pour la consultation sur place'));
$html [] = $this->view->abonne_OnPlaceConsultationReservationsTable($consultations_reservations,
$fiche);
$html [] = $this->view->closeBoiteContent();
}
$html [] = $this->view->abonne_RetourFiche();
return implode($html);
}
}
......@@ -39,8 +39,14 @@ class ZendAfi_View_Helper_Abonne_LoansBoard extends ZendAfi_View_Helper_BaseHelp
$request_params = $config->getRequestParams();
$this->_preferences = $preferences = new Class_Profil_Preferences_Loans();
if($error)
return $this->_tag('p', $error, ['class' => 'error']);
$html = [$this->view->openBoiteContent($this->_('Prêts en cours'))];
if($error) {
$html [] = $this->_tag('p', $error, ['class' => 'error']);
$html [] = $this->view->closeBoiteContent();
$html [] = $this->view->abonne_RetourFiche();
return implode($html);
}
$extend_all = $renewable_loans
? ($this->view->tagAnchor(['action' => 'prolongerPret',
......@@ -54,20 +60,17 @@ class ZendAfi_View_Helper_Abonne_LoansBoard extends ZendAfi_View_Helper_BaseHelp
. $this->view->abonne_LoansPNB($user->getPNBLoans()))
: '';
$content = [$this->_tag('div',
$html [] = $this->_tag('div',
$user->getNomAff(),
['class' => 'abonneTitre']),
$this->_renderTools(),
$this->view->abonne_Loans($loans),
$this->_extend_all,
$pnb
];
return implode(array_filter($content));
['class' => 'abonneTitre']);
$html [] = $this->_renderTools();
$html [] = $this->view->abonne_Loans($loans);
$html [] = $this->_extend_all;
$html [] = $pnb;
$html [] = $this->view->closeBoiteContent();
$html [] = $this->view->abonne_RetourFiche();
return implode(array_filter($html));
}
......
......@@ -22,10 +22,13 @@
class Intonation_Library_ProfilePatcher {
protected $_profile;
protected $_profile_id;
public function upgrade($profile) {
$this->_profile = $profile;
$this->_profile_id = $profile->getId();
$this
->_upgradeProfile()
->_upgradeActions()
......@@ -70,6 +73,306 @@ class Intonation_Library_ProfilePatcher {
Class_Systeme_ModulesAccueil_Login::CODE],
[1,2,3,5],
4);
$this
->_addBreadcrumb()
->_addScrollTopWidget()
->_addScrollDownWidget()
->_addAdminWidget()
->_addCreditWidget()
->_addAccessibilityWidget()
->_addNotificationWidget();
return $this;
}
protected function _addBreadcrumb() {
Class_Profil::clearCache();
$this->_profile = Class_Profil::find($this->_profile_id);
$cfg_accueil = $this->_profile->getCfgAccueilAsArray();
$ids = [];
foreach($cfg_accueil['modules'] as $id => $config)
if ($config['type_module'] == 'ARIANE')
return $this;
$new_id = $this->_profile->createNewModuleAccueilId();
$this->_profile->updateModuleConfigAccueil($new_id,
['type_module' => 'ARIANE',
'division' => 4,
'preferences' => ['IntonationShowHeader' => 0,
'IntonationShowContent' => 1,
'IntonationShowFooter' => 0,
'IntonationWidthXsmall' => 12]]);
$this->_profile->moveModuleOldDivPosNewDivPos(4,
$this->_profile->getModulePositionInDiv($new_id, 4),
4,
99);
$this->_profile->save();
$widget = (new Class_Systeme_Widget_Widget())
->setId($new_id)
->setProfileId($this->_profile->getId())
->load()
->setNewDatas(array_merge(Class_Systeme_ModulesAccueil::getInstance()
->getModuleByCode('ARIANE')
->getDefaultValues(),
[]));
$widget->updateProfile();
return $this;
}
protected function _addScrollTopWidget() {
Class_Profil::clearCache();
$this->_profile = Class_Profil::find($this->_profile_id);
$cfg_accueil = $this->_profile->getCfgAccueilAsArray();
$ids = [];
foreach($cfg_accueil['modules'] as $id => $config) {
if (!$config['type_module'] == 'SCROLL')
continue;
if (!isset($config['preferences']['direction']))
continue;
if ($config['preferences']['direction'] == 'up')
return $this;
}
$new_id = $this->_profile->createNewModuleAccueilId();
$this->_profile->updateModuleConfigAccueil($new_id,
['type_module' => 'SCROLL',
'division' => 6,
'preferences' => ['IntonationShowHeader' => 0,
'IntonationShowContent' => 0,
'IntonationShowFooter' => 0]]);
$this->_profile->moveModuleOldDivPosNewDivPos(6,
$this->_profile->getModulePositionInDiv($new_id, 6),
6,
$this->_profile->getModulePositionInDiv(0, 6) + 1);
$this->_profile->save();
$widget = (new Class_Systeme_Widget_Widget())
->setId($new_id)
->setProfileId($this->_profile->getId())
->load()
->setNewDatas(array_merge(Class_Systeme_ModulesAccueil::getInstance()
->getModuleByCode('SCROLL')
->getDefaultValues(),
['direction' => 'up',
'boite' => 'position_fixed_bottom_right']));
$widget->updateProfile();
return $this;
}
protected function _addScrollDownWidget() {
Class_Profil::clearCache();
$this->_profile = Class_Profil::find($this->_profile_id);
$cfg_accueil = $this->_profile->getCfgAccueilAsArray();
$ids = [];
foreach($cfg_accueil['modules'] as $id => $config) {
if (!isset($config['type_module']))
continue;
if (!$config['type_module'] == 'SCROLL')
continue;
if (!isset($config['preferences']['direction']))
continue;
if ($config['preferences']['direction'] == 'down')
return $this;
}
$new_id = $this->_profile->createNewModuleAccueilId();
$this->_profile->updateModuleConfigAccueil($new_id,
['type_module' => 'SCROLL',
'division' => 4,
'preferences' => ['IntonationShowHeader' => 0,
'IntonationShowContent' => 0,
'IntonationShowFooter' => 0]]);
$this->_profile->save();
$widget = (new Class_Systeme_Widget_Widget())
->setId($new_id)
->setProfileId($this->_profile->getId())
->load()
->setNewDatas(array_merge(Class_Systeme_ModulesAccueil::getInstance()
->getModuleByCode('SCROLL')
->getDefaultValues(),
['direction' => 'down',
'boite' => 'position_fixed_top_right']));
$widget->updateProfile();
return $this;
}
protected function _addAdminWidget() {
Class_Profil::clearCache();
$this->_profile = Class_Profil::find($this->_profile_id);
$cfg_accueil = $this->_profile->getCfgAccueilAsArray();
$ids = [];
foreach($cfg_accueil['modules'] as $id => $config)
if ($config['type_module'] == 'ADMIN_TOOLS')
return $this;
$new_id = $this->_profile->createNewModuleAccueilId();
$this->_profile->updateModuleConfigAccueil($new_id,
['type_module' => 'ADMIN_TOOLS',
'division' => 4,
'preferences' => ['IntonationShowHeader' => 0,
'IntonationShowContent' => 0,
'IntonationShowFooter' => 0]]);
$this->_profile->moveModuleOldDivPosNewDivPos(4,
$this->_profile->getModulePositionInDiv($new_id, 4),
4,
$this->_profile->getModulePositionInDiv(0, 4) + 1);
$this->_profile->save();
$widget = (new Class_Systeme_Widget_Widget())
->setId($new_id)
->setProfileId($this->_profile->getId())
->load()
->setNewDatas(array_merge(Class_Systeme_ModulesAccueil::getInstance()
->getModuleByCode('ADMIN_TOOLS')
->getDefaultValues(),
['boite' => 'position_fixed_top_left']));
$widget->updateProfile();
return $this;
}
protected function _addCreditWidget() {
Class_Profil::clearCache();
$this->_profile = Class_Profil::find($this->_profile_id);
$cfg_accueil = $this->_profile->getCfgAccueilAsArray();
$ids = [];
foreach($cfg_accueil['modules'] as $id => $config)
if ($config['type_module'] == 'CREDITS')
return $this;
$new_id = $this->_profile->createNewModuleAccueilId();
$this->_profile->updateModuleConfigAccueil($new_id,
['type_module' => 'CREDITS',
'division' => 6,
'preferences' => ['IntonationShowHeader' => 0,
'IntonationShowContent' => 1,
'IntonationShowFooter' => 0]]);
$this->_profile->moveModuleOldDivPosNewDivPos(6,
$this->_profile->getModulePositionInDiv($new_id, 6),
6,
99);
$this->_profile->save();
$widget = (new Class_Systeme_Widget_Widget())
->setId($new_id)
->setProfileId($this->_profile->getId())
->load()
->setNewDatas(array_merge(Class_Systeme_ModulesAccueil::getInstance()
->getModuleByCode('CREDITS')
->getDefaultValues(),
['boite' => 'align-items-center']));
$widget->updateProfile();
return $this;
}
protected function _addAccessibilityWidget() {
Class_Profil::clearCache();
$this->_profile = Class_Profil::find($this->_profile_id);
$cfg_accueil = $this->_profile->getCfgAccueilAsArray();
$ids = [];
foreach($cfg_accueil['modules'] as $id => $config)
if ($config['type_module'] == 'ACCESSIBILITY')
return $this;
$new_id = $this->_profile->createNewModuleAccueilId();
$this->_profile->updateModuleConfigAccueil($new_id,
['type_module' => 'ACCESSIBILITY',
'division' => 4,