merge xmlrpc stuff, and put it in classes/
[platal.git] / include / banana.inc.php
index c395e8a..19dff94 100644 (file)
 require_once('banana/banana.inc.php');
 
 function hook_formatDisplayHeader($_header, $_text) {
-    global $globals, $banana;
+    global $banana;
     if ($_header == 'from') {
         $id = $banana->post->headers['x-org-id'];
         $_text = formatFrom($_text);
-        return $_text . ' <a href="' . $globals->baseurl . '/profile/' 
-             . $id . '" class="popup2" title="' . $id . '">'
-             . '<img src="' . $globals->baseurl . '/images/loupe.gif" alt="fiche" title="fiche" />'
-             . '</a>';
+        return $_text . ' <a href="profile/' . $id . '" class="popup2" title="' . $id . '">'
+             . '<img src="images/loupe.gif" alt="fiche" title="fiche" /></a>';
     }
 }
 
 function hook_checkcancel($_headers) {
-    return ($_headers['x-org-id'] == Session::get('forlife') or has_perms());
+    return ($_headers['x-org-id'] == S::v('forlife') or S::has_perms());
 }
 
 function hook_shortcuts()
 {
-    global $globals;
-    return Array('profile' => Array('<a href="' . $globals->baseurl . '/banana/profile">Préférences</a>',
+    return Array('profile' => array('<a href="banana/profile">Préférences</a>',
                                     'Préférences'));
 }
 
 function hook_makeLink($params) {
-    global $globals;
-    $base = $globals->baseurl . '/banana'; 
+    $base = 'banana';
     if ($params['subscribe'] == 1) {
         return $base . '/subscription';
     }
@@ -81,8 +77,7 @@ function hook_makeLink($params) {
 
 function hook_makeImg($img, $alt, $height, $width)
 {
-    global $globals;
-    $url = $globals->baseurl . '/images/banana/' . $img;
+    $url = 'images/banana/' . $img;
 
     if (!is_null($width)) {
         $width = ' width="' . $width . '"';
@@ -117,17 +112,17 @@ class PlatalBanana extends Banana
     function PlatalBanana()
     {
         global $globals;
-    
-        $uid = Session::getInt('uid');
+
+        $uid = S::v('uid');
         $req = 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').")";
+            $nom  = S::v('prenom')." ".S::v('nom');
+            $mail = S::v('forlife')."@polytechnique.org";
+            $sig  = $nom." (".S::v('promo').")";
             $disp = 0;
             $maj  = 1;
         }
@@ -135,7 +130,7 @@ class PlatalBanana extends Banana
         $this->profile['sig']       = $sig;
         $this->profile['display']   = $disp;
         $this->profile['autoup']    = $maj;
-        $this->profile['lastnews']  = Session::get('banana_last');
+        $this->profile['lastnews']  = S::v('banana_last');
         
         if ($maj) {
             XDB::execute("UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}", gmdate("YmdHis"), $uid);
@@ -151,7 +146,7 @@ class PlatalBanana extends Banana
         array_splice($this->show_hdr,  count($this->show_hdr)  - 2, 0);
         array_splice($this->parse_hdr, count($this->parse_hdr) - 2, 0, 'x-org-id');
 
-        $this->host = 'news://web_'.Session::get('forlife')
+        $this->host = 'news://web_'.S::v('forlife')
             .":{$globals->banana->password}@{$globals->banana->server}:{$globals->banana->port}/";
 
         parent::Banana();
@@ -163,7 +158,7 @@ class PlatalBanana extends Banana
 
         if (Get::get('banana') == 'updateall'
                 || (!is_null($params) && isset($params['banana']) && $params['banana'] == 'updateall')) {
-            XDB::execute('UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}', gmdate('YmdHis'), Session::getInt('uid'));
+            XDB::execute('UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}', gmdate('YmdHis'), S::v('uid'));
             $_SESSION['banana_last'] = time();
         }
         return Banana::run('PlatalBanana', $params);
@@ -172,7 +167,7 @@ class PlatalBanana extends Banana
     function action_saveSubs()
     {
         global $globals;
-        $uid = Session::getInt('uid');
+        $uid = S::v('uid');
 
         $this->profile['subscribe'] = Array();
         XDB::execute("DELETE FROM {$globals->banana->table_prefix}abos WHERE uid={?}", $uid);