Ok this is basically an re-do of this [url="
https://www.torrenttrader.org/topic/10965-addon-announcements/?hl=announcement"]https://www.torrenttrader.org/topic/10965-addon-announcements/?hl=announcement[/url]
I thing I did not like about that was it was an popup and really hard if possible to link the annnouncement page to other pages if wanted to :(
you will need the sql from the old topic
or this.
CREATE TABLE IF NOT EXISTS `announcements` (
`id` int(10) unsigned NOT NULL auto_increment,
`subject` varchar(64) NOT NULL,
`message` text NOT NULL,
`by` varchar(16) NOT NULL default 'Admin',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
`minclassread` tinyint(3) unsigned NOT NULL,
`active` enum('yes','no') NOT NULL default 'yes',
PRIMARY KEY (`id`),
KEY `subject` (`subject`),
KEY `minclass_idx` (`minclassread`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Ok 1st off the new sql if did
not use the new above version,cause this new version can set announcements active or inactive instead of just plain deleting them
ALTER TABLE `announcements` ADD `active` enum('yes','no') NOT NULL default 'yes';
ALTER TABLE `announcements` ADD INDEX `minclass_idx` ( `minclassread` );
you will still need these in functions.php if you dont already have it.
New:
function announcement () {
GLOBAL $CURUSER;
if ($CURUSER && $CURUSER['announce_read'] == "no") {
$res = mysql_query("SELECT * FROM announcements WHERE minclassread <= $CURUSER[class] ORDER by added DESC LIMIT 1");
$ret = mysql_fetch_array($res);
}
return $ret;
}
if (!function_exists("pingto")) {
function pingto($url)
{
if (headers_sent()) {
?>
<script language="javascript"> window.location.href='<?php echo $url;?>';</script>
<meta http-equiv="refresh" content="2;<?php echo $url;?>">
<?php echo sprintf("Redirecting", $url);
} else
header('Location: ' . $url);
die();
}
}
now upload the new attached announcements.php to your site.
[url="
http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6899"]announcements.php[/url]
i use an classifieds_block.php to display the link myself on the top of the pages but you dont then in index.php (or header.php after middleblocks):
replace
if ($CURUSER && $CURUSER["announce_read"] == "no" && $arr = announcement()) {
?>
<script type="text/javascript" src="scripts/announcement.js"></script>
<script type="text/javascript" src="scripts/preview.js"></script>
<!-- annoucement start #<?=$arr[id];?> -->
<div id="dropin" style="position:absolute;visibility:hidden;left:300px;top:100px;width:500px;height:100px">
<table border="0" cellpadding="0" cellspacing="0" width="650" class="error">
<tbody><tr><td class="none" style="padding: 2px 0 0 10px; background: red">
<font color=black><b>Title:</b> <?=$arr["subject"]?> -- <b>Created on"</b> <?=$arr["added"]?> -- <b>By:</b> <?=$arr["by"]?></b></font></td>
<td width="50" align="right" class="none" style="padding: 2px; background: red"><a href="#" onClick="dismissbox();return false"><img src="images/close.jpg" border="0"></a></td></tr>
<tr><td colspan="2" class=none width="650" style="padding: 0 0 0 10px;" bgcolor="#ffffff">
<p>
<?=format_comment($arr["message"])?>
</p>
<img id="loading" style=" visibility: hidden" src="images/load.gif">
<span style="color:red" name="preview" id="previewr" align="left">
<a href="#" onclick="java script:clearannouncement(this.parentNode,'clear_ann.php')">Click here to mark announcement read.</a>
</span><br><br></form>
</td></tr></tbody></table>
</div>
<!-- annoucement end #<?=$arr[id];?>-->
<span id="new_ann" style="visibility: visible"><table border=0 cellspacing=0 cellpadding=10 bgcolor=red width=100% align=center><tr><td style='padding: 10px; background: red' align='center'>
<b><a href="java script:show_announcement()"><font color=white>New announcement! Please click here to read!</font></a></b></td></tr></table></span><br />
<?php
}
with
if ($CURUSER["announce_read"] == "no" && $arr_annouce = announcement()) {
?>
<span id="new_ann" style="visibility: visible"><table border=0 cellspacing=0 cellpadding=10 bgcolor=#AB0000 width=100% align=center><tr><td style='padding: 10px; background: #AB0000' align='center'>
<div style='font: bold 14px Times New Roman; color:#FFBF00'>There is a New Announcement! Please click <a href="<?php echo $SITEURL;?>/announcements.php"><font size=3 color=#CBCBCB>HERE</font></a> to read!</div></td></tr></table></span><br />
<?php
}
Note: Make sure you change this in announcements.php if your classes dont match stock 2.08 classes..
// Config
$min_class = 6; // <-- Set this to the class you want to be able to edit the announcements.
$allow_class = array(1,2,3,4,5,6,7); // <-- Set this to your classes....
$announcement_autoclear = true; // <-- Set this to true if have the announcements to auto clear once viewed them.
// Config End
You can also change the auto clearing of announcements for people by changing true to false in the same above.Basically now if auto clears aka marks them as read once people view the announcements page the 1st time after a new announcement.
1st screenshot is staff that can edit the announcements.
2nd on is everyone else.
That should be it, I hope people like it.
Ps: I have included an new classifieds_block.php for those people that use that.
[url="
http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6898"]classifieds_block.php[/url]