[eluser]K.Brown[/eluser]
I don't know what to call it, really--I'm a CI noob!
I'm using DX Auth, and making a simple posting system.
Here's how I'd like it to work:
1. Site lists entries of various users.
2. Entries that have been submitted by users first have a status "pending" (to be reviewed).
3. When a user is logged in they can see their entry with the text beside saying "Pending Approval"
4. If the user is an admin, they can see all the posts--no matter what the status is.
5. If the user is an admin, they can click a button beside the list that says "Approve" and it will change the status to "open" via ajax!
This is my current model:
Code:
function getLivePosts($limit){
$data = array();
$this->db->limit($limit);
$this->db->where('status', 'open');
$this->db->order_by('createdate','desc');
$Q = $this->db->get('posts');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function getPost($id){
$data = array();
$this->db->where('id',$id);
$this->db->limit(1);
$Q = $this->db->get('posts');
if ($Q->num_rows() > 0){
$data = $Q->row_array();
}
$Q->free_result();
return $data;
}
I'm open to any suggestions!