function get($name = '', $limit = 5, $offset = 0, $order = 'DESC', $cms = false, $preview)
 {
     $blogs = array();
     $this->db->select('*, fs_blog.id as id');
     if (!$preview) {
         $this->db->where('status', 'publish');
     }
     $this->db->from(self::table_name);
     if ($name) {
         $this->db->where('name', $name);
     }
     $this->db->order_by('date', $order);
     $this->db->group_by(self::table_name . '.id');
     $this->db->limit($limit, $offset);
     $this->db->join("fs_membership", "fs_membership.id = fs_blog.author");
     $query = $this->db->get();
     // create an object for each blog
     foreach ($query->result() as $c) {
         $blog = new Blog_model();
         $blog->_load_from_query($c);
         if (!$cms) {
             $blog->author = $c->first_name . ' ' . $c->last_name;
         }
         $blogs[$c->id] = $blog;
     }
     return $blogs;
 }
Example #2
0
 function _save($id)
 {
     $blog = new Blog_model($id);
     $config['upload_path'] = $this->config->item('base_dir') . 'uploads/images/Blog/';
     $config['allowed_types'] = 'gif|jpg|png';
     //        $config['max_size']	= '100';
     //        $config['max_width']  = '1024';
     //        $config['max_height']  = '768';
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload()) {
         $error = array('error' => $this->upload->display_errors());
         //            $this->load->view('upload_form', $error);
         //echo "ERROR" . print_r($error, 1);
     } else {
         $uploaded = $this->upload->data();
         $_POST['thumb'] = $uploaded['orig_name'];
     }
     $uid = $this->session->userdata('id');
     $_POST['current_author'] = $uid > 0 ? $uid : 1;
     if ($id) {
         $blog->save($_POST);
     } else {
         $id = $blog->create($_POST);
     }
     return $id;
 }