<?php

# INFORMÁCIÓS FAL ELEMEI

if ($this->is_id()) {
    $news = new news();
    $news->set_news_data_by_id($this->get_id());

    $smarty->assign('news',$news);
    $smarty->display('news_data_edit.tpl');
}
else {
    //lista
    $news_query = "SELECT * FROM news WHERE n_deleted = 0 AND n_user_ua_id = " . $user->get_ua_id() . " ORDER BY n_date DESC";

    $news_assoc_array = $sql->assoc_array($news_query);

    $news_array = array();
    foreach ($news_assoc_array as $key => $news) {
        $new_news = new news();
        $new_news->set_news_data_by_id($news['n_id']);
        $news_array[] = $new_news;
    }

    $smarty->assign('news_array', $news_array);
    $smarty->display('news_list.tpl');
}

?>
