author | Dan |
Tue, 13 Nov 2007 19:39:50 -0500 | |
changeset 6 | 3f66ec435f08 |
parent 3 | 88b85b9b9272 |
child 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); |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
38 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
39 |
$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
|
40 |
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
|
41 |
$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
|
42 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
43 |
$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
|
44 |
$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
|
45 |
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
|
46 |
$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
|
47 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
48 |
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
|
49 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
50 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
51 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
52 |
* 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
|
53 |
* @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
|
54 |
* @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
|
55 |
* @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
|
56 |
* @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
|
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 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
59 |
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
|
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 |
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
|
62 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
63 |
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
|
64 |
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
|
65 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
66 |
$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
|
67 |
$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
|
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 |
$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
|
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 |
$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
|
72 |
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
|
73 |
$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
|
74 |
$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
|
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 |
// 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
|
77 |
$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
|
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 |
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
|
80 |
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
|
81 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
82 |
// 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
|
83 |
$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
|
84 |
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
|
85 |
$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
|
86 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
87 |
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
|
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 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
90 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
91 |
* 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
|
92 |
* @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
|
93 |
* @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
|
94 |
* @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
|
95 |
* @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
|
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 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
98 |
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
|
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 |
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
|
101 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
102 |
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
|
103 |
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
|
104 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
105 |
$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
|
106 |
$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
|
107 |
$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
|
108 |
$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
|
109 |
$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
|
110 |
|
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
111 |
// 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
|
112 |
$grace = time() - ( 10 * 60 ); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
113 |
$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
|
114 |
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
|
115 |
$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
|
116 |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
117 |
$q = $db->sql_query('UPDATE '.table_prefix."decir_posts_text SET post_text='$post_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
|
118 |
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
|
119 |
$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
|
120 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
121 |
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
|
122 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
123 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
124 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
125 |
* 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
|
126 |
* @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
|
127 |
* @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
|
128 |
* @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
|
129 |
*/ |
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 |
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
|
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 |
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
|
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 |
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
|
136 |
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
|
137 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
138 |
// 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
|
139 |
$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
|
140 |
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
|
141 |
$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
|
142 |
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
|
143 |
// 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
|
144 |
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
|
145 |
$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
|
146 |
$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
|
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 |
$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
|
149 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
150 |
// 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
|
151 |
$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
|
152 |
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
|
153 |
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
|
154 |
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
|
155 |
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
|
156 |
$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
|
157 |
$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
|
158 |
$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
|
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 |
$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
|
161 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
162 |
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
|
163 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
164 |
// first post in the thread |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
165 |
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
|
166 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
167 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
168 |
$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
|
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 |
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
|
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 |
$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
|
173 |
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
|
174 |
$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
|
175 |
$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
|
176 |
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
|
177 |
$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
|
178 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
179 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
180 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
181 |
// 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
|
182 |
$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
|
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 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
186 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
187 |
// 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
|
188 |
$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
|
189 |
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
|
190 |
$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
|
191 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
192 |
// 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
|
193 |
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
|
194 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
195 |
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
|
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 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
198 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
199 |
* 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
|
200 |
* @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
|
201 |
* @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
|
202 |
* @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
|
203 |
*/ |
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 |
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
|
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 |
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
|
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 |
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
|
210 |
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
|
211 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
212 |
// 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
|
213 |
$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
|
214 |
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
|
215 |
$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
|
216 |
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
|
217 |
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
|
218 |
$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
|
219 |
$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
|
220 |
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
|
221 |
{ |
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
|
222 |
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
|
223 |
// 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
|
224 |
$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
|
225 |
$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
|
226 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
227 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
228 |
// 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
|
229 |
$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
|
230 |
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
|
231 |
$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
|
232 |
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
|
233 |
$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
|
234 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
235 |
// 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
|
236 |
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
|
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 |
// 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
|
239 |
$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
|
240 |
$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
|
241 |
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
|
242 |
$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
|
243 |
$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
|
244 |
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
|
245 |
$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
|
246 |
// 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
|
247 |
$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
|
248 |
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
|
249 |
$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
|
250 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
251 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
252 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
253 |
$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
|
254 |
$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
|
255 |
$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
|
256 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
257 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
258 |
// 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
|
259 |
$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
|
260 |
$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
|
261 |
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
|
262 |
$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
|
263 |
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
|
264 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
265 |
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
|
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 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
269 |
* 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
|
270 |
* @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
|
271 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
272 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
273 |
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
|
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 |
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
|
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 |
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
|
278 |
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
|
279 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
280 |
$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
|
281 |
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
|
282 |
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
|
283 |
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
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
$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
|
288 |
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
|
289 |
$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
|
290 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
291 |
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
|
292 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
293 |
$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
|
294 |
$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
|
295 |
$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
|
296 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
297 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
298 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
299 |
$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
|
300 |
$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
|
301 |
$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
|
302 |
$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
|
303 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
304 |
$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
|
305 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
306 |
$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
|
307 |
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
|
308 |
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
|
309 |
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
|
310 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
311 |
$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
|
312 |
} |
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 |
/** |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
315 |
* 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
|
316 |
* @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
|
317 |
*/ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
318 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
319 |
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
|
320 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
321 |
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
|
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 |
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
|
324 |
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
|
325 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
326 |
$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
|
327 |
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
|
328 |
$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
|
329 |
|
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
330 |
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
|
331 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
332 |
// 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
|
333 |
$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
|
334 |
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
|
335 |
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
|
336 |
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
|
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 |
$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
|
340 |
$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
|
341 |
$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
|
342 |
// 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
|
343 |
$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
|
344 |
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
|
345 |
$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
|
346 |
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
|
347 |
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
|
348 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
349 |
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
|
350 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
351 |
|
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
352 |
/** |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
353 |
* 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
|
354 |
* @param int Topic ID |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
355 |
*/ |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
356 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
357 |
function decir_restore_topic($topic_id) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
358 |
{ |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
359 |
global $db, $session, $paths, $template, $plugins; // Common objects |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
360 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
361 |
if ( !is_int($topic_id) ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
362 |
return false; |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
363 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
364 |
// 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
|
365 |
$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
|
366 |
if ( !$q ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
367 |
$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
|
368 |
if ( $db->numrows() < 1 ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
369 |
return false; |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
370 |
$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
|
371 |
$del_count = 0; |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
372 |
while ( $row = $db->fetchrow() ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
373 |
{ |
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
|
374 |
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
|
375 |
// 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
|
376 |
$del_count++; |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
377 |
$posts[] = $row['post_id']; |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
378 |
} |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
379 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
380 |
// Obtain forum ID |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
381 |
$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
|
382 |
if ( !$q ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
383 |
$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
|
384 |
list($forum_id) = $db->fetchrow_num(); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
385 |
$db->free_result(); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
386 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
387 |
$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
|
388 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
389 |
// 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
|
390 |
$post_count = count($posts) - $del_count; |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
391 |
$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
|
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 |
decir_update_forum_stats($forum_id); |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
395 |
|
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
396 |
return true; |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
397 |
} |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
398 |
|
6 | 399 |
/** |
400 |
* Shows the administration link on the foot of the page. |
|
401 |
*/ |
|
402 |
||
403 |
function decir_show_footers() |
|
404 |
{ |
|
405 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
406 |
if ( $session->user_level >= USER_LEVEL_ADMIN ) |
|
407 |
{ |
|
408 |
echo '<p style="text-align: center; margin: 20px 0 0 0;"><small><a href="' . makeUrlNS('Special', 'DecirAdmin') . '">Administration control panel</a></small></p>'; |
|
409 |
} |
|
410 |
} |
|
411 |
||
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
diff
changeset
|
412 |
?> |