From fc9d9368a4c8781f26a34a8f28523073d645f508 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Fri, 9 Mar 2007 20:15:44 +0000 Subject: [PATCH] Close #648 and #649: Layout of nl/show (and ax/show) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1561 839d8a87-29fc-0310-9880-83ba4fa771e5 --- ChangeLog | 4 ++ htdocs/images/icons/resultset_next.gif | Bin 1034 -> 1034 bytes htdocs/images/icons/resultset_previous.gif | Bin 0 -> 1034 bytes include/massmailer.inc.php | 59 +++++++++++++++++++++++++++-- include/newsletter.inc.php | 7 +--- modules/axletter/axletter.inc.php | 7 +--- templates/axletter/show.tpl | 19 ++++++---- templates/include/massmailer-nav.tpl | 55 +++++++++++++++++++++++++++ templates/newsletter/show.tpl | 37 ++++++++++-------- 9 files changed, 149 insertions(+), 39 deletions(-) create mode 100644 htdocs/images/icons/resultset_previous.gif create mode 100644 templates/include/massmailer-nav.tpl diff --git a/ChangeLog b/ChangeLog index 5ca1597..4b6ff78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,10 @@ Bug/Wish: * Emails: - #595: Update antispam description -FRU + * Newsletter: + - #648: Add navigation link in preview page -FRU + - #649: Fix layout of preview page -FRU + * Profile: - Better checks on image type for photos -FRU - #646: Don't send a mail to an invalid address -FRU diff --git a/htdocs/images/icons/resultset_next.gif b/htdocs/images/icons/resultset_next.gif index b71a4f71546d2b23794090eeea7962fb8ec0831e..6f845184673dd93f33a1b9eae8e8bcd78504fff2 100644 GIT binary patch delta 17 YcmeC;=;E00hxIxGGXv*lMn+C%05RtTS^xk5 delta 17 YcmeC;=;E00hxHl*H-p?}Mn+C%05Y2db^rhX diff --git a/htdocs/images/icons/resultset_previous.gif b/htdocs/images/icons/resultset_previous.gif new file mode 100644 index 0000000000000000000000000000000000000000..465328c51cce79feafcc77195c8a7e178a1a207b GIT binary patch literal 1034 zcmcJOUr19?9LK+##e-PPvXBm$+# z8$pcdVOf|##G;5j?s0{|BC7i!af2Rw6oep3ZohMHAw<$k9r&I5IltfUobS26bI!ov z8DEdcfx|nn#tDU7aa}8}&lik{W(bKg7b?sqsJR7fX{PyY$uzg_lg1iQN=eho zjFn5-&K}@zWBcdq)$K!IIzNrMf8({3RR9)&0Ne`#qxHbhRp8DipzR58-~|xc1B~>* z>HGZ4>|$B-S_0xka$FJBSd?cMCNMQIrKDw1ido@**Qv1#9SRVbl4q4anvn5RqdRrFDOAl`zJz0NydE?o>=!53#5iZ&O zyvg78XrrNh;nlIar<`!(_0r2X*+UCg)Xv#n*RXqk^^xpcZDZ}6-{H8nc)lN}egGFE B%nJYj literal 0 HcmV?d00001 diff --git a/include/massmailer.inc.php b/include/massmailer.inc.php index fd5093d..fce33ca 100644 --- a/include/massmailer.inc.php +++ b/include/massmailer.inc.php @@ -36,11 +36,16 @@ abstract class MassMailer public $_head; - function __construct($tpl, $css, $prefix) + protected $_table; + protected $_subscriptionTable; + + function __construct($tpl, $css, $prefix, $tbl, $stbl) { $this->_tpl = $tpl; $this->_css = $css; $this->_prefix = $prefix; + $this->_table = $tbl; + $this->_subscriptionTable = $stbl; } public function id() @@ -48,6 +53,53 @@ abstract class MassMailer return is_null($this->_shortname) ? $this->_id : $this->_shortname; } + private function selectId($where) + { + $res = XDB::query("SELECT IF (n.short_name IS NULL, n.id, n.short_name) + FROM {$this->_table} AS n + WHERE n.bits != 'new' AND {$where} + LIMIT 1"); + if ($res->numRows() != 1) { + return null; + } + return $res->fetchOneCell(); + } + + public function prev() + { + static $val; + if (!isset($val)) { + $val = $this->selectId("n.id < {$this->_id} ORDER BY n.id DESC"); + } + return $val; + } + + public function next() + { + static $val; + if (!isset($val)) { + $val = $this->selectId("n.id > {$this->_id} ORDER BY n.id"); + } + return $val; + } + + public function last() + { + static $val; + if (!isset($val)) { + $res = XDB::query("SELECT MAX(n.id) + FROM {$this->_table} AS n + WHERE n.bits != 'new' AND n.id > {?}", + $this->_id); + if ($res->numRows() != 1) { + $val = null; + } else { + $val = $res->fetchOneCell(); + } + } + return $val; + } + public function title($mail = false) { return $mail ? $this->_title_mail : $this->_title; @@ -126,7 +178,7 @@ abstract class MassMailer u.prenom, IF(u.nom_usage='', u.nom, u.nom_usage), FIND_IN_SET('femme', u.flags), q.core_mail_fmt AS pref, 0 AS hash - FROM {$this->subscriptionTable()} AS ni + FROM {$this->_subscriptionTable} AS ni INNER JOIN auth_user_md5 AS u USING(user_id) INNER JOIN auth_user_quick AS q ON(q.user_id = u.user_id) INNER JOIN aliases AS a ON(u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags)) @@ -149,7 +201,7 @@ abstract class MassMailer $sent[] = "(user_id='$uid'" . (!$uid ? " AND email='$bestalias')": ')'); $this->sendTo($prenom, $nom, $bestalias, $sexe, $fmt=='html', $hash); } - XDB::execute("UPDATE {$this->subscriptionTable()} + XDB::execute("UPDATE {$this->_subscriptionTable} SET last = {?} WHERE " . implode(' OR ', $sent), $this->_id); @@ -160,7 +212,6 @@ abstract class MassMailer abstract protected function assignData(&$smarty); abstract protected function setSent(); - abstract protected function subscriptionTable(); abstract protected function subscriptionWhere(); } diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 02e5248..386ef16 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -31,7 +31,7 @@ class NewsLetter extends MassMailer function __construct($id = null) { - parent::__construct('newsletter/nl.tpl', 'nl.css', 'nl/show'); + parent::__construct('newsletter/nl.tpl', 'nl.css', 'nl/show', 'newsletter', 'newsletter_ins'); if (isset($id)) { if ($id == 'last') { $res = XDB::query("SELECT MAX(id) FROM newsletter WHERE bits!='new'"); @@ -146,11 +146,6 @@ class NewsLetter extends MassMailer VALUES ({?}, 0)", $user); } - protected function subscriptionTable() - { - return 'newsletter_ins'; - } - protected function subscriptionWhere() { return '1'; diff --git a/modules/axletter/axletter.inc.php b/modules/axletter/axletter.inc.php index e405f3b..af34cac 100644 --- a/modules/axletter/axletter.inc.php +++ b/modules/axletter/axletter.inc.php @@ -33,7 +33,7 @@ class AXLetter extends MassMailer function __construct($id) { - parent::__construct('axletter/letter.tpl', 'ax.css', 'ax/show'); + parent::__construct('axletter/letter.tpl', 'ax.css', 'ax/show', 'axletter', 'axletter_ins'); $this->_head = ' ,'; if (!is_array($id)) { @@ -184,11 +184,6 @@ class AXLetter extends MassMailer return XDB::execute("DELETE FROM axletter_rights WHERE user_id = {?}", $uid); } - protected function subscriptionTable() - { - return 'axletter_ins'; - } - protected function subscriptionWhere() { if (!$this->_promo_min && !$this->_promo_max) { diff --git a/templates/axletter/show.tpl b/templates/axletter/show.tpl index 25ed9e0..08a46c6 100644 --- a/templates/axletter/show.tpl +++ b/templates/axletter/show.tpl @@ -20,7 +20,7 @@ {* *} {**************************************************************************} -

+

{if $am->_date} Lettre de l'AX du {$am->_date|date_format} {else} @@ -28,8 +28,7 @@ {/if}

-

-[liste des lettres] +

{if $smarty.get.text} [version HTML] {else} @@ -40,15 +39,21 @@ {/if}

+{include file="include/massmailer-nav.tpl" mm=$am base=ax} +
-
+
-
-{$am->title(true)} - {include file="axletter/letter.tpl"} + + + + + {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/include/massmailer-nav.tpl b/templates/include/massmailer-nav.tpl new file mode 100644 index 0000000..ac68c62 --- /dev/null +++ b/templates/include/massmailer-nav.tpl @@ -0,0 +1,55 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2007 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program 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 General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +
{$am->title(true)}
+ {include file="axletter/letter.tpl"} +
+ + {if $mm->prev() neq null} + + {/if} + + {if $mm->next() neq null} + + {/if} + + {if $mm->last() neq null} + + + + {/if} +
+ + {icon name=resultset_previous title="Lettre précédente"}Lettre précédente + + + [Liste des lettres] + + + Lettre suivante{icon name=resultset_next title="Lettre suivante"} + +
+ + Dernière lettre + +
+ + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/newsletter/show.tpl b/templates/newsletter/show.tpl index 3cf0ce9..71f2160 100644 --- a/templates/newsletter/show.tpl +++ b/templates/newsletter/show.tpl @@ -20,31 +20,36 @@ {* *} {**************************************************************************} -

+

Lettre de Polytechnique.org du {$nl->_date|date_format}

-

-[liste des lettres] -{if $smarty.get.text} -[version HTML] -{else} -[version Texte] -{/if} -{if $smarty.session.perms->hasFlag('admin')} -[Editer] -{/if} +

+ {if $smarty.get.text} + [version HTML] + {else} + [version Texte] + {/if} + {if $smarty.session.perms->hasFlag('admin')} + [Editer] + {/if}

+{include file="include/massmailer-nav.tpl" mm=$nl base=nl} +
-
+
-
-{$nl->title(true)} - {include file="newsletter/nl.tpl"} -
+ + + + + +
{$nl->title(true)}
+ {include file="newsletter/nl.tpl"} +
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4