git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-229
+++ /dev/null
-<?php
-/********************************************************************************
-* index.php : main page (newsgroups list)
-* -----------
-*
-* This file is part of the banana distribution
-* Copyright: See COPYING files that comes with this distribution
-********************************************************************************/
-
-require_once('xorg.inc.php');
-new_skinned_page('banana.tpl', AUTH_COOKIE, 'banana.head.tpl');
-$page->caching = false;
-require_once('hack.inc.php');
-
-$page->register_function('banana', 'banana', false);
-
-$page->run();
-?>
+++ /dev/null
-<?php
-/********************************************************************************
-* index.php : main page (newsgroups list)
-* -----------
-*
-* This file is part of the banana distribution
-* Copyright: See COPYING files that comes with this distribution
-********************************************************************************/
-
-require_once('xorg.inc.php');
-new_skinned_page('banana.tpl', AUTH_COOKIE, 'banana.head.tpl');
-$page->caching = false;
-require_once('hack.inc.php');
-
-$page->register_function('banana', 'banana', false);
-
-$page->run();
-?>
+++ /dev/null
-precious ^(misc|groups|NetNNTP|post|spool|banana).inc.php
+++ /dev/null
-<?php
-
-switch (basename($_SERVER['SCRIPT_NAME'])) {
- case 'index.php':
- if (Get::get('banana') == 'updateall') {
- $globals->xdb->execute('UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}', gmdate('YmdHis'), Session::getInt('uid'));
- $_SESSION['banana_last'] = time();
- }
-}
-
-function hook_banana(&$banana) {
- global $globals;
-
- array_splice($banana->show_hdr, count($banana->show_hdr) - 2, 0, 'x-org-id');
- array_splice($banana->parse_hdr, count($banana->parse_hdr) - 2, 0, 'x-org-id');
-
-
- $serv = "{$globals->banana->server}:{$globals->banana->port}/";
- $sname = basename($_SERVER['SCRIPT_NAME']);
- if ($sname == "spoolgen.php") {
- $banana->host = "news://{$globals->banana->web_user}:{$globals->banana->web_pass}@$serv";
- } elseif (Session::has('forlife')) {
- $banana->host = 'news://web_'.Session::get('forlife').":{$globals->banana->password}@$serv";
- }
-}
-
-function url($string)
-{
- if(strpos($string, "http://")!==false)
- return $string;
- $chemins = Array('', '../', '../../');
- foreach ($chemins as $ch) {
- if (file_exists($ch.'../htdocs/')) {
- return $ch.$string;
- }
- }
- return '';
-}
-
-function hook_displayshortcuts($sname, $first = -1) {
- global $banana,$css;
-
- switch ($sname) {
- case 'subscribe.php' :
- return '[<a href="index.php">Liste des forums</a>] [<a href="'.url("confbanana.php").'">Profil</a>] ';
- break;
-
- case 'index.php' :
- case 'thread.php' :
- case 'article.php' :
- case 'post.php' :
- $res = '';
- if (!$banana->profile['autoup']) {
- $res .= '[<a href="index.php?banana=updateall">Mettre à jour</a>] ';
- }
- return $res . '[<a href="'.url("confbanana.php").'">Profil</a>] ';
- break;
- }
-}
-
-function hook_formatDisplayHeader($_header,$_text) {
- global $banana;
- switch ($_header) {
- case "x-org-id":
- return "$_text".(preg_match("/[\w]+\.[\w\d]+/",$_text)?" [<a href=\"".url("fiche.php")."?user=$_text\" class='popup2'>fiche</a>]":"");
-
- default:
- return htmlentities($_text);
- }
-}
-
-function hook_header_translate($hdr) {
- switch ($hdr) {
- case 'x-org-id': return 'Identité';
-
- default:
- return $hdr;
- }
-}
-
-function hook_checkcancel($_headers) {
- return ($_headers['x-org-id'] == Session::get('forlife') or has_perms());
-}
-
-function hook_getprofile() {
- if (logged()) {
- global $globals;
-
- $uid = Session::getInt('uid');
- $req = $globals->xdb->query(
- "SELECT nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
- IF(FIND_IN_SET('automaj',flags),'1','0')
- FROM {$globals->banana->table_prefix}profils
- WHERE uid={?}", $uid);
- if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
- $nom = Session::get('prenom')." ".Session::get('nom');
- $mail = Session::get('forlife')."@polytechnique.org";
- $sig = $nom." (".Session::getInt('promo').")";
- $disp = 0;
- $maj = 1;
- }
- $array['name'] = "$nom <$mail>";
- $array['sig'] = $sig;
- $array['org'] = "Utilisateur de Polytechnique.org";
- $array['customhdr'] = "";
- $array['display'] = $disp;
- $array['autoup'] = $maj;
- $array['lastnews'] = Session::get('banana_last');
- if ($maj) {
- $globals->xdb->execute("UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}", gmdate("YmdHis"), $uid);
- }
- $req = $globals->xdb->query(
- "SELECT nom
- FROM {$globals->banana->table_prefix}abos
- LEFT JOIN {$globals->banana->table_prefix}list ON list.fid=abos.fid
- WHERE uid={?}", $uid);
- $array['subscribe'] = $req->fetchColumn();
- } else {
- $array = array();
- }
- $array['locale'] = 'fr';
- return $array;
-}
-
-$css = array(
- 'bananashortcuts' => 'bananashortcuts',
- 'bicol' => 'bicol',
- 'bicoltitre' => 'bicoltitre',
- 'bicolvpadd' => 'bicolvpadd',
- 'pair' => 'pair',
- 'impair' => 'impair',
- 'bouton' => 'bouton',
- 'error' => 'erreur',
- 'normal' => 'normal',
- 'total' => 'bananatotal',
- 'unread' => 'bananaunread',
- 'group' => 'bananagroup',
- 'description' => 'bananadescription',
- 'date' => 'bananadate',
- 'subject' => 'bananasubject',
- 'from' => 'bananafrom',
- 'author' => 'author',
- 'nopadd' => 'banananopadd',
- 'overview' => 'bananaoverview',
- 'tree' => 'bananatree'
-);
-
-function banana($params) {
- global $globals, $page;
- global $banana,$css;
- $sname = basename($_SERVER['SCRIPT_NAME']);
- require_once("../../../banana/$sname");
-}
-
-?>
+++ /dev/null
-<?php
-
- /** mise à jour des abonnements
- * @param $_subscriptions ARRAY liste des forums auxquel l'utilisateur est abonné
- */
-
-function update_subscriptions($_subscriptions) {
- global $globals;
- $uid = Session::getInt('uid');
-
- $globals->xdb->execute("DELETE FROM {$globals->banana->table_prefix}abos WHERE uid={?}", $uid);
- if (!count($_subscriptions)) {
- return true;
- }
-
- // Récupération des fid
- $req = $globals->xdb->iterRow("SELECT fid,nom FROM {$globals->banana->table_prefix}list");
- $fids =array();
- while (list($fid,$fnom) = $req->next()) {
- $fids[$fnom] = $fid;
- }
-
- // MAJ table de forums
- if (count(array_keys($fids))) {
- $diff = array_diff($_subscriptions,array_keys($fids));
- } else {
- $diff = $_subscriptions;
- }
- if (count($diff)) {
- foreach ($diff as $g) {
- $globals->xdb->execute("INSERT INTO {$globals->banana->table_prefix}list (nom) VALUES ({?})", $g);
- $fids[$g] = mysql_insert_id();
- }
- }
- // MAJ Abonnements
- foreach ($_subscriptions as $g) {
- $globals->xdb->execute("REPLACE INTO {$globals->banana->table_prefix}abos (fid,uid) VALUES ({?},{?})", $fids[$g], $uid);
- }
-}
-
-?>
********************************************************************************/
require_once('xorg.inc.php');
-new_skinned_page('banana.tpl', AUTH_COOKIE, 'banana.head.tpl');
-$page->caching = false;
-require_once('hack.inc.php');
-
-$page->register_function('banana', 'banana', false);
+new_skinned_page('banana/index.tpl', AUTH_COOKIE, 'banana/index.head.tpl');
+require_once('banana.inc.php');
+$res = PlatalBanana::run();
+$page->assign_by_ref('banana', $banana);
+$page->assign('banana_res', $res);
$page->run();
?>
#!/bin/bash
-ln -sf ../../../banana/{img,spool} .
-
-pushd include &> /dev/null
-ln -sf ../../../../banana/include/{groups,NetNNTP,post,spool,banana}.inc.php .
-popd &> /dev/null
-
-ln -sf ../../../banana/xface.php .
+ln -sf ../../../banana/{img,xface.php} .
ln -sf ../../../banana/css/style.css banana.css
+++ /dev/null
-<?php
-/********************************************************************************
-* index.php : main page (newsgroups list)
-* -----------
-*
-* This file is part of the banana distribution
-* Copyright: See COPYING files that comes with this distribution
-********************************************************************************/
-
-require_once('xorg.inc.php');
-new_skinned_page('banana.tpl', AUTH_COOKIE, 'banana.head.tpl');
-$page->caching = false;
-require_once('hack.inc.php');
-
-$page->register_function('banana', 'banana', false);
-
-$page->run();
-?>
***************************************************************************/
require_once("xorg.inc.php");
-new_skinned_page('confbanana.tpl', AUTH_MDP);
+new_skinned_page('banana/profile.tpl', AUTH_MDP);
if (!(Post::has('action') && Post::has('banananame') && Post::has('bananasig') && Post::has('bananadisplay')
&& Post::has('bananamail') && Post::has('bananaupdate') && Post::get('action')=="OK" ))
+++ /dev/null
-<?php
-/********************************************************************************
-* spoolgen.php : spool generation
-* --------------
-*
-* This file is part of the banana distribution
-* Copyright: See COPYING files that comes with this distribution
-********************************************************************************/
-
-ini_set('max_execution_time','300');
-ini_set('include_path', '..:../include:../../include:../../../include');
-
-require_once("include/encoding.inc.php");
-require_once("include/config.inc.php");
-require_once("include/NetNNTP.inc.php");
-require_once("include/post.inc.php");
-require_once("include/groups.inc.php");
-require_once("include/spool.inc.php");
-require_once("include/password.inc.php");
-
-
-$nntp = new nntp($news['server']);
-if (!$nntp) {
- print "cannot connect to server\n";
- exit;
-}
-
-if ($news['user']!="anonymous") {
- $result = $nntp->authinfo($news["user"],$news["pass"]);
- if (!$result) {
- print "authentication error\n";
- exit;
- }
-}
-unset($result);
-
-$groups = new groups($nntp,2);
-$list = array_keys($groups->overview);
-unset($groups);
-foreach ($list as $g) {
- print "Generating spool for $g : ";
- $spool = new spool($nntp,$g);
- print "done.\n";
- unset($spool);
-}
-$nntp->quit();
-?>
+++ /dev/null
-<?php
-/********************************************************************************
-* index.php : main page (newsgroups list)
-* -----------
-*
-* This file is part of the banana distribution
-* Copyright: See COPYING files that comes with this distribution
-********************************************************************************/
-
-require_once('xorg.inc.php');
-new_skinned_page('banana.tpl', AUTH_COOKIE, 'banana.head.tpl');
-$page->caching = false;
-require_once('hack.inc.php');
-
-$page->register_function('banana', 'banana', false);
-
-$page->run();
-?>
+++ /dev/null
-<?php
-/********************************************************************************
-* index.php : main page (newsgroups list)
-* -----------
-*
-* This file is part of the banana distribution
-* Copyright: See COPYING files that comes with this distribution
-********************************************************************************/
-
-require_once('xorg.inc.php');
-new_skinned_page('banana.tpl', AUTH_COOKIE, 'banana.head.tpl');
-$page->caching = false;
-require_once('hack.inc.php');
-
-$page->register_function('banana', 'banana', false);
-
-$page->run();
-?>
--- /dev/null
+../../banana/include
\ No newline at end of file
--- /dev/null
+<?php
+require_once('banana/banana.inc.php');
+
+function hook_formatDisplayHeader($_header,$_text) {
+ global $banana;
+ if ($_header == 'x-org-id') {
+ return "$_text [<a href=\"../fiche.php?user=$_text\" class='popup2'>fiche</a>]";
+ }
+}
+
+function hook_headerTranslate($hdr) {
+ if ($hdr == 'x-org-id') {
+ return 'Identité';
+ }
+}
+
+function hook_checkcancel($_headers) {
+ return ($_headers['x-org-id'] == Session::get('forlife') or has_perms());
+}
+
+class PlatalBanana extends Banana
+{
+ var $profile = Array( 'name' => '', 'sig' => '', 'org' => 'Utilisateur de Polytechnique.org',
+ 'customhdr' =>'', 'display' => 0, 'lastnews' => 0, 'locale' => 'fr_FR', 'subscribe' => array());
+
+ function PlatalBanana()
+ {
+ global $globals;
+
+ $uid = Session::getInt('uid');
+ $req = $globals->xdb->query(
+ "SELECT nom, mail, sig, FIND_IN_SET('threads',flags), FIND_IN_SET('automaj',flags)
+ FROM {$globals->banana->table_prefix}profils
+ WHERE uid={?}", $uid);
+
+ if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
+ $nom = Session::get('prenom')." ".Session::get('nom');
+ $mail = Session::get('forlife')."@polytechnique.org";
+ $sig = $nom." (".Session::getInt('promo').")";
+ $disp = 0;
+ $maj = 1;
+ }
+ $this->profile['name'] = "$nom <$mail>";
+ $this->profile['sig'] = $sig;
+ $this->profile['display'] = $disp;
+ $this->profile['autoup'] = $maj;
+ $this->profile['lastnews'] = Session::get('banana_last');
+
+ if ($maj) {
+ $globals->xdb->execute("UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}", gmdate("YmdHis"), $uid);
+ }
+
+ $req = $globals->xdb->query(
+ "SELECT nom
+ FROM {$globals->banana->table_prefix}abos
+ LEFT JOIN {$globals->banana->table_prefix}list ON list.fid=abos.fid
+ WHERE uid={?}", $uid);
+ $this->profile['subscribe'] = $req->fetchColumn();
+
+ array_splice($this->show_hdr, count($this->show_hdr) - 2, 0, 'x-org-id');
+ array_splice($this->parse_hdr, count($this->parse_hdr) - 2, 0, 'x-org-id');
+
+ $this->host = 'news://web_'.Session::get('forlife')
+ .":{$globals->banana->password}@{$globals->banana->server}:{$globals->banana->port}/";
+
+ parent::Banana();
+ }
+
+ function run()
+ {
+ global $banana;
+
+ if (Get::get('banana') == 'updateall') {
+ $globals->xdb->execute('UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}', gmdate('YmdHis'), Session::getInt('uid'));
+ $_SESSION['banana_last'] = time();
+ }
+ return Banana::run('PlatalBanana');
+ }
+
+ function action_saveSubs()
+ {
+ global $globals;
+ $uid = Session::getInt('uid');
+
+ $this->profile['subscribe'] = Array();
+ $globals->xdb->execute("DELETE FROM {$globals->banana->table_prefix}abos WHERE uid={?}", $uid);
+ if (!count($_POST['subscribe'])) {
+ return true;
+ }
+
+ $req = $globals->xdb->iterRow("SELECT fid,nom FROM {$globals->banana->table_prefix}list");
+ $fids = array();
+ while (list($fid,$fnom) = $req->next()) {
+ $fids[$fnom] = $fid;
+ }
+
+ $diff = array_diff($_POST['subscribe'], array_keys($fids));
+ foreach ($diff as $g) {
+ $globals->xdb->execute("INSERT INTO {$globals->banana->table_prefix}list (nom) VALUES ({?})", $g);
+ $fids[$g] = mysql_insert_id();
+ }
+
+ foreach ($_POST['subscribe'] as $g) {
+ $globals->xdb->execute("INSERT INTO {$globals->banana->table_prefix}abos (fid,uid) VALUES ({?},{?})", $fids[$g], $uid);
+ $this->profile['subscribe'][] = $g;
+ }
+ }
+}
+
+?>
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************}
-{banana}
+<h1>Options</h1>
+
+{if !$banana->profile.autoup}
+[<a href="?banana=updateall">Mettre à jour</a>]
+{/if}
+[<a href="profile.php">Profil</a>]
+
+<br />
+
+{$banana_res|smarty:nodefaults}
{* vim:set et sw=2 sts=2 sws=2: *}
n'afficher que les fils de discussion contenant des messages lus.
</p>
<p class="normal">
- Retour aux <a href="banana/index.php">forums</a>
+Retour aux <a href="{rel}/banana/">forums</a>
</p>
<form action="{$smarty.server.PHP_SELF}" method="post">
Ton profil est enregistré !!!
</p>
<p class="normal">
- Retour aux <a href="banana/index.php">forums</a>
+Retour aux <a href="{rel}/banana/">forums</a>
</p>
{/if}