/***************************************************************************
* Dolphin Smart Community Builder
* -----------------
* begin : Mon Mar 23 2006
* copyright : (C) 2006 BoonEx Group
* website : http://www.boonex.com/
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
* http://creativecommons.org/licenses/by/3.0/
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Creative Commons Attribution 3.0 License for more details.
* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/
require_once( '../inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'news.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
$logged['admin'] = member_auth( 1, true, true );
$_page['css_name'] = 'news.css';
$_page['extraCodeInHead'] = '
';
function MemberPrintNews()
{
global $site;
global $short_date_format;
$bNewsFriendly = getParam('permalinks_news') == 'on' ? true : false;
$res = getNewsList();
if ( !$res )
return;
echo "
\n";
if ( !mysql_num_rows($res) )
{
echo "No news available. |
\n";
}
while ( $news_arr = mysql_fetch_array($res) )
{
$news_header = process_line_output( $news_arr['Header'] );
$sNewsUrl = getNewsUrl($news_arr['newsID'], $news_arr['NewsUri'], $bNewsFriendly);
echo "
Edit |
Delete
|
".date( str_replace('%','',$short_date_format), $news_arr['Date'] )." |
{$news_header} |
\n";
}
echo "
\n";
}
function MemberDeleteNews()
{
$res = db_res( "DELETE FROM `News` WHERE `ID` = ". (int)$_GET['delete_id'] );
return $res;
}
function MemberAddNews()
{
global $max_l;
global $max_h;
$news_text = strlen( $_POST['text'] ) > $max_l ? "LEFT ( '". process_db_input( $_POST['text'] ) ."', $max_l )" : "'". process_db_input( $_POST['text'] ) ."'";
$news_header = strlen( $_POST['header'] ) > $max_h ? "LEFT ( '". process_db_input( $_POST['header'] ) ."', $max_h )" : "'". process_db_input( $_POST['header'] ). "'";
$news_snippet = "'".process_db_input( $_POST['snippet'] )."'";
$sNewsUri = uriGenerate($news_header, 'News', 'NewsUri', 50);
$res = db_res( "INSERT INTO `News` ( `Date`, `Header`, `Text`, `Snippet`, `NewsUri` ) VALUES ( NOW(), $news_header, $news_text, $news_snippet, '$sNewsUri')" );
return $res;
}
function MemberEditNews()
{
global $max_l;
global $max_h;
$news_id = (int)$_POST['edit_id'];
$news_text = strlen( $_POST['text'] ) > $max_l ? "LEFT ( '". process_db_input( $_POST['text'] ) ."', $max_l )" : "'". process_db_input( $_POST['text'] ) ."'";
$news_header = strlen( $_POST['header'] ) > $max_h ? "LEFT ( '". process_db_input( $_POST['header'] ) ."', $max_h )" : "'". process_db_input( $_POST['header'] ). "'";
$news_snippet = "'".process_db_input( $_POST['snippet'] )."'";
$res = db_res( "UPDATE `News` SET `Date`=NOW(), `Header`=$news_header, `Text`=$news_text, `Snippet`=$news_snippet WHERE `ID` = $news_id" );
return $res;
}
$max_l = getParam( "max_news_text" );
$max_p = getParam( "max_news_preview" );
$max_h = getParam( "max_news_header" );
if ( !$max_l )
$max_l = 4096;
if ( !$max_h )
$max_h = 32;
$action_result = "";
if ( !$demo_mode && $_POST['action'] == 'new' )
{
if ( MemberAddNews() )
$action_result .= "News was added";
else
$action_result .= "News adding failed";
}
if ( !$demo_mode && $_POST['action'] == 'edit' && ((int)$_POST['edit_id'] != 0) )
{
if ( MemberEditNews() )
$action_result .= "News was updated";
else
$action_result .= "News updating failed";
}
if ( !$demo_mode && (int)$_GET['delete_id'] != 0 && $_GET['action'] == "delete" )
{
if ( MemberDeleteNews() )
$action_result .= "News was deleted";
else
$action_result .= "News deleting failed";
}
$_page['header'] = "News";
$_page['header_text'] = "News compose";
TopCodeAdmin();
ContentBlockHead("News");
if ( strlen($action_result) )
echo "
$action_result
\n";
MemberPrintNews();
if ( (int)$_GET['edit_id'] != 0 )
{
$news_arr = db_arr( "SELECT `ID`, DATE_FORMAT(`Date`, '$short_date_format' ) AS 'Date', `Header`, `Snippet`, `Text` FROM `News` WHERE `ID` = ". (int)$_GET['edit_id'] );
}
{
ContentBlockFoot();
ContentBlockHead("News compose");
?>
ContentBlockFoot();
}
BottomCode();
?>