diff options
-rw-r--r-- | phpBB/admin/admin_forums.php | 77 | ||||
-rw-r--r-- | phpBB/includes/prune.php | 28 | ||||
-rwxr-xr-x | phpBB/language/lang_english.php | 10 | ||||
-rw-r--r-- | phpBB/templates/PSO/admin/forum_edit_body.tpl | 19 |
4 files changed, 116 insertions, 18 deletions
diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php index 4da935a502..d9fa09729f 100644 --- a/phpBB/admin/admin_forums.php +++ b/phpBB/admin/admin_forums.php @@ -224,19 +224,71 @@ if(isset($mode)) // Are we supposed to do something? { message_die(GENERAL_ERROR, "Couldn't insert row in forums table", "", __LINE__, __FILE__, $sql); } + if($HTTP_POST_VARS['prune_enable'] == 1) + { + $new_forum_id = $db->sql_nextid(); + $sql = "INSERT INTO ".PRUNE_TABLE." ( + forum_id, + prune_days, + prune_freq) + VALUES( + '$new_forum_id', + '".$HTTP_POST_VARS['prune_days']."', + '".$HTTP_POST_VARS['prune_freq']."')"; + if( !$result = $db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, "Couldn't insert row in prune table", "", __LINE__, __FILE__, $sql); + } + } $show_index = TRUE; break; case 'modforum': // Modify a forum in the DB + if($HTTP_POST_VARS['prune_enable'] != 1) + { + $HTTP_POST_VARS['prune_enable'] = 0; + } $sql = "UPDATE ".FORUMS_TABLE." SET forum_name = '".$HTTP_POST_VARS['forumname']."', cat_id = '".$HTTP_POST_VARS['cat_id']."', forum_desc = '".$HTTP_POST_VARS['forumdesc']."', - forum_status = '".$HTTP_POST_VARS['forumstatus']."' + forum_status = '".$HTTP_POST_VARS['forumstatus']."', + prune_enable = '".$HTTP_POST_VARS['prune_enable']."' WHERE forum_id = '".$HTTP_POST_VARS['forum_id']."'"; if( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Couldn't update forum information", "", __LINE__, __FILE__, $sql); } + if($HTTP_POST_VARS['prune_enable'] == 1) + { + $sql = "SELECT * FROM ".PRUNE_TABLE." + WHERE forum_id = '".$HTTP_POST_VARS['forum_id']."'"; + if( !$result = $db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, "Couldn't get forum Prune Information","",__LINE__, __FILE__, $sql); + } + if( $db->sql_numrows($result) > 0 ) + { + $sql = "UPDATE ".PRUNE_TABLE." SET + prune_days = '".$HTTP_POST_VARS['prune_days']."', + prune_freq = '".$HTTP_POST_VARS['prune_freq']."' + WHERE forum_id = '".$HTTP_POST_VARS['forum_id']."'"; + } + else + { + $sql = "INSERT INTO ".PRUNE_TABLE."( + forum_id, + prune_days, + prune_freq) + VALUES( + '".$HTTP_POST_VARS['forum_id']."', + '".$HTTP_POST_VARS['prune_days']."', + '".$HTTP_POST_VARS['prune_freq']."')"; + } + if( !$result = $db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, "Couldn't Update Forum Prune Information","",__LINE__, __FILE__, $sql); + } + } $show_index = TRUE; break; @@ -279,6 +331,21 @@ if(isset($mode)) // Are we supposed to do something? $cat_id = $row['cat_id']; $forumdesc = $row['forum_desc']; $forumstatus = $row['forum_status']; + // + // start forum prune stuff. + // + if( $row['prune_enable'] == 1 ) + { + $prune_enabled = "CHECKED"; + $sql = "SELECT * + FROM " . PRUNE_TABLE . " + WHERE forum_id = $forum_id"; + if(!$pr_result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Auto-Prune: Couldn't read auto_prune table.", __LINE__, __FILE__); + } + $pr_row = $db->sql_fetchrow($pr_result); + } } else { @@ -304,10 +371,18 @@ if(isset($mode)) // Are we supposed to do something? $template->assign_vars(array( 'FORUMNAME' => $forumname, 'DESCRIPTION' => $forumdesc, + 'S_FORUM_ACTION' => $PHP_SELF, 'S_CATLIST' => $catlist, 'S_STATUSLIST' => $statuslist, 'S_FORUMID' => $forum_id, 'S_NEWMODE' => $newmode, + 'S_PRUNE_EN' => $prune_enabled, + 'S_PRUNE_DAYS' => $pr_row['prune_days'], + 'S_PRUNE_FREQ' => $pr_row['prune_freq'], + 'L_ENABLED' => $lang['Enabled'], + 'L_PRUNE_DAYS' => $lang['prune_days'], + 'L_PRUNE_FREQ' => $lang['prune_freq'], + 'L_DAYS' => $lang['days'], 'BUTTONVALUE' => $buttonvalue) ); $template->pparse("body"); diff --git a/phpBB/includes/prune.php b/phpBB/includes/prune.php index b820f24359..9224e71a25 100644 --- a/phpBB/includes/prune.php +++ b/phpBB/includes/prune.php @@ -158,25 +158,23 @@ function auto_prune($forum_id = 0) while($row = $db->sql_fetchrow($result)) { - $forum_id = $row['forum_id']; - - $prune_date = time() - ($row['prune_days'] * $one_day); - - $pruned = prune($forum_id, $prune_date); - - $next_prune = time() + ($row['prune_freq'] * $one_day); - - $sql = "UPDATE " . FORUMS_TABLE . " - SET prune_next = $next_prune - WHERE forum_id = $forum_id"; - if(!$db->sql_query($sql)) + if($row['prune_freq'] > 0 && $row['prune_days'] > 0) { - message_die(GENERAL_ERROR, "Auto-Prune: Couldn't update forum table.", __LINE__, __FILE__); + $forum_id = $row['forum_id']; + $prune_date = time() - ($row['prune_days'] * $one_day); + $pruned = prune($forum_id, $prune_date); + $next_prune = time() + ($row['prune_freq'] * $one_day); + $sql = "UPDATE " . FORUMS_TABLE . " + SET prune_next = $next_prune + WHERE forum_id = $forum_id"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Auto-Prune: Couldn't update forum table.", __LINE__, __FILE__); + } } - } return; } -?>
\ No newline at end of file +?> diff --git a/phpBB/language/lang_english.php b/phpBB/language/lang_english.php index 62994d1218..80c7abda4a 100755 --- a/phpBB/language/lang_english.php +++ b/phpBB/language/lang_english.php @@ -70,7 +70,7 @@ $lang['Month'] = "Month"; $lang['Months'] = "Months"; $lang['Year'] = "Year"; $lang['Years'] = "Years"; - +$lang['Enabled'] = "Enabled"; $lang['Next'] = "Next"; $lang['Previous'] = "Previous"; $lang['Goto_page'] = "Goto page"; @@ -835,6 +835,12 @@ $lang['group_delete'] = "Delete group"; $lang['group_delete_check'] = "Click here to delete this group."; $lang['submit_group_changes'] = "Submit Changes"; $lang['reset_group_changes'] = "Reset Changes"; +// +// Prune Administration +// +$lang['prune_days'] = 'Remove topics that haven\'t been posted to in'; +$lang['prune_freq'] = 'Check for topic age every'; +$lang['days'] = 'Days'; // // End @@ -939,4 +945,4 @@ $l_emailpass = "Email Lost Password"; $l_passexplain = "Please fill out the form, a new password will be sent to your Email address"; $l_sendpass = "Send Password"; -?>
\ No newline at end of file +?> diff --git a/phpBB/templates/PSO/admin/forum_edit_body.tpl b/phpBB/templates/PSO/admin/forum_edit_body.tpl index 46a329ace1..dbe7241cbd 100644 --- a/phpBB/templates/PSO/admin/forum_edit_body.tpl +++ b/phpBB/templates/PSO/admin/forum_edit_body.tpl @@ -37,6 +37,25 @@ </td> </tr> <tr> + <td class="row1">Auto Pruning:</td> + <td class="row2"> + <table> + <tr> + <td align="right" valign="middle">{L_ENABLED}</td> + <td align="left" valign="middle"><input type="checkbox" name="prune_enable" value="1" {S_PRUNE_EN}></td> + </tr> + <tr> + <td align="right" valign="middle">{L_PRUNE_DAYS}</td> + <td align="left" valign="middle"> <input type="text" name="prune_days" value="{S_PRUNE_DAYS}" size="5"> {L_DAYS}</td> + </tr> + <tr> + <td align="right" valign="middle">{L_PRUNE_FREQ}</td> + <td align="left" valign="middle"> <input type="text" name="prune_freq" value="{S_PRUNE_FREQ}" size="5"> {L_DAYS}</td> + </tr> + </table> + </td> + </tr> + <tr> <td class="row2" colspan="2" align="center"> <input type="hidden" name="mode" value="{S_NEWMODE}"> <input type="hidden" name="forum_id" value="{S_FORUMID}"> |