source: temp/test-xoops.ec-cube.net/html/modules/rssj/plugins/rssfitj.bluesbb.php @ 405

Revision 405, 7.8 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2###############################################################################
3##                RSSFit - Extendable XML news feed generator                ##
4##                   Copyright (c) 2004 NS Tai (aka tuff)                    ##
5##                       <http://www.brandycoke.com/>                        ##
6##                      Modified By 2005 CACHE RSSfitJ                       ##
7##                       <http://gyakubiki.kir.jp/>                          ##
8###############################################################################
9##                    XOOPS - PHP Content Management System                  ##
10##                       Copyright (c) 2000 XOOPS.org                        ##
11##                          <http://www.xoops.org/>                          ##
12###############################################################################
13##  This program is free software; you can redistribute it and/or modify     ##
14##  it under the terms of the GNU General Public License as published by     ##
15##  the Free Software Foundation; either version 2 of the License, or        ##
16##  (at your option) any later version.                                      ##
17##                                                                           ##
18##  You may not change or alter any portion of this comment or credits       ##
19##  of supporting developers from this source code or any supporting         ##
20##  source code which is considered copyrighted (c) material of the          ##
21##  original comment or credit authors.                                      ##
22##                                                                           ##
23##  This program is distributed in the hope that it will be useful,          ##
24##  but WITHOUT ANY WARRANTY; without even the implied warranty of           ##
25##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            ##
26##  GNU General Public License for more details.                             ##
27##                                                                           ##
28##  You should have received a copy of the GNU General Public License        ##
29##  along with this program; if not, write to the Free Software              ##
30##  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA ##
31###############################################################################
32##  Author of this file: CACHE                                               ##
33##  URL: http://gyakubiki.kir.jp/                                            ##
34##  Project: RSSFitJ                                                         ##
35###############################################################################
36/*
37* Step 0: Stop here if you are not sure what you are doing, it's no fun at all
38* Step 1: Clone this file and rename as rssfitj.[mod_dir].php
39* Step 2: Replace the text "RssfitjSample" with "Rssfitj[mod_dir]" at line 47 and line 55, i.e. "RssfitjNews" for the module "News"
40* Step 3: Modify the word in line 48 from 'sample' to [mod_dir]
41* Step 4: Modify the function "grabEntries" to satisfy your needs
42* Step 5: Move the new plug-in file to the plugins folder, i.e.  your-xoops-root/modules/rss/plugins
43* Step 6: Install your plug-in by pointing your browser to your-xoops-url/modules/rss/admin/index.php
44* [mod_dir]: Name of the driectory of your module, i.e. 'news'
45*/
46
47class RssfitjBluesbb{
48    var $dirname = 'bluesbb';
49    var $modname;
50   
51    /*
52    * private
53    * Nothing here so far
54    */
55    function RssfitjBluesbb(){
56    }
57   
58    function loadModule(){
59        global $module_handler;
60        $mod = $module_handler->getByDirname($this->dirname);
61        if( !$mod || !$mod->getVar('isactive') ){
62            return false;
63        }
64        $this->modname = $mod->getVar('name');
65        return $mod;
66    }
67
68    /*
69    * public
70    * return module name
71    */
72    function getDirName(){
73        return $this->dirname;
74    }
75
76    function grabEntries(&$obj){
77        global $xoopsDB;
78
79        $myts =& MyTextSanitizer::getInstance();
80        $ret = array();
81        $i = 0;
82
83        if ($obj->getVar('rssfj_param')) {
84            $rcdId=explode(',',$obj->getVar('rssfj_param'));
85            $Farray=array();
86            $farray=array();
87            $Tarray=array();
88            $tarray=array();
89            $Carray=array();
90            $carray=array();
91            $Garray=array();
92            $garray=array();
93            foreach ($rcdId as $eachId) {
94                if (substr($eachId,0,1)=='F')
95                    array_push($Farray,substr($eachId,1,strlen($eachId)-1));
96                if (substr($eachId,0,1)=='f')
97                    array_push($farray,substr($eachId,1,strlen($eachId)-1));
98                if (substr($eachId,0,1)=='T')
99                    array_push($Tarray,substr($eachId,1,strlen($eachId)-1));
100                if (substr($eachId,0,1)=='N' || substr($eachId,0,1)=='t')
101                    array_push($tarray,substr($eachId,1,strlen($eachId)-1));
102                if (substr($eachId,0,1)=='C')
103                    array_push($Carray,substr($eachId,1,strlen($eachId)-1));
104                if (substr($eachId,0,1)=='c')
105                    array_push($carray,substr($eachId,1,strlen($eachId)-1));
106                if (substr($eachId,0,1)=='G')
107                    array_push($Garray,substr($eachId,1,strlen($eachId)-1));
108                if (substr($eachId,0,1)=='g')
109                    array_push($garray,substr($eachId,1,strlen($eachId)-1));
110            }
111            $add_sql="";
112            if (count($Tarray)) {
113                $add_sql.=" AND (";
114                foreach($Tarray as $TopicId) {
115                    $add_sql .= "t.sread_id=".$TopicId." OR ";
116                }
117                $add_sql = substr($add_sql,0,strlen($add_sql)-4);
118                $add_sql .= ")";
119            }
120            if (count($tarray)) {
121                $add_sql.=" AND NOT(";
122                foreach($tarray as $TopicId) {
123                    $add_sql .= "t.sread_id=".$TopicId." OR ";
124                }
125                $add_sql = substr($add_sql,0,strlen($add_sql)-4);
126                $add_sql .= ")";
127            }
128            if (count($Farray)) {
129                $add_sql.=" AND (";
130                foreach($Farray as $forumId) {
131                    $add_sql .= "t.topic_id=".$forumId." OR ";
132                }
133                $add_sql = substr($add_sql,0,strlen($add_sql)-4);
134                $add_sql .= ")";
135            }
136            if (count($farray)) {
137                $add_sql.=" AND NOT(";
138                foreach($farray as $forumId) {
139                    $add_sql .= "t.topic_id=".$forumId." OR ";
140                }
141                $add_sql = substr($add_sql,0,strlen($add_sql)-4);
142                $add_sql .= ")";
143            }
144            if (count($Carray)) {
145                $add_sql.=" AND (";
146                foreach($Carray as $CatId) {
147                    $add_sql .= "f.cat_id=".$CatId." OR ";
148                }
149                $add_sql = substr($add_sql,0,strlen($add_sql)-4);
150                $add_sql .= ")";
151            }
152            if (count($carray)) {
153                $add_sql.=" AND NOT(";
154                foreach($carray as $CatId) {
155                    $add_sql .= "f.cat_id=".$CatId." OR ";
156                }
157                $add_sql = substr($add_sql,0,strlen($add_sql)-4);
158                $add_sql .= ")";
159            }
160            $add_sql2="";
161            if (count($Garray)) {
162                foreach($Garray as $GroupId) {
163                    $add_sql2 .= " OR (f.topic_access=6 AND f.topic_group=".$GroupId.")";
164                }
165            }
166            if (count($garray)) {
167                foreach($garray as $GroupId) {
168                    $add_sql2 .= " OR (f.topic_access=6 AND f.topic_group<>".$GroupId.")";
169                }
170            }
171        } else {
172            $add_sql="";
173            $add_sql2="";
174        }
175
176        $sql = 'SELECT t.post_id, t.topic_id, t.sread_id, t.res_id, t.title, t.message, t.post_time, f.topic_name, c.cat_title FROM '.$xoopsDB->prefix('bluesbb').' t, '.$xoopsDB->prefix('bluesbb_topic').' f, '.$xoopsDB->prefix('bluesbb_categories').' c WHERE f.topic_id = t.topic_id AND f.cat_id = c.cat_id'.$add_sql.' AND (f.topic_access <= 2 OR f.topic_access=5'.$add_sql2.') ORDER BY t.post_time DESC';
177        if( !$result = $xoopsDB->query($sql, $obj->getVar('rssfj_grab'), 0) ){
178            return false;
179        }
180
181        while( $row = $xoopsDB->fetchArray($result) ){
182            $desc = $myts->makeTareaData4Show($row['message']);
183            $link = XOOPS_URL.'/modules/'.$this->dirname.'/viewsread.php?topic='.$row['topic_id'].'&amp;sread_id='.$row['sread_id'].'&amp;number=l50';
184        //  required
185            $desc2=$this->modname." : ".$row['cat_title']." : ".$row['topic_name']." : ".$row['title'];
186            $ret[$i]['title'] = $myts->makeTareaData4Show($desc2);
187            $ret[$i]['link'] = $ret[$i]['guid'] = $link;
188            $ret[$i]['timestamp'] = $row['post_time'];
189            $ret[$i]['description'] = $desc;
190        //  optional
191            $ret[$i]['category'] = $this->modname;
192            $ret[$i]['domain'] = XOOPS_URL.'/modules/'.$this->dirname.'/';          $i++;
193        }
194        return $ret;
195    }
196}
197
198?>
Note: See TracBrowser for help on using the repository browser.