Revision 600
Added by thorn almost 17 years ago
trunk/CHANGELOG | ||
---|---|---|
14 | 14 |
26-Jan-2008 Matthias Gallas |
15 | 15 |
+ Added keywords to files where they are missing |
16 | 16 |
26-Jan-2008 Thomas Hornik |
17 |
+ module news: added publish_until field to control the visibility of a news-posting by date and time |
|
17 | 18 |
! added strongly "condensed" fonts with many intersections for ttf-CAPTCHA as default fonts. |
18 | 19 |
It should be very difficult for spam-bots to recognize intersected characters. |
19 | 20 |
25-Jan-2008 Christian Sommer |
trunk/wb/upgrade-script.php | ||
---|---|---|
473 | 473 |
//Start of upgrade script for the news modul |
474 | 474 |
//****************************************************************************** |
475 | 475 |
|
476 |
echo "<BR><B>Adding new field to database table mod_news_posts</B><BR>"; |
|
476 |
echo "<BR><B>Adding new fields to database table mod_news_posts</B><BR>";
|
|
477 | 477 |
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_news_posts` ADD `published_when` INT NOT NULL AFTER `commenting`")) { |
478 | 478 |
echo 'Database Field published_when added successfully<br />'; |
479 | 479 |
} |
480 | 480 |
echo mysql_error().'<br />'; |
481 |
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_news_posts` ADD `published_until` INT NOT NULL AFTER `published_when`")) { |
|
482 |
echo 'Database Field published_until added successfully<br />'; |
|
483 |
} |
|
484 |
echo mysql_error().'<br />'; |
|
481 | 485 |
|
482 | 486 |
// UPDATING DATA INTO FIELDS |
483 | 487 |
echo "<BR>"; |
trunk/wb/modules/news/search.php | ||
---|---|---|
34 | 34 |
$result = false; |
35 | 35 |
|
36 | 36 |
// fetch all active news-posts (from active groups) in this section. |
37 |
$t = time(); |
|
37 | 38 |
$table_posts = TABLE_PREFIX."mod_news_posts"; |
38 | 39 |
$table_groups = TABLE_PREFIX."mod_news_groups"; |
39 | 40 |
$query = $func_database->query(" |
40 | 41 |
SELECT p.post_id, p.title, p.content_short, p.content_long, p.link, p.posted_when, p.posted_by |
41 | 42 |
FROM $table_posts AS p LEFT OUTER JOIN $table_groups AS g ON p.group_id = g.group_id |
42 | 43 |
WHERE p.section_id='$func_section_id' AND p.active = '1' AND ( g.active IS NULL OR g.active = '1' ) |
44 |
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) |
|
43 | 45 |
ORDER BY p.post_id DESC |
44 | 46 |
"); |
45 | 47 |
// now call print_excerpt() for every single post |
trunk/wb/modules/news/view.php | ||
---|---|---|
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
// Query posts (for this page) |
112 |
$query_posts = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra ORDER BY position DESC".$limit_sql); |
|
112 |
$t = time(); |
|
113 |
$query_posts = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts |
|
114 |
WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra |
|
115 |
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) |
|
116 |
ORDER BY position DESC".$limit_sql); |
|
113 | 117 |
$num_posts = $query_posts->numRows(); |
114 | 118 |
|
115 | 119 |
// Create previous and next links |
... | ... | |
256 | 260 |
} |
257 | 261 |
|
258 | 262 |
// Get post info |
259 |
$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '".POST_ID."' AND active = '1'"); |
|
263 |
$t = time(); |
|
264 |
$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts |
|
265 |
WHERE post_id = '".POST_ID."' AND active = '1' |
|
266 |
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) |
|
267 |
"); |
|
260 | 268 |
if($query_post->numRows() > 0) { |
261 | 269 |
$post = $query_post->fetchRow(); |
262 | 270 |
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active |
... | ... | |
282 | 290 |
$post_long = ($post['content_long']); |
283 | 291 |
} |
284 | 292 |
} else { |
285 |
header("Location: ".WB_URL.PAGES_DIRECTORY."");
|
|
293 |
$wb->print_error($MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'], "javascript: history.go(-1);", false);
|
|
286 | 294 |
exit(0); |
287 | 295 |
} |
288 | 296 |
|
... | ... | |
298 | 306 |
echo str_replace($vars, $values, $setting_post_footer); |
299 | 307 |
|
300 | 308 |
// Show comments section if we have to |
301 |
if($post['commenting'] == 'private' AND isset($admin) AND $admin->is_authenticated() == true OR $post['commenting'] == 'public') {
|
|
309 |
if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public') {
|
|
302 | 310 |
|
303 | 311 |
// Print comments header |
304 | 312 |
echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID.'&sid='.$section_id, $setting_comments_header); |
trunk/wb/modules/news/modify.php | ||
---|---|---|
82 | 82 |
} |
83 | 83 |
?> |
84 | 84 |
</td> |
85 |
<td width="80">
|
|
85 |
<td width="120">
|
|
86 | 86 |
<?php echo $TEXT['COMMENTS'].': '; |
87 | 87 |
// Get number of comments |
88 | 88 |
$query_title = $database->query("SELECT title FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".$post['post_id']."'"); |
... | ... | |
93 | 93 |
<?php echo $TEXT['ACTIVE'].': '; if($post['active'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; } ?> |
94 | 94 |
</td> |
95 | 95 |
<td width="20"> |
96 |
<?php |
|
97 |
$start = $post['published_when']; |
|
98 |
$end = $post['published_until']; |
|
99 |
$t = time(); |
|
100 |
$icon = ''; |
|
101 |
if($start<=$t && $end==0) |
|
102 |
$icon=ADMIN_URL.'/images/noclock_16.png'; |
|
103 |
elseif(($start<=$t || $start==0) && $end>=$t) |
|
104 |
$icon=ADMIN_URL.'/images/clock_16.png'; |
|
105 |
else |
|
106 |
$icon=ADMIN_URL.'/images/clock_red_16.png'; |
|
107 |
?> |
|
108 |
<a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section_id; ?>&post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>"> |
|
109 |
<img src="<?php echo $icon; ?>" border="0" alt="" /> |
|
110 |
</td> |
|
111 |
<td width="20"> |
|
96 | 112 |
<?php if($post['position'] != $num_posts) { ?> |
97 | 113 |
<a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section_id; ?>&post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>"> |
98 | 114 |
<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" border="0" alt="^" /> |
trunk/wb/modules/news/modify_post.php | ||
---|---|---|
50 | 50 |
} |
51 | 51 |
|
52 | 52 |
// include jscalendar-setup |
53 |
$jscal_use_time = false; // whether to use a clock, too
|
|
53 |
$jscal_use_time = true; // whether to use a clock, too
|
|
54 | 54 |
require_once(WB_PATH."/include/jscalendar/wb-setup.php"); |
55 | 55 |
// override some vars: (normally, there is no need to change this) |
56 | 56 |
//$jscal_lang = "en"; //- calendar-language (default: wb-backend-language) |
... | ... | |
121 | 121 |
</td> |
122 | 122 |
</tr> |
123 | 123 |
<tr> |
124 |
<td><?php echo $TEXT['DATE']; ?>:</td> |
|
124 |
<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
|
|
125 | 125 |
<td> |
126 |
<input type="text" id="publishdate" name="publishdate" value="<?php if($fetch_content['published_when']==0) print ""; else print date($jscal_format, $fetch_content['published_when'])?>" style="width: 120px;" /> |
|
127 |
<img src="<?php echo WB_URL ?>/include/jscalendar/img.gif" id="publishdate_trigger" style="cursor: pointer; border: 1px solid red;" title="Calendar" onmouseover="this.style.background='red';" onmouseout="this.style.background=''" /> |
|
126 |
<input type="text" id="publishdate" name="publishdate" value="<?php if($fetch_content['published_when']==0) print date($jscal_format, time()); else print date($jscal_format, $fetch_content['published_when']);?>" style="width: 120px;" /> |
|
127 |
<img src="<?php echo ADMIN_URL ?>/images/clock_16.png" id="publishdate_trigger" style="cursor: pointer;" title="Calendar" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" /> |
|
128 |
<img src="<?php echo ADMIN_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="delete date" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.publishdate.value=''" /> |
|
128 | 129 |
</td> |
129 | 130 |
</tr> |
131 |
<tr> |
|
132 |
<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td> |
|
133 |
<td> |
|
134 |
<input type="text" id="enddate" name="enddate" value="<?php if($fetch_content['published_until']==0) print ""; else print date($jscal_format, $fetch_content['published_until'])?>" style="width: 120px;" /> |
|
135 |
<img src="<?php echo ADMIN_URL ?>/images/clock_16.png" id="enddate_trigger" style="cursor: pointer;" title="Calendar" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" /> |
|
136 |
<img src="<?php echo ADMIN_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="delete date" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.enddate.value=''" /> |
|
137 |
</td> |
|
138 |
</tr> |
|
130 | 139 |
</table> |
131 | 140 |
|
132 | 141 |
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%"> |
... | ... | |
179 | 188 |
step : 1 |
180 | 189 |
} |
181 | 190 |
); |
191 |
Calendar.setup( |
|
192 |
{ |
|
193 |
inputField : "enddate", |
|
194 |
ifFormat : "<?php echo $jscal_ifformat ?>", |
|
195 |
button : "enddate_trigger", |
|
196 |
firstDay : <?php echo $jscal_firstday ?>, |
|
197 |
<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE) { ?> |
|
198 |
showsTime : "true", |
|
199 |
timeFormat : "24", |
|
200 |
<?php } ?> |
|
201 |
date : "<?php echo $jscal_today ?>", |
|
202 |
range : [1970, 2037], |
|
203 |
step : 1 |
|
204 |
} |
|
205 |
); |
|
182 | 206 |
</script> |
183 | 207 |
|
184 | 208 |
<br /> |
trunk/wb/modules/news/comment.php | ||
---|---|---|
50 | 50 |
define('POST_TITLE', $post_title); |
51 | 51 |
|
52 | 52 |
// don't allow commenting if its disabled, or if post or group is inactive |
53 |
$t = time(); |
|
53 | 54 |
$table_posts = TABLE_PREFIX."mod_news_posts"; |
54 | 55 |
$table_groups = TABLE_PREFIX."mod_news_groups"; |
55 | 56 |
$query = $database->query(" |
56 | 57 |
SELECT p.post_id |
57 | 58 |
FROM $table_posts AS p LEFT OUTER JOIN $table_groups AS g ON p.group_id = g.group_id |
58 | 59 |
WHERE p.post_id='$post_id' AND p.commenting != 'none' AND p.active = '1' AND ( g.active IS NULL OR g.active = '1' ) |
60 |
AND (p.published_when = '0' OR p.published_when <= $t) AND (p.published_until = 0 OR p.published_until >= $t) |
|
59 | 61 |
"); |
60 | 62 |
if($query->numRows() == 0) { |
61 | 63 |
header("Location: ".WB_URL.PAGES_DIRECTORY.""); |
trunk/wb/modules/news/save_post.php | ||
---|---|---|
45 | 45 |
$title = $admin->add_slashes($admin->get_post('title')); |
46 | 46 |
$short = $admin->add_slashes($admin->get_post('short')); |
47 | 47 |
$long = $admin->add_slashes($admin->get_post('long')); |
48 |
$publishedwhen = strtotime($admin->get_post('publishdate')); |
|
48 |
$publishedwhen = strtotime($admin->get_post('publishdate')); |
|
49 |
$publisheduntil = strtotime($admin->get_post('enddate')); |
|
49 | 50 |
$commenting = $admin->get_post('commenting'); |
50 | 51 |
$active = $admin->get_post('active'); |
51 | 52 |
$old_link = $admin->get_post('link'); |
... | ... | |
102 | 103 |
} |
103 | 104 |
|
104 | 105 |
// Update row |
105 |
$database->query("UPDATE ".TABLE_PREFIX."mod_news_posts SET group_id = '$group_id', title = '$title', link = '$post_link', content_short = '$short', content_long = '$long', commenting = '$commenting', active = '$active', published_when = '$publishedwhen', posted_when = '".mktime()."', posted_by = '".$admin->get_user_id()."' WHERE post_id = '$post_id'"); |
|
106 |
$database->query("UPDATE ".TABLE_PREFIX."mod_news_posts SET group_id = '$group_id', title = '$title', link = '$post_link', content_short = '$short', content_long = '$long', commenting = '$commenting', active = '$active', published_when = '$publishedwhen', published_until = '$publisheduntil', posted_when = '".mktime()."', posted_by = '".$admin->get_user_id()."' WHERE post_id = '$post_id'");
|
|
106 | 107 |
|
107 | 108 |
// Check if there is a db error, otherwise say successful |
108 | 109 |
if($database->is_error()) { |
trunk/wb/modules/news/install.php | ||
---|---|---|
38 | 38 |
. '`content_short` TEXT NOT NULL ,' |
39 | 39 |
. '`content_long` TEXT NOT NULL ,' |
40 | 40 |
. '`commenting` VARCHAR(7) NOT NULL DEFAULT \'\',' |
41 |
. '`published_when` INT NOT NULL DEFAULT \'0\',' |
|
42 |
. '`posted_when` INT NOT NULL DEFAULT \'0\',' |
|
41 |
. '`published_when` INT NOT NULL DEFAULT \'0\',' |
|
42 |
. '`published_until` INT NOT NULL DEFAULT \'0\',' |
|
43 |
. '`posted_when` INT NOT NULL DEFAULT \'0\',' |
|
43 | 44 |
. '`posted_by` INT NOT NULL DEFAULT \'0\',' |
44 | 45 |
. 'PRIMARY KEY (post_id)' |
45 |
. ' )';
|
|
46 |
. ' )';
|
|
46 | 47 |
$database->query($mod_news); |
47 | 48 |
|
48 | 49 |
$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_groups`"); |
Also available in: Unified diff
module news: added publish_until field to control the visibility of a news-posting by date and time