From: x2003bruneau Date: Wed, 7 Mar 2007 16:16:24 +0000 (+0000) Subject: Each event create a new thread on a dedicated forum X-Git-Tag: xorg/0.9.14~228 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=b2bffbe6b6812e63fa718fdcc2b860055d5642db;p=platal.git Each event create a new thread on a dedicated forum git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1556 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/configs/platal.ini b/configs/platal.ini index 7d79051..d6b1e63 100644 --- a/configs/platal.ini +++ b/configs/platal.ini @@ -15,6 +15,9 @@ table_prefix = "banana_" spool_root = "/var/spool/banana" mbox_helper = "/usr/bin/banana-mbox-helper" +event_forum = "" +event_reply = "" + [Geoloc] webservice_url = "" diff --git a/include/banana/forum.inc.php b/include/banana/forum.inc.php index 1abeafb..9dc0291 100644 --- a/include/banana/forum.inc.php +++ b/include/banana/forum.inc.php @@ -29,13 +29,17 @@ function hook_checkcancel($_headers) class ForumsBanana extends Banana { - function __construct($params = null) + private $forlife; + + public function __construct($forlife, $params = null) { + $this->forlife = $forlife; + global $globals; Banana::$msgedit_canattach = false; Banana::$spool_root = $globals->banana->spool_root; array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail'); - Banana::$nntp_host = 'news://web_'.S::v('forlife') + Banana::$nntp_host = 'news://web_'.$forlife . ":{$globals->banana->password}@{$globals->banana->server}:{$globals->banana->port}/"; if (S::has_perms()) { Banana::$msgshow_mimeparts[] = 'source'; @@ -115,6 +119,20 @@ class ForumsBanana extends Banana return parent::run(); } + public function post($dest, $reply, $subject, $body) + { + global $globals; + $res = XDB::query('SELECT nom, prenom, promo, b.alias AS bestalias + FROM auth_user_md5 AS u + INNER JOIN aliases AS a ON (a.id = u.user_id) + INNER JOIN aliases AS b ON (b.id = a.id AND FIND_IN_SET(\'bestalias\', b.flags)) + WHERE a.alias = {?}', $this->forlife); + list($nom, $prenom, $promo, $bestalias) = $res->fetchOneRow(); + Banana::$profile['headers']['From'] = "$prenom $nom ($promo) <$bestalias@{$globals->mail->domain}>"; + Banana::$profile['headers']['Organization'] = 'Utilisateur de Polytechnique.org'; + return parent::post($dest, $reply, $subject, $body); + } + protected function action_saveSubs($groups) { global $globals; diff --git a/include/banana/hooks.inc.php b/include/banana/hooks.inc.php index fe000d5..4c92e09 100644 --- a/include/banana/hooks.inc.php +++ b/include/banana/hooks.inc.php @@ -202,7 +202,7 @@ function get_banana_params(array &$get, $group = null, $action = null, $artid = function run_banana(&$page, $class, array $args) { - $banana = new $class($args); + $banana = new $class(S::v('forlife'), $args); $page->assign('banana', $banana->run()); $page->addCssInline($banana->css()); $page->addCssLink('banana.css'); diff --git a/include/banana/ml.inc.php b/include/banana/ml.inc.php index b635346..6eb7b0c 100644 --- a/include/banana/ml.inc.php +++ b/include/banana/ml.inc.php @@ -27,7 +27,7 @@ class MLBanana extends Banana static public $listname; static public $domain; - function __construct($params = null) + function __construct($forlife, $params = null) { global $globals; Banana::$spool_root = $globals->banana->spool_root; diff --git a/include/banana/moderate.inc.php b/include/banana/moderate.inc.php index 2c743ac..d597fc2 100644 --- a/include/banana/moderate.inc.php +++ b/include/banana/moderate.inc.php @@ -56,7 +56,7 @@ class ModerationBanana extends Banana static public $domain; static public $client; - function __construct($params = null) + function __construct($forlife, $params = null) { global $globals; ModerationBanana::$client = $params['client']; diff --git a/include/validations/evts.inc.php b/include/validations/evts.inc.php index 1adf6db..adf6a9f 100644 --- a/include/validations/evts.inc.php +++ b/include/validations/evts.inc.php @@ -139,11 +139,27 @@ class EvtReq extends Validate peremption={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide')", $this->uid, $this->titre, $this->texte, $this->peremption, $this->pmin, $this->pmax)) { + $eid = XDB::insertId(); if ($this->img) { XDB::execute("INSERT INTO evenements_photo SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}", XDB::insertId(), $this->imgtype, $this->imgx, $this->imgy, $this->img); } + global $globals; + if ($globals->banana->event_forum) { + require_once 'user.func.inc.php'; + $forlife = get_user_forlife($this->uid); + require_once 'banana/forum.inc.php'; + $banana = new ForumsBanana($forlife); + $post = $banana->post($globals->banana->event_forum, + $globals->banana->event_reply, + $this->titre, pl_entity_decode(strip_tags($this->texte))); + if ($post != -1) { + XDB::execute("UPDATE evenements + SET creation_date = creation_date, post_id = {?} + WHERE id = {?}", $post, $eid); + } + } return true; } return false; diff --git a/modules/banana.php b/modules/banana.php index 6a82468..8193a43 100644 --- a/modules/banana.php +++ b/modules/banana.php @@ -139,7 +139,7 @@ class BananaModule extends PLModule $_SESSION = array_merge($row, $_SESSION); require_once 'banana/forum.inc.php'; - $banana = new ForumsBanana(array('group' => $group, 'action' => 'rss2')); + $banana = new ForumsBanana(S::v('forlife'), array('group' => $group, 'action' => 'rss2')); $banana->run(); exit; } diff --git a/modules/events.php b/modules/events.php index 2ac6457..20a0f56 100644 --- a/modules/events.php +++ b/modules/events.php @@ -99,7 +99,7 @@ class EventsModule extends PLModule if (!$sum->total()) { return false; } - $sql = "SELECT e.id,e.titre,e.texte,a.user_id,a.nom,a.prenom,a.promo,l.alias AS forlife, + $sql = "SELECT e.id,e.titre,e.texte,e.post_id,a.user_id,a.nom,a.prenom,a.promo,l.alias AS forlife, p.x, p.y, p.attach IS NOT NULL AS img FROM evenements AS e LEFT JOIN evenements_photo AS p ON (e.id = p.eid) diff --git a/modules/lists.php b/modules/lists.php index 16c5016..4d2bc63 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -392,7 +392,7 @@ class ListsModule extends PLModule exit; } require_once('banana/ml.inc.php'); - $banana = new MLBanana(Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2')); + $banana = new MLBanana(S::v('forlife'), Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2')); $banana->run(); } exit; diff --git a/templates/events/index.tpl b/templates/events/index.tpl index 5284ea1..c1fcb5a 100644 --- a/templates/events/index.tpl +++ b/templates/events/index.tpl @@ -190,11 +190,11 @@ Bienvenue {$smarty.session.prenom}
- {* if $ev.img *} + {if $ev.img}
{$ev.title}
- {* /if *} + {/if}
{tidy} {$ev.texte|smarty:nodefaults|nl2br} @@ -204,16 +204,22 @@ Bienvenue {$smarty.session.prenom} - - - Sommaire - - - Annonce proposée par - - {$ev.prenom} {$ev.nom} X{$ev.promo} + +
+ + {if $ev.post_id} + + {icon name="comments" title="Discussion"}Suivre la discussion + • + {/if} + + Sommaire - +
+ Annonce proposée par + + {$ev.prenom} {$ev.nom} X{$ev.promo} + diff --git a/upgrade/0.9.14/03_evenements.tpl b/upgrade/0.9.14/03_evenements.tpl index 40a959f..5c8555d 100644 --- a/upgrade/0.9.14/03_evenements.tpl +++ b/upgrade/0.9.14/03_evenements.tpl @@ -1,4 +1,5 @@ alter table evenements change flags flags set('valide', 'archive', 'important') not null; +alter table evenements add post_id smallint(4) unsigned default NULL; create table evenements_photo ( eid smallint(4) unsigned not null, attachmime enum('jpeg', 'png', 'gif') not null default 'jpeg',