source: temp/test-xoops.ec-cube.net/html/modules/newbb/blocks/newbb_new.php @ 405

Revision 405, 7.2 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: newbb_new.php,v 1.4 2005/08/03 12:39:13 onokazu Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7//  ------------------------------------------------------------------------ //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27// Author: Kazumi Ono (AKA onokazu)                                          //
28// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
29// Project: The XOOPS Project                                                //
30// ------------------------------------------------------------------------- //
31// Recent private forums block (Bloc Forum privé©                            //
32// Author: L'éñuipe de TheNetSpace ( http://www.thenetspace.com )            //
33// ------------------------------------------------------------------------- //
34
35function b_newbb_new_show($options) {
36    $db =& Database::getInstance();
37    $myts =& MyTextSanitizer::getInstance();
38    $block = array();
39    switch($options[2]) {
40    case 'views':
41        $order = 't.topic_views';
42        break;
43    case 'replies':
44        $order = 't.topic_replies';
45        break;
46    case 'time':
47    default:
48        $order = 't.topic_time';
49        break;
50    }
51    $query='SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.topic_time, t.topic_views, t.topic_replies, t.forum_id, f.forum_name FROM '.$db->prefix('bb_topics').' t, '.$db->prefix('bb_forums').' f WHERE f.forum_id=t.forum_id AND f.forum_type <> 1 ORDER BY '.$order.' DESC';
52    if (!$result = $db->query($query,$options[0],0)) {
53        return false;
54    }
55    if ( $options[1] != 0 ) {
56        $block['full_view'] = true;
57    } else {
58        $block['full_view'] = false;
59    }
60    $block['lang_forum'] = _MB_NEWBB_FORUM;
61    $block['lang_topic'] = _MB_NEWBB_TOPIC;
62    $block['lang_replies'] = _MB_NEWBB_RPLS;
63    $block['lang_views'] = _MB_NEWBB_VIEWS;
64    $block['lang_lastpost'] = _MB_NEWBB_LPOST;
65    $block['lang_visitforums'] = _MB_NEWBB_VSTFRMS;
66    while ($arr = $db->fetchArray($result)) {
67        $topic['forum_id'] = $arr['forum_id'];
68        $topic['forum_name'] = $myts->makeTboxData4Show($arr['forum_name']);
69        $topic['id'] = $arr['topic_id'];
70        $topic['title'] = $myts->makeTboxData4Show($arr['topic_title']);
71        $topic['replies'] = $arr['topic_replies'];
72        $topic['views'] = $arr['topic_views'];
73        $topic['post_id'] = $arr['topic_last_post_id'];
74        $lastpostername = $db->query("SELECT post_id, uid FROM ".$db->prefix("bb_posts")." WHERE post_id = ".$topic['post_id']);
75        while ($tmpdb=$db->fetchArray($lastpostername)) {
76            $tmpuser = XoopsUser::getUnameFromId($tmpdb['uid']);
77            //if ( $options[1] != 0 ) {
78                $topic['time'] = formatTimestamp($arr['topic_time'],'m')." $tmpuser";
79            //}
80        }
81        $block['topics'][] =& $topic;
82        unset($topic);
83    }
84    return $block;
85}
86
87function b_newbb_new_private_show($options) {
88    $db =& Database::getInstance();
89    $myts =& MyTextSanitizer::getInstance();
90    $block = array();
91    switch($options[2]) {
92    case 'views':
93        $order = 't.topic_views';
94        break;
95    case 'replies':
96        $order = 't.topic_replies';
97        break;
98    case 'time':
99    default:
100        $order = 't.topic_time';
101        break;
102    }
103    $query='SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.topic_time, t.topic_views, t.topic_replies, t.forum_id, f.forum_name FROM '.$db->prefix('bb_topics').' t, '.$db->prefix('bb_forums').' f WHERE f.forum_id=t.forum_id AND f.forum_type = 1 ORDER BY '.$order.' DESC';
104
105    if (!$result = $db->query($query,$options[0],0)) {
106        return false;
107    }
108    if ( $options[1] != 0 ) {
109        $block['full_view'] = true;
110    } else {
111        $block['full_view'] = false;
112    }
113    $block['lang_forum'] = _MB_NEWBB_FORUM;
114    $block['lang_topic'] = _MB_NEWBB_TOPIC;
115    $block['lang_replies'] = _MB_NEWBB_RPLS;
116    $block['lang_views'] = _MB_NEWBB_VIEWS;
117    $block['lang_lastpost'] = _MB_NEWBB_LPOST;
118    $block['lang_visitforums'] = _MB_NEWBB_VSTFRMS;
119    while ($arr = $db->fetchArray($result)) {
120        $topic['forum_id'] = $arr['forum_id'];
121        $topic['forum_name'] = $myts->makeTboxData4Show($arr['forum_name']);
122        $topic['id'] = $arr['topic_id'];
123        $topic['title'] = $myts->makeTboxData4Show($arr['topic_title']);
124        $topic['replies'] = $arr['topic_replies'];
125        $topic['views'] = $arr['topic_views'];
126        $tmpuser2 = $arr['topic_last_post_id'];
127        $lastpostername = $db->query("SELECT post_id, uid FROM ".$db->prefix("bb_posts")." WHERE post_id = $tmpuser2");
128        while ($tmpdb=$db->fetchArray($lastpostername)) {
129            $tmpuser = XoopsUser::getUnameFromId($tmpdb['uid']);
130            if ( $options[1] != 0 ) {
131                $topic['time'] = formatTimestamp($arr['topic_time'],'m')." $tmpuser";
132            }
133        }
134        $block['topics'][] =& $topic;
135        unset($topic);
136    }
137    return $block;
138}
139
140function b_newbb_new_edit($options) {
141    $inputtag = "<input type='text' name='options[0]' value='".$options[0]."' />";
142    $form = sprintf(_MB_NEWBB_DISPLAY,$inputtag);
143    $form .= "<br />"._MB_NEWBB_DISPLAYF."&nbsp;<input type='radio' name='options[1]' value='1'";
144    if ( $options[1] == 1 ) {
145        $form .= " checked='checked'";
146    }
147    $form .= " />&nbsp;"._YES."<input type='radio' name='options[1]' value='0'";
148    if ( $options[1] == 0 ) {
149        $form .= " checked='checked'";
150    }
151    $form .= " />&nbsp;"._NO;
152    $form .= '<input type="hidden" name="options[2]" value="'.$options[2].'" />';
153    return $form;
154}
155
156?>
Note: See TracBrowser for help on using the repository browser.