212 lines
3.9 KiB
PHP
212 lines
3.9 KiB
PHP
<?php
|
|
|
|
//HÍREK OSZTÁLY
|
|
|
|
class news {
|
|
private $n_id;
|
|
private $n_title;
|
|
private $n_date;
|
|
private $n_text;
|
|
private $n_deleted;
|
|
private $n_user_ua_id; //only id
|
|
private $n_user; //obj
|
|
|
|
public function set_news_data_by_id($_n_id) {
|
|
global $sql;
|
|
$news_data_assoc_array = $sql->assoc_array("select * from news where n_id = " . $_n_id);
|
|
$news_data_array = $news_data_assoc_array[0];
|
|
foreach ($news_data_array as $field => $value) {
|
|
$function_name = "set_" . $field;
|
|
$this->$function_name($value); //alapadatok beállítása
|
|
if ($field == 'n_user_ua_id' && !empty($value)) {
|
|
$coach = new user();
|
|
$coach->set_user_data_by_id($value);
|
|
$this->set_n_user($coach);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static function create_news($_values, $user_id = null) {
|
|
global $sql, $user;
|
|
if (null === $user_id) {
|
|
$user_id = $user->get_ua_id();
|
|
}
|
|
|
|
if (!isset($_values['n_title'])) {
|
|
$title = 'null';
|
|
}
|
|
else {
|
|
$title = $_values['n_title'];
|
|
}
|
|
|
|
return $sql->insert_into('news', array(
|
|
'n_title' => $title,
|
|
'n_user_ua_id' => $user_id,
|
|
'n_text' => $_values['n_text'],
|
|
'n_date' => $_values['n_date']
|
|
));
|
|
}
|
|
|
|
public static function update_news($_values, $n_id) {
|
|
global $sql, $user;
|
|
|
|
if (!isset($_values['n_title'])) {
|
|
$title = 'null';
|
|
}
|
|
else {
|
|
$title = $_values['n_title'];
|
|
}
|
|
|
|
$sql->update_table('news', array(
|
|
'n_title' => $title,
|
|
'n_text' => $_values['n_text'],
|
|
'n_date' => $_values['n_date']
|
|
), array(
|
|
'n_id' => $n_id,
|
|
));
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function get_n_id()
|
|
{
|
|
return $this->n_id;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $n_id
|
|
*
|
|
* @return self
|
|
*/
|
|
public function set_n_id($n_id)
|
|
{
|
|
$this->n_id = $n_id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function get_n_title()
|
|
{
|
|
return $this->n_title;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $n_title
|
|
*
|
|
* @return self
|
|
*/
|
|
public function set_n_title($n_title)
|
|
{
|
|
$this->n_title = $n_title;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function get_n_date()
|
|
{
|
|
return $this->n_date;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $n_date
|
|
*
|
|
* @return self
|
|
*/
|
|
public function set_n_date($n_date)
|
|
{
|
|
$this->n_date = $n_date;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function get_n_text()
|
|
{
|
|
return $this->n_text;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $n_text
|
|
*
|
|
* @return self
|
|
*/
|
|
public function set_n_text($n_text)
|
|
{
|
|
$this->n_text = $n_text;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function get_n_deleted()
|
|
{
|
|
return $this->n_deleted;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $n_deleted
|
|
*
|
|
* @return self
|
|
*/
|
|
public function set_n_deleted($n_deleted)
|
|
{
|
|
$this->n_deleted = $n_deleted;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function get_n_user_ua_id()
|
|
{
|
|
return $this->n_user_ua_id;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $n_user_ua_id
|
|
*
|
|
* @return self
|
|
*/
|
|
public function set_n_user_ua_id($n_user_ua_id)
|
|
{
|
|
$this->n_user_ua_id = $n_user_ua_id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function get_n_user()
|
|
{
|
|
return $this->n_user;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $n_user
|
|
*
|
|
* @return self
|
|
*/
|
|
public function set_n_user($n_user)
|
|
{
|
|
$this->n_user = $n_user;
|
|
|
|
return $this;
|
|
}
|
|
}
|
|
|
|
|
|
?>
|