userFilter.php

Go to the documentation of this file.
00001 <?php
00002   /*
00003    This file is part of DocBookWiki.  DocBookWiki is a web application
00004    that displays and edits DocBook documents.
00005 
00006    Copyright (C) 2004, 2005, 2006, 2007
00007    Dashamir Hoxha, dashohoxha@users.sourceforge.net
00008 
00009    DocBookWiki is free software; you can redistribute it and/or modify
00010    it under the  terms of the GNU General  Public License as published
00011    by the Free  Software Foundation; either version 2  of the License,
00012    or (at your option) any later version.
00013 
00014    DocBookWiki is distributed in the  hope that it will be useful, but
00015    WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
00016    MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
00017    General Public License for more details.
00018 
00019    You should have  received a copy of the  GNU General Public License
00020    along  with  DocBookWiki;  if  not,  write  to  the  Free  Software
00021    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022    USA
00023   */
00024 
00034 class userFilter extends WebObject
00035 {
00036   function init()
00037   {
00038     $this->addSVars( array(
00039                            'username' => '',
00040                            'realname' => '',
00041                            'email' => '',
00042                            'books' => '',
00043                            'level' => '',
00044                            'nodes' => '',
00045                            'langs' => '',
00046                            'filter' => '1'
00047                            ) );
00048   }
00049 
00050   function onParse()
00051   {
00052     $this->buildFilter();
00053   }
00054 
00055   function buildFilter()
00056   {
00057     //get state vars
00058     extract($this->getSVars());
00059 
00060     $arr_filters = array();
00061     if ($username != '')
00062       {
00063         $arr_filters[] = '($1 ~ "'.$username.'")';
00064       }
00065 
00066     if ($realname != '')
00067       {
00068         $arr_filters[] = '($3 ~ "'.$realname.'")';
00069       }
00070 
00071     if ($email != '')
00072       {
00073         $arr_filters[] = '($4 ~ "'.$email.'")';
00074       }
00075 
00076     if ($books != '')
00077       {
00078         $arr_filters[] = '($5 ~ "'.$books.'")';
00079       }
00080 
00081     $filter = implode(' && ', $arr_filters);
00082 
00083     if ($filter=='')  $filter = '1';
00084     $filter = '('.$filter.')';
00085     $filter = str_replace('"', '\\"', $filter);
00086     $filter = str_replace('$', '\\$', $filter);
00087 
00088     $this->setSVar('filter', $filter);
00089   }  
00090 }
00091 ?>

Generated on Wed Jan 9 08:27:32 2008 for DokBookWiki by  doxygen 1.5.2