Commit b5391c4a authored by Patrick Barroca's avatar Patrick Barroca 🐧

dev #44823 : newsletter controller normalization, introducing newsletter form

parent d131f15b
- ticket #44823 : Newsletter : Inscrire automatiquement un nouvel inscrit
\ No newline at end of file
<h1>Modifier la lettre: <?php echo $this->newsletter->getTitre() ?></h1>
<?php echo $this->renderForm($this->form) ?>
\ No newline at end of file
<?php echo $this->renderForm($this->form); ?>
......@@ -64,7 +64,8 @@ class Class_Newsletter extends Storm_Model_Abstract {
'dependents' => 'delete']];
protected $_notices_finder;
protected $_recipent_size = 20;
protected $_default_attribute_values = ['draft' => 0];
protected $_default_attribute_values = ['titre' => '',
'draft' => 0];
public function getSubscriptionsPage($page=0, $items_by_page=20) {
return Class_NewsletterSubscription::findAllBy(['newsletter_id' => $this->getId(),
......@@ -327,6 +328,9 @@ class Class_Newsletter extends Storm_Model_Abstract {
return true;
}
}
?>
\ No newline at end of file
public function getLibelle() {
return $this->getTitre();
}
}
......@@ -18,9 +18,7 @@
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OPAC3: Paniers de notices
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class PanierNoticeLoader extends Storm_Model_Loader {
public function findAllBelongsToAdmin() {
......@@ -42,6 +40,7 @@ class PanierNoticeLoader extends Storm_Model_Loader {
return array_filter($paniers, 'Class_PanierNotice::_withNoCatalogue');
}
public function _withNoCatalogue($panier) {
return 0 == $panier->numberOfPanierNoticeCatalogues();
}
......@@ -71,6 +70,17 @@ class PanierNoticeLoader extends Storm_Model_Loader {
$cart->index();
}
}
public function getPaniersForCombo() {
$paniers = Class_PanierNotice::findAllBelongsToAdmin();
$options = ['' => ''];
foreach($paniers as $panier)
$options[$panier->getId()] = $panier->getLibelle();
return $options;
}
}
......
<?php
/**
* Copyright (c) 2012-2014, 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_Form_Admin_Newsletter extends ZendAfi_Form {
public function init() {
parent::init();
$this->setAttrib('id', 'newsletter')
->setMethod(Zend_Form::METHOD_POST)
->addElement('text', 'titre',
['label' => $this->_('Titre'),
'size' => 30,
'required' => true,
'allowEmpty' => false])
->addElement('email', 'expediteur',
['label' => $this->_('Expéditeur'),
'size' => 30])
->addElement('checkbox', 'draft',
['label' => $this->_('Brouillon ?')])
->addElement('checkbox', 'auto_subscribe', ['label' => $this->_("Inscrire automatiquement les nouveaux lecteurs à la lettre d'information")])
->addElement('ckeditor', 'contenu',
['required' => true,
'allowEmpty' => false])
->addElement('select', 'id_catalogue',
['onchange' => "$('#id_panier').val('')",
'label' => $this->_('Domaine'),
'multiOptions' => Class_Catalogue::getCataloguesForCombo()])
->addElement('select', 'id_panier',
['onchange' => "$('#id_catalogue').val('')",
'label' => $this->_('Panier'),
'multiOptions' => Class_PanierNotice::getPaniersForCombo()])
->addElement('text', 'nb_notices',
['label' => $this->_('Nombre à afficher'),
'size' => 10,
'required' => true,
'allowEmpty' => false,
'value' => 0,
'validators' => [new Zend_Validate_Int()]])
->addDisplayGroup(['titre', 'expediteur', 'draft'],
'letter',
['legend' => $this->_('Lettre')])
->addDisplayGroup(['auto_subscribe'],
'add_reader',
['legend' => $this->_('Inscription automatique')])
->addDisplayGroup(['contenu'],
'contenu_html',
['legend' => $this->_('Contenu HTML')])
->addDisplayGroup(['id_catalogue', 'id_panier', 'nb_notices'],
'notices',
['legend' => $this->_('Notices')]);
}
}
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