phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] nntp admin.php preferences.php inc/class.decode... [V


From: Dave Hall
Subject: [Phpgroupware-cvs] nntp admin.php preferences.php inc/class.decode... [Version-0_9_16-branch]
Date: Tue, 24 Oct 2006 13:56:46 +0000

CVSROOT:        /sources/phpgroupware
Module name:    nntp
Branch:         Version-0_9_16-branch
Changes by:     Dave Hall <skwashd>     06/10/24 13:56:46

Modified files:
        .              : admin.php preferences.php 
        inc            : class.decode.inc.php 
        templates/default: nntp.tpl 

Log message:
        applying patch #5447

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/nntp/admin.php?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.25.2.1.2.1&r2=1.25.2.1.2.2
http://cvs.savannah.gnu.org/viewcvs/nntp/preferences.php?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.36.4.1&r2=1.36.4.2
http://cvs.savannah.gnu.org/viewcvs/nntp/inc/class.decode.inc.php?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.8.2.1&r2=1.8.2.1.2.1
http://cvs.savannah.gnu.org/viewcvs/nntp/templates/default/nntp.tpl?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.8&r2=1.8.6.1

Patches:
Index: admin.php
===================================================================
RCS file: /sources/phpgroupware/nntp/admin.php,v
retrieving revision 1.25.2.1.2.1
retrieving revision 1.25.2.1.2.2
diff -u -b -r1.25.2.1.2.1 -r1.25.2.1.2.2
--- admin.php   15 Dec 2005 14:06:41 -0000      1.25.2.1.2.1
+++ admin.php   24 Oct 2006 13:56:46 -0000      1.25.2.1.2.2
@@ -10,7 +10,13 @@
        *  option) any later version.                                           
   *
        
\**************************************************************************/
 
-       /* $Id: admin.php,v 1.25.2.1.2.1 2005/12/15 14:06:41 skwashd Exp $ */
+  /**************************************************************************\
+  * Modified by Steve Price <address@hidden>                         *
+  * Modified to make the search function work properly, and work with the    *
+  * nextmatchs class                                                         *
+  \**************************************************************************/
+
+       /* $Id: admin.php,v 1.25.2.1.2.2 2006/10/24 13:56:46 skwashd Exp $ */
 
        if ( (isset($_POST['submit']) && $_POST['submit']) 
                && (isset($_POST['nntplist']) && $_POST['nntplist']) )
@@ -35,16 +41,16 @@
        $GLOBALS['phpgw_info']['flags'] = $phpgw_flags;
        include('../header.inc.php');
 
-       function get_tg()
+       function get_tg($where='')
        {
-               $GLOBALS['phpgw']->db->query('SELECT count(con) FROM 
newsgroups');
+               $GLOBALS['phpgw']->db->query("SELECT count(con) FROM newsgroups 
$where");
                $GLOBALS['phpgw']->db->next_record();
                $tg = $GLOBALS['phpgw']->db->f(0);
                if($tg == 0)
                {
                        @set_time_limit(0);
                        $GLOBALS['nntp']->load_table();
-                       return get_tg();
+                       return get_tg($where);
                }
                else
                {
@@ -63,9 +69,6 @@
                        $tg = intval($_REQUEST['tg']);
                }
 
-               //$phpgw->common->phpgw_header();
-               //echo parse_navbar();
-
                $max = 
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']);
 
                $urlname = '/nntp/admin.php';
@@ -87,15 +90,6 @@
                        $start = (int) $_REQUEST['start'];
                }
 
-               if (!isset($_REQUEST['query_result']) || 
!$_REQUEST['query_result'] )
-               {
-                       $query_result = 0;
-               }
-               else
-               {
-                       $query_result = (int) $_REQUEST['query_result'];
-               }
-
                if ( !isset($_REQUEST['order']) || !$_REQUEST['order'] )
                {
                        $order = 1;
@@ -126,22 +120,17 @@
                        }
                }
 
-               $query_result = get_var('query_result', array('POST'), 0);
-               if ( (isset($_REQUEST['search']) && $_REQUEST['search']) || 
(isset($_REQUEST['next']) && $_REQUEST['next']) )
-               {
-                       if (isset($_REQUEST['next']) && $_REQUEST['next'])
+               $where_str = '' ;
+               if (isset($_REQUEST['search']) && $_REQUEST['search'])
                        {
-                               $query_result++;
-                       }
+                       $where_str = "WHERE name LIKE '%" . 
$GLOBALS['phpgw']->db->db_addslashes($_REQUEST['query']) ."%'" ;
+                       $tg = intval(get_tg($where_str));
 
-                       $GLOBALS['phpgw']->db->limit_query("SELECT con FROM 
newsgroups WHERE name LIKE '%" 
-                                       . 
$GLOBALS['phpgw']->db->db_addslashes($_REQUEST['query']) . "%'$orderby ",
-                               $query_result, __LINE__, __FILE__);
-                       $GLOBALS['phpgw']->db->next_record();
-                       $start = (int)$GLOBALS['phpgw']->db->f('con') - 1;
-                       if($start < 0)
+                       // if 'stop' is set then this is a search
+                       if (isset($_REQUEST['stop']))
                        {
-                               $start = 0;
+                               // Always reset counter for a new search
+                               $start=0;
                        }
                }
 
@@ -149,12 +138,6 @@
                                        . '<input type="hidden" name="stop" 
value="' . ($start + $max) . "\">\n"
                                        . "<input type=\"hidden\" name=\"tg\" 
value=\"{$tg}\">";
 
-               if (isset($query_result) && $query_result)
-               {
-                       $common_hidden_vars .= "<input type=\"hidden\" 
name=\"query_result\" value=\"{$query_result}\" />\n";
-               }
-
-
                $extra_parms = array();
                $extra_parms['tg'] = $tg;
 
@@ -167,9 +150,20 @@
                        $extra_parms['order'] = $order;
                }
 
+               $query_val = get_var('query', array('POST', 'GET'), '');
+               if( $query_val )
+               {
+                       $extra_parms['query'] = $query_val;
+                       $extra_parms['search'] = 'Search' ;
+                       $common_hidden_vars .= 
+                                       "<input type=\"hidden\" name=\"query\" 
value=\"{$query_val}\" />\n" .
+                                       "<input type=\"hidden\" name=\"search\" 
value=\"Search\">";
+                       
+               }
+
                $var = array
                        (
-                               'search_value'          =>      
get_var('query', array('POST'), ''),
+                               'search_value'          =>      $query_val,
                                'search'                =>      lang('search'),
                                'next'                  =>      lang('next'),
                                'nml'                   =>      
$GLOBALS['phpgw']->nextmatchs->left($urlname,intval($start),intval($tg),$extra_parms),
@@ -195,7 +189,7 @@
                        $totaltodisplay = ($tg - $start) - 1;
                }
 
-               $GLOBALS['phpgw']->db->limit_query('SELECT con, name, active 
FROM newsgroups'.$orderby,$start);
+               $GLOBALS['phpgw']->db->limit_query("SELECT con, name, active 
FROM newsgroups $where_str $orderby", $start);
 
                for ( $i = 0; $i < $totaltodisplay; $i++)
                {
@@ -233,8 +227,9 @@
                }
                $var = array
                        (
+                               'common_hidden_vars'    =>      
$common_hidden_vars,
                                'lang_update'   =>      lang('update'),
-                               'checkmark'     =>      
$GLOBALS['phpgw']->common->get_image_path('email').'/check'
+                               'checkmark'     =>      
$GLOBALS['phpgw']->common->get_image_path('email').'/check.gif'
                        );
 
                $p->set_var($var);
@@ -255,6 +250,15 @@
                }
                $GLOBALS['phpgw']->db->unlock();
 
-               $GLOBALS['phpgw']->redirect_link('/nntp/admin.php', 
array('start' => $_REQUEST['start'], 'tg' => $_REQUEST['tg']) );
+               $params = array() ;
+               foreach (array('start', 'tg', 'search', 'query') as $field)
+               {
+                       if (isset($_REQUEST[$field]))
+                       {
+                               $params[$field] = $_REQUEST[$field] ;
+                       }
+               }
+       
+               $GLOBALS['phpgw']->redirect_link('/nntp/admin.php', $params) ;
        }
 ?>

Index: preferences.php
===================================================================
RCS file: /sources/phpgroupware/nntp/preferences.php,v
retrieving revision 1.36.4.1
retrieving revision 1.36.4.2
diff -u -b -r1.36.4.1 -r1.36.4.2
--- preferences.php     15 Dec 2005 14:06:41 -0000      1.36.4.1
+++ preferences.php     24 Oct 2006 13:56:46 -0000      1.36.4.2
@@ -10,7 +10,13 @@
   *  option) any later version.                                              *
   \**************************************************************************/
 
-       /* $Id: preferences.php,v 1.36.4.1 2005/12/15 14:06:41 skwashd Exp $ */
+  /**************************************************************************\
+  * Modified by Steve Price <address@hidden>                         *
+  * Modified to make the search function work properly, and work with the    *
+  * nextmatchs class                                                         *
+  \**************************************************************************/
+
+       /* $Id: preferences.php,v 1.36.4.2 2006/10/24 13:56:46 skwashd Exp $ */
 
        $GLOBALS['phpgw_info']['flags'] = array
                        (
@@ -22,16 +28,18 @@
 
        include('../header.inc.php');
 
-       function get_tg()
+       function get_tg($where='')
        {
                $db = $GLOBALS['phpgw']->db;
-               $db->query("SELECT count(con) FROM newsgroups WHERE 
active='Y'");
+               $db->query("SELECT count(con) FROM newsgroups WHERE active='Y' 
$where");
                $db->next_record();
                $con = $db->f(0);
                unset($db);
                return $con;
        }
        
+       
//===========================================================================================
+       // Update
        if( isset($_REQUEST['submit']) && $_REQUEST['submit'] )
        {
                $GLOBALS['phpgw']->preferences->read_repository();
@@ -57,10 +65,21 @@
                }
                $GLOBALS['phpgw']->preferences->save_repository(True);
 
-               $GLOBALS['phpgw']->redirect_link('/nntp/preferences.php', 
array('start' => $_REQUEST['start'], 'tg' => $_REQUEST['tg']) );
+               $params = array() ;
+               foreach (array('start', 'tg', 'search', 'query') as $field)
+               {
+                       if (isset($_REQUEST[$field]))
+                       {
+                               $params[$field] = $_REQUEST[$field] ;
+                       }
+               }
+       
+               $GLOBALS['phpgw']->redirect_link('/nntp/preferences.php', 
$params );
                $GLOBALS['phpgw']->common->phpgw_exit();
        }
 
+       
//===========================================================================================
+       // View
        if ( !isset($_REQUEST['start']) || !$_REQUEST['start'] )
        {
                $start = 0;
@@ -70,15 +89,6 @@
                $start = (int) $_REQUEST['start'];
        }
 
-       if (!isset($_REQUEST['query_result']) || !$_REQUEST['query_result'] )
-       {
-               $query_result = 0;
-       }
-       else
-       {
-               $query_result = (int) $_REQUEST['query_result'];
-       }
-
        if ( !isset($_REQUEST['order']) || !$_REQUEST['order'] )
        {
                $order = 1;
@@ -111,36 +121,25 @@
 
        $db2 = $GLOBALS['phpgw']->db;
        
-       //FIXME this is ugly shit!
-       $query_result = get_var('query_result', array('POST'), 0);
-       if ( (isset($_REQUEST['search']) && $_REQUEST['search']) || 
(isset($_REQUEST['next']) && $_REQUEST['next']) )
-       {
-               if (isset($_REQUEST['next']) && $_REQUEST['next'])
-               {
-                       $query_result++;
-               }
-               $db2->query("SELECT name FROM newsgroups WHERE 
active='Y'$orderby");
-               $j = 0;
-               $i = 0;
-               while($db2->next_record())
-               {
-                       if (stristr($db2->f('name'),$query))
-                       {
-                               if($i==$query_result)
+               $query_val = get_var('query', array('POST', 'GET'), '');
+
+               $where_str = '' ;
+               if (isset($_REQUEST['search']) && $_REQUEST['search'])
                                {
-                                       $start = $j;
-                                       break;
-                               }
-                               else
+                       $where_str = "AND name LIKE '%" . 
$GLOBALS['phpgw']->db->db_addslashes($query_val) ."%'" ;
+                       $tg = intval(get_tg($where_str));
+
+                       // if 'stop' is set then this is a search
+                       if (isset($_REQUEST['stop']))
                                {
-                                       $i++;
-                               }
-                       }
-                       $j++;
+                               // Always reset counter for a new search
+                               $start=0;
                }
        }
 
-       $querystr = "SELECT con, name FROM newsgroups WHERE active='Y'$orderby";
+
+
+       $querystr = "SELECT con, name FROM newsgroups WHERE active='Y' 
$where_str $orderby";
        $db2->limit_query($querystr,$start,__LINE__,__FILE__);
 
        if(!$db2->num_rows())
@@ -150,8 +149,6 @@
        }
        else
        {
-               $GLOBALS['phpgw']->common->phpgw_header();
-               echo parse_navbar();
                $minarray = Array();
                $nntpavail = Array();
                while($db2->next_record())
@@ -164,6 +161,10 @@
                        $minarray[] = $db2->f('con');
                }
                unset($db2);
+
+               $GLOBALS['phpgw']->common->phpgw_header();
+               echo parse_navbar();
+
        }
 
        $p = 
CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('nntp'));
@@ -178,7 +179,7 @@
 
        if (!isset($tg) || !$tg)
        {
-               $tg = get_tg();
+               $tg = get_tg($where_str);
        }
        $first = count($minarray) ? min($minarray) : 0;
 
@@ -187,6 +188,7 @@
        $common_hidden_vars = '<input type="hidden" name="start" 
value="'.$start.'">'."\n"
                . '<input type="hidden" name="first" value="'.$first.'">'."\n"
                . '<input type="hidden" name="nntparray" 
value="'.urlencode(serialize($minarray)).'">'."\n"
+                                       . '<input type="hidden" name="stop" 
value="' . 1 . "\">\n"
                . '<input type="hidden" name="tg" value="'.$tg.'">'."\n";
        if(isset($order) && $order)
        {
@@ -196,10 +198,6 @@
        {
                $common_hidden_vars .= '<input type="hidden" name="sort" 
value="'.$sort.'">'."\n";
        }
-       if(isset($query_result) && $query_result)
-       {
-               $common_hidden_vars .= '<input type="hidden" 
name="query_result" value="'.$query_result.'">'."\n";
-       }
 
        $extra_parms = '&tg='.$tg;
        if(isset($sort) && $sort)
@@ -211,11 +209,21 @@
                $extra_parms .= '&order='.$order;
        }
 
+               if( $query_val )
+               {
+                       $extra_parms .= '&query='.$query_val;
+                       $extra_parms .='&search=Search' ;
+                       $common_hidden_vars .= 
+                                       "<input type=\"hidden\" name=\"query\" 
value=\"{$query_val}\" />\n" .
+                                       "<input type=\"hidden\" name=\"search\" 
value=\"Search\">";
+                       
+               }
+
        $urlname = '/nntp/preferences.php';
 
        $p->set_var(array
                (
-                       'search_value'          => (isset($query) && 
$query?$query:''),
+                       'search_value'          => $query_val,
                        'search'                => lang('search'),
                        'next'                  => lang('next'),
                        'nml'                   => 
$GLOBALS['phpgw']->nextmatchs->left($urlname,$start,$tg,$extra_parms),
@@ -259,6 +267,7 @@
 
        $p->set_var(array
                (       
+                               'common_hidden_vars'    =>      
$common_hidden_vars,
                        'lang_update'   => lang('update'),
                        'checkmark'     => 
$GLOBALS['phpgw']->common->get_image_path('email').'/check.gif'
                ));

Index: inc/class.decode.inc.php
===================================================================
RCS file: /sources/phpgroupware/nntp/inc/class.decode.inc.php,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.1.2.1
diff -u -b -r1.8.2.1 -r1.8.2.1.2.1
--- inc/class.decode.inc.php    27 Jan 2002 00:34:59 -0000      1.8.2.1
+++ inc/class.decode.inc.php    24 Oct 2006 13:56:46 -0000      1.8.2.1.2.1
@@ -10,7 +10,7 @@
   *  option) any later version.                                              *
   \**************************************************************************/
 
-  /* $Id: class.decode.inc.php,v 1.8.2.1 2002/01/27 00:34:59 skeeter Exp $ */
+  /* $Id: class.decode.inc.php,v 1.8.2.1.2.1 2006/10/24 13:56:46 skwashd Exp $ 
*/
 
        class decode
        {
@@ -192,6 +192,8 @@
                        $mime_encoding = $this->get_mime_encoding($de_part);
 
                        $tag = "pre";
+                       $str="";
+                       
                        //  $jnk = isset($de_part->disposition) ? 
$de_part->disposition : "unknown";
 
                        //  echo "<!-- MIME disp: $jnk -->\n";
@@ -223,7 +225,7 @@
                        }
                        elseif (isset($de_part->subtype) && 
strtoupper($de_part->subtype) == 'HTML')
                        {
-                               $str = 
$this->output_bound($mime_section.':',$mime_type.'/'.$de_part->subtype);
+//                             $str = 
$this->output_bound($mime_section.':',$mime_type.'/'.$de_part->subtype);
                                return $str.$dsp;
                        }
                        elseif (isset($de_part->subtype) && 
@@ -234,12 +236,12 @@
                                strtoupper($de_part->subtype) == 'PNG'))
                        {
                                $att_name = $this->get_att_name($de_part);
-                               $str = 
$this->output_bound($mime_section.':',$mime_type.'/'.$de_part->subtype);
+//                             $str = 
$this->output_bound($mime_section.':',$mime_type.'/'.$de_part->subtype);
                                return 
$str.$this->image_display($dsp,$att_name);
                        }
                        else
                        {
-                               $str = 
$this->output_bound($mime_section.':',$mime_type.'/'.$de_part->subtype);
+//                             $str = 
$this->output_bound($mime_section.':',$mime_type.'/'.$de_part->subtype);
                                return "$str<$tag>$dsp</$tag>\n";
                        }
                }

Index: templates/default/nntp.tpl
===================================================================
RCS file: /sources/phpgroupware/nntp/templates/default/Attic/nntp.tpl,v
retrieving revision 1.8
retrieving revision 1.8.6.1
diff -u -b -r1.8 -r1.8.6.1
--- templates/default/nntp.tpl  17 May 2001 01:51:06 -0000      1.8
+++ templates/default/nntp.tpl  24 Oct 2006 13:56:46 -0000      1.8.6.1
@@ -1,13 +1,21 @@
-<!-- $Id: nntp.tpl,v 1.8 2001/05/17 01:51:06 skeeter Exp $ -->
+<!-- $Id: nntp.tpl,v 1.8.6.1 2006/10/24 13:56:46 skwashd Exp $ -->
 <!-- BEGIN nntp -->
 <script>
 function check_all()
 {
-  for (i=0; i<document.allow.elements.length; i++) {
-      if (document.allow.elements[i].type == "checkbox") {
-        if (document.allow.elements[i].checked) {
+  check=-1;
+  for (i=0; i<document.allow.elements.length; i++) 
+  {
+       if (document.allow.elements[i].type == "checkbox") 
+       {
+               if (check<0) {check = document.allow.elements[i].checked; } 
+               
+               if (check)
+               {
            document.allow.elements[i].checked = false;
-        } else {
+               } 
+               else 
+               {
            document.allow.elements[i].checked = true;
         }
       }        
@@ -24,7 +32,7 @@
           {common_hidden_vars}
           <input type="text" name="query" value="{search_value}">
           <input type="submit" name="search" value="{search}">
-          <input type="submit" name="next" value="{next}">
+<!--          <input type="submit" name="next" value="{next}"> -->
         </form>
        </div>
       </td>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]