1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-30 01:30:32 +02:00

Add admin logging to news

This commit is contained in:
e107steved
2008-12-07 13:08:54 +00:00
parent 5741db2bb8
commit bff38dadde
7 changed files with 181 additions and 102 deletions

View File

@@ -9,17 +9,18 @@
* News handler
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/news_class.php,v $
* $Revision: 1.6 $
* $Date: 2008-12-02 16:50:15 $
* $Author: secretr $
* $Revision: 1.7 $
* $Date: 2008-12-07 13:08:41 $
* $Author: e107steved $
*/
if (!defined('e107_INIT')) { exit; }
class news {
function submit_item($news) {
global $sql, $tp, $e107cache, $e_event, $pref;
function submit_item($news)
{
global $sql, $tp, $e107cache, $e_event, $pref, $admin_log;
if (!is_object($tp)) $tp = new e_parse;
if (!is_object($sql)) $sql = new db;
@@ -32,21 +33,32 @@ class news {
$author_insert = ($news['news_author'] == 0) ? "news_author = '".USERID."'," : "news_author = '".intval($news['news_author'])."', ";
$news['news_author'] = ($news['news_author']) ? $news['news_author'] : USERID;
if ($news['news_id']) {
if ($news['news_id'])
{ // Updating existing item
$vals = "news_datestamp = '".intval($news['news_datestamp'])."', ".$author_insert." news_title='".$news['news_title']."', news_body='".$news['news_body']."', news_extended='".$news['news_extended']."', news_category='".intval($news['cat_id'])."', news_allow_comments='".intval($news['news_allow_comments'])."', news_start='".intval($news['news_start'])."', news_end='".intval($news['news_end'])."', news_class='".$tp->toDB($news['news_class'])."', news_render_type='".intval($news['news_rendertype'])."' , news_summary='".$news['news_summary']."', news_thumbnail='".$tp->toDB($news['news_thumbnail'])."', news_sticky='".intval($news['news_sticky'])."' WHERE news_id='".intval($news['news_id'])."' ";
if ($sql -> db_Update('news', $vals)) {
if ($sql -> db_Update('news', $vals))
{
$admin_log->logArrayAll('NEWS_09', $news);
$e_event -> trigger('newsupd', $news);
$message = LAN_NEWS_21;
$e107cache -> clear('news.php');
} else {
}
else
{
$message = "<strong>".(!mysql_errno() ? LAN_NEWS_46 : LAN_NEWS_5)."</strong>";
}
} else {
if ($news['news_id'] = $sql ->db_Insert('news', "0, '".$news['news_title']."', '".$news['news_body']."', '".$news['news_extended']."', ".intval($news['news_datestamp']).", ".intval($news['news_author']).", '".intval($news['cat_id'])."', '".intval($news['news_allow_comments'])."', '".intval($news['news_start'])."', '".intval($news['news_end'])."', '".$tp->toDB($news['news_class'])."', '".intval($news['news_rendertype'])."', '0' , '".$news['news_summary']."', '".$tp->toDB($news['news_thumbnail'])."', '".intval($news['news_sticky'])."' ")) {
}
else
{ // Adding item
if ($news['news_id'] = $sql ->db_Insert('news', "0, '".$news['news_title']."', '".$news['news_body']."', '".$news['news_extended']."', ".intval($news['news_datestamp']).", ".intval($news['news_author']).", '".intval($news['cat_id'])."', '".intval($news['news_allow_comments'])."', '".intval($news['news_start'])."', '".intval($news['news_end'])."', '".$tp->toDB($news['news_class'])."', '".intval($news['news_rendertype'])."', '0' , '".$news['news_summary']."', '".$tp->toDB($news['news_thumbnail'])."', '".intval($news['news_sticky'])."' "))
{
$admin_log->logArrayAll('NEWS_08', $news);
$e_event -> trigger('newspost', $news);
$message = LAN_NEWS_6;
$e107cache -> clear('news.php');
} else {
}
else
{
$message = "<strong>".LAN_NEWS_7."</strong>";
}
}
@@ -103,17 +115,20 @@ class news {
return $message;
}
function render_newsitem($news, $mode = 'default', $n_restrict = '', $NEWS_TEMPLATE = '', $param='') {
function render_newsitem($news, $mode = 'default', $n_restrict = '', $NEWS_TEMPLATE = '', $param='')
{
global $e107, $tp, $sql, $override, $pref, $ns, $NEWSSTYLE, $NEWSLISTSTYLE, $news_shortcodes, $loop_uid, $imode;
if ($override_newsitem = $override -> override_check('render_newsitem')) {
$result = call_user_func($override_newsitem, $news, $mode, $n_restrict, $NEWS_TEMPLATE, $param);
if ($result == 'return') {
if ($result == 'return')
{
return;
}
}
if (!is_object($e107->tp)) $e107->tp = new e_parse;
if ($n_restrict == 'userclass') {
if ($n_restrict == 'userclass')
{
$news['news_id'] = 0;
$news['news_title'] = LAN_NEWS_1;
$news['data'] = LAN_NEWS_2;
@@ -194,15 +209,19 @@ class news {
require_once(e_FILE.'shortcode/batch/news_shortcodes.php');
$text = $e107->tp -> parseTemplate($NEWS_PARSE, TRUE, $news_shortcodes);
if ($mode == 'return') {
if ($mode == 'return')
{
return $text;
} else {
}
else
{
echo $text;
return TRUE;
}
}
function make_xml_compatible($original) {
function make_xml_compatible($original)
{
global $e107;
if (!is_object($e107->tp)) $e107->tp = new e_parse;
$original = $e107->tp->toHTML($original, TRUE);