Additions for forum auto_pruning, and fix for form submission on edits

git-svn-id: file:///svn/phpbb/trunk@956 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
the_systech 2001-08-31 20:58:31 +00:00
parent ddf104d781
commit 5c6eb1e149
4 changed files with 116 additions and 18 deletions

View file

@ -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); 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; $show_index = TRUE;
break; break;
case 'modforum': // Modify a forum in the DB 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 $sql = "UPDATE ".FORUMS_TABLE." SET
forum_name = '".$HTTP_POST_VARS['forumname']."', forum_name = '".$HTTP_POST_VARS['forumname']."',
cat_id = '".$HTTP_POST_VARS['cat_id']."', cat_id = '".$HTTP_POST_VARS['cat_id']."',
forum_desc = '".$HTTP_POST_VARS['forumdesc']."', 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']."'"; WHERE forum_id = '".$HTTP_POST_VARS['forum_id']."'";
if( !$result = $db->sql_query($sql) ) if( !$result = $db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, "Couldn't update forum information", "", __LINE__, __FILE__, $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; $show_index = TRUE;
break; break;
@ -279,6 +331,21 @@ if(isset($mode)) // Are we supposed to do something?
$cat_id = $row['cat_id']; $cat_id = $row['cat_id'];
$forumdesc = $row['forum_desc']; $forumdesc = $row['forum_desc'];
$forumstatus = $row['forum_status']; $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 else
{ {
@ -304,10 +371,18 @@ if(isset($mode)) // Are we supposed to do something?
$template->assign_vars(array( $template->assign_vars(array(
'FORUMNAME' => $forumname, 'FORUMNAME' => $forumname,
'DESCRIPTION' => $forumdesc, 'DESCRIPTION' => $forumdesc,
'S_FORUM_ACTION' => $PHP_SELF,
'S_CATLIST' => $catlist, 'S_CATLIST' => $catlist,
'S_STATUSLIST' => $statuslist, 'S_STATUSLIST' => $statuslist,
'S_FORUMID' => $forum_id, 'S_FORUMID' => $forum_id,
'S_NEWMODE' => $newmode, '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) 'BUTTONVALUE' => $buttonvalue)
); );
$template->pparse("body"); $template->pparse("body");

View file

@ -157,15 +157,13 @@ function auto_prune($forum_id = 0)
} }
while($row = $db->sql_fetchrow($result)) while($row = $db->sql_fetchrow($result))
{
if($row['prune_freq'] > 0 && $row['prune_days'] > 0)
{ {
$forum_id = $row['forum_id']; $forum_id = $row['forum_id'];
$prune_date = time() - ($row['prune_days'] * $one_day); $prune_date = time() - ($row['prune_days'] * $one_day);
$pruned = prune($forum_id, $prune_date); $pruned = prune($forum_id, $prune_date);
$next_prune = time() + ($row['prune_freq'] * $one_day); $next_prune = time() + ($row['prune_freq'] * $one_day);
$sql = "UPDATE " . FORUMS_TABLE . " $sql = "UPDATE " . FORUMS_TABLE . "
SET prune_next = $next_prune SET prune_next = $next_prune
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
@ -173,7 +171,7 @@ function auto_prune($forum_id = 0)
{ {
message_die(GENERAL_ERROR, "Auto-Prune: Couldn't update forum table.", __LINE__, __FILE__); message_die(GENERAL_ERROR, "Auto-Prune: Couldn't update forum table.", __LINE__, __FILE__);
} }
}
} }
return; return;

View file

@ -70,7 +70,7 @@ $lang['Month'] = "Month";
$lang['Months'] = "Months"; $lang['Months'] = "Months";
$lang['Year'] = "Year"; $lang['Year'] = "Year";
$lang['Years'] = "Years"; $lang['Years'] = "Years";
$lang['Enabled'] = "Enabled";
$lang['Next'] = "Next"; $lang['Next'] = "Next";
$lang['Previous'] = "Previous"; $lang['Previous'] = "Previous";
$lang['Goto_page'] = "Goto page"; $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['group_delete_check'] = "Click here to delete this group.";
$lang['submit_group_changes'] = "Submit Changes"; $lang['submit_group_changes'] = "Submit Changes";
$lang['reset_group_changes'] = "Reset 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 // End

View file

@ -36,6 +36,25 @@
</select> </select>
</td> </td>
</tr> </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">&nbsp;<input type="text" name="prune_days" value="{S_PRUNE_DAYS}" size="5">&nbsp;{L_DAYS}</td>
</tr>
<tr>
<td align="right" valign="middle">{L_PRUNE_FREQ}</td>
<td align="left" valign="middle">&nbsp;<input type="text" name="prune_freq" value="{S_PRUNE_FREQ}" size="5">&nbsp;{L_DAYS}</td>
</tr>
</table>
</td>
</tr>
<tr> <tr>
<td class="row2" colspan="2" align="center"> <td class="row2" colspan="2" align="center">
<input type="hidden" name="mode" value="{S_NEWMODE}"> <input type="hidden" name="mode" value="{S_NEWMODE}">