author | Dan |
Thu, 29 Nov 2007 21:48:02 -0500 | |
changeset 11 | 5585ac341820 |
parent 7 | 37387f84fe25 |
permissions | -rw-r--r-- |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
1 |
<?php |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
2 |
/* |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
3 |
* Decir |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
4 |
* Version 0.1 |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
5 |
* Copyright (C) 2007 Dan Fuhry |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
6 |
* functions.php - Utility functions used by most Decir modules |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
7 |
* |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
10 |
* |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
13 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
14 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
15 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
16 |
* Inserts a post in reply to a topic. Does NOT check any type of authorization at all. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
17 |
* @param int Topic ID |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
18 |
* @param string Post subject |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
19 |
* @param string Post text |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
20 |
* @param reference Will be set to the new post ID. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
21 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
22 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
23 |
function decir_submit_post($topic_id, $post_subject, $post_text, &$post_id = false) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
24 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
25 |
global $db, $session, $paths, $template, $plugins; // Common objects |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
26 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
27 |
if ( !is_int($topic_id) ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
28 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
29 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
30 |
$poster_id = $session->user_id; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
31 |
$poster_name = ( $session->user_logged_in ) ? $db->escape($session->username) : 'Anonymous'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
32 |
$timestamp = time(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
33 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
34 |
$post_text = bbcode_inject_uid($post_text, $bbcode_uid); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
35 |
$post_text = $db->escape($post_text); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
36 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
37 |
$post_subject = $db->escape($post_subject); |
11
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
38 |
if ( empty($post_subject) ) |
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
39 |
{ |
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
40 |
$q = $db->sql_query('SELECT topic_title FROM '.table_prefix.'decir_topics WHERE topic_id = ' . $topic_id . ';'); |
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
41 |
if ( !$q ) |
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
42 |
$db->_die('Decir functions.php in decir_submit_post()'); |
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
43 |
if ( $db->numrows() < 1 ) |
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
44 |
return false; |
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
45 |
list($post_subject) = $db->fetchrow_num(); |
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
46 |
$post_subject = 'Re: ' . $db->escape($post_subject); |
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
47 |
} |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
48 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
49 |
$q = $db->sql_query('INSERT INTO '.table_prefix."decir_posts(topic_id,poster_id,poster_name,post_subject,timestamp) VALUES($topic_id, $poster_id, '$poster_name', '$post_subject', $timestamp);"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
50 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
51 |
$db->_die('Decir functions.php in decir_submit_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
52 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
53 |
$post_id = $db->insert_id(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
54 |
$q = $db->sql_query('INSERT INTO '.table_prefix."decir_posts_text(post_id, post_text, bbcode_uid) VALUES($post_id, '$post_text', '$bbcode_uid');"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
55 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
56 |
$db->_die('Decir functions.php in decir_submit_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
57 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
58 |
return true; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
59 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
60 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
61 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
62 |
* Registers a new topic. Does not perform any type of authorization checks at all. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
63 |
* @param int Forum ID |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
64 |
* @param string Post subject |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
65 |
* @param string Post text |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
66 |
* @param reference Will be set to the new topic ID |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
67 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
68 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
69 |
function decir_submit_topic($forum_id, $post_subject, $post_text, &$topic_id = false, &$post_id = false) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
70 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
71 |
global $db, $session, $paths, $template, $plugins; // Common objects |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
72 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
73 |
if ( !is_int($forum_id) ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
74 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
75 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
76 |
$poster_id = $session->user_id; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
77 |
$timestamp = time(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
78 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
79 |
$topic_subject = $db->escape($post_subject); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
80 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
81 |
$q = $db->sql_query('INSERT INTO ' . table_prefix . "decir_topics(forum_id, topic_title, topic_starter, timestamp) VALUES( $forum_id, '$topic_subject', $poster_id, $timestamp );"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
82 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
83 |
$db->_die('Decir functions.php in decir_submit_topic()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
84 |
$topic_id = $db->insert_id(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
85 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
86 |
// Submit the post |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
87 |
$postsub = decir_submit_post($topic_id, $post_subject, $post_text, $post_id); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
88 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
89 |
if ( !$postsub ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
90 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
91 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
92 |
// Update "last post" |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
93 |
$q = $db->sql_query('UPDATE '.table_prefix."decir_topics SET last_post=$post_id WHERE topic_id=$topic_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
94 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
95 |
$db->_die('Decir functions.php in decir_submit_topic()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
96 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
97 |
return true; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
98 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
99 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
100 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
101 |
* Modifies a post's text. Does not perform any type of authorization checks at all. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
102 |
* @param int Post ID |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
103 |
* @param string Post subject |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
104 |
* @param string Post text |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
105 |
* @param string Reason for editing |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
106 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
107 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
108 |
function decir_edit_post($post_id, $subject, $message, $reason) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
109 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
110 |
global $db, $session, $paths, $template, $plugins; // Common objects |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
111 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
112 |
if ( !is_int($post_id) ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
113 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
114 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
115 |
$last_edited_by = $session->user_id; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
116 |
$edit_reason = $db->escape($reason); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
117 |
$post_subject = $db->escape($subject); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
118 |
$post_text = bbcode_inject_uid($message, $bbcode_uid); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
119 |
$post_text = $db->escape($post_text); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
120 |
|
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
121 |
// grace period: if the user is editing his/her own post 10 minutes or less after they originally submitted it, don't mark it as edited |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
122 |
$grace = time() - ( 10 * 60 ); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
123 |
$q = $db->sql_query('UPDATE '.table_prefix."decir_posts SET post_subject='$post_subject', edit_count = edit_count + 1, edit_reason='$edit_reason', last_edited_by=$last_edited_by WHERE post_id=$post_id AND timestamp < $grace;"); |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
124 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
125 |
$db->_die('Decir functions.php in decir_edit_post()'); |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
126 |
|
11
5585ac341820
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents:
7
diff
changeset
|
127 |
$q = $db->sql_query('UPDATE '.table_prefix."decir_posts_text SET post_text='$post_text',bbcode_uid='$bbcode_uid' WHERE post_id=$post_id;"); |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
128 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
129 |
$db->_die('Decir functions.php in decir_edit_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
130 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
131 |
return true; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
132 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
133 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
134 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
135 |
* Deletes a post, or a topic if the post is the first topic in the thread. Does not perform any type of authorization checks at all. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
136 |
* @param int Post id |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
137 |
* @param string Reason for deletion |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
138 |
* @param bool If true, removes the post physically from the database instead of "soft" deleting it |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
139 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
140 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
141 |
function decir_delete_post($post_id, $del_reason, $for_real = false) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
142 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
143 |
global $db, $session, $paths, $template, $plugins; // Common objects |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
144 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
145 |
if ( !is_int($post_id) ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
146 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
147 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
148 |
// Is this the first post in the thread? |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
149 |
$q = $db->sql_query('SELECT topic_id FROM '.table_prefix."decir_posts WHERE post_id = $post_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
150 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
151 |
$db->_die('Decir functions.php in decir_delete_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
152 |
if ( $db->numrows() < 1 ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
153 |
// Post doesn't exist |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
154 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
155 |
$row = $db->fetchrow(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
156 |
$db->free_result(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
157 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
158 |
$topic_id = intval($row['topic_id']); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
159 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
160 |
// while we're at it, also get the forum id |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
161 |
$q = $db->sql_query('SELECT p.post_id, t.forum_id FROM '.table_prefix."decir_posts AS p |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
162 |
LEFT JOIN ".table_prefix."decir_topics AS t |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
163 |
ON ( t.topic_id = p.topic_id ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
164 |
WHERE p.topic_id = $topic_id ORDER BY p.timestamp ASC LIMIT 1;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
165 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
166 |
$db->_die('Decir functions.php in decir_delete_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
167 |
$row = $db->fetchrow(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
168 |
$db->free_result(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
169 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
170 |
$forum_id = intval($row['forum_id']); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
171 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
172 |
if ( $row['post_id'] == $post_id ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
173 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
174 |
// first post in the thread |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
175 |
return decir_delete_topic($topic_id, $del_reason, $for_real); |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
176 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
177 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
178 |
$del_reason = $db->escape($del_reason); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
179 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
180 |
if ( $for_real ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
181 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
182 |
$q = $db->sql_query('DELETE FROM '.table_prefix."decir_posts_text WHERE post_id = $post_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
183 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
184 |
$db->_die('Decir functions.php in decir_delete_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
185 |
$q = $db->sql_query('DELETE FROM '.table_prefix."decir_posts WHERE post_id = $post_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
186 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
187 |
$db->_die('Decir functions.php in decir_delete_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
188 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
189 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
190 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
191 |
// Delete the post |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
192 |
$q = $db->sql_query('UPDATE '.table_prefix."decir_posts SET post_deleted = 1, last_edited_by = $session->user_id, edit_reason = '$del_reason' WHERE post_id = $post_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
193 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
194 |
$db->_die('Decir functions.php in decir_delete_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
195 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
196 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
197 |
// update forum stats |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
198 |
$q = $db->sql_query('UPDATE '.table_prefix."decir_forums SET num_posts = num_posts - 1 WHERE forum_id = $forum_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
199 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
200 |
$db->_die('Decir functions.php in decir_delete_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
201 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
202 |
// update last post and topic |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
203 |
decir_update_forum_stats($forum_id); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
204 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
205 |
return true; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
206 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
207 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
208 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
209 |
* Deletes a topic. Does not perform any type of authorization checks at all. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
210 |
* @param int Topic ID |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
211 |
* @param string Reason for deleting the topic |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
212 |
* @param bool If true, physically removes the topic from the database; else, just turns on the delete switch |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
213 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
214 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
215 |
function decir_delete_topic($topic_id, $del_reason, $unlink = false) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
216 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
217 |
global $db, $session, $paths, $template, $plugins; // Common objects |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
218 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
219 |
if ( !is_int($topic_id) ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
220 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
221 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
222 |
// Obtain a list of posts in the topic |
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
|
223 |
$q = $db->sql_query('SELECT post_id, post_deleted FROM '.table_prefix.'decir_posts WHERE topic_id = ' . $topic_id . ';'); |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
224 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
225 |
$db->_die('Decir functions.php in decir_delete_topic()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
226 |
if ( $db->numrows() < 1 ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
227 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
228 |
$posts = array(); |
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
|
229 |
$del_count = 0; |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
230 |
while ( $row = $db->fetchrow() ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
231 |
{ |
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
|
232 |
if ( $row['post_deleted'] == 1 ) |
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
|
233 |
// Don't decrement the post count for deleted posts |
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
|
234 |
$del_count++; |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
235 |
$posts[] = $row['post_id']; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
236 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
237 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
238 |
// Obtain forum ID |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
239 |
$q = $db->sql_query('SELECT forum_id FROM '.table_prefix."decir_topics WHERE topic_id = $topic_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
240 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
241 |
$db->_die('Decir functions.php in decir_delete_topic()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
242 |
list($forum_id) = $db->fetchrow_num(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
243 |
$db->free_result(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
244 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
245 |
// Perform delete |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
246 |
if ( $unlink ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
247 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
248 |
// Remove all posts from the database |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
249 |
$post_list = implode(' OR post_id=', $posts); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
250 |
$q = $db->sql_query('DELETE FROM '.table_prefix."decir_posts_text WHERE $post_list;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
251 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
252 |
$db->_die('Decir functions.php in decir_delete_topic()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
253 |
$q = $db->sql_query('DELETE FROM '.table_prefix."decir_posts WHERE $post_list;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
254 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
255 |
$db->_die('Decir functions.php in decir_delete_topic()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
256 |
// Remove the topic itself |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
257 |
$q = $db->sql_query('DELETE FROM '.table_prefix."decir_topics WHERE topic_id = $topic_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
258 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
259 |
$db->_die('Decir functions.php in decir_delete_topic()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
260 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
261 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
262 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
263 |
$reason = $db->escape($del_reason); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
264 |
$topic_deletor = $session->user_id; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
265 |
$q = $db->sql_query('UPDATE ' . table_prefix . "decir_topics SET topic_deleted = 1, topic_deletor = $topic_deletor, topic_delete_reason = '$reason' WHERE topic_id = $topic_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
266 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
267 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
268 |
// Update forum stats |
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
|
269 |
$post_count = count($posts) - $del_count; |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
270 |
$q = $db->sql_query('UPDATE '.table_prefix."decir_forums SET num_topics = num_topics - 1, num_posts = num_posts - $post_count WHERE forum_id = $forum_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
271 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
272 |
$db->_die('Decir functions.php in decir_delete_topic()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
273 |
decir_update_forum_stats($forum_id); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
274 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
275 |
return true; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
276 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
277 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
278 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
279 |
* Updates the last post information for the specified forum. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
280 |
* @param int Forum ID |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
281 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
282 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
283 |
function decir_update_forum_stats($forum_id) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
284 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
285 |
global $db, $session, $paths, $template, $plugins; // Common objects |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
286 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
287 |
if ( !is_int($forum_id) ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
288 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
289 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
290 |
$sql = 'SELECT p.post_id, p.poster_id, p.topic_id FROM ' . table_prefix . "decir_posts AS p |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
291 |
LEFT JOIN ".table_prefix."decir_topics AS t |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
292 |
ON ( t.topic_id = p.topic_id ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
293 |
WHERE t.forum_id = $forum_id |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
294 |
AND p.post_deleted != 1 |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
295 |
ORDER BY p.timestamp DESC |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
296 |
LIMIT 1;"; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
297 |
$q = $db->sql_query($sql); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
298 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
299 |
$db->_die('Decir functions.php in decir_update_forum_stats()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
300 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
301 |
if ( $db->numrows() < 1 ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
302 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
303 |
$last_post_id = 'NULL'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
304 |
$last_post_topic = 'NULL'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
305 |
$last_post_user = 'NULL'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
306 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
307 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
308 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
309 |
$row = $db->fetchrow(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
310 |
$last_post_id = intval($row['post_id']); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
311 |
$last_post_topic = intval($row['topic_id']); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
312 |
$last_post_user = intval($row['poster_id']); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
313 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
314 |
$db->free_result(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
315 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
316 |
$sql = 'UPDATE ' . table_prefix . "decir_forums SET last_post_id = $last_post_id, last_post_topic = $last_post_topic, |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
317 |
last_post_user = $last_post_user WHERE forum_id = $forum_id;"; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
318 |
if ( $db->sql_query($sql) ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
319 |
return true; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
320 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
321 |
$db->_die('Decir functions.php in decir_update_forum_stats()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
322 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
323 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
324 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
325 |
* Un-deletes a post so that the public can see it. |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
326 |
* @param int Post ID |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
327 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
328 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
329 |
function decir_restore_post($post_id) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
330 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
331 |
global $db, $session, $paths, $template, $plugins; // Common objects |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
332 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
333 |
if ( !is_int($post_id) ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
334 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
335 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
336 |
$q = $db->sql_query('UPDATE ' . table_prefix . "decir_posts SET post_deleted = 0, edit_count = 0, last_edited_by = NULL, edit_reason = '' WHERE post_id = $post_id AND post_deleted = 1;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
337 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
338 |
$db->_die('Decir functions.php in decir_restore_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
339 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
340 |
if ( $db->sql_affectedrows() > 0 ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
341 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
342 |
// get forum id |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
343 |
$q = $db->sql_query('SELECT t.forum_id FROM '.table_prefix."decir_posts AS p |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
344 |
LEFT JOIN ".table_prefix."decir_topics AS t |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
345 |
ON ( p.topic_id = t.topic_id ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
346 |
WHERE p.post_id = $post_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
347 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
348 |
$db->_die('Decir functions.php in decir_restore_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
349 |
$row = $db->fetchrow(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
350 |
$db->free_result(); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
351 |
$forum_id = intval($row['forum_id']); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
352 |
// Update forum stats |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
353 |
$q = $db->sql_query('UPDATE ' . table_prefix . "decir_forums SET num_posts = num_posts + 1 WHERE forum_id = $forum_id;"); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
354 |
if ( !$q ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
355 |
$db->_die('Decir functions.php in decir_restore_post()'); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
356 |
decir_update_forum_stats($forum_id); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
357 |
return true; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
358 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
359 |
return false; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
360 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
361 |
|
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
362 |
/** |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
363 |
* Un-deletes a topic so that the public can see it. |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
364 |
* @param int Topic ID |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
365 |
*/ |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
366 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
367 |
function decir_restore_topic($topic_id) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
368 |
{ |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
369 |
global $db, $session, $paths, $template, $plugins; // Common objects |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
370 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
371 |
if ( !is_int($topic_id) ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
372 |
return false; |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
373 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
374 |
// Obtain a list of posts in the topic |
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
|
375 |
$q = $db->sql_query('SELECT post_id, post_deleted FROM '.table_prefix.'decir_posts WHERE topic_id = ' . $topic_id . ';'); |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
376 |
if ( !$q ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
377 |
$db->_die('Decir functions.php in decir_delete_topic()'); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
378 |
if ( $db->numrows() < 1 ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
379 |
return false; |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
380 |
$posts = array(); |
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
|
381 |
$del_count = 0; |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
382 |
while ( $row = $db->fetchrow() ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
383 |
{ |
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
|
384 |
if ( $row['post_deleted'] == 1 ) |
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
|
385 |
// Don't decrement the post count for deleted posts |
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
|
386 |
$del_count++; |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
387 |
$posts[] = $row['post_id']; |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
388 |
} |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
389 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
390 |
// Obtain forum ID |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
391 |
$q = $db->sql_query('SELECT forum_id FROM '.table_prefix."decir_topics WHERE topic_id = $topic_id;"); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
392 |
if ( !$q ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
393 |
$db->_die('Decir functions.php in decir_restore_topic()'); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
394 |
list($forum_id) = $db->fetchrow_num(); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
395 |
$db->free_result(); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
396 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
397 |
$q = $db->sql_query('UPDATE ' . table_prefix . "decir_topics SET topic_deleted = 0, topic_deletor = NULL, topic_delete_reason = NULL WHERE topic_id = $topic_id;"); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
398 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
399 |
// Update forum stats |
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
|
400 |
$post_count = count($posts) - $del_count; |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
401 |
$q = $db->sql_query('UPDATE '.table_prefix."decir_forums SET num_topics = num_topics + 1, num_posts = num_posts + $post_count WHERE forum_id = $forum_id;"); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
402 |
if ( !$q ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
403 |
$db->_die('Decir functions.php in decir_restore_topic()'); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
404 |
decir_update_forum_stats($forum_id); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
405 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
406 |
return true; |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
407 |
} |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
408 |
|
6 | 409 |
/** |
410 |
* Shows the administration link on the foot of the page. |
|
411 |
*/ |
|
412 |
||
413 |
function decir_show_footers() |
|
414 |
{ |
|
415 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
416 |
echo '<p style="text-align: center; margin: 20px 0 0 0; color: #808080;"><small>'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
417 |
echo 'Powered by the <a href="http://decir.enanocms.org/">Decir Forum Engine</a> for <a href="' . makeUrlNS('Special', 'About_Enano') . '">Enano</a><br /> |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
418 |
© 2007 Dan Fuhry and the Enano CMS team'; |
6 | 419 |
if ( $session->user_level >= USER_LEVEL_ADMIN ) |
420 |
{ |
|
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
421 |
echo '<br />'; |
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
422 |
echo '<a href="' . makeUrlNS('Special', 'DecirAdmin') . '">Administration control panel</a>'; |
6 | 423 |
} |
7
37387f84fe25
Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents:
6
diff
changeset
|
424 |
echo '</small></p>'; |
6 | 425 |
} |
426 |
||
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
427 |
?> |