initial commit with snapshot 20140213
This commit is contained in:
119
inc/models/ForumsModel.class.php
Normal file
119
inc/models/ForumsModel.class.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
require_once('./inc/model.class.php');
|
||||
|
||||
class ForumsModel extends Model
|
||||
{
|
||||
private $forum_info = null;
|
||||
private $cat_info = null;
|
||||
public function getForums()
|
||||
{
|
||||
return $this->select (FORUMS_VIEW);
|
||||
}
|
||||
|
||||
public function getCats()
|
||||
{
|
||||
return $this->select (CATS_TABLE);
|
||||
}
|
||||
|
||||
public function getForumsNames()
|
||||
{
|
||||
$out = $this->select (FORUMS_TABLE, 'forum_id, name', '', 'forum_id ASC');
|
||||
if (count($out) > 0)
|
||||
return $out;
|
||||
else
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getForum($forum_id)
|
||||
{
|
||||
if ($this->forum_info == null)
|
||||
{
|
||||
$out = $this->select(FORUMS_TABLE, '*', 'forum_id=\''.$forum_id.'\'');
|
||||
|
||||
if (count($out) > 0)
|
||||
$this->forum_info = $out[0];
|
||||
}
|
||||
|
||||
return $this->forum_info;
|
||||
}
|
||||
|
||||
public function getTopics($forum_id)
|
||||
{
|
||||
$out = $this->select(TOPICS_VIEW, '*', 'forum_id=\''.$forum_id.'\'', 'lastpost_post_id DESC');
|
||||
if (count($out) > 0)
|
||||
return $out;
|
||||
else
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getCat($cat_id)
|
||||
{
|
||||
if ($this->cat_info == null)
|
||||
{
|
||||
$out = $this->select(CATS_TABLE, '*', 'category_id=\''.$cat_id.'\'');
|
||||
|
||||
if (count($out) > 0)
|
||||
$this->cat_info = $out[0];
|
||||
}
|
||||
|
||||
return $this->cat_info;
|
||||
}
|
||||
|
||||
public function changeCat($cat_id, $cat_name)
|
||||
{
|
||||
$query = 'UPDATE '.CATS_TABLE.'
|
||||
SET `name`=\''.$cat_name.'\'
|
||||
WHERE `category_id`=\''.$cat_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function addCat($cat_name)
|
||||
{
|
||||
$query = 'INSERT INTO '.CATS_TABLE.'
|
||||
(category_id, name)
|
||||
VALUES (NULL, \''.$cat_name.'\')';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function deleteCat($cat_id)
|
||||
{
|
||||
$query = 'DELETE FROM '.CATS_TABLE.'
|
||||
WHERE `category_id`=\''.$cat_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function changeForum($forum_id, $forum_name, $forum_desc, $forum_category_id, $forum_locked)
|
||||
{
|
||||
$query = 'UPDATE '.FORUMS_TABLE.'
|
||||
SET `name`=\''.$forum_name.'\',
|
||||
`desc`=\''.$forum_desc.'\',
|
||||
`category_id`=\''.$forum_category_id.'\',
|
||||
`locked`=\''.$forum_locked.'\'
|
||||
WHERE `forum_id`=\''.$forum_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function addForum($forum_name, $forum_desc, $forum_category_id, $forum_locked)
|
||||
{
|
||||
$query = 'INSERT INTO '.FORUMS_TABLE.'
|
||||
(`forum_id`, `name`, `desc`, `category_id`, `locked`)
|
||||
VALUES (NULL, \''.$forum_name.'\', \''.$forum_desc.'\', \''.$forum_category_id.'\', \''.$forum_locked.'\')';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function deleteForum($forum_id)
|
||||
{
|
||||
$query = 'DELETE FROM '.FORUMS_TABLE.'
|
||||
WHERE `forum_id`=\''.$forum_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user