Fix syntax errors.
[platal.git] / include / banana / forum.inc.php
index 0c54f45..b721d64 100644 (file)
@@ -36,7 +36,7 @@ class ForumsBanana extends Banana
 
         global $globals;
         Banana::$msgedit_canattach = false;
-        Banana::$spool_root = $globals->banana->spool_root;
+        Banana::$spool_root = $globals->spoolroot . '/spool/banana/';
         array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail');
         Banana::$nntp_host = self::buildURL($user->login());
         if (S::admin()) {
@@ -59,9 +59,12 @@ class ForumsBanana extends Banana
         $user = $globals->banana->web_user;
         if ($login != null) {
             $user .= '_' . $login;
+            $pass = $globals->banana->password;
+        } else {
+            $pass = $globals->banana->web_pass;
         }
         return $scheme . '://' . $user
-                       . ":{$globals->banana->password}@{$globals->banana->server}:{$globals->banana->port}/";
+                       . ":{$pass}@{$globals->banana->server}:{$globals->banana->port}/";
 
     }
 
@@ -101,7 +104,7 @@ class ForumsBanana extends Banana
         $time = null;
         if (!is_null($this->params) && isset($this->params['updateall'])) {
             $time = intval($this->params['updateall']);
-            S::set('banana_last', $time);
+            $this->user->banana_last = $time;
         }
 
         $infos = $this->fetchProfile();
@@ -119,7 +122,7 @@ class ForumsBanana extends Banana
         Banana::$profile['signature']               = $infos['sig'];
         Banana::$profile['display']                 = $infos['threads'];
         Banana::$profile['autoup']                  = $infos['maj'];
-        Banana::$profile['lastnews']                = S::v('banana_last');
+        Banana::$profile['lastnews']                = $this->user->banana_last;
         Banana::$profile['subscribe']               = $req->fetchColumn();
         Banana::$tree_unread = $infos['tree_unread'];
         Banana::$tree_read = $infos['tree_read'];
@@ -131,8 +134,8 @@ class ForumsBanana extends Banana
                            WHERE  uid = {?}',
                          $time, $this->user->id());
             if (XDB::affectedRows() == 0) {
-                XDB::execute('INSERT INTO  forum_profiles (uid, last_seen)
-                                   VALUES  ({?}, FROM_UNIXTIME({?}))',
+                XDB::execute('INSERT IGNORE INTO  forum_profiles (uid, last_seen)
+                                          VALUES  ({?}, FROM_UNIXTIME({?}))',
                              $this->user->id(), $time);
             }
         }
@@ -235,8 +238,10 @@ class ForumsBanana extends Banana
                 } else {
                     $last_seen = '0000-00-00';
                 }
-                XDB::execute('REPLACE INTO  forum_profiles (uid, sig, mail, name, flags, tree_unread, tree_read, last_seen)
-                                    VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+                XDB::execute('INSERT INTO  forum_profiles (uid, sig, mail, name, flags, tree_unread, tree_read, last_seen)
+                                   VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
+                  ON DUPLICATE KEY UPDATE  sig = VALUES(sig), mail = VALUES(mail), name = VALUES(name), flags = VALUES(flags),
+                                           tree_unread = VALUES(tree_unread), tree_read = VALUES(tree_read), last_seen = VALUES(last_seen)',
                              $this->user->id(), Post::v('bananasig'),
                              Post::v('bananamail'), Post::v('banananame'),
                              $flags, $unread, $read, $last_seen);