Commit 666372c9 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch...

Merge branch 'dev#69826_contractuel_minsoc_diffusion_selective_de_l_information_enregistrer_modifier_ma_recherche' into 'master'

Dev#69826 contractuel minsoc diffusion selective de l information enregistrer modifier ma recherche

See merge request afi/opacce!2516
parents b3fc3f13 4d1f6d90
- ticket #69826 : Compte abonné : possibilité d'enregistrer une recherche et d'être notifié par email des nouveautés liées à celle-ci.
...@@ -12,7 +12,7 @@ if (Class_AdminVar::isCmsFormulairesEnabled()) ...@@ -12,7 +12,7 @@ if (Class_AdminVar::isCmsFormulairesEnabled())
$datas[] = $this->tag('li', $this->_('Nombre de formulaires : %s', $datas[] = $this->tag('li', $this->_('Nombre de formulaires : %s',
$this->model->numberOfFormulaires())); $this->model->numberOfFormulaires()));
if ($count = Class_Versions::forArticle($this->model)->count()) if ($count = $this->model->numberOfversions())
$datas[] = $this->tag('li', $this->_('Nombre de versions : %s', $count)); $datas[] = $this->tag('li', $this->_('Nombre de versions : %s', $count));
if ($session = Class_SessionActivity::findFirstBy(['article_id' => $this->model->getId()])) if ($session = Class_SessionActivity::findFirstBy(['article_id' => $this->model->getId()]))
......
<!DOCTYPE html>
<?php
echo $this->Layout_Admin(
(new Class_Entity())
->setActionScript($this->Admin_ActionScript())
->setHead($this->Admin_Head()));
?>
...@@ -97,8 +97,8 @@ class AbonneController extends ZendAfi_Controller_Action { ...@@ -97,8 +97,8 @@ class AbonneController extends ZendAfi_Controller_Action {
$this->_user->removeSessionActivity($session); $this->_user->removeSessionActivity($session);
if ($this->_user->save()) { if ($this->_user->save()) {
$this->_helper->notify($this->_('Vous n\'êtes plus inscrit à la session du %s de l\'activité %s', $this->_helper->notify($this->_('Vous n\'êtes plus inscrit à la session du %s de l\'activité %s',
$this->view->humanDate($session->getDateDebut(), 'd MMMM YYYY'), $this->view->humanDate($session->getDateDebut(), 'd MMMM YYYY'),
$session->getLibelleActivity())); $session->getLibelleActivity()));
(new Class_Activity_UnregistrationMail($session, $this->_user))->send(); (new Class_Activity_UnregistrationMail($session, $this->_user))->send();
}; };
...@@ -622,17 +622,17 @@ class AbonneController extends ZendAfi_Controller_Action { ...@@ -622,17 +622,17 @@ class AbonneController extends ZendAfi_Controller_Action {
$mode = $this->_getParam('mode', ''); $mode = $this->_getParam('mode', '');
if ($mode === 'holdable-day') if ($mode === 'holdable-day')
return $this->_forward('is-holdable-day', 'multimedia', $this->_request->getModuleName(), return $this->_forward('is-holdable-day', 'multimedia', $this->_request->getModuleName(),
$this->_request->getParams()); $this->_request->getParams());
if ($mode === 'hold') if ($mode === 'hold')
return $this->_forward('hold-device', 'multimedia', $this->_request->getModuleName(), return $this->_forward('hold-device', 'multimedia', $this->_request->getModuleName(),
$this->_request->getParams()); $this->_request->getParams());
if ($mode === 'modified-hold') if ($mode === 'modified-hold')
return $this->_forward('close-holding', 'multimedia', $this->_request->getModuleName(), return $this->_forward('close-holding', 'multimedia', $this->_request->getModuleName(),
$this->_request->getParams()); $this->_request->getParams());
return $this->_forward('authenticate', 'multimedia', $this->_request->getModuleName(), return $this->_forward('authenticate', 'multimedia', $this->_request->getModuleName(),
$this->_request->getParams()); $this->_request->getParams());
} }
...@@ -998,7 +998,7 @@ class AbonneController extends ZendAfi_Controller_Action { ...@@ -998,7 +998,7 @@ class AbonneController extends ZendAfi_Controller_Action {
} }
public function settingsAction() { public function manageSettingsAction() {
if(!Class_Users::getIdentity()) if(!Class_Users::getIdentity())
return $this->_forward('popup-login', 'auth', 'opac', ['redirect' => $this->view->url()]); return $this->_forward('popup-login', 'auth', 'opac', ['redirect' => $this->view->url()]);
...@@ -1009,13 +1009,28 @@ class AbonneController extends ZendAfi_Controller_Action { ...@@ -1009,13 +1009,28 @@ class AbonneController extends ZendAfi_Controller_Action {
unset($data['id_items']); unset($data['id_items']);
$this->_user->setSettings(Class_User_Settings::serializeSettings($data)); $this->_user->setSettings(Class_User_Settings::serializeSettings($data));
$this->_user->save(); $this->_user->save();
$this->_javascriptRedirectToReferrer(); $this->_helper->notify($this->_('Favoris sauvegardés'));
return $this->_redirectClose($this->_getReferer());
} }
$this->view->titre = $this->view->_('Gérer mes favoris'); $this->view->titre = $this->view->_('Gérer mes favoris');
} }
public function settingsAction() {
$this->view->titre = $this->view->_('Mes favoris');
$this->view->bookmarked_searches = Class_User_BookmarkedSearch::findAllBy(['id_user' => $this->_user->getId(),
'order' => 'creation_date desc']);
$form = ZendAfi_Form_User_Settings::forUser($this->_user);
$this->view->form = $form->getElements()
? $form
: null;
if ($this->_request->isPost())
$this->_forward('manage-settings');
}
public function viewableLibrariesJsonAction() { public function viewableLibrariesJsonAction() {
$this->_helper->json([$this->view->TreeSelect_Json_Libraries(Class_Profil::getCurrentProfil()->getLibraries())]); $this->_helper->json([$this->view->TreeSelect_Json_Libraries(Class_Profil::getCurrentProfil()->getLibraries())]);
} }
...@@ -1059,7 +1074,7 @@ class AbonneController extends ZendAfi_Controller_Action { ...@@ -1059,7 +1074,7 @@ class AbonneController extends ZendAfi_Controller_Action {
function($child) function($child)
{ {
return $this->_('Vous n\'utilisez plus la carte de %s', return $this->_('Vous n\'utilisez plus la carte de %s',
$child->getNomComplet()); $child->getNomComplet());
}); });
} }
......
<?php
/**
* Copyright (c) 2012-2017, 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 BookmarkedSearchesController extends ZendAfi_Controller_Action {
public function getPlugins() {
return ['ZendAfi_Controller_Plugin_ResourceDefinition_BookmarkedSearches',
'ZendAfi_Controller_Plugin_Manager_BookmarkedSearches'];
}
public function indexAction() {
return $this->_redirectClose($this->_getReferer());
}
}
...@@ -108,6 +108,10 @@ class RechercheController extends ZendAfi_Controller_Action { ...@@ -108,6 +108,10 @@ class RechercheController extends ZendAfi_Controller_Action {
['prependBase' => false]); ['prependBase' => false]);
} }
if ($criteres_recherche->isBookmarked()
&& !$criteres_recherche->ownedBy(Class_Users::getIdentity()))
return $this->_redirect('opac/auth/login?redirect=' . urlencode(Class_Url::absolute($this->view->url())));
$this->getFrontController()->getRouter()->getCurrentRoute() $this->getFrontController()->getRouter()->getCurrentRoute()
->match(str_replace(BASE_URL, ->match(str_replace(BASE_URL,
'', '',
...@@ -214,21 +218,24 @@ class RechercheController extends ZendAfi_Controller_Action { ...@@ -214,21 +218,24 @@ class RechercheController extends ZendAfi_Controller_Action {
if ($titre = $this->_request->getParam('titre')) if ($titre = $this->_request->getParam('titre'))
return $titre; return $titre;
if($titre_from_profil = $this->_getTitreFromProfil()) if ($this->_request->getParam('rubrique'))
return $this->view->_('Recherche guidée');
if ($titre_from_profil = $this->_getTitreFromProfil())
return $titre_from_profil; return $titre_from_profil;
if($titre_from_module = $this->getTitreFromModule()) if ($titre_from_module = $this->getTitreFromModule())
return $titre_from_module; return $titre_from_module;
if ($this->_request->getParam('rubrique')) if ($criteres_recherche->isBookmarked())
return $this->view->_('Recherche guidée'); return $criteres_recherche->getBookmarkedLabel();
if ($catalogue = $criteres_recherche->getCatalogue())
return $catalogue->getLibelle();
if ($panier = $criteres_recherche->getPanier()) if ($panier = $criteres_recherche->getPanier())
return $panier->getLibelle(); return $panier->getLibelle();
if ($catalogue = $criteres_recherche->getCatalogue())
return $catalogue->getLibelle();
return null; return null;
} }
......
<?php <?php
echo $this->renderForm($this->form); if($this->form) {
?> $this->openBoite($this->titre);
echo $this->renderForm($this->form);
$this->closeBoite();
}
$description = (new Class_TableDescription('bookmarked_searches'))
->addColumn($this->_('Libellé'), function($model) { return $model->getLabel(); })
->addColumn($this->_('Critères'), function($model) { return $this->Search_Criterias($model->getUnserializedCriterias()); })
->addColumn($this->_('Date de création'), function($model) { return $model->getCreationDate(); })
->addRowAction(function($model) {
if(!$url = $model->getResultUrl())
return Class_Admin_Skin::current()
->renderActionIconOn('help',
$this,
['title' => $this->_('Pas encore de nouveauté.'),
'class' => 'ico']);
$title = $this->_('Voir les dernières nouveautés de la recherche "%s"', $model->getLabel());
return $this->tagAnchor(Class_Url::absolute($url),
Class_Admin_Skin::current()
->renderActionIconOn('map', $this,
['title' => $title,
'alt' => $title]),
['title' => $title,
'target' => '_blank']);
})
->addRowAction(function($model) {
$title = $this->_('Voir le résultat de la recherche');
return $this->tagAnchor(Class_Url::absolute($model->getCriteriasUrl()),
Class_Admin_Skin::current()
->renderActionIconOn('loupe', $this,
['title' => $title,
'alt' => $title]),
['title' => $title,
'target' => '_blank']);
})
->addRowAction(function($model)
{
if(!Class_AdminVar::isBookmarkSearchesNotifyEnabled())
return '';
$action = 'notify';
$label = $this->_('Me notifier des nouveautés');
if($model->isNotified()) {
$action = 'unnotify';
$label = $this->_('Annuler la notification des nouveautés');
}
$params = ['controller' => 'bookmarked-searches',
'action' => $action,
'id' => $model->getId()];
return $this->tagAnchor($this->url($params, null, true),
Class_Admin_Skin::current()->renderActionIconOn('mail',
$this,
['title' => $label,
'alt' => $label]),
['title' => $label]);
})
->addRowAction(function ($model) {
$label = $this->_('Supprimer la recherche "%s"', $model->getLabel());
return $this->tagAnchor($this->url(['controller' => 'bookmarked-searches',
'action' => 'delete',
'id' => $model->getId()],null,true),
Class_Admin_Skin::current()->renderActionIconOn('delete', $this,
['title' => $label,
'alt' => $label]),
['onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette recherche ?');",
'title' => $label]);
});
if(!$searches = $this->renderTable($description, $this->bookmarked_searches, ['sorter' => true]))
$searches = $this->_('Vous n\'avez pas enregistré de recherche dans vos favoris');
$this->openBoite($this->_('Mes recherches favorites'));
echo $searches;
$this->closeBoite();
echo $this->abonne_RetourFiche();
...@@ -41,69 +41,69 @@ ...@@ -41,69 +41,69 @@
initializePopups(); initializePopups();
initializeDivisionFive(); initializeDivisionFive();
initializeReloadModule();') initializeReloadModule();')
->showNotifications(); ->showNotifications();
$this->adminTools(); $this->adminTools();
if($current_profil->isResponsive()) if($current_profil->isResponsive())
$head_scripts->addOpacStyleSheet('responsive')->addOpacScript('responsive'); $head_scripts->addOpacStyleSheet('responsive')->addOpacScript('responsive');
if ($this->header_js) if ($this->header_js)
$head_scripts->addJQueryReady('$.getScript("' . $this->header_js . '")'); $head_scripts->addJQueryReady('$.getScript("' . $this->header_js . '")');
if (Class_Users::isCurrentUserAdmin()) { if (Class_Users::isCurrentUserAdmin()) {
$head_scripts->loadAmber(true) $head_scripts->loadAmber(true)
->addAmberPackage('AFI-OPAC'); ->addAmberPackage('AFI-OPAC');
if ($this->header_css) if ($this->header_css)
$this->header_css .= '?cache='.md5(time()); $this->header_css .= '?cache='.md5(time());
} }
if ($this->header_css && ($current_profil->getUseParentCss() || !$current_profil->hasParentProfil()) && !$current_profil->hasPageCss()) if ($this->header_css && ($current_profil->getUseParentCss() || !$current_profil->hasParentProfil()) && !$current_profil->hasPageCss())
$head_scripts->addStyleSheet($this->header_css, ['id' => 'profil_css', $head_scripts->addStyleSheet($this->header_css, ['id' => 'profil_css',
'media' => 'all']); 'media' => 'all']);
if ($this->header_css && $current_profil->getUseParentCss() && $current_profil->hasPageCss()) if ($this->header_css && $current_profil->getUseParentCss() && $current_profil->hasPageCss())
$head_scripts->addStyleSheet($this->header_css); $head_scripts->addStyleSheet($this->header_css);
if($current_profil->hasPageCss()) if($current_profil->hasPageCss())
$head_scripts->addStyleSheet($current_profil->getPageCss(), ['id' => 'profil_css', $head_scripts->addStyleSheet($current_profil->getPageCss(), ['id' => 'profil_css',
'media' => 'all']); 'media' => 'all']);
if ($this->accessibilite_on) { if ($this->accessibilite_on) {
//Feuilles de styles pour les déficiences visuelles //Feuilles de styles pour les déficiences visuelles
$head_scripts $head_scripts
->addOPACStyleSheet('blanc_sur_noir', ['rel' => 'alternate stylesheet', ->addOPACStyleSheet('blanc_sur_noir', ['rel' => 'alternate stylesheet',
'title' => $this->_('Blanc sur noir'), 'title' => $this->_('Blanc sur noir'),
'data-name' => 'style_blanc_sur_noir']) 'data-name' => 'style_blanc_sur_noir'])
->addOPACStyleSheet('noir_sur_blanc', ['rel' => 'alternate stylesheet', ->addOPACStyleSheet('noir_sur_blanc', ['rel' => 'alternate stylesheet',
'title' => $this->_('Noir sur blanc'), 'title' => $this->_('Noir sur blanc'),
'data-name' => 'style_noir_sur_blanc']) 'data-name' => 'style_noir_sur_blanc'])
->addOPACStyleSheet('bleu_sur_jaune', ['rel' => 'alternate stylesheet', ->addOPACStyleSheet('bleu_sur_jaune', ['rel' => 'alternate stylesheet',
'title' => $this->_('Bleu sur jaune'), 'title' => $this->_('Bleu sur jaune'),
'data-name' => 'style_bleu_sur_jaune']) 'data-name' => 'style_bleu_sur_jaune'])
->cssAddLine($this->_('<link rel="alternate stylesheet" type="text/css" href="" title="%s" data-name="style_defaut">', ->cssAddLine($this->_('<link rel="alternate stylesheet" type="text/css" href="" title="%s" data-name="style_defaut">',
'Style par défaut')) 'Style par défaut'))
->cssAddLine('<link id="accessibility_stylesheet" rel="stylesheet" type="text/css" href="" title="CSS accessibilité">') ->cssAddLine('<link id="accessibility_stylesheet" rel="stylesheet" type="text/css" href="" title="CSS accessibilité">')
->addAdminScript('jquery.cookie') ->addAdminScript('jquery.cookie')
->addJQueryReady('initAccessibilityOptions();'); ->addJQueryReady('initAccessibilityOptions();');
} }
if ($read_speaker = Class_AdminVar::get('ID_READ_SPEAKER')) if ($read_speaker = Class_AdminVar::get('ID_READ_SPEAKER'))
$head_scripts $head_scripts
->addJQueryReady(sprintf('$.getScript("https://wr.readspeaker.com/webreader/webreader.js.php?cid=%s")', ->addJQueryReady(sprintf('$.getScript("https://wr.readspeaker.com/webreader/webreader.js.php?cid=%s")',
$read_speaker)); $read_speaker));
echo $this->partial('skin_head.phtml', ['profil' => $this->profil]); echo $this->partial('skin_head.phtml', ['profil' => $this->profil]);
$script_loader = Class_ScriptLoader::getInstance(); $script_loader = Class_ScriptLoader::getInstance();
foreach([7,8] as $ie) foreach([7,8] as $ie)
$script_loader->addSkinStyleSheet('ie' . $ie, ['ie_version' => $ie]) $script_loader->addSkinStyleSheet('ie' . $ie, ['ie_version' => $ie])
->addUserFilesStylSheet($current_profil->getHeaderCssIE($ie), ->addUserFilesStylSheet($current_profil->getHeaderCssIE($ie),
['ie_version' => $ie]); ['ie_version' => $ie]);
$script_loader->addJQueryReady('setupAnchorsTarget();'); $script_loader->addJQueryReady('setupAnchorsTarget();');
$head_scripts->renderStyleSheets(); $head_scripts->renderStyleSheets();
$script_loader->renderStyleSheets(); $script_loader->renderStyleSheets();
...@@ -111,5 +111,5 @@ $script_loader->addJQueryReady('setupAnchorsTarget();'); ...@@ -111,5 +111,5 @@ $script_loader->addJQueryReady('setupAnchorsTarget();');
$head_scripts->renderJavaScripts(); $head_scripts->renderJavaScripts();
$script_loader->renderJavaScripts(); $script_loader->renderJavaScripts();
echo $this->heartbeat(); echo $this->heartbeat();
?> ?>
</head> </head>
<?php <?php
$script_loader = Class_ScriptLoader::getInstance()
->addAdminScript('onload_utils')
->addInlineScript(sprintf('var imagesUrl = "%s";', URL_IMG))
->addSkinStyleSheet('iframe');
ob_start(); ob_start();
echo $this->render($this->actionScript); echo $this->render($this->actionScript);
$html_contents = ob_get_contents(); $html_contents = ob_get_contents();
ob_end_clean(); ob_end_clean();
echo $this->render('head.phtml');
?> ?>
<!DOCTYPE html>
<html lang="<?php echo $this->_translate()->getLocale() ?>">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<?php echo $script_loader->html(); ?>
<style>#ZFDebug {display:none}</style>
</head>
<body style="margin:0px;padding:0px;background-color:transparent;background-image:none" class="auto_resize iframe"> <body style="margin:0px;padding:0px;background-color:transparent;background-image:none" class="auto_resize iframe">
<?php echo $html_contents; ?> <?php echo $html_contents; ?>
</body> </body>
......
...@@ -48,7 +48,7 @@ $script_loader = Class_ScriptLoader::getInstance() ...@@ -48,7 +48,7 @@ $script_loader = Class_ScriptLoader::getInstance()
ZendAfi_View_Helper_Notice_Vignette::MODE_VIEW); ZendAfi_View_Helper_Notice_Vignette::MODE_VIEW);
if ($this->display_modifier_vignette_link) if ($this->display_modifier_vignette_link)
echo $this->admin_button((new Class_Entity()) echo $this->Admin_Button((new Class_Entity())
->setUrl($this->url(['module' => 'admin', ->setUrl($this->url(['module' => 'admin',
'controller' => 'records', 'controller' => 'records',
'action' => 'thumbnail'])) 'action' => 'thumbnail']))
...@@ -58,7 +58,7 @@ $script_loader = Class_ScriptLoader::getInstance() ...@@ -58,7 +58,7 @@ $script_loader = Class_ScriptLoader::getInstance()
'data-popup' => 'true'])); 'data-popup' => 'true']));
if ($this->show_reset_thumbnail_link) if ($this->show_reset_thumbnail_link)
echo $this->admin_button((new Class_Entity()) echo $this->Admin_Button((new Class_Entity())
->setUrl($this->url(['module' => 'admin', ->setUrl($this->url(['module' => 'admin',
'controller' => 'records', 'controller' => 'records',
'action' => 'reset-thumbnail'])) 'action' => 'reset-thumbnail']))
......
...@@ -532,11 +532,24 @@ if ($phase==14 or $phase==15) { ...@@ -532,11 +532,24 @@ if ($phase==14 or $phase==15) {
$phase = 16; $phase = 16;
} }
// ----------------------------------------------------------------
// Indexation Domaines
// ----------------------------------------------------------------
if ($phase==16 or $phase==17) { if ($phase==16 or $phase==17) {
include("integration/domaines.php"); include("integration/domaines.php");
}
// ----------------------------------------------------------------
// DSI - Notifications des nouveautés
// ----------------------------------------------------------------
if ($phase==17 or $phase==18) {
startIntegrationPhase('BookmarkedSearches');
$phase=20; $phase=20;
} }
// ---------------------------------------------------------------- // ----------------------------------------------------------------
// Envoi de mails aux bibs qui ont du retard // Envoi de mails aux bibs qui ont du retard
// ---------------------------------------------------------------- // ----------------------------------------------------------------
......
<?php
Zend_Db_Table_Abstract::getDefaultAdapter()
->query('CREATE TABLE if not exists `bookmarked_search` ( '
. 'id int(11) unsigned not null auto_increment,'
. 'label TEXT not null,'
. 'criterias text not null,'
. 'notified tinyint(1) not null default 0,'
. 'creation_date timestamp not null,'
. 'id_user int(11) unsigned not null default 0,'