2 /***************************************************************************
3 * Copyright (C) 2003-2011 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class UserFilterIterator
implements PlIterator
26 public function __construct(PlIterator
$it, PlUser
$user)
32 public function total()
34 return $this->it
->total();
37 public function first()
39 return $this->it
->first();
42 public function last()
44 return $this->it
->last();
47 public function next()
49 while ($n = $this->it
->next()) {
50 $uf = UserFilter
::getLegacy($n['promo_min'], $n['promo_max']);
51 if ($uf->checkUser($this->user
)) {
59 class XnetGrpEventFeed
extends PlFeed
61 public function __construct()
64 $name = $globals->asso('nom');
65 $url = $globals->baseurl
. '/' . $globals->asso('diminutif');
66 parent
::__construct('Polytechnique.net :: ' . $name . ' :: News',
68 'L\'actualité du groupe ' . $name,
70 'xnetgrp/announce-rss.tpl');
73 protected function fetch(PlUser
$user)
76 if (!is_null($user)) {
77 return new UserFilterIterator(
78 XDB
::iterator("SELECT id, titre AS title, texte, contacts,
79 create_date AS publication,
80 FIND_IN_SET('photo', flags) AS photo,
81 CONCAT({?}, '/#art', id) AS link
83 WHERE expiration >= NOW() AND asso_id = {?}",
84 $this->link
, $globals->asso('id'), $user));
86 return XDB
::iterator("SELECT id, titre AS title, texte, create_date AS publication,
87 CONCAT({?}, '/#art', id) AS link,
88 NULL AS photo, NULL AS contacts
90 WHERE FIND_IN_SET('public', flags) AND expiration >= NOW() AND asso_id = {?}",
91 $this->link
, $globals->asso('id'));
96 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: