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

Revision 405, 38.3 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2/***************************************************************************
3                          admin_forums.php  -  description
4                             -------------------
5    begin                : Wed July 19 2000
6    copyright            : (C) 2001 The phpBB Group
7    email                : [email protected]
8
9    $Id: admin_forums.php,v 1.5 2005/09/04 20:46:10 onokazu Exp $
10 ***************************************************************************/
11
12/***************************************************************************
13 *
14 *   This program is free software; you can redistribute it and/or modify
15 *   it under the terms of the GNU General Public License as published by
16 *   the Free Software Foundation; either version 2 of the License, or
17 *   (at your option) any later version.
18 *
19 ***************************************************************************/
20
21include '../../../include/cp_header.php';
22include '../functions.php';
23include '../config.php';
24
25if (!empty($_GET['mode'])){
26    $mode = $_GET['mode'];
27} elseif (!empty($_POST['mode'])) {
28    $mode = $_POST['mode'];
29}
30
31switch (trim($mode)) {
32case 'editforum':
33    $myts =& MyTextSanitizer::getInstance();
34    if ( isset($_POST['save']) && $_POST['save'] != "" ) {
35        if ( empty($_POST['delete']) ) {
36            foreach (array('name', 'desc') as $k) {
37                $$k = !empty($_POST[$k]) ? trim($myts->stripSlashesGPC($_POST[$k])) : '';
38            }
39            foreach (array('type', 'cat', 'forum_access', 'html', 'sig', 'ppp', 'hot', 'tpp', 'forum') as $k) {
40                $$k = !empty($_POST[$k]) ? intval($_POST[$k]) : 0;
41            }
42            $sql = sprintf("UPDATE %s SET forum_name = %s, forum_desc = %s, forum_type = %s, cat_id = %u, forum_access = %u, allow_html = %s, allow_sig = %s, posts_per_page = %u, hot_threshold = %u, topics_per_page = %u WHERE forum_id = %u", $xoopsDB->prefix("bb_forums"), $xoopsDB->quoteString($name), $xoopsDB->quoteString($desc), $xoopsDB->quoteString($type), $cat, $forum_access, $xoopsDB->quoteString($html), $xoopsDB->quoteString($sig), $ppp, $hot, $tpp, $forum);
43
44            if ( !$r = $xoopsDB->query($sql) ) {
45                redirect_header("./index.php", 1);
46                exit();
47            }
48            $count = 0;
49            if ( isset($_POST["mods"]) ) {
50                while ( list($null, $mod) = each($_POST["mods"]) ) {
51                    $mod_data = new XoopsUser($mod);
52                    if ( $mod_data->isActive() ) {
53                        $sql = sprintf("INSERT INTO %s (forum_id, user_id) VALUES (%u, %u)", $xoopsDB->prefix("bb_forum_mods"), $forum, $mod);
54                        if ( !$xoopsDB->query($sql) ) {
55                            redirect_header("./index.php", 1);
56                            exit();
57                        }
58                    }
59                }
60            }
61            if (empty($_POST["mods"])) {
62                $current_mods = "SELECT count(*) AS total FROM ".$xoopsDB->prefix("bb_forum_mods")." WHERE forum_id = $forum";
63                $r = $xoopsDB->query($current_mods);
64                list($total) = $xoopsDB->fetchRow($r);
65            } else {
66                $total = count($_POST["mods"]) + 1;
67            }
68
69            if ( !empty($_POST["rem_mods"]) && $total > 1 ) {
70                while ( list($null, $mod) = each($_POST["rem_mods"]) ) {
71                    $sql = sprintf("DELETE FROM %s WHERE forum_id = %u AND user_id = %u", $xoopsDB->prefix("bb_forum_mods"), $forum, $mod);
72                    if ( !$xoopsDB->query($sql) ) {
73                        redirect_header("./index.php", 1);
74                        exit();
75                    }
76                }
77            } else {
78                if (!empty($_POST["rem_mods"])) {
79                    $mod_not_removed = 1;
80                }
81            }
82            if (!empty($mod_not_removed)) {
83                redirect_header("./index.php", 1, _MD_A_FORUMUPDATED."<br />"._MD_A_HTSMHNBRBITHBTWNLBAMOTF);
84            }else{
85                redirect_header("./index.php", 1, _MD_A_FORUMUPDATED);
86            }
87        } else {
88            $forum = !empty($_POST['forum']) ? intval($_POST['forum']) : 0;
89            $sql = "SELECT post_id FROM ".$xoopsDB->prefix("bb_posts")." WHERE forum_id = $forum";
90            if ( !$r = $xoopsDB->query($sql) ) {
91                redirect_header("./index.php", 1);
92                exit();
93            }
94            if ( $xoopsDB->getRowsNum($r) > 0 ) {
95                $sql = "DELETE FROM ".$xoopsDB->prefix("bb_posts_text")." WHERE ";
96                $looped = false;
97                while ( $ids = $xoopsDB->fetchArray($r) ) {
98                    if ( $looped == true ) {
99                        $sql .= " OR ";
100                    }
101                    $sql .= "post_id = ".$ids["post_id"]." ";
102                    $looped = true;
103                }
104                if ( !$r = $xoopsDB->query($sql) ) {
105                    redirect_header("./index.php", 1);
106                    exit();
107                }
108                $sql = sprintf("DELETE FROM %s WHERE forum_id = %u", $xoopsDB->prefix("bb_posts"), $forum);
109                if ( !$r = $xoopsDB->query($sql) ) {
110                    redirect_header("./index.php", 1);
111                    exit();
112                }
113            }
114            // RMV-NOTIFY
115            xoops_notification_deletebyitem ($xoopsModule->getVar('mid'), 'forum', $forum);
116            // Get list of all topics in forum, to delete them too
117            $sql = sprintf("SELECT topic_id FROM %s WHERE forum_id = %u", $xoopsDB->prefix("bb_topics"), $forum);
118            if ($r = $xoopsDB->query($sql)) {
119                while ($row = $xoopsDB->fetchArray($r)) {
120                    xoops_notification_deletebyitem ($xoopsModule->getVar('mid'), 'thread', $row['topic_id']);
121                }
122            }
123
124            $sql = sprintf("DELETE FROM %s WHERE forum_id = %u", $xoopsDB->prefix("bb_topics"), $forum);
125            if ( !$r = $xoopsDB->query($sql) ) {
126                redirect_header("./index.php", 1);
127                exit();
128            }
129            $sql = sprintf("DELETE FROM %s WHERE forum_id = %u", $xoopsDB->prefix("bb_forums"), $forum);
130            if ( !$r = $xoopsDB->query($sql) ) {
131                redirect_header("./index.php", 1);
132                exit();
133            }
134
135            $sql = sprintf("DELETE FROM %s WHERE forum_id = %u", $xoopsDB->prefix("bb_forum_mods"), $forum);
136            if ( !$r = $xoopsDB->query($sql) ) {
137                redirect_header("./index.php", 1);
138                exit();
139            }
140            redirect_header("./index.php", 1, _MD_A_FORUMREMOVED);
141        }
142    }
143    if ( isset($_POST['submit']) && !isset($_POST['save']) ) {
144        $forum = !empty($_POST['forum']) ? intval($_POST['forum']) : 0;
145        $sql = "SELECT * FROM ".$xoopsDB->prefix("bb_forums")." WHERE forum_id = $forum";
146        if ( !$result = $xoopsDB->query($sql) ) {
147            redirect_header("./index.php", 1);
148            exit();
149        }
150        if ( !$myrow = $xoopsDB->fetchArray($result) ) {
151             redirect_header("./index.php", 1, _MD_A_NOSUCHFORUM);
152        }
153        $name = $myts->makeTboxData4Edit($myrow['forum_name']);
154        $desc = $myts->makeTareaData4Edit($myrow['forum_desc']);
155        xoops_cp_header();
156        echo"<table width='100%' border='0' cellspacing='1' class='outer'>"
157        ."<tr><td class=\"odd\">";
158        echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
159        ?>
160        <form action="<?php echo xoops_getenv('PHP_SELF'); ?>" method='post'>
161        <table border="0" cellpadding="1" cellspacing="0" align='center' valign="top" width="95%"><tr><td class='bg2'>
162        <table border="0" cellpadding="1" cellspacing="1" width="100%">
163        <tr class='bg3' align='left'>
164        <td align='center' colspan="2"><span class='fg2'><b><?php echo _MD_A_EDITTHISFORUM;?></b></span></td>
165        </tr>
166        <tr class='bg1' align='left'>
167        <td colspan=2><input type="checkbox" name='delete' value="1" /><span class='fg2'> <?php echo _MD_A_DTFTWARAPITF;?></span></td>
168        </tr>
169        <tr class='bg1' align='left'>
170        <td><span class='fg2'><?php echo _MD_A_FORUMNAME;?></span></td>
171        <td><input type='text' name='name' size="40" maxlength="150" value="<?php echo $name?>" /></td>
172        </tr>
173        <tr class='bg1' align='left'>
174        <td><span class='fg2'><?php echo _MD_A_FORUMDESCRIPTION;?></span></td>
175        <td><textarea name='desc' rows="15" cols="45" wrap="virtual"><?php echo $desc?></textarea></td>
176        </tr>
177        <tr class='bg1' align='left'>
178        <td valign="top"><span class='fg2'><?php echo _MD_A_MODERATOR;?></span></td>
179        <td><b>Current:</b><br />
180        <?php
181        $sql = "SELECT u.uname, u.uid FROM ".$xoopsDB->prefix("users")." u, ".$xoopsDB->prefix("bb_forum_mods")." f WHERE f.forum_id = $forum AND u.uid = f.user_id";
182        if ( !$r = $xoopsDB->query($sql) ) {
183            echo"</td></tr></table></td></tr></table></form></td></tr></table>";
184            xoops_cp_footer();
185            exit();
186        }
187        $current_mods = array();
188        if ( $row = $xoopsDB->fetchArray($r) ) {
189            do {
190                echo $row['uname']." (<input type=\"checkbox\" name=\"rem_mods[]\" value=\"".$row['uid']."\" /> "._MD_A_REMOVE.")<br />";
191                $current_mods[] = $row['uid'];
192            } while ( $row = $xoopsDB->fetchArray($r) );
193            echo "<br />";
194        } else {
195            echo _MD_A_NOMODERATORASSIGNED."<br /><br />\n";
196        }
197
198        ?>
199        <b>Add:</b><br />
200        <select name='mods[]' size="5" multiple>
201        <?php
202        $sql = "SELECT uid, uname FROM ".$xoopsDB->prefix("users")." WHERE uid > 0 AND level > 0 ";
203        while ( list($null, $currMod) = each($current_mods) ) {
204            $sql .= "AND uid != $currMod ";
205        }
206        $sql .= "ORDER BY uname";
207        if ( !$r = $xoopsDB->query($sql) ) {
208            echo"</td></tr></table></td></tr></table></form></td></tr></table>";
209            xoops_cp_footer();
210            exit();
211        }
212        if ( $row = $xoopsDB->fetchArray($r) ) {
213            do {
214                $s = "";
215                if ( $row['uid'] == $myrow['forum_moderator'] ) {
216                    $s = " selected='selected'";
217                }
218                echo "<option value=\"".$row['uid']."\"$s>".$row['uname']."</option>\n";
219            } while ( $row = $xoopsDB->fetchArray($r) );
220        } else {
221            echo "<option value=\"0\">"._MD_A_NONE."</option>\n";
222        }
223        ?>
224        </select></td>
225        </tr>
226        <tr class='bg1' align='left'>
227        <td><span class='fg2'><?php echo _MD_A_CATEGORY;?></span></td>
228        <td><select name='cat'>
229        <?php
230        $sql = "SELECT * FROM ".$xoopsDB->prefix("bb_categories")."";
231        if ( !$r = $xoopsDB->query($sql) ) {
232            echo"</td></tr></table>";
233            xoops_cp_footer();
234            exit();
235        }
236        if ( $row = $xoopsDB->fetchArray($r) ) {
237            do {
238                $s = "";
239                if ( $row['cat_id'] == $myrow['cat_id'] ) {
240                    $s = " selected='selected'";
241                }
242                echo "<option value=\"".$row['cat_id']."\"$s>".$row['cat_title']."</option>\n";
243            } while ( $row = $xoopsDB->fetchArray($r) );
244        } else {
245            echo "<option value=\"0\">"._MD_A_NONE."</option>\n";
246        }
247        ?>
248        </select></td>
249        <?php
250        $access1 = $access2 = $access3 = '';
251        if ( $myrow['forum_access'] == 1 ) {
252            $access1 = " selected='selected'";
253        }
254        if ( $myrow['forum_access'] == 2 ) {
255            $access2 = " selected='selected'";
256        }
257        if ( $myrow['forum_access'] == 3 ) {
258            $access3 = " selected='selected'";
259        }
260        ?>
261        </tr>
262        <tr class='bg1' align='left'>
263        <td><span class='fg2'>Access Level:</span></td>
264        <td><select name='forum_access'>
265        <option value="2"<?php echo $access2?>><?php echo _MD_A_ANONYMOUSPOST;?></option>
266        <option value="1"<?php echo $access1?>><?php echo _MD_A_REGISTERUSERONLY;?></option>
267        <option value="3"<?php echo $access3?>><?php echo _MD_A_MODERATORANDADMINONLY;?></option>
268        </select>
269        </td>
270        </tr>
271        <tr class='bg1' align='left'>
272        <td><span class='fg2'><?php echo _MD_A_TYPE;?></span></td>
273        <td><select name='type'>
274        <?php
275        $pub = $priv = '';
276        if ( $myrow['forum_type'] == 1 ) {
277            $priv = " selected='selected'";
278        } else {
279            $pub = " selected='selected'";
280        }
281        ?>
282        <option value="0"<?php echo $pub?>><?php echo _MD_A_PUBLIC;?></option>
283        <option value="1"<?php echo $priv?>><?php echo _MD_A_PRIVATE;?></option>
284        </select>
285        </td>
286        </tr>
287        <?php
288        $html_yes = $html_no = $sig_yes = $sig_no = "";
289        if ( $myrow['allow_html'] == 1 ) {
290            $html_yes = " checked='checked'";
291        } else {
292            $html_no = " checked='checked'";
293        }
294        if ( $myrow['allow_sig'] == 1) {
295            $sig_yes = " checked='checked'";
296        } else {
297            $sig_no = " checked='checked'";
298        }
299        echo "<tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_ALLOWHTML ."</span></td>          <td><input type='radio' name='html' value='1'".$html_yes." />"._MD_A_YES."<input type='radio' name='html' value='0'".$html_no." />"._MD_A_NO ."</td></tr>
300        <tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_ALLOWSIGNATURES ."</span></td>
301        <td><input type='radio' name='sig' value='1'$sig_yes />". _MD_A_YES ."<input type='radio' name='sig' value='0'$sig_no />". _MD_A_NO ."</td></tr>
302        <tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_HOTTOPICTHRESHOLD ."</span></td><td><input type='text' name='hot' size='3' maxlength='3' value='". $myrow['hot_threshold']."' /></td></tr>
303        <tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_POSTPERPAGE ."</span><br /><span class='fg2'><i>". _MD_A_TITNOPPTTWBDPPOT ."</i></span></td>
304        <td><input type='text' name='ppp' size='3' maxlength='3' value='".$myrow['posts_per_page']."' /></td></tr>
305        <tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_TOPICPERFORUM ."</span><br /><span class='fg2'><i>". _MD_A_TITNOTPFTWBDPPOAF ."</i></span></td><td><input type='text' name='tpp' size='3' maxlength='3' value='". $myrow['topics_per_page'] ."' /></td></tr>";
306        echo "<tr class='bg3' align='left'><td align='center' colspan='2'><input type='hidden' name='mode' value='editforum' /><input type='hidden' name='forum' value='$forum' /><input type='submit' name='save' value='". _MD_A_SAVECHANGES ."' />&nbsp;&nbsp;<input type='reset' value='". _MD_A_CLEAR ."' /></td></tr>";
307        echo "</table></td></tr></table></form>";
308    }
309    if ( !isset($_POST['submit']) && !isset($_POST['save']) ) {
310        xoops_cp_header();
311        echo"<table width='100%' border='0' cellspacing='1' class='outer'>"
312        ."<tr><td class=\"odd\">";
313        echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
314        ?>
315        <form action="<?php echo xoops_getenv('PHP_SELF'); ?>" method='post'>
316        <table border="0" cellpadding="1" cellspacing="0" align='center' valign="TOP" width="95%"><tr><td class='bg2'>
317        <table border="0" cellpadding="1" cellspacing="1" width="100%">
318        <tr class='bg3' align='left'>
319        <td align='center' colspan="2"><span class='fg2'><b><?php echo _MD_A_SELECTFORUMEDIT;?></b><span class='fg2'></td>
320        </tr>
321        <tr class='bg1' align='left'>
322        <td align='center' colspan="2"><select name='forum' size="0">
323        <?php
324        $sql = "SELECT forum_name, forum_id FROM ".$xoopsDB->prefix("bb_forums")." ORDER BY forum_id";
325        if ( $result = $xoopsDB->query($sql) ) {
326            if ( $myrow = $xoopsDB->fetchArray($result) ) {
327                do {
328                    $name = $myts->makeTboxData4Show($myrow['forum_name']);
329                    echo "<option value=\"".$myrow['forum_id']."\">$name</option>\n";
330                } while ( $myrow = $xoopsDB->fetchArray($result) );
331            } else {
332                echo "<option value=\"-1\">"._MD_A_NOFORUMINDATABASE."</option>\n";
333            }
334        } else {
335            echo "<option value=\"-1\">"._MD_A_DATABASEERROR."</option>\n";
336        }
337        ?>
338        </select></td>
339        </tr>
340        <tr class='bg3' align='left'>
341        <td align='center' colspan="2">
342        <input type="hidden" name='mode' value="editforum" />
343        <input type='submit' name='submit' value="<?php echo _MD_A_EDIT;?>" />&nbsp;&nbsp;
344        </td>
345        </tr>
346        </table></td></tr></table></form>
347        <?php
348    }
349    break;
350
351case 'editcat':
352    $myts =& MyTextSanitizer::getInstance();
353    if ( isset($_POST['submit']) && isset($_POST['save']) ) {
354        $new_title = $myts->stripSlashesGPC($_POST['new_title']);
355        $cat_id = !empty($_POST['cat_id']) ? intval($_POST['cat_id']) : 0;
356        $sql = "UPDATE ".$xoopsDB->prefix("bb_categories")." SET cat_title = ".$xoopsDB->quoteString($new_title)." WHERE cat_id = $cat_id";
357        if ( !$result = $xoopsDB->query($sql) ) {
358            redirect_header("./index.php", 1);
359            exit();
360        } else {
361            redirect_header("./index.php", 1, _MD_A_CATEGORYUPDATED);
362        }
363    } else if(isset($_POST['submit']) && $_POST['submit'] != "") {
364        $sql = "SELECT cat_title FROM ".$xoopsDB->prefix("bb_categories")." WHERE cat_id = ".intval($_POST['cat']);
365        if ( !$result = $xoopsDB->query($sql) ) {
366            redirect_header("./index.php", 1);
367            exit();
368        }
369        xoops_cp_header();
370        echo"<table width='100%' border='0' cellspacing='1' class='outer'>"
371        ."<tr><td class=\"odd\">";
372        echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
373        $cat_data = $xoopsDB->fetchArray($result);
374        $cat_title = $myts->makeTboxData4Edit($cat_data["cat_title"]);
375        ?>
376        <form action="<?php echo xoops_getenv('PHP_SELF'); ?>" method='post'>
377        <table border="0" cellpadding="1" cellspacing="0" align='center' valign="top" width="95%"><tr><td class='bg2'>
378        <table border="0" cellpadding="1" cellspacing="1" width="100%">
379        <tr class='bg3' align='left'>
380        <td align='center' colspan="2"><span class='fg2'><b><?php echo _MD_A_EDITCATEGORY;?> <?php echo $cat_title ?></b><span class='fg2'></td>
381        </tr>
382        <tr class='bg1' align='left'>
383        <td><?php echo _MD_A_CATEGORYTITLE;?></td>
384        <td><input type="text" name="new_title" value="<?php echo $cat_title ?>" size="45" maxlength="100" /></td>
385        </tr>
386        <tr class='bg3' align='left'>
387        <td align='center' colspan="2">
388        <input type="hidden" name='mode' value="editcat" />
389        <input type="hidden" name="save" value="true" />
390        <input type="hidden" name="cat_id" value="<?php echo intval($_POST['cat']);?>" />
391        <input type='submit' name='submit' value="<?php echo _MD_A_SAVECHANGES;?>" />
392        </td>
393        </tr>
394        </table></td></tr></table></form>
395        <?php
396    } else {
397        $sql = "SELECT cat_id, cat_title FROM ".$xoopsDB->prefix("bb_categories")." ORDER BY cat_order";
398        if ( !$result = $xoopsDB->query($sql) ) {
399            redirect_header("./index.php", 1);
400            exit();
401        }
402        xoops_cp_header();
403        echo"<table width='100%' border='0' cellspacing='1' class='outer'>"
404        ."<tr><td class=\"odd\">";
405        echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
406        ?>
407        <form action="<?php echo xoops_getenv('PHP_SELF'); ?>" method='post'>
408        <table border="0" cellpadding="1" cellspacing="0" align='center' valign="top" width="95%"><tr><td class='bg2'>
409        <table border="0" cellpadding="1" cellspacing="1" width="100%">
410        <tr class='bg3' align='left'>
411        <td align='center' colspan="2"><span class='fg2'><b><?php echo _MD_A_SELECTACATEGORYEDIT;?></b><span class='fg2'></td>
412        </tr>
413        <tr class='bg1' align='left'>
414        <td align='center' colspan="2"><select name='cat' size="0">
415        <?php
416        while ( $cat_data = $xoopsDB->fetchArray($result) ) {
417            echo "<option value=\"".$cat_data["cat_id"]."\">".$myts->makeTboxData4Show($cat_data["cat_title"])."</option>\n";
418        }
419        ?>
420        </select></td></tr>
421        <tr class='bg3' align='left'>
422        <td align='center' colspan="2">
423        <input type="hidden" name='mode' value="editcat" />
424        <input type='submit' name='submit' value="<?php echo _MD_A_EDIT;?>" />&nbsp;&nbsp;
425        </td>
426        </tr>
427        </table></td></tr></table></form>
428        <?php
429    }
430    break;
431case 'remcat':
432    $myts =& MyTextSanitizer::getInstance();
433    if ( isset($_POST['submit']) && $_POST['submit'] != "" ) {
434        $sql = sprintf("DELETE FROM %s WHERE cat_id = %u", $xoopsDB->prefix("bb_categories"), $_POST['cat']);
435        if ( !$r = $xoopsDB->query($sql) ) {
436            redirect_header("./index.php", 1);
437            exit();
438        }
439        redirect_header("./index.php", 1, _MD_A_CATEGORYDELETED);
440    } else {
441        xoops_cp_header();
442        echo"<table width='100%' border='0' cellspacing='1' class='outer'>"
443        ."<tr><td class=\"odd\">";
444        echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
445        ?>
446        <form action="<?php echo xoops_getenv('PHP_SELF'); ?>" method='post'>
447        <table border="0" cellpadding="1" cellspacing="0" align='center' width="95%"><tr><td class='bg2'>
448        <table border="0" cellpadding="1" cellspacing="1" width="100%">
449        <tr class='bg3' align='left'>
450        <td align='center' colspan="2"><span class='fg2'><b><?php echo _MD_A_RMVACAT;?></b></span></td>
451        </tr>
452        <tr class='bg3' align='left'>
453        <td align='center' colspan="2"><span class='fg2'><i><?php echo _MD_A_NTWNRTFUTCYMDTVTEFS;?></i></span></td>
454        </tr>
455        <tr class='bg1'>
456        <td align='center' colspan="2"><span class='fg2'>
457        <select name='cat'>
458        <?php
459        $sql = "SELECT * FROM ".$xoopsDB->prefix("bb_categories")." ORDER BY cat_title";
460        if ( !$r = $xoopsDB->query($sql) ) {
461            echo"</td></tr></table>";
462            xoops_cp_footer();
463            exit();
464        }
465        while (  $m = $xoopsDB->fetchArray($r) ) {
466            echo "<option value=\"".$m['cat_id']."\">".$myts->makeTboxData4Show($m['cat_title'])."</option>\n";
467        }
468        ?>
469        </select>
470        <input type='hidden' name='mode' value='<?php echo $mode ?>' /></td>
471        </tr>
472        <tr class='bg3'>
473        <td align='center' colspan="2"><span class='fg2'>
474        <input type="submit" name="submit" value="<?php echo _MD_A_REMOVECATEGORY;?>" /></td></tr>
475        </table></td></tr></table></form>
476        <?php
477    }
478    break;
479case 'addcat':
480    $myts =& MyTextSanitizer::getInstance();
481    if ( isset($_POST['submit']) && $_POST['submit'] != "" ) {
482        $nextid = $xoopsDB->genId($xoopsDB->prefix("bb_categories")."_cat_id_seq");
483        $sql = "SELECT max(cat_order) AS highest FROM ".$xoopsDB->prefix("bb_categories")."";
484        if ( !$r = $xoopsDB->query($sql) ) {
485            redirect_header("./index.php", 1);
486            exit();
487        }
488        list($highest) = $xoopsDB->fetchRow($r);
489        $highest++;
490        $title = $myts->stripSlashesGPC($_POST['title']);
491        $sql = sprintf("INSERT INTO %s (cat_id, cat_title, cat_order) VALUES (%u, %s, %u)", $xoopsDB->prefix("bb_categories"), $nextid, $xoopsDB->quoteString($title), $highest);
492        if ( !$result = $xoopsDB->query($sql) ) {
493            redirect_header("./index.php", 1);
494            exit();
495        }
496        redirect_header("./index.php", 1, _MD_A_CATEGORYCREATED);
497    } else {
498        xoops_cp_header();
499        echo"<table width='100%' border='0' cellspacing='1' class='outer'>"
500        ."<tr><td class=\"odd\">";
501        echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
502        ?>
503        <form action="<?php echo xoops_getenv('PHP_SELF'); ?>" method='post'>
504        <table border="0" cellpadding="1" cellspacing="0" align='center' valign="top" width="95%"><tr><td class='bg2'>
505        <table border="0" cellpadding="1" cellspacing="1" width="100%">
506        <tr class='bg3' align='left'>
507        <td align='center' colspan="2"><span class='fg2'><b><?php echo _MD_A_CREATENEWCATEGORY;?></b></span></td>
508        </tr>
509        <tr class='bg1' align='left'>
510        <td><span class='fg2'><?php echo _MD_A_CATEGORYTITLE;?></span></td>
511        <td><input type="text" name="title" size="40" maxlength="100" /></td>
512        </tr>
513        <tr class='bg3' align="left">
514        <td align='center' colspan="2">
515        <input type="hidden" name="mode" value="addcat" />
516        <input type="submit" name="submit" value="<?php echo _MD_A_CREATENEWCATEGORY;?>" />&nbsp;&nbsp;
517        <input type="reset" value="<?php echo _MD_A_CLEAR;?>" />
518        </td>
519        </tr>
520        </table></td></tr></table></form>
521        <?php
522    }
523    break;
524case 'addforum':
525    $myts =& MyTextSanitizer::getInstance();
526    if ( isset($_POST['submit']) && $_POST['submit'] != "" ) {
527        foreach (array('name', 'desc') as $k) {
528            $$k = !empty($_POST[$k]) ? trim($myts->stripSlashesGPC($_POST[$k])) : '';
529        }
530        foreach (array('type', 'cat', 'forum_access', 'html', 'sig', 'ppp', 'hot', 'tpp', 'forum') as $k) {
531            $$k = !empty($_POST[$k]) ? intval($_POST[$k]) : 0;
532        }
533        $mods = !empty($_POST['mods']) ? $_POST['mods'] : array();
534        if ( $name == '' || $desc == '' || empty($mods) ) {
535            xoops_cp_header();
536            echo"<table width='100%' border='0' cellspacing='1' class='outer'>"
537            ."<tr><td class=\"odd\">";
538            echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
539            echo _MD_A_YDNFOATPOTFDYAA;
540            echo"</td></tr></table>";
541            xoops_cp_footer();
542            exit();
543        }
544        $nextid = $xoopsDB->genId($xoopsDB->prefix("bb_forums")."_forum_id_seq");
545        $sql = "INSERT INTO ".$xoopsDB->prefix("bb_forums")." (forum_id, forum_name, forum_desc, forum_access, cat_id, forum_type, allow_html, allow_sig,posts_per_page,hot_threshold,topics_per_page) VALUES ($nextid, ".$xoopsDB->quoteString($name).", ".$xoopsDB->quoteString($desc).", $forum_access, $cat, $type, ".$xoopsDB->quoteString($html).", ".$xoopsDB->quoteString($sig).", $ppp, $hot, $tpp)";
546        if ( !$result = $xoopsDB->query($sql) ) {
547            redirect_header("./index.php", 1);
548            exit();
549        }
550        if ( $nextid == 0 ) {
551            $nextid = $xoopsDB->getInsertId();
552        }
553        // RMV-NOTIFY
554        $tags = array();
555        $tags['FORUM_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $nextid;
556        $tags['FORUM_NAME'] = $name;
557        $tags['FORUM_DESCRIPTION'] = $desc;
558        $notification_handler =& xoops_gethandler('notification');
559        $notification_handler->triggerEvents('global', 0, 'new_forum', $tags);
560
561        $count = 0;
562        while ( list($mod_number, $mod) = each($mods) ) {
563            $mod = intval($mod);
564            $mod_data = new XoopsUser($mod);
565            if (is_object($mod_data) && $mod_data->isActive() && $mod_data->level() < 2 ) {
566                if ( !isset($user_query) ) {
567                    $user_query = "UPDATE ".$xoopsDB->prefix("users")." SET level = 2 WHERE ";
568                }
569                if ( $count > 0 ) {
570                    $user_query .= "OR ";
571                }
572                $user_query .= "uid = $mod ";
573                $count++;
574            }
575            $mod_query = "INSERT INTO ".$xoopsDB->prefix("bb_forum_mods")." (forum_id, user_id) VALUES ($nextid, $mod)";
576            if ( !$xoopsDB->query($mod_query) ) {
577                redirect_header("./index.php", 1);
578                exit();
579            }
580        }
581
582        if ( isset($user_query) ) {
583            if ( !$xoopsDB->query($user_query) ) {
584                redirect_header("./index.php", 1);
585                exit();
586            }
587        }
588        redirect_header("./index.php", 1, _MD_A_FORUMCREATED);
589    } else {
590        $sql = "SELECT count(*) AS total FROM ".$xoopsDB->prefix("bb_categories")."";
591        if ( !$r = $xoopsDB->query($sql) ) {
592            redirect_header("./index.php", 1);
593            exit();
594        }
595        xoops_cp_header();
596        echo"<table width='100%' border='0' cellspacing='1' class='outer'>"."<tr><td class=\"odd\">";
597        echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
598        list($total) = $xoopsDB->fetchRow($r);
599        if ( $total < 1 || !isset($total) ) {
600            echo _MD_A_EYMAACBYAF;
601            echo"</td></tr></table>";
602            xoops_cp_footer();
603            exit();
604        }
605        ?>
606        <form action="<?php echo xoops_getenv('PHP_SELF'); ?>" method='post'>
607        <table border="0" cellpadding="1" cellspacing="0" align='center' valign="top" width="95%"><tr><td class='bg2'>
608        <table border="0" cellpadding="1" cellspacing="1" width="100%">
609        <tr class='bg3' align='left'>
610        <td align='center' colspan="2"><span class='fg2'><b><?php echo _MD_A_CREATENEWFORUM;?></b></span></td>
611        </tr>
612        <tr class='bg1' align='left'>
613        <td><span class='fg2'><?php echo _MD_A_FORUMNAME;?></span></td>
614        <td><input type='text' name='name' size="40" maxlength="150" /></td>
615        </tr>
616        <tr class='bg1' align='left'>
617        <td><span class='fg2'><?php echo _MD_A_FORUMDESCRIPTION;?></span></td>
618        <td><textarea name='desc' rows="15" cols="45" wrap="virtual"></textarea></td>
619        </tr>
620        <tr class='bg1' align='left'>
621        <td><span class='fg2'><?php echo _MD_A_MODERATOR;?></span></td>
622        <td><select name='mods[]' size='5' multiple='multiple'>
623        <?php
624        $sql = "SELECT uid, uname FROM ".$xoopsDB->prefix("users")." WHERE uid > 0 AND level > 0 ORDER BY uname";
625        if ( !$result = $xoopsDB->query($sql) ) {
626            echo"</td></tr></table>";
627            xoops_cp_footer();
628            exit();
629        }
630        if ( $myrow = $xoopsDB->fetchArray($result) ) {
631            do {
632                echo "<option value=\"".$myrow['uid']."\">".$myrow['uname']."</option>\n";
633            } while ( $myrow = $xoopsDB->fetchArray($result) );
634        } else {
635            echo "<option value=\"0\">"._MD_A_NONE."</option>\n";
636        }
637        ?>
638        </select></td>
639        </tr>
640        <tr class='bg1' align='left'>
641        <td><span class='fg2'><?php echo _MD_A_CATEGORY;?></span></td>
642        <td><select name="cat">
643        <?php
644        $sql = "SELECT * FROM ".$xoopsDB->prefix("bb_categories")."";
645        if ( !$result = $xoopsDB->query($sql) ) {
646            echo"</td></tr></table>";
647            xoops_cp_footer();
648            exit();
649        }
650        if ( $myrow = $xoopsDB->fetchArray($result) ) {
651            do {
652                echo "<option value=\"".$myrow['cat_id']."\">".$myrow['cat_title']."</option>\n";
653            } while ( $myrow = $xoopsDB->fetchArray($result) );
654        } else {
655            echo "<option value=\"0\">"._MD_A_NONE."</option>\n";
656        }
657        ?>
658        </select></td>
659        </tr>
660        <tr class='bg1' align='left'>
661        <td><span class='fg2'><?php echo _MD_A_ACCESSLEVEL;?></span></td>
662        <td><select name="forum_access">
663        <option value="2"><?php echo _MD_A_ANONYMOUSPOST;?></option>
664        <option value="1"><?php echo _MD_A_REGISTERUSERONLY;?></option>
665        <option value="3"><?php echo _MD_A_MODERATORANDADMINONLY;?></option>
666        </select>
667        </td>
668        </tr>
669        <tr class='bg1' align='left'>
670        <td><span class='fg2'><?php echo _MD_A_TYPE;?></span></td>
671        <td><select name="type">
672        <option value="0"><?php echo _MD_A_PUBLIC;?></option>
673        <option value="1"><?php echo _MD_A_PRIVATE;?></option>
674        </select>
675        </td>
676        </tr>
677        <?php
678        echo "<tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_ALLOWHTML ."</span></td>          <td><input type='radio' name='html' value='1' />"._MD_A_YES."<input type='radio' name='html' value='0' checked='checked'  />"._MD_A_NO ."</td></tr>
679        <tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_ALLOWSIGNATURES ."</span></td>
680        <td><input type='radio' name='sig' value='1' checked='checked' />". _MD_A_YES ."<input type='radio' name='sig' value='0' />". _MD_A_NO ."</td></tr>
681        <tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_HOTTOPICTHRESHOLD ."</span></td><td><input type='text' name='hot' size='3' maxlength='3' value='10' /></td></tr>
682        <tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_POSTPERPAGE ."</span><br /><span class='fg2'><i>". _MD_A_TITNOPPTTWBDPPOT ."</i></span></td>
683        <td><input type='text' name='ppp' size='3' maxlength='3' value='10' /></td></tr>
684        <tr class='bg1' align='left'><td><span class='fg2'>". _MD_A_TOPICPERFORUM ."</span><br /><span class='fg2'><i>". _MD_A_TITNOTPFTWBDPPOAF ."</i></span></td><td><input type='text' name='tpp' size='3' maxlength='3' value='20' /></td></tr>";
685        ?>
686        <tr class='bg3' align='left'>
687        <td align='center' colspan="2">
688        <input type="hidden" name="mode" value="addforum" />
689        <input type="submit" name="submit" value="<?php echo _MD_A_CREATENEWFORUM;?>" />&nbsp;&nbsp;
690        <input type="reset" value="<?php echo _MD_A_CLEAR;?>" />
691        </td>
692        </tr>
693        </table></td></tr></table></form>
694        <?php
695    }
696    break;
697case 'catorder':
698    $myts =& MyTextSanitizer::getInstance();
699    xoops_cp_header();
700    echo"<table width='100%' border='0' cellspacing='1' class='outer'>"
701    ."<tr><td class=\"odd\">";
702    echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
703    $cat_id = !empty($_POST['cat_id']) ? intval($_POST['cat_id']) : 0;
704    $last_id = !empty($_POST['last_id']) ? intval($_POST['last_id']) : 0;
705    $current_order = !empty($_POST['current_order']) ? intval($_POST['current_order']) : 0;
706    if (!empty($_POST['up'])) {
707        if ( $current_order > 1 ) {
708            $order = $current_order - 1;
709            $sql1 = "UPDATE ".$xoopsDB->prefix("bb_categories")." SET cat_order = $order WHERE cat_id = $cat_id";
710            if ( !$r = $xoopsDB->query($sql1) ) {
711                echo"</td></tr></table>";
712                xoops_cp_footer();
713                exit();
714            }
715            $sql2 = "UPDATE ".$xoopsDB->prefix("bb_categories")." SET cat_order = $current_order WHERE cat_id = $last_id";
716            if ( !$r = $xoopsDB->query($sql2) ) {
717                echo"</td></tr></table>";
718                xoops_cp_footer();
719                exit();
720            }
721            echo "<div>"._MD_A_CATEGORYMOVEUP."</div><br />";
722        } else {
723            echo "<div>"._MD_A_TCIATHU."</div><br />";
724        }
725    } else if (!empty($_POST['down'])) {
726        $sql = "SELECT cat_order FROM ".$xoopsDB->prefix("bb_categories")." ORDER BY cat_order DESC";
727        if ( !$r  = $xoopsDB->query($sql,1,0) ) {
728            echo"</td></tr></table>";
729            xoops_cp_footer();
730            exit();
731        }
732        list($last_number) = $xoopsDB->fetchRow($r);
733        if ( $last_number != $current_order ) {
734            $order = $current_order + 1;
735            $sql = "UPDATE ".$xoopsDB->prefix("bb_categories")." SET cat_order = $current_order WHERE cat_order = $order";
736            if ( !$r  = $xoopsDB->query($sql) ) {
737                echo"</td></tr></table>";
738                xoops_cp_footer();
739                exit();
740            }
741            $sql = "UPDATE ".$xoopsDB->prefix("bb_categories")." SET cat_order = $order where cat_id = $cat_id";
742            if ( !$r  = $xoopsDB->query($sql) ) {
743                echo"</td></tr></table>";
744                xoops_cp_footer();
745                exit();
746            }
747            echo "<div>"._MD_A_CATEGORYMOVEDOWN."</div><br />";
748        } else {
749            echo "<div>"._MD_A_TCIATLD."</div><br />";
750        }
751    }
752    ?>
753    <form action="<?php echo xoops_getenv('PHP_SELF'); ?>" method='post'>
754    <table border="0" cellpadding="1" cellspacing="0" align='center' valign="top" width="95%"><tr><td class='bg2'>
755    <table border="0" cellpadding="1" cellspacing="1" width="100%">
756    <tr class='bg3' align='left'>
757    <td align='center' colspan="3"><span class='fg2'><b><?php echo _MD_A_SETCATEGORYORDER;?></b></span><br />
758    <?php echo _MD_A_TODHITOTCWDOTIP;?><br />
759    <?php echo _MD_A_ECWMTCPUODITO;?></td>
760    </tr>
761    <tr class='bg3' align='center'>
762    <td><?php echo _MD_A_CATEGORY1;?></td><td><?php echo _MD_A_MOVEUP;?></td><td><?php echo _MD_A_MOVEDOWN;?></td>
763    </tr>
764    <?php
765    $sql = "SELECT * FROM ".$xoopsDB->prefix("bb_categories")." ORDER BY cat_order";
766    if ( !$r = $xoopsDB->query($sql) ) {
767        exit();
768    }
769    while ( $m = $xoopsDB->fetchArray($r) ) {
770        echo "<!-- New Row -->\n";
771        echo "<form action=\"".xoops_getenv('PHP_SELF')."\" METHOD=\"POST\">\n";
772        echo "<tr class='bg1' align='center'>\n";
773        echo "<td>".$myts->makeTboxData4Show($m['cat_title'])."</td>\n";
774        echo "<td><input type=\"hidden\" name=\"mode\" value=\"$mode\" />\n";
775        echo "<input type=\"hidden\" name=\"cat_id\" value=\"".$m['cat_id']."\" />\n";
776        echo "<input type=\"hidden\" name=\"last_id\" value=\"";
777        if ( isset($last_id) ) {
778            echo $last_id;
779        }
780        echo "\" />\n";
781        echo "<input type=\"hidden\" name=\"current_order\" value=\"".$m['cat_order']."\" /><input type=\"submit\" name=\"up\" value=\""._MD_A_MOVEUP."\" /></td>\n";
782        echo "<td><input type=\"submit\" name=\"down\" value=\""._MD_A_MOVEDOWN."\" /></td></tr></form>\n<!-- End of Row -->\n";
783        $last_id = $m['cat_id'];
784    }
785    ?>
786    </table></td></tr></table></form>
787    <?php
788    break;
789case 'sync':
790    if ( !empty($_POST['submit']) ) {
791        flush();
792        sync(null, "all forums");
793        flush();
794        sync(null, "all topics");
795        redirect_header("./index.php", 1, _MD_A_SYNCHING);
796    } else {
797        xoops_cp_header();
798        echo"<table width='100%' border='0' cellspacing='1' class='outer'>"
799        ."<tr><td class=\"odd\">";
800        echo "<a href='./index.php'><h4>"._MD_A_FORUMCONF."</h4></a>";
801        ?>
802        <table border="0" cellpadding="1" cellspacing="0" align="center" width="95%"><tr><td class='bg2'>
803        <table border="0" cellpadding="1" cellspacing="1" width="100%">
804        <tr class='bg3' align='left'>
805        <td><?php echo _MD_A_CLICKBELOWSYNC;?></td>
806        </tr>
807        <tr class='bg1' align='center'>
808        <td><form action="<?php echo xoops_getenv('PHP_SELF'); ?>" method="post">
809        <input type="hidden" name="mode" value="<?php echo $mode?>" /><input type="submit" name="submit" value="<?php echo _MD_A_SYNCFORUM;?>" /></form></td>
810        </td>
811        </tr>
812        </table>
813        </td></tr></table>
814        <?php
815    }
816    break;
817}
818
819echo"</td></tr></table>";
820xoops_cp_footer();
821?>
Note: See TracBrowser for help on using the repository browser.