author | Dan |
Sat, 15 Mar 2008 15:19:42 -0400 | |
changeset 4 | f50742368f90 |
parent 2 | 4e7762863437 |
child 6 | c51809bdf6af |
permissions | -rw-r--r-- |
0
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
1 |
<?php |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
2 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
3 |
/* |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
4 |
* Nuggie |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
5 |
* Version 0.1 |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
6 |
* Copyright (C) 2007 Dan Fuhry |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
7 |
* |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
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 |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
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. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
10 |
* |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
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 |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
13 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
14 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
15 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
16 |
* Class for displaying a Nuggie blog post. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
17 |
* @package Enano |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
18 |
* @subpackage Nuggie |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
19 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
20 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
21 |
class NuggiePostbit |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
22 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
23 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
24 |
* The unique row ID of the post. This can be false if |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
25 |
* the post is being displayed as part of a preview or |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
26 |
* otherwise doesn't actually exist in the database. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
27 |
* @var int |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
28 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
29 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
30 |
var $post_id = false; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
31 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
32 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
33 |
* The title of the post. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
34 |
* @var string |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
35 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
36 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
37 |
var $post_title; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
38 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
39 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
40 |
* The cleaned title of the post. This is calculated |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
41 |
* internally and need not be set. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
42 |
* @var string |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
43 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
44 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
45 |
var $post_title_clean; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
46 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
47 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
48 |
* Who wrote this post (user ID). |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
49 |
* @var int |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
50 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
51 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
52 |
var $post_author = 1; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
53 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
54 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
55 |
* When the post was posted. UNIX timestamp. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
56 |
* @var int |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
57 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
58 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
59 |
var $post_timestamp = 1; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
60 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
61 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
62 |
* The actual content of the post. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
63 |
* @var string |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
64 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
65 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
66 |
var $post_text = ''; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
67 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
68 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
69 |
* Whether the user can edit the post or not. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
70 |
* @var bool |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
71 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
72 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
73 |
var $auth_edit = false; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
74 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
75 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
76 |
* The number of comments on the post |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
77 |
* @var int |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
78 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
79 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
80 |
var $num_comments = 0; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
81 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
82 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
83 |
* The master permission set for the blog. Only used during pagination, don't worry about this |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
84 |
* @var object |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
85 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
86 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
87 |
var $blog_perms; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
88 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
89 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
90 |
* Renders the post. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
91 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
92 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
93 |
function render_post() |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
94 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
95 |
global $db, $session, $paths, $template, $plugins; // Common objects |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
96 |
|
4 | 97 |
if ( empty($template->theme) ) |
98 |
$template->load_theme(); |
|
99 |
||
100 |
if ( file_exists( ENANO_ROOT . "/themes/{$template->theme}/blog_post.tpl" ) ) |
|
0
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
101 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
102 |
$parser = $template->makeParser('blog_post.tpl'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
103 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
104 |
else |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
105 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
106 |
$tpl_code = <<<TPLBLOCK |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
107 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
108 |
<!-- Start of blog post --> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
109 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
110 |
<div class="blog-post"> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
111 |
<div class="blog-post-header"> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
112 |
<div class="blog-post-datemark"> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
113 |
{DATE_D} {DATE_j}<br /> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
114 |
{DATE_M} {DATE_Y} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
115 |
</div> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
116 |
<h3><a href="{PERMALINK}">{POST_TITLE}</a></h3> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
117 |
<div class="blog-post-author"> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
118 |
Posted by {USER_LINK} on {TIMESTAMP} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
119 |
</div> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
120 |
<div class="blog-post-buttons"> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
121 |
<a href="{PERMALINK}#do:comments" onclick="ajaxComments();">{COMMENT_STRING}</a> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
122 |
<!-- BEGIN auth_edit --> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
123 |
• |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
124 |
<a href="{EDIT_LINK}">Edit this post</a> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
125 |
<!-- END auth_edit --> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
126 |
</div> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
127 |
</div> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
128 |
<div class="blog-post-body"> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
129 |
{POST_TEXT} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
130 |
</div> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
131 |
</div> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
132 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
133 |
<!-- Finish blog post --> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
134 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
135 |
TPLBLOCK; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
136 |
$parser = $template->makeParserText($tpl_code); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
137 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
138 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
139 |
$this->post_title_clean = nuggie_sanitize_title($this->post_title); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
140 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
141 |
// List of valid characters for date() |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
142 |
$date_chars = 'dDjlNSwzWFmMntLoYyaABgGhHiseIOTZcrU'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
143 |
$date_chars = enano_str_split($date_chars); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
144 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
145 |
$strings = array(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
146 |
foreach ( $date_chars as $char ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
147 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
148 |
$strings["DATE_$char"] = date($char, $this->post_timestamp); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
149 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
150 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
151 |
$strings['POST_TITLE'] = htmlspecialchars($this->post_title); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
152 |
$strings['POST_TEXT'] = RenderMan::render($this->post_text); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
153 |
$strings['PERMALINK'] = makeUrlNS('Blog', $this->post_author . date('/Y/n/j/', $this->post_timestamp) . $this->post_title_clean, false, true); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
154 |
$strings['EDIT_LINK'] = makeUrlNS('Special', "Preferences/Blog/Write/{$this->post_id}", false, true); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
155 |
|
1
6e76ca311f2d
Put a placeholder into that user link part so I don't forget to fix it ;-)
Dan
parents:
0
diff
changeset
|
156 |
/* |
6e76ca311f2d
Put a placeholder into that user link part so I don't forget to fix it ;-)
Dan
parents:
0
diff
changeset
|
157 |
* FIXME: Make this a real colored userpage link |
6e76ca311f2d
Put a placeholder into that user link part so I don't forget to fix it ;-)
Dan
parents:
0
diff
changeset
|
158 |
*/ |
6e76ca311f2d
Put a placeholder into that user link part so I don't forget to fix it ;-)
Dan
parents:
0
diff
changeset
|
159 |
|
6e76ca311f2d
Put a placeholder into that user link part so I don't forget to fix it ;-)
Dan
parents:
0
diff
changeset
|
160 |
$strings['USER_LINK'] = '<fixme>' . htmlspecialchars($this->post_author) . '</fixme>'; |
6e76ca311f2d
Put a placeholder into that user link part so I don't forget to fix it ;-)
Dan
parents:
0
diff
changeset
|
161 |
|
0
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
162 |
if ( $this->num_comments == 0 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
163 |
$comment_string = 'No comments'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
164 |
else if ( $this->num_comments == 1 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
165 |
$comment_string = '1 comment'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
166 |
else |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
167 |
$comment_string = intval($this->num_comments) . ' comments'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
168 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
169 |
$strings['COMMENT_STRING'] = $comment_string; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
170 |
$strings['TIMESTAMP'] = date('l, F j, Y \a\t h:i <\s\m\a\l\l>A</\s\m\a\l\l>', $this->post_timestamp); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
171 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
172 |
$parser->assign_vars($strings); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
173 |
$parser->assign_bool(array( |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
174 |
'auth_edit' => ( $this->auth_edit ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
175 |
)); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
176 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
177 |
return $parser->run(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
178 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
179 |
/** |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
180 |
* Don't worry about this, it's only called from the paginator. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
181 |
* @access private |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
182 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
183 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
184 |
function paginate_handler($_, $row) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
185 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
186 |
global $db, $session, $paths, $template, $plugins; // Common objects |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
187 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
188 |
if ( !is_object($this->blog_perms) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
189 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
190 |
$this->blog_perms = $session->fetch_page_acl($row['username'], 'Blog'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
191 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
192 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
193 |
$perms = $session->fetch_page_acl("{$row['post_timestamp']}_{$row['post_id']}", 'Blog'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
194 |
$perms->perms = $session->acl_merge($this->blog_perms->perms, $perms->perms); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
195 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
196 |
/* |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
197 |
if ( !$perms->get_permissions('read') ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
198 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
199 |
return "POST {$this->post_id} DENIED"; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
200 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
201 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
202 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
203 |
$this->post_id = intval($row['post_id']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
204 |
$this->post_title = $row['post_title']; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
205 |
$this->post_text = $row['post_text']; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
206 |
$this->post_author = $row['username']; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
207 |
$this->post_timestamp = intval($row['post_timestamp']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
208 |
$this->num_comments = intval($row['num_comments']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
209 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
210 |
return $this->render_post(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
211 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
212 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
213 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
214 |
function nuggie_blog_uri_handler($uri) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
215 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
216 |
global $db, $session, $paths, $template, $plugins; // Common objects |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
217 |
$template->add_header('<link rel="stylesheet" type="text/css" href="' . scriptPath . '/plugins/nuggie/style.css" />'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
218 |
if ( strstr($uri, '/') ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
219 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
220 |
// |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
221 |
// Permalinked post |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
222 |
// |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
223 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
224 |
// Split and parse URI |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
225 |
$particles = explode('/', $uri); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
226 |
if ( count($particles) < 5 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
227 |
return false; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
228 |
$sz = count($particles); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
229 |
for ( $i = 5; $i < $sz; $i++ ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
230 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
231 |
$particles[4] .= '/' . $particles[$i]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
232 |
unset($particles[$i]); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
233 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
234 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
235 |
$particles[4] = nuggie_sanitize_title($particles[4]); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
236 |
$poster =& $particles[0]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
237 |
$year =& $particles[1]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
238 |
$month =& $particles[2]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
239 |
$day =& $particles[3]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
240 |
$post_title_clean =& $particles[4]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
241 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
242 |
$particlecomp = $db->escape(implode('/', $particles)); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
243 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
244 |
$year = intval($year); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
245 |
$month = intval($month); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
246 |
$day = intval($day); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
247 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
248 |
$time_min = mktime(0, 0, 0, $month, $day, $year); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
249 |
$time_max = $time_min + 86400; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
250 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
251 |
$ptc = $db->escape($post_title_clean); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
252 |
$uname = $db->escape(dirtify_page_id($poster)); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
253 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
254 |
$q = $db->sql_query("SELECT p.post_id, p.post_title, p.post_title_clean, p.post_author, p.post_timestamp, p.post_text, b.blog_name,\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
255 |
. " b.blog_subtitle, b.blog_type, b.allowed_users, u.username, u.user_level, COUNT(c.comment_id) AS num_comments\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
256 |
. " FROM " . table_prefix . "blog_posts AS p\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
257 |
. " LEFT JOIN " . table_prefix . "blogs AS b\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
258 |
. " ON ( b.user_id = p.post_author )\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
259 |
. " LEFT JOIN " . table_prefix . "users AS u\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
260 |
. " ON ( u.user_id = p.post_author )\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
261 |
. " LEFT JOIN " . table_prefix . "comments AS c\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
262 |
. " ON ( ( c.page_id = '{$particlecomp}' AND c.namespace = 'Blog' ) OR ( c.page_id IS NULL AND c.namespace IS NULL ) )\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
263 |
. " WHERE p.post_timestamp >= $time_min AND p.post_timestamp <= $time_max\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
264 |
. " AND p.post_title_clean = '$ptc' AND u.username = '$uname'\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
265 |
. " GROUP BY p.post_id;"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
266 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
267 |
$db->_die('Nuggie post handler selecting main post data'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
268 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
269 |
if ( $db->numrows() < 1 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
270 |
return false; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
271 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
272 |
if ( $db->numrows() > 1 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
273 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
274 |
die_friendly('Ambiguous blog posts', '<p>FIXME: You have two posts with the same title posted on the same day by the same user. I was |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
275 |
not able to distinguish which post you wish to view.</p>'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
276 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
277 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
278 |
$row = $db->fetchrow(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
279 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
280 |
// |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
281 |
// Determine permissions |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
282 |
// |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
283 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
284 |
// The way we're doing this is first fetching permissions for the blog, and then merging them |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
285 |
// with permissions specific to the post. This way the admin can set custom permissions for the |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
286 |
// entire blog, and they'll be inherited unless individual posts have overriding permissions. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
287 |
$perms_blog = $session->fetch_page_acl($row['username'], 'Blog'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
288 |
$perms = $session->fetch_page_acl("{$row['post_timestamp']}_{$row['post_id']}", 'Blog'); |
4 | 289 |
$perms->perms = $session->acl_merge($perms->perms, $perms_blog->perms); |
0
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
290 |
unset($perms_blog); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
291 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
292 |
if ( $row['blog_type'] == 'private' ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
293 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
294 |
$allowed_users = unserialize($row['allowed_users']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
295 |
if ( !in_array($session->username, $allowed_users) && !$perms->get_permissions('nuggie_see_non_public') && $row['username'] != $session->username ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
296 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
297 |
return '_err_access_denied'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
298 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
299 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
300 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
301 |
$acl_type = ( $row['post_author'] == $session->user_id ) ? 'nuggie_edit_own' : 'nuggie_edit_other'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
302 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
303 |
if ( !$perms->get_permissions('read') ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
304 |
return '_err_access_denied'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
305 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
306 |
// We're validated - display post |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
307 |
$postbit = new NuggiePostbit(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
308 |
$postbit->post_id = intval($row['post_id']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
309 |
$postbit->post_title = $row['post_title']; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
310 |
$postbit->post_text = $row['post_text']; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
311 |
$postbit->post_author = $row['username']; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
312 |
$postbit->post_timestamp = intval($row['post_timestamp']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
313 |
$postbit->auth_edit = $perms->get_permissions($acl_type); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
314 |
$postbit->num_comments = intval($row['num_comments']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
315 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
316 |
$template->tpl_strings['PAGE_NAME'] = htmlspecialchars($row['post_title']) . ' « ' . htmlspecialchars($row['blog_name']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
317 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
318 |
$template->header(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
319 |
echo '< <a href="' . makeUrlNS('Blog', $row['username']) . '">' . htmlspecialchars($row['blog_name']) . '</a>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
320 |
echo $postbit->render_post(); |
2 | 321 |
display_page_footers(); |
0
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
322 |
$template->footer(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
323 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
324 |
return true; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
325 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
326 |
else |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
327 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
328 |
return nuggie_blog_index($uri); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
329 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
330 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
331 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
332 |
function nuggie_blog_index($username) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
333 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
334 |
global $db, $session, $paths, $template, $plugins; // Common objects |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
335 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
336 |
$username_esc = $db->escape($username); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
337 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
338 |
// First look for the user's blog so we can get permissions |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
339 |
$q = $db->sql_query('SELECT b.blog_type, b.allowed_users, b.user_id, b.blog_name, b.blog_subtitle FROM ' . table_prefix . "blogs AS b LEFT JOIN " . table_prefix . "users AS u ON ( u.user_id = b.user_id ) WHERE u.username = '$username_esc';"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
340 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
341 |
$db->_die('Nuggie main blog page doing preliminary security check'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
342 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
343 |
if ( $db->numrows() < 1 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
344 |
return false; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
345 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
346 |
list($blog_type, $allowed_users, $user_id, $blog_name, $blog_subtitle) = $db->fetchrow_num(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
347 |
$db->free_result(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
348 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
349 |
$perms = $session->fetch_page_acl($username, 'Blog'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
350 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
351 |
if ( $blog_type == 'private' ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
352 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
353 |
$allowed_users = unserialize($allowed_users); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
354 |
if ( !in_array($session->username, $allowed_users) && !$perms->get_permissions('nuggie_see_non_public') && $username != $session->username ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
355 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
356 |
return '_err_access_denied'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
357 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
358 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
359 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
360 |
// Determine number of posts and prefetch ACL info |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
361 |
$q = $db->sql_query('SELECT post_timestamp, post_id FROM ' . table_prefix . 'blog_posts WHERE post_author = ' . $user_id . ' AND post_published = 1;'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
362 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
363 |
$db->_die('Nuggie main blog page doing rowcount of blog posts'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
364 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
365 |
$count = $db->numrows(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
366 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
367 |
while ( $row = $db->fetchrow($q) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
368 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
369 |
$session->fetch_page_acl("{$row['post_timestamp']}_{$row['post_id']}", 'Blog'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
370 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
371 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
372 |
$db->free_result($q); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
373 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
374 |
$q = $db->sql_unbuffered_query("SELECT p.post_id, p.post_title, p.post_title_clean, p.post_author, p.post_timestamp, p.post_text, b.blog_name,\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
375 |
. " b.blog_subtitle, u.username, u.user_level, COUNT(c.comment_id) AS num_comments\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
376 |
. " FROM " . table_prefix . "blog_posts AS p\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
377 |
. " LEFT JOIN " . table_prefix . "blogs AS b\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
378 |
. " ON ( b.user_id = p.post_author )\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
379 |
. " LEFT JOIN " . table_prefix . "users AS u\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
380 |
. " ON ( u.user_id = p.post_author )\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
381 |
. " LEFT JOIN " . table_prefix . "comments AS c\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
382 |
. " ON ( ( c.page_id REGEXP CONCAT('([0-9]+)/([0-9]+)/([0-9]+)/', p.post_title_clean) AND c.namespace = 'Blog' ) OR ( c.page_id IS NULL AND c.namespace IS NULL ) )\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
383 |
. " WHERE p.post_author = $user_id AND p.post_published = 1\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
384 |
. " GROUP BY p.post_id\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
385 |
. " ORDER BY p.post_timestamp DESC;"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
386 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
387 |
$db->_die('Nuggie main blog page selecting the whole shebang'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
388 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
389 |
if ( $count < 1 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
390 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
391 |
// Either the user hasn't created a blog yet, or he isn't even registered |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
392 |
return false; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
393 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
394 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
395 |
$template->tpl_strings['PAGE_NAME'] = htmlspecialchars($blog_name) . ' » ' . htmlspecialchars($blog_subtitle); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
396 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
397 |
$postbit = new NuggiePostbit(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
398 |
// $q, $tpl_text, $num_results, $result_url, $start = 0, $perpage = 10, $callers = Array(), $header = '', $footer = '' |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
399 |
$html = paginate( |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
400 |
$q, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
401 |
'{post_id}', |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
402 |
$count, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
403 |
makeUrlNS('Blog', $username, "start=%s", true), |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
404 |
0, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
405 |
10, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
406 |
array( 'post_id' => array($postbit, 'paginate_handler') ), |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
407 |
'<span class="menuclear"></span>' |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
408 |
); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
409 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
410 |
$template->header(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
411 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
412 |
echo $html; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
413 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
414 |
$template->footer(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
415 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
416 |
return true; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
417 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
418 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
419 |
?> |