Variante I: (siehe auch weiter unten Variante II)
Jeder Benutzer egal ob Admin oder Moderator kann das Thema das er eröffnet hat schließen/locken bzw. auch wieder öffnen. Man beachte die von Simpson erwähnte Problematik falls ein Admin/Moderator das Thema geschlossen hat.
phpBB2/language/lang_xxx/lang_main.php
suche nach
und füge in die nächste Zeile ein:
Code: Alles auswählen
$lang['Rules_openclose'] = 'You <b>can</b> lock/unlock <b>this</b> topic';
phpBB2/viewtopic.php
suche nach
und füge danach ein:
Code: Alles auswählen
$sql = "SELECT t.topic_id, t.topic_first_post_id, p.post_id, p.poster_id
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE t.topic_id = " . $topic_id . "
AND t.topic_first_post_id = p.post_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
if ($row['poster_id'] == $userdata['user_id'] AND $userdata['user_id'] != '-1' AND !$is_auth['auth_mod'])
{
$s_auth_can .= $lang['Rules_openclose'];
$topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=lock") . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['Lock_topic'] . '" title="' . $lang['Lock_topic'] . '" border="0" /></a> ' : '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=unlock") . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['Unlock_topic'] . '" title="' . $lang['Unlock_topic'] . '" border="0" /></a> ';
}
phpBB2/modcp.php
suche nach
Code: Alles auswählen
if ( !$is_auth['auth_mod'] )
{
message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
}
und
ersetze dies durch
Code: Alles auswählen
$sql = "SELECT t.topic_id, t.topic_first_post_id, p.post_id, p.poster_id
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE t.topic_id = " . $topic_id . "
AND t.topic_first_post_id = p.post_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
if ($row['poster_id'] == $userdata['user_id'] AND $userdata['user_id'] != '-1' AND !$is_auth['auth_mod'] AND ($mode == 'lock' OR $mode == 'unlock'))
{
if ($mode == 'lock')
{
if ( empty($topic_id) )
{
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_status = " . TOPIC_LOCKED . "
WHERE topic_id = " . $topic_id . "
AND topic_moved_id = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
}
if ( !empty($topic_id) )
{
$redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
$message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
}
$message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
);
message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . '<br /><br />' . $message);
}
if ($mode == 'unlock')
{
if ( empty($topic_id) )
{
message_die(GENERAL_MESSAGE, $lang['None_selected']);
}
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_status = " . TOPIC_UNLOCKED . "
WHERE topic_id = " . $topic_id . "
AND topic_moved_id = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
}
if ( !empty($topic_id) )
{
$redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
$message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
}
$message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
);
message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . '<br /><br />' . $message);
}
else
{
message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
}
//nur zur Sicherheit nochmal exit ;)
exit;
}
else
{
if ( !$is_auth['auth_mod'] )
{
message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
}
}
Ich weiß, dass da ein paar Sachen doppelt durchgecheckt werden, aber ich hab jetzt nicht die Lust das weiter auseinander zunehmen, bei meinen kurzen Tests ging alles ohne Probleme, der Themenstarter kann ohne Probleme sein Thema schließen bzw. öffnen.
@Simpson es sollte auch möglich sein, dass der Themenstarter sein Thema NUR schließen kann, aber nicht mehr öffnen.
Bitte probiert diesen Code in Ruhe aus, irgendeine Sicherheitslück sollte nicht entstehen (wie gesagt manches checke ich ja sogar mehrfach durch), falls ich etwas übersehen haben sollte bitte melden!