<?php
/* Include Files *********************/
require_once('require.php');
require_once('../../JSON/jsonwrapper_inner.php');
/*************************************/

global $rSdb;

$user	= new userManagement();

if(  !$user->_logged_in  )
	die(__('Access denied.','recipeshelf'));

if( ! check_ajax_referer('list-thoughts', false) )
	die(__('Security Alert: Direct access not permitted!','recipeshelf'));

### User specific ideas
$UID = ' AND 0';
if( $user->_user_id!='' )
	$UID = " AND uid='{$user->_user_id}'";

$sql	= "SELECT id as n, object as o FROM {$rSdb->DBobjects} WHERE type='5'{$UID} ORDER BY id DESC";
$list	= $rSdb->fetchArr( $sql );

if ( !is_array($list) || count($list)==0 ){
	$list[0]->result = 0;
	$list[0]->n = 0;
	$list[0]->o = __('No ideas yet...','recipeshelf');
} else
	$list[0]->result = 1;

$i=0;
$list_esc = $list;
foreach( $list as $l)
	$list_esc[$i++]->o = esc_html( $l->o );
	
echo json_encode($list_esc);
?>