/** * Add a news item * * @param int $p_project_id project id * @param int $p_poster_id user id of poster * @param int $p_view_state View state * @param bool $p_announcement annoucement * @param string $p_headline News Headline * @param string $p_body News Body * @return int news article id */ function news_create($p_project_id, $p_poster_id, $p_view_state, $p_announcement, $p_headline, $p_body) { if (is_blank($p_headline)) { error_parameters(lang_get('headline')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } if (is_blank($p_body)) { error_parameters(lang_get('body')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $t_news_table = db_get_table('news'); $t_query = "INSERT\n\t\t\t\tINTO {$t_news_table}\n\t \t\t ( project_id, poster_id, date_posted, last_modified,\n\t \t\t view_state, announcement, headline, body )\n\t\t\t\tVALUES\n\t\t\t\t ( " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t " . db_param() . "\n\t\t\t\t\t)"; db_query_bound($t_query, array((int) $p_project_id, (int) $p_poster_id, db_now(), db_now(), (int) $p_view_state, $p_announcement, $p_headline, $p_body)); $t_news_id = db_insert_id($t_news_table); twitter_news($t_news_id); return $t_news_id; }
function news_create($p_project_id, $p_poster_id, $p_view_state, $p_announcement, $p_headline, $p_body) { $c_project_id = db_prepare_int($p_project_id); $c_poster_id = db_prepare_int($p_poster_id); $c_view_state = db_prepare_int($p_view_state); $c_announcement = db_prepare_bool($p_announcement); $c_headline = db_prepare_string($p_headline); $c_body = db_prepare_string($p_body); if (is_blank($c_headline)) { error_parameters(lang_get('headline')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } if (is_blank($c_body)) { error_parameters(lang_get('body')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $t_news_table = config_get('mantis_news_table'); # Add item $query = "INSERT\n\t\t\t\tINTO {$t_news_table}\n\t \t\t ( project_id, poster_id, date_posted, last_modified,\n\t \t\t view_state, announcement, headline, body )\n\t\t\t\tVALUES\n\t\t\t\t ( '{$c_project_id}', '{$c_poster_id}', " . db_now() . "," . db_now() . ",\n\t\t\t\t '{$c_view_state}', '{$c_announcement}', '{$c_headline}', '{$c_body}' )"; db_query($query); $t_news_id = db_insert_id(); twitter_news($t_news_id); return $t_news_id; }
function news_create( $p_project_id, $p_poster_id, $p_view_state, $p_announcement, $p_headline, $p_body ) { $c_project_id = db_prepare_int( $p_project_id ); $c_poster_id = db_prepare_int( $p_poster_id ); $c_view_state = db_prepare_int( $p_view_state ); $c_announcement = db_prepare_bool( $p_announcement ); if( is_blank( $p_headline ) ) { error_parameters( lang_get( 'headline' ) ); trigger_error( ERROR_EMPTY_FIELD, ERROR ); } if( is_blank( $p_body ) ) { error_parameters( lang_get( 'body' ) ); trigger_error( ERROR_EMPTY_FIELD, ERROR ); } $t_news_table = db_get_table( 'news' ); # Add item $query = "INSERT INTO $t_news_table ( project_id, poster_id, date_posted, last_modified, view_state, announcement, headline, body ) VALUES ( " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . " )"; db_query_bound( $query, Array( $c_project_id, $c_poster_id, db_now(), db_now(), $c_view_state, $c_announcement, $p_headline, $p_body ) ); $t_news_id = db_insert_id( $t_news_table ); twitter_news( $t_news_id ); return $t_news_id; }