author | Dan |
Tue, 13 Nov 2007 23:33:14 -0500 | |
changeset 9 | 6d9655e02026 |
parent 7 | 37387f84fe25 |
permissions | -rw-r--r-- |
6 | 1 |
<?php |
2 |
/* |
|
3 |
* Decir |
|
4 |
* Version 0.1 |
|
5 |
* Copyright (C) 2007 Dan Fuhry |
|
6 |
* admin_forums.php - forum creation and management frontend |
|
7 |
* |
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
13 |
*/ |
|
14 |
||
15 |
$decir_menu['DecirForums'] = 'Manage forums'; |
|
16 |
require( DECIR_ROOT . '/constants.php' ); |
|
17 |
||
18 |
function page_Admin_DecirForums() |
|
19 |
{ |
|
20 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
21 |
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) |
|
22 |
{ |
|
23 |
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>'; |
|
24 |
return; |
|
25 |
} |
|
26 |
||
27 |
$show_main_menu = true; |
|
28 |
||
29 |
if ( isset($_POST['act']) ) |
|
30 |
{ |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
31 |
$act = ( strpos($_POST['act'], ';') ) ? substr($_POST['act'], 0, strpos($_POST['act'], ';')) : $_POST['act']; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
32 |
if ( strpos($_POST['act'], ';') ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
33 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
34 |
$parms = substr($_POST['act'], strpos($_POST['act'], ';') + 1); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
35 |
preg_match_all('/([a-z0-9_]+)=([^;]*)/', $parms, $matches); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
36 |
$parms = array(); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
37 |
foreach ( $matches[2] as $id => $parmdata ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
38 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
39 |
if ( preg_match('/^[0-9]+$/', $parmdata) ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
40 |
$parmdata = intval($parmdata); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
41 |
$parms[ $matches[1][$id] ] = $parmdata; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
42 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
43 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
44 |
switch ( $act ) |
6 | 45 |
{ |
46 |
case "create": |
|
47 |
case "create_finish": |
|
48 |
||
49 |
// Do we have any categories yet? |
|
50 |
$q = $db->sql_query('SELECT forum_id, forum_name FROM ' . table_prefix . 'decir_forums WHERE forum_type = ' . FORUM_CATEGORY . ';'); |
|
51 |
if ( !$q ) |
|
52 |
$db->_die('Decir admin_forums.php retrieving category count'); |
|
53 |
$need_category = ( $db->numrows() < 1 ); |
|
54 |
$cats = array(); |
|
55 |
if ( !$need_category ) |
|
56 |
{ |
|
57 |
while ( list($cat_id, $cat_name) = $db->fetchrow_num() ) |
|
58 |
{ |
|
59 |
$cats[ $cat_id ] = $cat_name; |
|
60 |
} |
|
61 |
} |
|
62 |
||
63 |
$db->free_result(); |
|
64 |
||
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
65 |
if ( $act == 'create_finish' ) |
6 | 66 |
{ |
67 |
$errors = array(); |
|
68 |
$forum_type = intval($_POST['forum_type']); |
|
69 |
if ( $forum_type != FORUM_FORUM && $forum_type != FORUM_CATEGORY ) |
|
70 |
$errors[] = 'Invalid forum type. <tt>X.X</tt>'; |
|
71 |
$forum_name = trim($_POST['forum_name']); |
|
72 |
if ( empty($forum_name) ) |
|
73 |
$errors[] = 'Please enter a name for this forum.'; |
|
74 |
$forum_desc = ''; |
|
75 |
$forum_parent = 0; |
|
76 |
if ( $forum_type == FORUM_FORUM ) |
|
77 |
{ |
|
78 |
$forum_desc = trim($_POST['forum_desc']); |
|
79 |
if ( empty($forum_desc) ) |
|
80 |
$errors[] = 'Please enter a description for this forum.'; |
|
81 |
$forum_parent = intval($_POST['forum_parent']); |
|
82 |
if ( !isset($cats[$forum_parent]) ) |
|
83 |
$errors[] = 'Invalid parent category'; |
|
84 |
} |
|
85 |
if ( count($errors) > 0 ) |
|
86 |
{ |
|
87 |
// Errors encountered - bounce form back to the user |
|
88 |
$show_main_menu = false; |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
89 |
echo '<div class="error-box">The forum could not be created.<ul><li>' . implode("</li>\n <li>", $errors) . '</li></ul></div>'; |
6 | 90 |
$form = new Decir_Admin_SmartForm_Forum(DECIR_ADMIN_MODE_CREATE); |
91 |
$form->forum_name = $forum_name; |
|
92 |
$form->forum_desc = $forum_desc; |
|
93 |
$form->forum_type = $forum_type; |
|
94 |
$form->need_category = $need_category; |
|
95 |
$form->category_list = $cats; |
|
96 |
echo $form->html(); |
|
97 |
break; |
|
98 |
} |
|
99 |
// All checks passed. Create forum. |
|
100 |
$forum_name_db = $db->escape($forum_name); |
|
101 |
$forum_desc_db = $db->escape($forum_desc); |
|
102 |
$sql = 'INSERT INTO ' . table_prefix . "decir_forums(forum_name, forum_desc, forum_type, parent, num_topics, num_posts) VALUES\n" |
|
103 |
. " ( '$forum_name_db', '$forum_desc_db', $forum_type, $forum_parent, 0, 0 );"; |
|
104 |
if ( $db->sql_query($sql) ) |
|
105 |
{ |
|
106 |
$forum_name = htmlspecialchars($forum_name); |
|
107 |
$type = ( $forum_type == FORUM_FORUM ) ? 'forum' : 'category'; |
|
108 |
echo "<div class=\"info-box\">The {$type} \"{$forum_name}\" has been created successfully.</div>"; |
|
109 |
} |
|
110 |
break; |
|
111 |
} |
|
112 |
// Create a smartform |
|
113 |
$show_main_menu = false; |
|
114 |
$form = new Decir_Admin_SmartForm_Forum(DECIR_ADMIN_MODE_CREATE); |
|
115 |
$form->need_category = $need_category; |
|
116 |
$form->category_list = $cats; |
|
117 |
echo $form->html(); |
|
118 |
break; |
|
9
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
119 |
case 'delete': |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
120 |
case 'delete_finish': |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
121 |
if ( !isset($parms['fid']) || ( isset($parms['fid']) && !is_int($parms['fid']) ) ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
122 |
{ |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
123 |
echo '<div class="error-box">Invalid forum ID passed to editor.</div>'; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
124 |
break; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
125 |
} |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
126 |
|
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
127 |
// $fid is safe (validated as an integer). |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
128 |
$fid =& $parms['fid']; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
129 |
$q = $db->sql_query('SELECT forum_id, forum_name, forum_type FROM ' . table_prefix . 'decir_forums WHERE forum_id = ' . $fid . ';'); |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
130 |
if ( !$q ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
131 |
$db->_die('Decir admin_forums.php selecting forum data for deletion'); |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
132 |
|
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
133 |
$row = $db->fetchrow(); |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
134 |
$db->free_result(); |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
135 |
|
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
136 |
if ( $row['forum_type'] == FORUM_FORUM ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
137 |
{ |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
138 |
// Provide the option of moving the posts in this forum to another forum |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
139 |
$q = $db->sql_query('SELECT forum_id, forum_name FROM ' . table_prefix . "decir_forums WHERE forum_id != {$row['forum_id']} AND forum_type = " . FORUM_FORUM . ';'); |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
140 |
if ( !$q ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
141 |
$db->_die('Decir admin_forums.php selecting list of possible forums to move topics to'); |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
142 |
$opt_move = ''; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
143 |
if ( $db->numrows() > 0 ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
144 |
{ |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
145 |
$opt_move .= '<p><label><input type="radio" name="with_content" value="move" /> Move to forum:</label><br /> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
146 |
<select name="move_to">'; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
147 |
while ( $drow = $db->fetchrow() ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
148 |
{ |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
149 |
$opt_move .= "<option value=\"{$drow['forum_id']}\">" . htmlspecialchars($drow['forum_name']) . '</option>'; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
150 |
} |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
151 |
$opt_move .= "</select></p>"; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
152 |
} |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
153 |
} |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
154 |
else if ( $row['forum_type'] == FORUM_CATEGORY ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
155 |
{ |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
156 |
// Provide the option of moving the posts in this forum to another forum |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
157 |
$q = $db->sql_query('SELECT forum_id, forum_name FROM ' . table_prefix . "decir_forums WHERE forum_id != {$row['forum_id']} AND forum_type = " . FORUM_CATEGORY . ';'); |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
158 |
if ( !$q ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
159 |
$db->_die('Decir admin_forums.php selecting list of possible categories to move forums to'); |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
160 |
$opt_move = ''; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
161 |
if ( $db->numrows() > 0 ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
162 |
{ |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
163 |
$opt_move .= '<p><label><input type="radio" name="with_content" value="move" /> Move to category:</label><br /> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
164 |
<select name="move_to">'; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
165 |
while ( $drow = $db->fetchrow() ) |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
166 |
{ |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
167 |
$opt_move .= "<option value=\"{$drow['forum_id']}\">" . htmlspecialchars($drow['forum_name']) . '</option>'; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
168 |
} |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
169 |
$opt_move .= "</select></p>"; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
170 |
} |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
171 |
} |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
172 |
else |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
173 |
{ |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
174 |
break; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
175 |
} |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
176 |
|
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
177 |
$forcat = ( $row['forum_type'] == FORUM_FORUM ) ? 'forum' : 'category'; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
178 |
echo '<div class="tblholder"> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
179 |
<table border="0" cellspacing="1" cellpadding="4"> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
180 |
<tr> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
181 |
<th>Deleting ' . $forcat . '</th> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
182 |
</tr> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
183 |
<tr> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
184 |
<td class="row2"> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
185 |
<div style="margin: 0 auto; display: table;"> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
186 |
<p><b>You are about to obliterate the '. $forcat .' "' . htmlspecialchars($row['forum_name']) . '".</b><br /> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
187 |
You can either preserve its contents or delete them. Beware that if you are deleting a<br /> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
188 |
' . $forcat . ' with a large number of posts in it, this process may take some time.</p> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
189 |
</div> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
190 |
<div style="margin: 0 auto; display: table;"> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
191 |
<p><label><input type="radio" checked="checked" name="with_content" value="delete" /> Delete contents</p> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
192 |
' . $opt_move . ' |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
193 |
</div> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
194 |
</td> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
195 |
</tr> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
196 |
<tr> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
197 |
<td class="row1" style="text-align: center;"> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
198 |
<button name="act" value="delete_finish;fid=' . $row['forum_id'] . '"><span style="font-weight: bold; color: red;">Delete forum</span></button> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
199 |
<button name="act" value="noop" style="font-weight: normal;">Cancel</button> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
200 |
</td> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
201 |
</tr> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
202 |
</table> |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
203 |
</div>'; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
204 |
|
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
205 |
$show_main_menu = false; |
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
206 |
|
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
207 |
break; |
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
208 |
case 'edit': |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
209 |
case 'edit_finish': |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
210 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
211 |
if ( !isset($parms['fid']) || ( isset($parms['fid']) && !is_int($parms['fid']) ) ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
212 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
213 |
echo '<div class="error-box">Invalid forum ID passed to editor.</div>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
214 |
break; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
215 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
216 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
217 |
// Fetch category list |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
218 |
$q = $db->sql_query('SELECT forum_id, forum_name FROM ' . table_prefix . 'decir_forums WHERE forum_type = ' . FORUM_CATEGORY . ';'); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
219 |
if ( !$q ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
220 |
$db->_die('Decir admin_forums.php retrieving category count'); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
221 |
$need_category = ( $db->numrows() < 1 ); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
222 |
$cats = array(); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
223 |
if ( !$need_category ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
224 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
225 |
while ( list($cat_id, $cat_name) = $db->fetchrow_num() ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
226 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
227 |
$cats[ $cat_id ] = $cat_name; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
228 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
229 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
230 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
231 |
$db->free_result(); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
232 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
233 |
// $fid is safe (validated as an integer). |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
234 |
$fid =& $parms['fid']; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
235 |
$q = $db->sql_query('SELECT forum_id, forum_name, forum_desc, parent, forum_type FROM ' . table_prefix . 'decir_forums WHERE forum_id = ' . $fid . ';'); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
236 |
if ( !$q ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
237 |
$db->_die('Decir admin_forums.php selecting forum data for edit'); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
238 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
239 |
$row = $db->fetchrow(); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
240 |
$db->free_result(); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
241 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
242 |
if ( $act == 'edit_finish' ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
243 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
244 |
$errors = array(); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
245 |
// Validate and update |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
246 |
if ( $row['forum_type'] == FORUM_FORUM ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
247 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
248 |
$forum_name = trim($_POST['forum_name']); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
249 |
if ( empty($forum_name) ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
250 |
$errors[] = 'Please enter a name for this forum.'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
251 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
252 |
$forum_desc = trim($_POST['forum_desc']); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
253 |
if ( empty($forum_desc) ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
254 |
$errors[] = 'Please enter a description for this forum.'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
255 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
256 |
$forum_parent = intval($_POST['forum_parent']); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
257 |
if ( !isset($cats[$forum_parent]) ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
258 |
$errors[] = 'Invalid parent category'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
259 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
260 |
$forum_name_db = $db->escape($forum_name); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
261 |
$forum_desc_db = $db->escape($forum_desc); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
262 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
263 |
$sql = 'UPDATE ' . table_prefix . "decir_forums SET forum_name='$forum_name_db',forum_desc='$forum_desc_db',parent=$forum_parent WHERE forum_id = $fid;"; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
264 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
265 |
else if ( $row['forum_type'] == FORUM_CATEGORY ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
266 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
267 |
$forum_name = trim($_POST['forum_name']); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
268 |
if ( empty($forum_name) ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
269 |
$errors[] = 'Please enter a name for this forum.'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
270 |
$forum_name_db = $db->escape($forum_name); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
271 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
272 |
$sql = 'UPDATE ' . table_prefix . "decir_forums SET forum_name='$forum_name_db' WHERE forum_id = $fid;"; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
273 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
274 |
else |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
275 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
276 |
$db->_die('Mom, I feel sick. Can I lay down for a while? ' . __FILE__ . ':' . __LINE__); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
277 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
278 |
if ( count($errors) < 1 ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
279 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
280 |
if ( $db->sql_query($sql) ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
281 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
282 |
$show_main_menu = true; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
283 |
echo '<div class="info-box">The forum or category was updated.</div>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
284 |
break; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
285 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
286 |
else |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
287 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
288 |
$db->_die('Decir admin_forums.php update forum main SQL query'); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
289 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
290 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
291 |
else |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
292 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
293 |
echo '<div class="error-box">The forum was not updated because you entered something invalid.<ul><li>' . implode("</li>\n <li>", $errors) . '</li></ul></div>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
294 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
295 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
296 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
297 |
// This is the amazing part. We'll let the smart form do the work for us. |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
298 |
$form = new Decir_Admin_SmartForm_Forum(DECIR_ADMIN_MODE_EDIT); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
299 |
$form->forum_name = $row['forum_name']; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
300 |
$form->forum_desc = $row['forum_desc']; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
301 |
$form->forum_type = $row['forum_type']; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
302 |
$form->forum_parent = $row['parent']; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
303 |
$form->forum_id = $row['forum_id']; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
304 |
$form->category_list = $cats; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
305 |
echo $form->html(); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
306 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
307 |
$show_main_menu = false; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
308 |
break; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
309 |
case 'save_order': |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
310 |
$order = explode(',', $_POST['forum_order']); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
311 |
$i = 0; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
312 |
$sql = array(); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
313 |
foreach ( $order as $forum_id ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
314 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
315 |
$i++; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
316 |
if ( strval(intval($forum_id)) != $forum_id ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
317 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
318 |
echo '<p>Hacking attempt</p>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
319 |
break; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
320 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
321 |
$sql[] = 'UPDATE ' . table_prefix . "decir_forums SET forum_order = $i WHERE forum_id = $forum_id;"; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
322 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
323 |
foreach ( $sql as $s ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
324 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
325 |
if ( !$db->sql_query($s) ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
326 |
$db->_die('Decir admin_forums.php updating forum order'); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
327 |
} |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
328 |
echo '<div class="info-box">The forum order was updated.</div>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
329 |
break; |
6 | 330 |
} |
331 |
} |
|
332 |
||
333 |
if ( $show_main_menu ) |
|
334 |
{ |
|
335 |
// Display the main forum admin interface |
|
336 |
$form_url = makeUrlNS('Special', 'DecirAdmin', "module={$paths->nslist['Admin']}DecirForums", true); |
|
337 |
echo "<form action=\"$form_url\" method=\"post\" enctype=\"multipart/form-data\">"; |
|
338 |
echo '<div class="tblholder"> |
|
339 |
<table border="0" cellspacing="1" cellpadding="4"> |
|
340 |
<tr> |
|
341 |
<th colspan="4">Forum administration</th> |
|
342 |
</tr>'; |
|
343 |
// Select and display all forums |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
344 |
$q = $db->sql_unbuffered_query('SELECT forum_id, forum_name, forum_desc, forum_type, num_topics, num_posts FROM ' . table_prefix . 'decir_forums GROUP BY parent, forum_id ORDER BY forum_order;'); |
6 | 345 |
|
346 |
if ( !$q ) |
|
347 |
$db->_die('Decir admin_forums.php selecting main forum datum'); |
|
348 |
||
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
349 |
$order_forums = array(); |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
350 |
$order_cats = array(); |
6 | 351 |
if ( $row = $db->fetchrow() ) |
352 |
{ |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
353 |
$cat_open = false; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
354 |
echo '<tr> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
355 |
<th class="subhead">Forum</th> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
356 |
<th class="subhead" style="max-width: 50px;">Topics</th> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
357 |
<th class="subhead" style="max-width: 50px;">Posts</th> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
358 |
<th class="subhead">Admin tasks</th> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
359 |
</tr>'; |
6 | 360 |
do |
361 |
{ |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
362 |
switch ( $row['forum_type'] ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
363 |
{ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
364 |
case FORUM_FORUM: |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
365 |
// Forum |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
366 |
echo '<tr> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
367 |
<td class="row2 decir_forum"><input type="hidden" value="' . $row['forum_id'] . '" /> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
368 |
<b><a href="' . makeUrlNS('DecirForum', $row['forum_id']) . '">' |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
369 |
. $row['forum_name'] . '</a></b><br />' . $row['forum_desc'].' |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
370 |
</td> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
371 |
<td class="row3" style="text-align: center;">' . $row['num_topics'] . '</td> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
372 |
<td class="row3" style="text-align: center;">' . $row['num_posts'] . '</td> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
373 |
<td class="row1" style="text-align: center;">'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
374 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
375 |
echo '<button name="act" value="edit;fid=' . $row['forum_id'] . '">Edit</button> '; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
376 |
echo '<button name="act" value="delete;fid=' . $row['forum_id'] . '">Delete</button>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
377 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
378 |
echo '</td> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
379 |
</tr>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
380 |
$order_forums[] = $row['forum_id']; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
381 |
break; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
382 |
case FORUM_CATEGORY: |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
383 |
// Category |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
384 |
if ( $cat_open ) |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
385 |
echo '</tbody>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
386 |
echo '<tr> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
387 |
<td class="row1 decir_category" colspan="1"><input type="hidden" value="' . $row['forum_id'] . '" /> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
388 |
<h3 style="margin: 0; padding: 0;">' . $row['forum_name'] . '</h3> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
389 |
</td> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
390 |
<td class="row2" colspan="2"></td>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
391 |
echo '<td class="row1" style="text-align: center;">'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
392 |
echo '<button name="act" value="edit;fid=' . $row['forum_id'] . '">Edit</button> '; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
393 |
echo '<button name="act" value="delete;fid=' . $row['forum_id'] . '">Delete</button>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
394 |
echo '</td>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
395 |
echo '</tr> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
396 |
<tbody id="forum_cat_' . $row['forum_id'] . '">'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
397 |
$cat_open = true; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
398 |
$order_cats[] = $row['forum_id']; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
399 |
break; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
400 |
} |
6 | 401 |
} |
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
402 |
while ( $row = $db->fetchrow($q) ); |
6 | 403 |
} |
404 |
else |
|
405 |
{ |
|
406 |
echo '<td colspan="4" class="row3">There are no forums on this board.</td>'; |
|
407 |
} |
|
408 |
||
409 |
// Create forum button |
|
410 |
echo ' <tr> |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
411 |
<th class="subhead" colspan="4"> |
6 | 412 |
<button name="act" value="create">Create new forum</button> |
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
413 |
<button name="act" value="save_order">Save forum order</button> |
6 | 414 |
</th> |
415 |
</tr>'; |
|
416 |
||
417 |
echo ' </table> |
|
418 |
</div>'; |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
419 |
$order = /* implode(',', $order_cats) . ';' . */ implode(',', $order_forums); |
9
6d9655e02026
Removed all dragger debugging info and started on the form for forum/category deletion
Dan
parents:
7
diff
changeset
|
420 |
echo '<input type="hidden" name="forum_order" id="forum_order" value="' . $order . '" />'; |
6 | 421 |
echo "</form>"; |
422 |
} |
|
423 |
} |
|
424 |
||
425 |
/** |
|
426 |
* Smart form for creating and editing Decir forums. |
|
427 |
* @package Decir |
|
428 |
* @subpackage Administration |
|
429 |
* @copyright 2007 Dan Fuhry |
|
430 |
* @license GPL |
|
431 |
*/ |
|
432 |
||
433 |
class Decir_Admin_SmartForm_Forum |
|
434 |
{ |
|
435 |
||
436 |
/** |
|
437 |
* Whether we are creating or editing a forum. |
|
438 |
* @var int |
|
439 |
*/ |
|
440 |
||
441 |
var $form_mode; |
|
442 |
||
443 |
/** |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
444 |
* The unique ID of the forum - only used in edit mode. |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
445 |
* @var int |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
446 |
*/ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
447 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
448 |
var $forum_id = 0; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
449 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
450 |
/** |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
451 |
* The name of the forum - only used in edit mode or if performing a bounceback from a failed form validation. |
6 | 452 |
* @var string |
453 |
*/ |
|
454 |
||
455 |
var $forum_name = ''; |
|
456 |
||
457 |
/** |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
458 |
* The description of the forum - only used in edit mode or if performing a bounceback from a failed form validation. |
6 | 459 |
* @var string |
460 |
*/ |
|
461 |
||
462 |
var $forum_desc = ''; |
|
463 |
||
464 |
/** |
|
465 |
* The type of entry this is (forum or category) |
|
466 |
* @var int |
|
467 |
*/ |
|
468 |
||
469 |
var $forum_type = -1; |
|
470 |
||
471 |
/** |
|
472 |
* Track if we need to make the user create a category as opposed to a forum. |
|
473 |
* @var bool |
|
474 |
*/ |
|
475 |
||
476 |
var $need_category = false; |
|
477 |
||
478 |
/** |
|
479 |
* The list of categories on the site. |
|
480 |
* @var array |
|
481 |
*/ |
|
482 |
||
483 |
var $category_list = array(); |
|
484 |
||
485 |
/** |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
486 |
* The parent category of the forum we're editing. |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
487 |
* @var int |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
488 |
*/ |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
489 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
490 |
var $forum_parent = -1; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
491 |
|
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
492 |
/** |
6 | 493 |
* Instance ID for javascripting |
494 |
* @var string |
|
495 |
*/ |
|
496 |
||
497 |
var $instance_id; |
|
498 |
||
499 |
/** |
|
500 |
* Constructor |
|
501 |
* @param int Form type - should be DECIR_ADMIN_MODE_CREATE or DECIR_ADMIN_MODE_EDIT |
|
502 |
*/ |
|
503 |
||
504 |
function __construct($form_mode) |
|
505 |
{ |
|
506 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
507 |
$form_mode = intval($form_mode); |
|
508 |
if ( $form_mode != DECIR_ADMIN_MODE_CREATE && $form_mode != DECIR_ADMIN_MODE_EDIT ) |
|
509 |
die('Syntax error: $form_mode to Decir_Admin_SmartForm_Forum::__construct should be DECIR_ADMIN_MODE_CREATE or DECIR_ADMIN_MODE_EDIT.'); |
|
510 |
||
511 |
$this->form_mode = $form_mode; |
|
512 |
$this->instance_id = $session->dss_rand(); |
|
513 |
} |
|
514 |
||
515 |
/** |
|
516 |
* PHP4 compatibility constructor. |
|
517 |
* @see Decir_Admin_SmartForm_Forum::__construct |
|
518 |
*/ |
|
519 |
||
520 |
function Decir_Admin_SmartForm_Forum($form_type) |
|
521 |
{ |
|
522 |
$this->__construct($form_type); |
|
523 |
} |
|
524 |
||
525 |
/** |
|
526 |
* Render the form into HTML. |
|
527 |
* @return string |
|
528 |
*/ |
|
529 |
||
530 |
function html() |
|
531 |
{ |
|
532 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
533 |
$f_f = FORUM_FORUM; |
|
534 |
$f_c = FORUM_CATEGORY; |
|
535 |
$tpl_code = <<<EOF |
|
536 |
<!-- Start forum creation/edit smartform {INSTANCE_ID} --> |
|
537 |
||
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
538 |
<!-- BEGIN mode_is_create --> |
6 | 539 |
<script type="text/javascript"> |
540 |
||
541 |
function set_form_type_category_{INSTANCE_ID}() |
|
542 |
{ |
|
543 |
document.getElementById('type_category_{INSTANCE_ID}').style.display = 'block'; |
|
544 |
document.getElementById('type_forum_{INSTANCE_ID}').style.display = 'none'; |
|
545 |
} |
|
546 |
||
547 |
function set_form_type_forum_{INSTANCE_ID}() |
|
548 |
{ |
|
549 |
document.getElementById('type_category_{INSTANCE_ID}').style.display = 'none'; |
|
550 |
document.getElementById('type_forum_{INSTANCE_ID}').style.display = 'block'; |
|
551 |
} |
|
552 |
var set_form_type_auto_{INSTANCE_ID} = function() |
|
553 |
{ |
|
554 |
if ( document.getElementById('radio_forum_{INSTANCE_ID}').checked ) |
|
555 |
{ |
|
556 |
set_form_type_forum_{INSTANCE_ID}(); |
|
557 |
} |
|
558 |
else if ( document.getElementById('radio_category_{INSTANCE_ID}').checked ) |
|
559 |
{ |
|
560 |
set_form_type_category_{INSTANCE_ID}(); |
|
561 |
} |
|
562 |
} |
|
563 |
||
564 |
addOnloadHook(set_form_type_auto_{INSTANCE_ID}); |
|
565 |
</script> |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
566 |
<!-- END mode_is_create --> |
6 | 567 |
|
568 |
<form action="{FORM_ACTION}" name="decir_forum_smartform_{INSTANCE_ID}" method="post" enctype="multipart/form-data"> |
|
569 |
||
570 |
<div class="tblholder"> |
|
571 |
<table border="0" cellspacing="1" cellpadding="4"> |
|
572 |
<tr> |
|
573 |
<th colspan="2"> |
|
574 |
<!-- BEGIN mode_is_create --> |
|
575 |
Create new forum |
|
576 |
<!-- BEGINELSE mode_is_create --> |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
577 |
Editing {FORUM_NAME} |
6 | 578 |
<!-- END mode_is_create --> |
579 |
</th> |
|
580 |
</tr> |
|
581 |
<!-- BEGIN mode_is_create --> |
|
582 |
<tr> |
|
583 |
<td class="row2" style="width: 50%;"> |
|
584 |
Forum type: |
|
585 |
</td> |
|
586 |
<td class="row1" style="width: 50%;"> |
|
587 |
<label> |
|
588 |
<input id="radio_forum_{INSTANCE_ID}" type="radio" name="forum_type" value="{TYPE_FORUM}" onclick="set_form_type_forum_{INSTANCE_ID}();" <!-- BEGIN type_is_forum -->checked="checked" <!-- END type_is_forum -->/> Forum |
|
589 |
</label> |
|
590 |
<label> |
|
591 |
<input id="radio_category_{INSTANCE_ID}" type="radio" name="forum_type" value="{TYPE_CATEGORY}" onclick="set_form_type_category_{INSTANCE_ID}();" <!-- BEGINNOT type_is_forum -->checked="checked" <!-- END type_is_forum -->/> Category |
|
592 |
</label> |
|
593 |
</td> |
|
594 |
</tr> |
|
595 |
<!-- END mode_is_create --> |
|
596 |
<tr> |
|
597 |
<td class="row2" style="width: 50%;"> |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
598 |
<!-- BEGINNOT mode_is_create --> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
599 |
<!-- BEGINNOT type_is_forum --> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
600 |
Category name: |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
601 |
<!-- BEGINELSE type_is_forum --> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
602 |
Forum name: |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
603 |
<!-- END type_is_forum --> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
604 |
<!-- BEGINELSE mode_is_create --> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
605 |
Forum name: |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
606 |
<!-- END mode_is_create --> |
6 | 607 |
</td> |
608 |
<td class="row1" style="width: 50%;"> |
|
609 |
<input type="text" name="forum_name" size="40" value="{FORUM_NAME}" /> |
|
610 |
</td> |
|
611 |
</tr> |
|
612 |
</table> |
|
613 |
</div> |
|
614 |
||
615 |
<!-- BEGIN show_opts_category --> |
|
616 |
<div class="tblholder" id="type_category_{INSTANCE_ID}"<!-- BEGIN mode_is_create --> style="display: none;" <!-- END mode_is_create -->> |
|
617 |
<table border="0" cellspacing="1" cellpadding="4"> |
|
618 |
<tr> |
|
619 |
<th colspan="2"> |
|
620 |
Category options |
|
621 |
</th> |
|
622 |
</tr> |
|
623 |
<tr> |
|
624 |
<td class="row2" style="width: 50%;"> |
|
625 |
Stub |
|
626 |
</td> |
|
627 |
<td class="row1" style="width: 50%;"> |
|
628 |
Stub |
|
629 |
</td> |
|
630 |
</tr> |
|
631 |
<tr> |
|
632 |
<th class="subhead" colspan="2"> |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
633 |
<!-- BEGIN mode_is_create --> |
6 | 634 |
<button name="act" value="create_finish"><b>Create category</b></button> |
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
635 |
<!-- BEGINELSE mode_is_create --> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
636 |
<button name="act" value="edit_finish;fid={FORUM_ID}"><b>Save changes</b></button> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
637 |
<!-- END mode_is_create --> |
6 | 638 |
<button name="act" value="noop" style="font-weight: normal;">Cancel</button> |
639 |
</th> |
|
640 |
</tr> |
|
641 |
</table> |
|
642 |
</div> |
|
643 |
<!-- END show_opts_category --> |
|
644 |
||
645 |
<!-- BEGIN show_opts_forum --> |
|
646 |
<div id="type_forum_{INSTANCE_ID}"> |
|
647 |
||
648 |
<!-- BEGIN need_category --> |
|
649 |
||
650 |
<div class="error-box"> |
|
651 |
There aren't any categories on this site yet. You need to create at least one category before you can create a forum. |
|
652 |
</div> |
|
653 |
||
654 |
<!-- BEGINELSE need_category --> |
|
655 |
||
656 |
<div class="tblholder"> |
|
657 |
<table border="0" cellspacing="1" cellpadding="4"> |
|
658 |
<tr> |
|
659 |
<th colspan="2"> |
|
660 |
Forum options |
|
661 |
</th> |
|
662 |
</tr> |
|
663 |
<tr> |
|
664 |
<td class="row2" style="width: 50%;"> |
|
665 |
Forum description: |
|
666 |
</td> |
|
667 |
<td class="row1" style="width: 50%;"> |
|
668 |
<input type="text" name="forum_desc" size="40" value="{FORUM_DESC}" /> |
|
669 |
</td> |
|
670 |
</tr> |
|
671 |
<tr> |
|
672 |
<td class="row2"> |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
673 |
<!-- BEGIN mode_is_create -->Create in category:<!-- BEGINELSE mode_is_create -->Parent category:<!-- END mode_is_create --> |
6 | 674 |
</td> |
675 |
<td class="row1"> |
|
676 |
<select name="forum_parent"> |
|
677 |
{CATEGORY_LIST}</select> |
|
678 |
</td> |
|
679 |
</tr> |
|
680 |
<tr> |
|
681 |
<th class="subhead" colspan="2"> |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
682 |
<!-- BEGIN mode_is_create --> |
6 | 683 |
<button name="act" value="create_finish"><b>Create forum</b></button> |
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
684 |
<!-- BEGINELSE mode_is_create --> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
685 |
<button name="act" value="edit_finish;fid={FORUM_ID}"><b>Save changes</b></button> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
686 |
<!-- END mode_is_create --> |
6 | 687 |
<button name="act" value="noop" style="font-weight: normal;">Cancel</button> |
688 |
</th> |
|
689 |
</tr> |
|
690 |
</table> |
|
691 |
</div> |
|
692 |
||
693 |
<!-- END need_category --> |
|
694 |
||
695 |
</div> |
|
696 |
<!-- END show_opts_forum --> |
|
697 |
||
698 |
</form> |
|
699 |
||
700 |
<!-- Finish forum creation/edit smartform {INSTANCE_ID} --> |
|
701 |
EOF; |
|
702 |
$parser = $template->makeParserText($tpl_code); |
|
703 |
||
704 |
$category_list = ''; |
|
705 |
foreach ( $this->category_list as $cat_id => $cat_name ) |
|
706 |
{ |
|
707 |
$cat_id = intval($cat_id); |
|
708 |
$cat_name = htmlspecialchars($cat_name); |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
709 |
$sel = ( $cat_id == $this->forum_parent ) ? ' selected="selected"' : ''; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
710 |
$category_list .= "<option {$sel}value=\"$cat_id\">$cat_name</option>\n "; |
6 | 711 |
} |
712 |
||
713 |
// FIXME: these should really call addslashes and htmlspecialchars |
|
714 |
||
715 |
$parser->assign_vars(array( |
|
716 |
'INSTANCE_ID' => $this->instance_id, |
|
717 |
'FORUM_NAME' => htmlspecialchars($this->forum_name), |
|
718 |
'FORUM_DESC' => htmlspecialchars($this->forum_desc), |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
719 |
'FORUM_ID' => $this->forum_id, |
6 | 720 |
'FORM_ACTION' => makeUrlNS('Special', 'DecirAdmin', 'module=' . $paths->nslist['Admin'] . 'DecirForums', true), |
721 |
'TYPE_FORUM' => FORUM_FORUM, |
|
722 |
'TYPE_CATEGORY' => FORUM_CATEGORY, |
|
723 |
'CATEGORY_LIST' => $category_list |
|
724 |
)); |
|
725 |
$parser->assign_bool(array( |
|
726 |
'mode_is_create' => ( $this->form_mode == DECIR_ADMIN_MODE_CREATE ), |
|
727 |
'show_opts_category' => ( $this->form_mode == DECIR_ADMIN_MODE_CREATE ? true : $this->forum_type == FORUM_CATEGORY ), |
|
728 |
'show_opts_forum' => ( $this->form_mode == DECIR_ADMIN_MODE_CREATE ? true : $this->forum_type == FORUM_FORUM ), |
|
729 |
'type_is_forum' => ( $this->forum_type != FORUM_CATEGORY ), |
|
730 |
'need_category' => ( $this->form_mode == DECIR_ADMIN_MODE_CREATE && $this->need_category ) |
|
731 |
)); |
|
732 |
||
733 |
return $parser->run(); |
|
734 |
} |
|
735 |
||
736 |
} |
|
737 |
||
738 |
?> |