diff options
Diffstat (limited to 'phpBB/adm')
-rw-r--r-- | phpBB/adm/admin_attachments.php | 86 | ||||
-rw-r--r-- | phpBB/adm/admin_forums.php | 62 |
2 files changed, 121 insertions, 27 deletions
diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php index 420e91434f..a3b5b64e7e 100644 --- a/phpBB/adm/admin_attachments.php +++ b/phpBB/adm/admin_attachments.php @@ -104,6 +104,7 @@ if ($mode == 'attach') if ($submit) { +/* // Update Extension Group Filesizes if ($config_name == 'max_filesize') { @@ -119,7 +120,7 @@ if ($mode == 'attach') $db->sql_query($sql); } } - +*/ set_config($config_name, $new[$config_name]); if (in_array($config_name, array('max_filesize', 'attachment_quota', 'max_filesize_pm'))) @@ -300,6 +301,8 @@ if ($submit && $mode == 'ext_groups') // Ok, build the update/insert array $upload_icon = request_var('upload_icon', 'no_image'); $size_select = request_var('size_select', 'b'); + $forum_select = request_var('forum_select', false); + $allowed_forums = isset($_REQUEST['allowed_forums']) ? array_map('intval', array_values($_REQUEST['allowed_forums'])) : array(); $max_filesize = request_var('max_filesize', 0); $max_filesize = ($size_select == 'kb') ? round($max_filesize * 1024) : (($size_select == 'mb') ? round($max_filesize * 1048576) : $max_filesize); @@ -308,13 +311,19 @@ if ($submit && $mode == 'ext_groups') $max_filesize = 0; } + if (!sizeof($allowed_forums)) + { + $forum_select = false; + } + $group_ary = array( 'group_name' => $group_name, 'cat_id' => request_var('special_category', NONE_CAT), 'allow_group' => (isset($_REQUEST['allow_group'])) ? 1 : 0, 'download_mode' => request_var('download_mode', INLINE_LINK), 'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon, - 'max_filesize' => $max_filesize + 'max_filesize' => $max_filesize, + 'allowed_forums'=> ($forum_select) ? serialize($allowed_forums) : '' ); $sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET '; @@ -784,6 +793,8 @@ if ($mode == 'ext_groups') extract($db->sql_fetchrow($result)); $db->sql_freeresult($result); + $forum_ids = (!$allowed_forums) ? array() : unserialize(trim($allowed_forums)); + case 'add': if ($action == 'add') @@ -794,6 +805,7 @@ if ($mode == 'ext_groups') $download_mode = 1; $upload_icon = ''; $max_filesize = 0; + $forum_ids = array(); } $extensions = array(); @@ -960,6 +972,70 @@ if ($mode == 'ext_groups') </select></td> </tr> <tr> + <td class="row1" valign="top"><b><?php echo $user->lang['ALLOWED_FORUMS']; ?></b>:<br /><span class="gensmall"><?php echo $user->lang['ALLOWED_FORUMS_EXPLAIN']; ?></span></td> + <td class="row2"><input type="radio" name="forum_select" value="0"<?php echo (!sizeof($forum_ids)) ? ' checked="checked"' : ''; ?> /> <?php echo $user->lang['ALLOW_ALL_FORUMS']; ?> <input type="radio" name="forum_select" value="1"<?php echo (sizeof($forum_ids)) ? ' checked="checked"' : ''; ?> /> <?php echo $user->lang['ALLOW_SELECTED_FORUMS']; ?><br /><br /> + <select name="allowed_forums[]" multiple="true" size="8"> +<?php + + $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id + FROM ' . FORUMS_TABLE . ' + ORDER BY left_id ASC'; + $result = $db->sql_query($sql); + + $right = $cat_right = $padding_inc = 0; + $padding = $forum_list = $holding = ''; + $padding_store = array('0' => ''); + while ($row = $db->sql_fetchrow($result)) + { + if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) + { + // Non-postable forum with no subforums, don't display + continue; + } + + if (!$auth->acl_get('f_list', $row['forum_id'])) + { + // if the user does not have permissions to list this forum skip + continue; + } + + if ($row['left_id'] < $right) + { + $padding .= ' '; + $padding_store[$row['parent_id']] = $padding; + } + else if ($row['left_id'] > $right + 1) + { + $padding = $padding_store[$row['parent_id']]; + } + + $right = $row['right_id']; + + $selected = (in_array($row['forum_id'], $forum_ids)) ? ' selected="selected"' : ''; + + if ($row['left_id'] > $cat_right) + { + $holding = ''; + } + + if ($row['right_id'] - $row['left_id'] > 1) + { + $cat_right = max($cat_right, $row['right_id']); + + $holding .= '<option value="' . $row['forum_id'] . '"' . (($row['forum_type'] == FORUM_POST) ? ' class="blue"' : '') . $selected . '>' . $padding . $row['forum_name'] . '</option>'; + } + else + { + echo $holding . '<option value="' . $row['forum_id'] . '"' . (($row['forum_type'] == FORUM_POST) ? ' class="blue"' : '') . $selected . '>' . $padding . $row['forum_name'] . '</option>'; + $holding = ''; + } + } + $db->sql_freeresult($result); + unset($padding_store); +?> + </select></td> + </tr> + <tr> <td class="cat" colspan="2" align="right"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" /> <input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" /></td> </tr> </table> @@ -1335,7 +1411,7 @@ function upload_file($post_id, $topic_id, $forum_id, $upload_dir, $filename) $message_parser->filename_data['filecomment'] = ''; $message_parser->filename_data['filename'] = $upload_dir . '/' . $filename; - $filedata = upload_attachment($filename, true, $upload_dir . '/' . $filename); + $filedata = upload_attachment($forum_id, $filename, true, $upload_dir . '/' . $filename); if ($filedata['post_attach'] && !sizeof($filedata['error'])) { @@ -1644,11 +1720,13 @@ function rewrite_extensions() { $extension = $row['extension']; - $extensions['_allowed_'][] = $extension; $extensions[$extension]['display_cat'] = (int) $row['cat_id']; $extensions[$extension]['download_mode']= (int) $row['download_mode']; $extensions[$extension]['upload_icon'] = (string) $row['upload_icon']; $extensions[$extension]['max_filesize'] = (int) $row['max_filesize']; + + // Store allowed extensions forum wise + $extensions['_allowed_'][$extension] = (!$row['allowed_forums']) ? 0 : unserialize(trim($row['allowed_forums'])); } $db->sql_freeresult($result); diff --git a/phpBB/adm/admin_forums.php b/phpBB/adm/admin_forums.php index 42438cfb1a..19cab76e6b 100644 --- a/phpBB/adm/admin_forums.php +++ b/phpBB/adm/admin_forums.php @@ -1134,7 +1134,7 @@ function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = ' if ($action_posts == 'delete') { $log_action_posts = 'POSTS'; - $errors += delete_forum_content($forum_id); + $errors = array_merge($errors, delete_forum_content($forum_id)); } elseif ($action_posts == 'move') { @@ -1160,7 +1160,7 @@ function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = ' $posts_to_name = $row['forum_name']; unset($row); - $errors += move_forum_content($forum_id, $subforums_to_id); + $errors = array_merge($errors, move_forum_content($forum_id, $subforums_to_id)); } } } @@ -1180,7 +1180,7 @@ function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = ' foreach ($rows as $row) { $forum_ids[] = $row['forum_id']; - $errors += delete_forum_content($row['forum_id']); + $errors = array_merge($errors, delete_forum_content($row['forum_id'])); } if (count($errors)) @@ -1265,6 +1265,27 @@ function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = ' WHERE left_id > $right_id"; $db->sql_query($sql); + if (!is_array($forum_ids)) + { + $forum_ids = array($forum_id); + } + + // Delete forum ids from extension groups table + $sql = 'SELECT group_id, allowed_forums + FROM ' . EXTENSION_GROUPS_TABLE . " + WHERE allowed_forums <> ''"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $allowed_forums = unserialize(trim($row['allowed_forums'])); + $allowed_forums = array_diff($allowed_forums, $forum_ids); + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " + SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "' + WHERE group_id = {$row['group_id']}"; + $db->sql_query($sql); + } + $log_action = implode('_', array($log_action_posts, $log_action_forums)); switch ($log_action) @@ -1311,11 +1332,10 @@ function delete_forum_content($forum_id) // Use delete_attachments('topic', $ids, false) here... // Select then delete all attachments - $sql = 'SELECT d.physical_filename, d.thumbnail - FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_DESC_TABLE . ' d, ' . ATTACHMENTS_TABLE . " a + $sql = 'SELECT a.physical_filename, a.thumbnail + FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a WHERE p.forum_id = $forum_id - AND a.post_id = p.post_id - AND d.attach_id = a.attach_id"; + AND a.post_id = p.post_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -1340,10 +1360,10 @@ function delete_forum_content($forum_id) POLL_VOTES_TABLE => 'pv.post_id' ); - $sql = 'DELETE QUICK FROM ' . POSTS_TABLE . ', ' . ATTACHMENTS_DESC_TABLE; - $sql_using = "\nUSING " . POSTS_TABLE . ' p, ' . ATTACHMENTS_DESC_TABLE . ' d'; - $sql_where = "\nWHERE p.forum_id = $forum_id\nAND d.attach_id = a.attach_id"; - $sql_optimise = 'OPTIMIZE TABLE . ' . POSTS_TABLE . ', ' . ATTACHMENTS_DESC_TABLE; + $sql = 'DELETE QUICK FROM ' . POSTS_TABLE; + $sql_using = "\nUSING " . POSTS_TABLE . ' p'; + $sql_where = "\nWHERE p.forum_id = $forum_id\n"; + $sql_optimise = 'OPTIMIZE TABLE . ' . POSTS_TABLE; foreach ($tables_ary as $table => $field) { @@ -1368,11 +1388,10 @@ function delete_forum_content($forum_id) default: // Select then delete all attachments - $sql = 'SELECT d.attach_id, d.physical_filename, d.thumbnail - FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . ' a, ' . ATTACHMENTS_DESC_TABLE . " d + $sql = 'SELECT a.attach_id, a.physical_filename, a.thumbnail + FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a WHERE p.forum_id = $forum_id - AND a.post_id = p.post_id - AND d.attach_id = a.attach_id"; + AND a.post_id = p.post_id"; $result = $db->sql_query($sql); $attach_ids = array(); @@ -1391,10 +1410,7 @@ function delete_forum_content($forum_id) if (count($attach_ids)) { $attach_id_list = implode(',', array_unique($attach_ids)); - $db->sql_query('DELETE FROM ' . ATTACHMENTS_TABLE . " WHERE attach_id IN ($attach_id_list)"); - $db->sql_query('DELETE FROM ' . ATTACHMENTS_DESC_TABLE . " WHERE attach_id IN ($attach_id_list)"); - unset($attach_ids, $attach_id_list); } @@ -1404,13 +1420,13 @@ function delete_forum_content($forum_id) SEARCH_MATCH_TABLE, RATINGS_TABLE, REPORTS_TABLE, - POLL_OPTIONS_TABLE, - POLL_VOTES_TABLE ), 'topic_id' => array( TOPICS_WATCH_TABLE, - TOPICS_TRACK_TABLE + TOPICS_TRACK_TABLE, + POLL_OPTIONS_TABLE, + POLL_VOTES_TABLE ) ); @@ -1446,7 +1462,7 @@ function delete_forum_content($forum_id) } unset($ids, $id_list); - $table_ary = array('phpbb_forum_access', POSTS_TABLE, TOPICS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, ACL_GROUPS_TABLE, ACL_USERS_TABLE, MODERATOR_TABLE, LOG_TABLE); + $table_ary = array('phpbb_forum_access', TOPICS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, ACL_GROUPS_TABLE, ACL_USERS_TABLE, MODERATOR_TABLE, LOG_TABLE); foreach ($table_ary as $table) { $db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id"); @@ -1456,7 +1472,7 @@ function delete_forum_content($forum_id) switch (SQL_LAYER) { case 'mysql': - $sql = 'OPTIMIZE TABLE ' . POSTS_TABLE . ', ' . ATTACHMENTS_TABLE . ', ' . ATTACHMENTS_DESC_TABLE . ', ' . implode(', ', $tables_ary['post_id']) . ', ' . implode(', ', $tables_ary['topic_id']) . ', ' . implode(', ', $table_ary); + $sql = 'OPTIMIZE TABLE ' . POSTS_TABLE . ', ' . ATTACHMENTS_TABLE . ', ' . implode(', ', $tables_ary['post_id']) . ', ' . implode(', ', $tables_ary['topic_id']) . ', ' . implode(', ', $table_ary); $db->sql_query($sql); break; |