Cleanup forum_ tables:
[platal.git] / include / banana / ml.inc.php
index 067a1e1..09632eb 100644 (file)
@@ -45,23 +45,25 @@ class MLBanana extends Banana
 {
     static public $listname;
     static public $domain;
+    private $user;
 
-    function __construct($forlife, $params = null)
+    function __construct(User &$user, $params = null)
     {
         global $globals;
+        $this->user = &$user;
+
         Banana::$spool_root = $globals->banana->spool_root;
         Banana::$spool_boxlist = false;
         Banana::$msgedit_canattach = true;
         Banana::$debug_mbox = ($globals->debug & DEBUG_BT);
         Banana::$debug_smarty = ($globals->debug & DEBUG_SMARTY);
         Banana::$mbox_helper = $globals->banana->mbox_helper;
+        Banana::$feed_updateOnDemand = true;
         if (S::has_perms()) {
             Banana::$msgshow_mimeparts[] = 'source';
         }
         array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail');
-        if (!S::v('core_rss_hash')) {
-            Banana::$feed_active = false;
-        }
+        Banana::$feed_active = S::hasAuthToken();
 
         MLBanana::$listname = $params['listname'];
         MLBanana::$domain   = $params['domain'];
@@ -74,9 +76,20 @@ class MLBanana extends Banana
         global $platal, $globals;
 
         $nom  = S::v('prenom') . ' ' . S::v('nom');
-        $mail = S::v('bestalias') . '@' . $globals->mail->domain;
+        $mail = $this->user->bestEmail();
         $sig  = $nom . ' (' . S::v('promo') . ')';
-        Banana::$msgedit_headers['X-Org-Mail'] = S::v('forlife') . '@' . $globals->mail->domain;
+        Banana::$msgedit_headers['X-Org-Mail'] = $this->user->forlifeEmail();
+
+        // Tree color
+        $req = XDB::query('SELECT  tree_unread, tree_read
+                             FROM  forum_profiles
+                            WHERE  uid= {?}', $this->user->id());
+        if (!(list($unread, $read) = $req->fetchOneRow())) {
+            $unread = 'o';
+            $read = 'dg';
+        }
+        Banana::$tree_unread = $unread;
+        Banana::$tree_read = $read;
 
         // Build user profile
         Banana::$profile['headers']['From']         = "$nom <$mail>";