author | Dan |
Thu, 29 Nov 2007 21:48:02 -0500 | |
changeset 11 | 5585ac341820 |
parent 3 | 88b85b9b9272 |
permissions | -rw-r--r-- |
2 | 1 |
<?php |
2 |
/* |
|
3 |
* Decir |
|
4 |
* Version 0.1 |
|
5 |
* Copyright (C) 2007 Dan Fuhry |
|
6 |
* restoretopic.php - restores a deleted topic |
|
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 |
require('common.php'); |
|
16 |
||
17 |
$tid = $paths->getParam(1); |
|
18 |
if ( strval(intval($tid)) !== $tid ) |
|
19 |
{ |
|
20 |
die_friendly('Error', '<p>Invalid topic ID</p>'); |
|
21 |
} |
|
22 |
||
23 |
$tid = intval($tid); |
|
24 |
||
25 |
// Obtain topic info |
|
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
26 |
$q = $db->sql_query('SELECT t.forum_id, t.topic_id, t.topic_deleted, t.topic_deletor, t.topic_starter, t.topic_delete_reason, u.username AS deletor FROM '.table_prefix.'decir_topics AS t |
2 | 27 |
LEFT JOIN '.table_prefix.'users AS u |
28 |
ON ( u.user_id = t.topic_deletor OR t.topic_deletor IS NULL ) |
|
29 |
WHERE t.topic_id='.$tid.';'); |
|
30 |
if ( !$q ) |
|
31 |
$db->_die('Decir restoretopic.php'); |
|
32 |
||
33 |
if ( $db->numrows() < 1 ) |
|
34 |
{ |
|
35 |
die_friendly('Error', '<p>The topic you requested does not exist.</p>'); |
|
36 |
} |
|
37 |
||
38 |
$row = $db->fetchrow(); |
|
39 |
$db->free_result(); |
|
40 |
||
41 |
$tid = intval($row['topic_id']); |
|
42 |
||
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
43 |
$acl_type = ( $row['topic_starter'] == $session->user_id && $session->user_logged_in ) ? 'decir_undelete_own_topic' : 'decir_undelete_other_topic'; |
2 | 44 |
|
45 |
$post_perms = $session->fetch_page_acl(strval($pid), 'DecirPost'); |
|
3
88b85b9b9272
What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents:
2
diff
changeset
|
46 |
if ( !$post_perms->get_permissions($acl_type) ) |
2 | 47 |
{ |
48 |
die_friendly('Error', '<p>You do not have permission to restore this topic.</p>'); |
|
49 |
} |
|
50 |
||
51 |
$edit_reason = ''; |
|
52 |
if ( isset($_GET['act']) && $_GET['act'] == 'submit' ) |
|
53 |
{ |
|
54 |
if ( isset($_POST['do']['restore']) ) |
|
55 |
{ |
|
56 |
$result = decir_restore_topic($tid); |
|
57 |
if ( $result ) |
|
58 |
{ |
|
59 |
$url = makeUrlNS('Special', 'Forum/Topic/' . $tid, false, true); |
|
60 |
redirect($url, 'Topic restored', 'The selected topic has been restored.', 4); |
|
61 |
} |
|
62 |
} |
|
63 |
else if ( isset($_POST['do']['noop']) ) |
|
64 |
{ |
|
65 |
$url = makeUrlNS('Special', 'Forum/Topic/' . $tid, false, true); |
|
66 |
redirect($url, '', '', 0); |
|
67 |
} |
|
68 |
} |
|
69 |
||
70 |
$template->header(true); |
|
71 |
$form_submit_url = makeUrlNS('Special', 'Forum/RestoreTopic/' . $tid, 'act=submit', true); |
|
72 |
?> |
|
73 |
<form action="<?php echo $form_submit_url; ?>" method="post" enctype="multipart/form-data"> |
|
74 |
<p>Are you sure you want to restore this topic? If you do this, the public will be able to view it (providing that an access rule hasn't specified otherwise).</p> |
|
75 |
<p><input type="submit" name="do[restore]" value="Restore topic" tabindex="3" /> <input tabindex="4" type="submit" name="do[noop]" value="Cancel" /></p> |
|
76 |
</form> |
|
77 |
<?php |
|
78 |
$template->footer(true); |
|
79 |
||
80 |
?> |