Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 544 lines (449 sloc) 22.072 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
<?php /*

ocPortal
Copyright (c) ocProducts, 2004-2012

See text/EN/licence.txt for full licencing information.


NOTE TO PROGRAMMERS:
Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
**** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****

*/

/**
* @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
* @copyright ocProducts Ltd
* @package news
*/


/**
* Add a news category of the specified details.
*
* @param SHORT_TEXT The news category title
* @param ID_TEXT The theme image ID of the picture to use for the news category
* @param LONG_TEXT Notes for the news category
* @param ?MEMBER The owner (NULL: public)
* @param ?AUTO_LINK Force an ID (NULL: don't force an ID)
* @return AUTO_LINK The ID of our new news category
*/
function add_news_category($title,$img,$notes,$owner=NULL,$id=NULL)
{
$map=array('nc_title'=>insert_lang($title,1),'nc_img'=>$img,'notes'=>$notes,'nc_owner'=>$owner);
if (!is_null($id)) $map['id']=$id;
$id=$GLOBALS['SITE_DB']->query_insert('news_categories',$map,true);

log_it('ADD_NEWS_CATEGORY',strval($id),$title);

decache('side_news_categories');

return $id;
}

/**
* Edit a news category.
*
* @param AUTO_LINK The news category to edit
* @param ?SHORT_TEXT The title (NULL: keep as-is)
* @param ?SHORT_TEXT The image (NULL: keep as-is)
* @param ?LONG_TEXT The notes (NULL: keep as-is)
* @param ?MEMBER The owner (NULL: public)
*/
function edit_news_category($id,$title,$img,$notes,$owner=NULL)
{
$myrows=$GLOBALS['SITE_DB']->query_select('news_categories',array('nc_title','nc_img','notes'),array('id'=>$id),'',1);
if (!array_key_exists(0,$myrows)) warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
$myrow=$myrows[0];

require_code('urls2');
suggest_new_idmoniker_for('news','misc',strval($id),$title);

log_it('EDIT_NEWS_CATEGORY',strval($id),$title);

if (is_null($title)) $title=get_translated_text($myrow['nc_title']);
if (is_null($img)) $img=$myrow['nc_img'];
if (is_null($notes)) $notes=$myrow['notes'];

$GLOBALS['SITE_DB']->query_update('news_categories',array('nc_title'=>lang_remap($myrow['nc_title'],$title),'nc_img'=>$img,'notes'=>$notes,'nc_owner'=>$owner),array('id'=>$id),'',1);

require_code('themes2');
tidy_theme_img_code($img,$myrow['nc_img'],'news_categories','nc_img');

decache('main_news');
decache('side_news');
decache('side_news_archive');
decache('bottom_news');
decache('side_news_categories');
}

/**
* Delete a news category.
*
* @param AUTO_LINK The news category to delete
*/
function delete_news_category($id)
{
$rows=$GLOBALS['SITE_DB']->query_select('news_categories',array('nc_title','nc_img'),array('id'=>$id),'',1);
if (!array_key_exists(0,$rows)) warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
$myrow=$rows[0];

$min=$GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT MIN(id) FROM '.get_table_prefix().'news_categories WHERE id<>'.strval((integer)$id));
if (is_null($min))
{
warn_exit(do_lang_tempcode('YOU_MUST_KEEP_ONE_NEWS_CAT'));
}

log_it('DELETE_NEWS_CATEGORY',strval($id),get_translated_text($myrow['nc_title']));

delete_lang($myrow['nc_title']);

$GLOBALS['SITE_DB']->query_update('news',array('news_category'=>$min),array('news_category'=>$id));
$GLOBALS['SITE_DB']->query_delete('news_categories',array('id'=>$id),'',1);
$GLOBALS['SITE_DB']->query_delete('news_category_entries',array('news_entry_category'=>$id));

$GLOBALS['SITE_DB']->query_delete('group_category_access',array('module_the_name'=>'news','category_name'=>strval($id)));
$GLOBALS['SITE_DB']->query_delete('gsp',array('module_the_name'=>'news','category_name'=>strval($id)));

require_code('themes2');
tidy_theme_img_code(NULL,$myrow['nc_img'],'news_categories','nc_img');

decache('side_news_categories');
}

/**
* Adds a news entry to the database, and send out the news to any RSS cloud listeners.
*
* @param SHORT_TEXT The news title
* @param LONG_TEXT The news summary (or if not an article, the full news)
* @param ?ID_TEXT The news author (possibly, a link to an existing author in the system, but does not need to be) (NULL: current username)
* @param BINARY Whether the news has been validated
* @param BINARY Whether the news may be rated
* @param SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style)
* @param BINARY Whether the news may have trackbacks
* @param LONG_TEXT Notes for the news
* @param LONG_TEXT The news entry (blank means no entry)
* @param ?AUTO_LINK The primary news category (NULL: personal)
* @param ?array The IDs of the news categories that this is in (NULL: none)
* @param ?TIME The time of submission (NULL: now)
* @param ?MEMBER The news submitter (NULL: current member)
* @param integer The number of views the article has had
* @param ?TIME The edit date (NULL: never)
* @param ?AUTO_LINK Force an ID (NULL: don't force an ID)
* @param URLPATH URL to the image for the news entry (blank: use cat image)
* @return AUTO_LINK The ID of the news just added
*/
function add_news($title,$news,$author=NULL,$validated=1,$allow_rating=1,$allow_comments=1,$allow_trackbacks=1,$notes='',$news_article='',$main_news_category=NULL,$news_category=NULL,$time=NULL,$submitter=NULL,$views=0,$edit_date=NULL,$id=NULL,$image='')
{
if (is_null($author)) $author=$GLOBALS['FORUM_DRIVER']->get_username(get_member());
if (is_null($news_category)) $news_category=array();
if (is_null($time)) $time=time();
if (is_null($submitter)) $submitter=get_member();
$already_created_personal_category=false;

require_code('comcode_check');
check_comcode($news_article,NULL,false,NULL,true);

if (is_null($main_news_category))
{
$main_news_category_id=$GLOBALS['SITE_DB']->query_value_null_ok('news_categories','id',array('nc_owner'=>$submitter));
if (is_null($main_news_category_id))
{
if (!has_specific_permission(get_member(),'have_personal_category','cms_news')) fatal_exit(do_lang_tempcode('INTERNAL_ERROR'));

$p_nc_title=insert_lang(do_lang('MEMBER_CATEGORY',$GLOBALS['FORUM_DRIVER']->get_username($submitter)),2);

$main_news_category_id=$GLOBALS['SITE_DB']->query_insert('news_categories',array('nc_title'=>$p_nc_title,'nc_img'=>'newscats/community','notes'=>'','nc_owner'=>$submitter),true);
$already_created_personal_category=true;

$groups=$GLOBALS['FORUM_DRIVER']->get_usergroup_list(false,true);

foreach (array_keys($groups) as $group_id)
$GLOBALS['SITE_DB']->query_insert('group_category_access',array('module_the_name'=>'news','category_name'=>strval($main_news_category_id),'group_id'=>$group_id));
}
}
else $main_news_category_id=$main_news_category;

if (!addon_installed('unvalidated')) $validated=1;
$map=array('news_image'=>$image,'edit_date'=>$edit_date,'news_category'=>$main_news_category_id,'news_views'=>$views,'news_article'=>0,'allow_rating'=>$allow_rating,'allow_comments'=>$allow_comments,'allow_trackbacks'=>$allow_trackbacks,'notes'=>$notes,'submitter'=>$submitter,'validated'=>$validated,'date_and_time'=>$time,'title'=>insert_lang_comcode($title,1),'news'=>insert_lang_comcode($news,1),'author'=>$author);
if (!is_null($id)) $map['id']=$id;
$id=$GLOBALS['SITE_DB']->query_insert('news',$map,true);

if (!is_null($news_category))
{
foreach ($news_category as $value)
{
if ((is_null($value)) && (!$already_created_personal_category))
{
$p_nc_title=insert_lang(do_lang('MEMBER_CATEGORY',$GLOBALS['FORUM_DRIVER']->get_username($submitter)),2);
$news_category_id=$GLOBALS['SITE_DB']->query_insert('news_categories',array('nc_title'=>$p_nc_title,'nc_img'=>'newscats/community','notes'=>'','nc_owner'=>$submitter),true);

$groups=$GLOBALS['FORUM_DRIVER']->get_usergroup_list(false,true);

foreach (array_keys($groups) as $group_id)
$GLOBALS['SITE_DB']->query_insert('group_category_access',array('module_the_name'=>'news','category_name'=>strval($news_category_id),'group_id'=>$group_id));
}
else $news_category_id=$value;

if (is_null($news_category_id)) continue; // Double selected

$GLOBALS['SITE_DB']->query_insert('news_category_entries',array('news_entry'=>$id,'news_entry_category'=>$news_category_id));
}
}

require_code('attachments2');
$map=array('news_article'=>insert_lang_comcode_attachments(2,$news_article,'news',strval($id)));
$GLOBALS['SITE_DB']->query_update('news',$map,array('id'=>$id),'',1);

log_it('ADD_NEWS',strval($id),$title);

if (function_exists('xmlrpc_encode'))
{
if (function_exists('set_time_limit')) @set_time_limit(0);

// Send out on RSS cloud
$GLOBALS['SITE_DB']->query('DELETE FROM '.get_table_prefix().'news_rss_cloud WHERE register_time<'.strval(time()-25*60*60));
$start=0;
do
{
$listeners=$GLOBALS['SITE_DB']->query_select('news_rss_cloud',array('*'),NULL,'',100,$start);
foreach ($listeners as $listener)
{
$data=$listener['watching_channel'];
if ($listener['rem_protocol']=='xml-rpc')
{
$request=xmlrpc_encode_request($listener['rem_procedure'],$data);
$length=strlen($request);
$_length=strval($length);
$packet=<<<END
POST /{$listener['rem_path']} HTTP/1.0
Host: {$listener['rem_ip']}
Content-Type: text/xml
Content-length: {$_length}

{$request}
END;
}
$errno=0;
$errstr='';
$mysock=@fsockopen($listener['rem_ip'],$listener['rem_port'],$errno,$errstr,6.0);
if ($mysock!==false)
{
@fwrite($mysock,$packet);
@fclose($mysock);
}
$start+=100;
}
}
while (array_key_exists(0,$listeners));
}

require_code('seo2');
seo_meta_set_for_implicit('news',strval($id),array($title,($news=='')?$news_article:$news/*,$news_article*/),($news=='')?$news_article:$news); // News article could be used, but it's probably better to go for the summary only to avoid crap

if ($validated==1)
{
decache('main_news');
decache('side_news');
decache('side_news_archive');
decache('bottom_news');

dispatch_news_notification($id,$title,$main_news_category_id);
}

if (($validated==1) && (get_option('site_closed')=='0') && (ocp_srv('HTTP_HOST')!='127.0.0.1') && (ocp_srv('HTTP_HOST')!='localhost') && (has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(),'news',strval($main_news_category_id))))
{
$_ping_url=str_replace('{url}',urlencode(get_base_url()),str_replace('{rss}',urlencode(find_script('backend')),str_replace('{title}',urlencode(get_site_name()),get_option('ping_url'))));
$ping_urls=explode(chr(10),$_ping_url);
foreach ($ping_urls as $ping_url)
{
$ping_url=trim($ping_url);
if ($ping_url!='') http_download_file($ping_url,NULL,false);
}
}

return $id;
}

/**
* Edit a news entry.
*
* @param AUTO_LINK The ID of the news to edit
* @param SHORT_TEXT The news title
* @param LONG_TEXT The news summary (or if not an article, the full news)
* @param ID_TEXT The news author (possibly, a link to an existing author in the system, but does not need to be)
* @param BINARY Whether the news has been validated
* @param BINARY Whether the news may be rated
* @param SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style)
* @param BINARY Whether the news may have trackbacks
* @param LONG_TEXT Notes for the news
* @param LONG_TEXT The news entry (blank means no entry)
* @param AUTO_LINK The primary news category (NULL: personal)
* @param ?array The IDs of the news categories that this is in (NULL: do not change)
* @param SHORT_TEXT Meta keywords
* @param LONG_TEXT Meta description
* @param ?URLPATH URL to the image for the news entry (blank: use cat image) (NULL: don't delete existing)
* @param ?TIME Recorded add time (NULL: leave alone)
*/
function edit_news($id,$title,$news,$author,$validated,$allow_rating,$allow_comments,$allow_trackbacks,$notes,$news_article,$main_news_category,$news_category,$meta_keywords,$meta_description,$image,$time=NULL)
{
$rows=$GLOBALS['SITE_DB']->query_select('news',array('title','news','news_article','submitter'),array('id'=>$id),'',1);
$_title=$rows[0]['title'];
$_news=$rows[0]['news'];
$_news_article=$rows[0]['news_article'];

require_code('urls2');

suggest_new_idmoniker_for('news','view',strval($id),$title);

require_code('attachments2');
require_code('attachments3');

if (!addon_installed('unvalidated')) $validated=1;

require_code('submit');
$just_validated=(!content_validated('news',strval($id))) && ($validated==1);
if ($just_validated)
{
send_content_validated_notification('news',strval($id));
}

$map=array('news_category'=>$main_news_category,'news_article'=>update_lang_comcode_attachments($_news_article,$news_article,'news',strval($id),NULL,false,$rows[0]['submitter']),'edit_date'=>time(),'allow_rating'=>$allow_rating,'allow_comments'=>$allow_comments,'allow_trackbacks'=>$allow_trackbacks,'notes'=>$notes,'validated'=>$validated,'title'=>lang_remap_comcode($_title,$title),'news'=>lang_remap_comcode($_news,$news),'author'=>$author);

if (!is_null($time)) $map['date_and_time']=$time;

if (!is_null($image))
{
$map['news_image']=$image;
require_code('files2');
delete_upload('uploads/grepimages','news','news_image','id',$id,$image);
}

/*$news_categories=$news_category[0];
foreach ($news_category as $key=>$value)
{
if($key>0) $news_categories.=','.$value;
}*/

if (!is_null($news_category))
{
$GLOBALS['SITE_DB']->query_delete('news_category_entries',array('news_entry'=>$id));

foreach ($news_category as $value)
{
$GLOBALS['SITE_DB']->query_insert('news_category_entries',array('news_entry'=>$id,'news_entry_category'=>$value));
}
}

log_it('EDIT_NEWS',strval($id),$title);

$GLOBALS['SITE_DB']->query_update('news',$map,array('id'=>$id),'',1);

$self_url=build_url(array('page'=>'news','type'=>'view','id'=>$id),get_module_zone('news'),NULL,false,false,true);

if ($just_validated)
{
dispatch_news_notification($id,$title,$main_news_category);
}

require_code('seo2');
seo_meta_set_for_explicit('news',strval($id),$meta_keywords,$meta_description);

decache('main_news');
decache('side_news');
decache('side_news_archive');
decache('bottom_news');

if (($validated==1) && (has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(),'news',strval($main_news_category))))
{
$_ping_url=str_replace('{url}',urlencode(get_base_url()),str_replace('{rss}',urlencode(find_script('backend')),str_replace('{title}',urlencode(get_site_name()),get_option('ping_url'))));
$ping_urls=explode(',',$_ping_url);
foreach ($ping_urls as $ping_url)
{
$ping_url=trim($ping_url);
if ($ping_url!='') http_download_file($ping_url,NULL,false);
}
}

require_code('feedback');
update_spacer_post($allow_comments!=0,'news',strval($id),$self_url,$title,get_value('comment_forum__news'));
}

/**
* Send out a notification of some new news.
*
* @param AUTO_LINK The ID of the news
* @param SHORT_TEXT The title
* @param AUTO_LINK The main news category
*/
function dispatch_news_notification($id,$title,$main_news_category)
{
$self_url=build_url(array('page'=>'news','type'=>'view','id'=>$id),get_module_zone('news'),NULL,false,false,true);

$is_blog=!is_null($GLOBALS['SITE_DB']->query_value('news_categories','nc_owner',array('id'=>$main_news_category)));

require_code('notifications');
require_lang('news');
if ($is_blog)
{
$subject=do_lang('BLOG_NOTIFICATION_MAIL_SUBJECT',get_site_name(),$title);
$mail=do_lang('BLOG_NOTIFICATION_MAIL',comcode_escape(get_site_name()),comcode_escape($title),array($self_url->evaluate()));
dispatch_notification('news_entry',strval($main_news_category),$subject,$mail);
} else
{
$subject=do_lang('NEWS_NOTIFICATION_MAIL_SUBJECT',get_site_name(),$title);
$mail=do_lang('NEWS_NOTIFICATION_MAIL',comcode_escape(get_site_name()),comcode_escape($title),array($self_url->evaluate()));
dispatch_notification('news_entry',strval($main_news_category),$subject,$mail);
}
}

/**
* Delete a news entry.
*
* @param AUTO_LINK The ID of the news to edit
*/
function delete_news($id)
{
$rows=$GLOBALS['SITE_DB']->query_select('news',array('title','news','news_article'),array('id'=>$id),'',1);
$title=$rows[0]['title'];
$news=$rows[0]['news'];
$news_article=$rows[0]['news_article'];

$_title=get_translated_text($title);
log_it('DELETE_NEWS',strval($id),$_title);

require_code('files2');
delete_upload('uploads/grepimages','news','news_image','id',$id);

$GLOBALS['SITE_DB']->query_delete('news',array('id'=>$id),'',1);
$GLOBALS['SITE_DB']->query_delete('news_category_entries',array('news_entry'=>$id));

$GLOBALS['SITE_DB']->query_delete('rating',array('rating_for_type'=>'news','rating_for_id'=>$id));
$GLOBALS['SITE_DB']->query_delete('trackbacks',array('trackback_for_type'=>'news','trackback_for_id'=>$id));

delete_lang($title);
delete_lang($news);
require_code('attachments2');
require_code('attachments3');
if (!is_null($news_article)) delete_lang_comcode_attachments($news_article,'news',strval($id));

require_code('seo2');
seo_meta_erase_storage('news',strval($id));

decache('main_news');
decache('side_news');
decache('side_news_archive');
decache('bottom_news');
}

/**
* Get a nice formatted XHTML list of news categories.
*
* @param ?mixed The selected news category. Array or AUTO_LINK (NULL: personal)
* @param boolean Whether to add all personal categories into the list (for things like the adminzone, where all categories must be shown, regardless of permissions)
* @param boolean Whether to only show for what may be added to by the current member
* @param boolean Whether to limit to only existing cats (otherwise we dynamically add unstarted blogs)
* @param ?boolean Whether to limit to only show blog categories (NULL: don't care, true: blogs only, false: no blogs)
* @param boolean Whether to prefer to choose a non-blog category as the default
* @return tempcode The tempcode for the news category select list
*/
function nice_get_news_categories($it=NULL,$show_all_personal_categories=false,$addable_filter=false,$only_existing=false,$only_blogs=NULL,$prefer_not_blog_selected=false)
{
if (!is_array($it)) $it=array($it);

if ($only_blogs===true)
{
$where='WHERE nc_owner IS NOT NULL';
}
elseif ($only_blogs===false)
{
$where='WHERE nc_owner IS NULL';
} else
{
$where='WHERE 1=1';
}
$count=$GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM '.get_table_prefix().'news_categories '.$where.' ORDER BY id');
if ($count>500) // Uh oh, loads, need to limit things more
{
$where.=' AND (nc_owner IS NULL OR nc_owner='.strval(get_member()).')';
}
$_cats=$GLOBALS['SITE_DB']->query('SELECT * FROM '.get_table_prefix().'news_categories '.$where.' ORDER BY id');

foreach ($_cats as $i=>$cat)
{
$_cats[$i]['nice_title']=get_translated_text($cat['nc_title']);
}
global $M_SORT_KEY;
$M_SORT_KEY='nice_title';
usort($_cats,'multi_sort');

$categories=new ocp_tempcode();
$add_cat=true;

foreach ($_cats as $cat)
{
if ($cat['nc_owner']==get_member()) $add_cat=false;

if (!has_category_access(get_member(),'news',strval($cat['id']))) continue;
if (($addable_filter) && (!has_submit_permission('high',get_member(),get_ip_address(),'cms_news',array('news',$cat['id'])))) continue;

if (is_null($cat['nc_owner']))
{
$li=form_input_list_entry(strval($cat['id']),($it!=array(NULL)) && in_array($cat['id'],$it),$cat['nice_title'].' (#'.strval($cat['id']).')');
$categories->attach($li);
} else
{
if ((((!is_null($cat['nc_owner'])) && (has_specific_permission(get_member(),'can_submit_to_others_categories'))) || (($cat['nc_owner']==get_member()) && (!is_guest()))) || ($show_all_personal_categories))
$categories->attach(form_input_list_entry(strval($cat['id']),(($cat['nc_owner']==get_member()) && ((!$prefer_not_blog_selected) && (in_array(NULL,$it)))) || (in_array($cat['id'],$it)),do_lang('MEMBER_CATEGORY',$GLOBALS['FORUM_DRIVER']->get_username($cat['nc_owner'])).' (#'.strval($cat['id']).')'));
}
}

if ((!$only_existing) && (has_specific_permission(get_member(),'have_personal_category','cms_news')) && ($add_cat) && (!is_guest()))
{
$categories->attach(form_input_list_entry('personal',(!$prefer_not_blog_selected) && in_array(NULL,$it),do_lang_tempcode('MEMBER_CATEGORY',do_lang_tempcode('_NEW',escape_html($GLOBALS['FORUM_DRIVER']->get_username(get_member()))))));
}

return $categories;
}

/**
* Get a nice formatted XHTML list of news.
*
* @param ?AUTO_LINK The selected news entry (NULL: none)
* @param ?MEMBER Limit news to those submitted by this member (NULL: show all)
* @param boolean Whether to only show for what may be edited by the current member
* @param boolean Whether to only show blog posts
* @return tempcode The list
*/
function nice_get_news($it,$only_owned=NULL,$editable_filter=false,$only_in_blog=false)
{
$where=is_null($only_owned)?'1':'submitter='.strval($only_owned);
if ($only_in_blog)
{
$rows=$GLOBALS['SITE_DB']->query('SELECT n.* FROM '.get_table_prefix().'news n JOIN '.get_table_prefix().'news_categories c ON c.id=n.news_category AND '.$where.' AND nc_owner IS NOT NULL ORDER BY date_and_time DESC',300/*reasonable limit*/);
} else
{
$rows=$GLOBALS['SITE_DB']->query('SELECT * FROM '.get_table_prefix().'news WHERE '.$where.' ORDER BY date_and_time DESC',300/*reasonable limit*/);
}

if (count($rows)==300) attach_message(do_lang_tempcode('TOO_MUCH_CHOOSE__RECENT_ONLY',escape_html(integer_format(300))),'warn');

$out=new ocp_tempcode();
foreach ($rows as $myrow)
{
if (!has_category_access(get_member(),'news',strval($myrow['news_category']))) continue;
if (($editable_filter) && (!has_edit_permission('high',get_member(),$myrow['submitter'],'cms_news',array('news',$myrow['news_category'])))) continue;

$selected=($myrow['id']==$it);

$out->attach(form_input_list_entry(strval($myrow['id']),$selected,get_translated_text($myrow['title'])));
}

return $out;
}
Something went wrong with that request. Please try again.