Can use a user-defined array instead of _GET
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sun, 9 Jul 2006 10:46:14 +0000 (10:46 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:34:48 +0000 (00:34 +0100)
git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@67 9869982d-c50d-0410-be91-f2a2ec7c7c7b

Changelog
banana/NetNNTP.inc.php
banana/banana.inc.php.in
banana/misc.inc.php

index 1a53c55..3c5ac82 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,7 @@
+Sun, 09 Jul 2006                    Florent Bruneau <florent.bruneau@m4x.org>
+
+       * Can use a user-defined Array instead of $_GET
+
 Sat, 08 Jul 2006                    Florent Bruneau <florent.bruneau@m4x.org>
 
        * Automatically set fup for crossposts
index 45af23f..f15b6b1 100644 (file)
@@ -46,7 +46,7 @@ class nntp
             $result        = $this->gline();
             $this->posting = ($result{0}=="200");
         }
-        if ($result{0}=="2" && $url['user'] && $url['user']!='anonymous') {
+        if ($result{0}=="2" && isset($url['user']) && $url['user'] != 'anonymous') {
             return $this->authinfo($url['user'], $url['pass']);
         }
         return ($result{0}=="2");
index 1ee9609..cfc5be9 100644 (file)
@@ -82,6 +82,8 @@ class Banana
     var $post;
     var $spool;
 
+       var $get;
+
     function Banana()
     {
         $this->_require('NetNNTP');
@@ -92,24 +94,35 @@ class Banana
         }
     }
 
-    function run($class = 'Banana')
+       /** Run Banana
+        * @param STRING class Name of the class to use
+        * @param ARRAY  myget If defined is used instead of get
+        */
+    function run($class = 'Banana', $myget = null)
     {
         global $banana;
 
         Banana::_require('misc');
         $banana = new $class();
 
+        if (is_null($myget)) {
+            $banana->get = $_GET;
+        } else {
+            $banana->get = $myget;
+        }
+
+
         if (!$banana->nntp) {
             return '<p class="error">'._b_('Impossible de contacter le serveur').'</p>';
         }
 
-        $group  = empty($_GET['group']) ? null : strtolower($_GET['group']);
-        $artid  = empty($_GET['artid']) ? null : strtolower($_GET['artid']);
-        $partid = !isset($_GET['part']) ? -1 : $_GET['part'];
+        $group  = empty($banana->get['group']) ? null : strtolower($banana->get['group']);
+        $artid  = empty($banana->get['artid']) ? null : strtolower($banana->get['artid']);
+        $partid = !isset($banana->get['part']) ? -1 : $banana->get['part'];
         $banana->state = Array ('group' => $group, 'artid' => $artid);
 
         if (is_null($group)) {
-            if (isset($_GET['subscribe'])) {
+            if (isset($banana->get['subscribe'])) {
                 return $banana->action_listSubs();
             } elseif (isset($_POST['subscribe'])) {
                 $banana->action_saveSubs();
@@ -119,10 +132,10 @@ class Banana
         } elseif (is_null($artid)) {
             if (isset($_POST['action']) && $_POST['action'] == 'new') {
                 return $banana->action_doFup($group, isset($_POST['artid']) ? intval($_POST['artid']) : -1);
-            } elseif (isset($_GET['action']) && $_GET['action'] == 'new') {
+            } elseif (isset($banana->get['action']) && $banana->get['action'] == 'new') {
                 return $banana->action_newFup($group);
             } else {
-                return $banana->action_showThread($group, isset($_GET['first']) ? intval($_GET['first']) : 1);
+                return $banana->action_showThread($group, isset($banana->get['first']) ? intval($banana->get['first']) : 1);
             }
 
         } else {
@@ -132,8 +145,8 @@ class Banana
                 $res = '';
             }
 
-            if (isset($_GET['action'])) {
-                switch ($_GET['action']) {
+            if (isset($banana->get['action'])) {
+                switch ($banana->get['action']) {
                     case 'cancel':
                         $res .= $banana->action_showArticle($group, $artid, $partid);
                         if ($banana->post->checkcancel()) {
@@ -154,12 +167,12 @@ class Banana
                 }
             }
 
-            if (isset($_GET['pj'])) {
+            if (isset($banana->get['pj'])) {
                 $action = false;
-                if (isset($_GET['action']) && $_GET['action'] == 'view') {
+                if (isset($banana->get['action']) && $banana->get['action'] == 'view') {
                     $action = true;
                 }
-                $att = $banana->action_getAttachment($group, $artid, $_GET['pj'], $action);
+                $att = $banana->action_getAttachment($group, $artid, $banana->get['pj'], $action);
                 if ($att != "") {
                     return $res.$att;
                 }
index fb55a9f..150af47 100644 (file)
@@ -85,7 +85,8 @@ function makeHREF($params, $text = null)
        if (is_null($text)) {
                $text = $link;
        }
-       if ($params['action'] == 'view') {
+       $target = null;
+       if (isset($params['action']) && $params['action'] == 'view') {
                $target = ' target="_blank"';
        }
        return '<a href="' . htmlentities($link) . $target . '">' . $text . '</a>';