diff --git a/classes/script_start.php b/classes/script_start.php
index 3c59631e..c7dbf127 100644
--- a/classes/script_start.php
+++ b/classes/script_start.php
@@ -366,6 +366,7 @@ function user_heavy_info($UserID) {
i.SiteOptions,
i.DownloadAlt,
i.LastReadNews,
+ i.LastReadBlog,
i.RestrictedForums,
i.PermittedForums,
m.FLTokens,
diff --git a/design/privateheader.php b/design/privateheader.php
index a847e84d..ce71338a 100644
--- a/design/privateheader.php
+++ b/design/privateheader.php
@@ -196,6 +196,22 @@
$Alerts[] = ''.'New Announcement!'.'';
}
+// Blog
+$MyBlog = $LoggedUser['LastReadBlog'];
+$CurrentBlog = $Cache->get_value('blog_latest_id');
+if ($CurrentBlog === false) {
+ $DB->query("SELECT ID FROM blog WHERE Important = 1 ORDER BY Time DESC LIMIT 1");
+ if ($DB->record_count() == 1) {
+ list($CurrentBlog) = $DB->next_record();
+ } else {
+ $CurrentBlog = -1;
+ }
+ $Cache->cache_value('blog_latest_id', $CurrentBlog, 0);
+}
+if ($MyBlog < $CurrentBlog) {
+ $Alerts[] = ''.'New Blog Post!'.'';
+}
+
//Staff PM
$NewStaffPMs = $Cache->get_value('staff_pm_new_'.$LoggedUser['ID']);
if ($NewStaffPMs === false) {
diff --git a/gazelle.sql b/gazelle.sql
index 88a83b25..35ac8930 100644
--- a/gazelle.sql
+++ b/gazelle.sql
@@ -89,6 +89,7 @@ CREATE TABLE `blog` (
`Body` text COLLATE utf8_bin NOT NULL,
`Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ThreadID` int(10) unsigned DEFAULT NULL,
+ `Important` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
KEY `UserID` (`UserID`),
KEY `Time` (`Time`)
@@ -1226,6 +1227,7 @@ CREATE TABLE `users_info` (
`DisableRequests` enum('0','1') NOT NULL DEFAULT '0',
`PermittedForums` varchar(150) NOT NULL DEFAULT '',
`UnseededAlerts` enum('0','1') NOT NULL DEFAULT '0',
+ `LastReadBlog` int(10) NOT NULL DEFAULT '0',
UNIQUE KEY `UserID` (`UserID`),
KEY `SupportFor` (`SupportFor`),
KEY `DisableInvites` (`DisableInvites`),
diff --git a/sections/blog/index.php b/sections/blog/index.php
index a3962db1..2951493f 100644
--- a/sections/blog/index.php
+++ b/sections/blog/index.php
@@ -61,8 +61,17 @@
}
}
- $DB->query("INSERT INTO blog (UserID, Title, Body, Time, ThreadID) VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', '".sqltime()."', ".$ThreadID.")");
+ $DB->query("INSERT INTO blog (UserID, Title, Body, Time, ThreadID, Important)
+ VALUES ('".$LoggedUser['ID']."',
+ '".db_string($_POST['title'])."',
+ '".db_string($_POST['body'])."',
+ '".sqltime()."',
+ ".$ThreadID.",
+ '".(($_POST['important']=='1')?'1':'0')."')");
$Cache->delete_value('blog');
+ if ($_POST['important']=='1') {
+ $Cache->delete_value('blog_latest_id');
+ }
if(isset($_POST['subscribe'])) {
$DB->query("INSERT IGNORE INTO users_subscriptions VALUES ('$LoggedUser[ID]', $ThreadID)");
$Cache->delete_value('subscriptions_user_'.$LoggedUser['ID']);
@@ -89,6 +98,7 @@
/>