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())
$datas[] = $this->tag('li', $this->_('Nombre de formulaires : %s',
$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));
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()));
?>
......@@ -998,7 +998,7 @@ class AbonneController extends ZendAfi_Controller_Action {
}
public function settingsAction() {
public function manageSettingsAction() {
if(!Class_Users::getIdentity())
return $this->_forward('popup-login', 'auth', 'opac', ['redirect' => $this->view->url()]);
......@@ -1009,13 +1009,28 @@ class AbonneController extends ZendAfi_Controller_Action {
unset($data['id_items']);
$this->_user->setSettings(Class_User_Settings::serializeSettings($data));
$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');
}
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() {
$this->_helper->json([$this->view->TreeSelect_Json_Libraries(Class_Profil::getCurrentProfil()->getLibraries())]);
}
......
<?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 {
['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()
->match(str_replace(BASE_URL,
'',
......@@ -214,21 +218,24 @@ class RechercheController extends ZendAfi_Controller_Action {
if ($titre = $this->_request->getParam('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;
if($titre_from_module = $this->getTitreFromModule())
if ($titre_from_module = $this->getTitreFromModule())
return $titre_from_module;
if ($this->_request->getParam('rubrique'))
return $this->view->_('Recherche guidée');
if ($catalogue = $criteres_recherche->getCatalogue())
return $catalogue->getLibelle();
if ($criteres_recherche->isBookmarked())
return $criteres_recherche->getBookmarkedLabel();
if ($panier = $criteres_recherche->getPanier())
return $panier->getLibelle();
if ($catalogue = $criteres_recherche->getCatalogue())
return $catalogue->getLibelle();
return null;
}
......
<?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();
......@@ -43,35 +43,35 @@
initializeReloadModule();')
->showNotifications();
$this->adminTools();
$this->adminTools();
if($current_profil->isResponsive())
if($current_profil->isResponsive())
$head_scripts->addOpacStyleSheet('responsive')->addOpacScript('responsive');
if ($this->header_js)
if ($this->header_js)
$head_scripts->addJQueryReady('$.getScript("' . $this->header_js . '")');
if (Class_Users::isCurrentUserAdmin()) {
if (Class_Users::isCurrentUserAdmin()) {
$head_scripts->loadAmber(true)
->addAmberPackage('AFI-OPAC');
if ($this->header_css)
$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',
'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);
if($current_profil->hasPageCss())
if($current_profil->hasPageCss())
$head_scripts->addStyleSheet($current_profil->getPageCss(), ['id' => 'profil_css',
'media' => 'all']);
if ($this->accessibilite_on) {
if ($this->accessibilite_on) {
//Feuilles de styles pour les déficiences visuelles
$head_scripts
->addOPACStyleSheet('blanc_sur_noir', ['rel' => 'alternate stylesheet',
......@@ -89,21 +89,21 @@ if ($this->accessibilite_on) {
->cssAddLine('<link id="accessibility_stylesheet" rel="stylesheet" type="text/css" href="" title="CSS accessibilité">')
->addAdminScript('jquery.cookie')
->addJQueryReady('initAccessibilityOptions();');
}
}
if ($read_speaker = Class_AdminVar::get('ID_READ_SPEAKER'))
if ($read_speaker = Class_AdminVar::get('ID_READ_SPEAKER'))
$head_scripts
->addJQueryReady(sprintf('$.getScript("https://wr.readspeaker.com/webreader/webreader.js.php?cid=%s")',
$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();
foreach([7,8] as $ie)
$script_loader = Class_ScriptLoader::getInstance();
foreach([7,8] as $ie)
$script_loader->addSkinStyleSheet('ie' . $ie, ['ie_version' => $ie])
->addUserFilesStylSheet($current_profil->getHeaderCssIE($ie),
['ie_version' => $ie]);
$script_loader->addJQueryReady('setupAnchorsTarget();');
$script_loader->addJQueryReady('setupAnchorsTarget();');
$head_scripts->renderStyleSheets();
$script_loader->renderStyleSheets();
......
<?php
$script_loader = Class_ScriptLoader::getInstance()
->addAdminScript('onload_utils')
->addInlineScript(sprintf('var imagesUrl = "%s";', URL_IMG))
->addSkinStyleSheet('iframe');
ob_start();
echo $this->render($this->actionScript);
$html_contents = ob_get_contents();
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">
<?php echo $html_contents; ?>
</body>
......
......@@ -48,7 +48,7 @@ $script_loader = Class_ScriptLoader::getInstance()
ZendAfi_View_Helper_Notice_Vignette::MODE_VIEW);
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',
'controller' => 'records',
'action' => 'thumbnail']))
......@@ -58,7 +58,7 @@ $script_loader = Class_ScriptLoader::getInstance()
'data-popup' => 'true']));
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',
'controller' => 'records',
'action' => 'reset-thumbnail']))
......
......@@ -532,11 +532,24 @@ if ($phase==14 or $phase==15) {
$phase = 16;
}
// ----------------------------------------------------------------
// Indexation Domaines
// ----------------------------------------------------------------
if ($phase==16 or $phase==17) {
include("integration/domaines.php");
}
// ----------------------------------------------------------------
// DSI - Notifications des nouveautés
// ----------------------------------------------------------------
if ($phase==17 or $phase==18) {
startIntegrationPhase('BookmarkedSearches');
$phase=20;
}
// ----------------------------------------------------------------
// 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,'
. 'primary key (id),'
. 'key (`id_user`)'
. ') engine=MyISAM default charset=utf8');
......@@ -221,7 +221,9 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
protected function _getUsersVars() {
return ['NDAYS_EXPIRY_NOTICE' => Class_AdminVar_Meta::newDefault($this->_('Prévenir l\'utilisateur xx jour(s) avant l\'expiration de son abonnement (par défaut 30 jours).'), ['value' => 30]),
'DISABLE_SUGGESTIONS' => Class_AdminVar_Meta::newOnOff($this->_('Désactivation des suggestions d\'achats'))->bePrivate(),
'ENABLE_BOOKMARKABLE_LIBRARIES' => Class_AdminVar_Meta::newOnOff($this->_('Les utilisateurs peuvent sélectionner des bibliothèques favorites pour leurs recherche'), ['value' => 1])];
'ENABLE_BOOKMARKABLE_LIBRARIES' => Class_AdminVar_Meta::newOnOff($this->_('Les utilisateurs peuvent sélectionner des bibliothèques favorites pour leurs recherche'), ['value' => 1]),
'ENABLE_BOOKMARKABLE_SEARCHES' => Class_AdminVar_Meta::newOnOff($this->_('Les utilisateurs peuvent enregister des recherches dans leurs favoris'), ['value' => 0]),
'ENABLE_BOOKMARKABLE_SEARCHES_NOTIFY' => Class_AdminVar_Meta::newOnOff($this->_('Les utilisateurs peuvent recevoir les nouveautés de leurs recherches favorites par email'), ['value' => 0])];
}
......@@ -861,6 +863,16 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
}
public static function isBookmarkSearchesReady() {
return Class_AdminVar::isModuleEnabled('ENABLE_BOOKMARKABLE_SEARCHES');
}
public static function isBookmarkSearchesNotifyEnabled() {
return Class_AdminVar::isModuleEnabled('ENABLE_BOOKMARKABLE_SEARCHES_NOTIFY');
}
public function getBabelthequeId() {
$mathes = [];
if (preg_match('/bw_([^\.]+)\.js/', (string)Class_AdminVar::get('BABELTHEQUE_JS'), $matches))
......
......@@ -499,7 +499,14 @@ class ArticleLoader extends Storm_Model_Loader {
class Class_Article extends Storm_Model_Abstract {
use Trait_TreeViewableItem, Trait_Indexable, Trait_HasManyDomaines, Trait_TimeSource, Trait_CustomFields, Trait_StaticFileWriter;
use
Trait_TreeViewableItem,
Trait_Indexable,
Trait_HasManyDomaines,
Trait_TimeSource,
Trait_CustomFields,
Trait_StaticFileWriter,
Trait_Versionable;
const END_TAG='{FIN}';
......
<?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 Class_Cosmogramme_Integration_PhaseBookmarkedSearches
extends Class_Cosmogramme_Integration_PhaseAbstract {
const MY_ID = 18;
public function __construct($phase, $log, $chrono) {
parent::__construct($phase, $log, $chrono);
$this->_label = $this->_('Notification des nouveautés dans les recherches favorites');
}
protected function _init($phase) {
$phase->resetDatas();
}
protected function _execute() {
if (!$this->_phase->isCron()) {
$this->_log->log($this->_('Ce traitement ne se lance qu\'en mode cron.'));
return;
}
foreach(Class_User_BookmarkedSearch::findAllBy(['notified' => 1]) as $search)
$this->_runOne($search);
$this->_cleanMemory();
}
protected function _runOne($search) {
$search->notify();
}
}
......@@ -72,7 +72,9 @@ class Class_CriteresRecherche {
'genre' => '',
'liste_format' => '',
'digital_lib' => '',
'no_extension' => ''
'no_extension' => '',
'bookmarked_search' => '',
'bookmarked_version' => '',
];
......@@ -195,6 +197,14 @@ class Class_CriteresRecherche {
}
public function unsetParam($name) {
if (array_key_exists($name, $this->_params))
unset($this->_params[$name]);
return $this;
}
public function rechercheElargie() {
$this->_params['pertinence']=1;
return $this;
......@@ -434,6 +444,7 @@ class Class_CriteresRecherche {
protected function cleansCritereForFilterOnDomain($criteres, $keys = []) {
foreach($keys as $key)
unset($criteres[$key]);
return $criteres;
}
......@@ -447,10 +458,12 @@ class Class_CriteresRecherche {
return (!$this->getCodeRebond() && !$this->getSerie() && $this->getParam('id_catalogue'));
}
protected function isRecherchePanier() {
return (!$this->getCodeRebond() && !$this->getSerie() && $this->getParam('id_panier'));
}
public function isRechercheCatalogueOuPanier() {
return ($this->isRechercheCatalogue() || $this->isRecherchePanier());
}
......@@ -566,7 +579,11 @@ class Class_CriteresRecherche {
foreach($filtres as $filtre)
$visitor->visitFiltre($filtre);
if($limit = $this->getMaxSearchResults())
if ($search = $this->_getBookmark())
$visitor->visitBookmarkedSearch($search,
$search->getVersion($this->getParam('bookmarked_version')));
if ($limit = $this->getMaxSearchResults())
$visitor->visitLimit($limit);
return $this;
......@@ -714,7 +731,6 @@ class Class_CriteresRecherche {
}
public function getUrlCriteresWithFacettes() {
$intersect=$this->_params;
if ($this->getFacettesUrlEncoded()!='')
......@@ -860,6 +876,15 @@ class Class_CriteresRecherche {
}
public function getUrlRemoveBookmarkVersion() {
$url = $this->getUrlRetourListe();
unset($url['bookmarked_search']);
unset($url['bookmarked_version']);
unset($url['page']);
return array_filter($url);
}
public function getUrlNouvelleRecherche(){
if (array_key_exists('expressionRecherche',$this->_params))
return ['controller' => 'recherche',
......@@ -925,4 +950,32 @@ class Class_CriteresRecherche {
public function getAvailableFormats() {
return Class_Systeme_ModulesAppli::getAvailableListeNoticeFormat();
}
public function isBookmarked() {
return $this->getParam('bookmarked_search');
}
<