public function update_gallery($id, $input) { // we need oldslug for later use $oldslug = parent::get($id)->slug; // Prepare the data unset($input['btnAction']); unset($input['form_id']); unset($input['token']); unset($input['action_to']); $input['slug'] = $this->generate_slug($input['slug']); $input['parent'] = !empty($input['parent_id']) ? $input['parent_id'] : 0; unset($input['parent_id']); if (!empty($input['gallery_thumbnail'])) { $input['thumbnail_id'] = $input['gallery_thumbnail']; unset($input['gallery_thumbnail']); } // Update the DB $result = parent::update($id, $input); // if we had no errors (like slug dublicate), proceed with renaming: if ($result) { if ($oldslug != $input['slug']) { rename('uploads/galleries/' . $oldslug, 'uploads/galleries/' . $input['slug']); } } return $result; }
public function get($params = NULL) { $clients = parent::get($params); if (is_array($clients)) { if ($this->mdl_mcb_data->setting('version') > '0.8.2') { if (isset($params['set_client_data'])) { foreach ($clients as $client) { $this->db->where('client_id', $client->client_id); $mcb_client_data = $this->db->get('mcb_client_data')->result(); foreach ($mcb_client_data as $client_data) { $client->{$client_data->mcb_client_key} = $client_data->mcb_client_value; } } } } } else { if ($this->mdl_mcb_data->setting('version') > '0.8.2') { if (isset($params['set_client_data'])) { $this->db->where('client_id', $clients->client_id); $mcb_client_data = $this->db->get('mcb_client_data')->result(); foreach ($mcb_client_data as $client_data) { $clients->{$client_data->mcb_client_key} = $client_data->mcb_client_value; } } } } return $clients; }
public function get($id = NULL, $single = FALSE) { $this->db->select("{$this->_table_name}.* , perm.perm_name , role.role_name "); $this->db->join('tbl_permission perm', " {$this->_table_name}.perm_id = perm.perm_id", 'left'); $this->db->join('tbl_role role', " {$this->_table_name}.role_id = role.role_id", 'left'); return parent::get($id, $single); }
public function get($id = NULL, $single = FALSE) { $this->db->select("{$this->_table_name}.* , mp.post_id mp_post_id , mp.post_name mp_post_name ,sp.post_id sp_post_id , sp.post_name sp_post_name "); $this->db->join('tbl_post mp', " {$this->_table_name}.post_id = mp.post_id", 'left'); $this->db->join('tbl_post sp', " {$this->_table_name}.loaded_post_id = sp.post_id", 'left'); return parent::get($id, $single); }
public function get_recent($limit = 3) { $limit = (int) $limit; $this->set_published(); $this->db->limit($limit); return parent::get(); }
public function get($id_or_fields = null, $first_only = false, $order_by = null, $select_fields = array()) { $tasks = parent::get($id_or_fields, $first_only, $order_by, $select_fields); if ($first_only || !is_array($tasks)) { $tasks = array($tasks); } if (!empty($tasks)) { foreach ($tasks as $key => $task) { if (empty($task)) { continue; } $diagnostic_issue = $this->diagnostic_issue_model->get_from_cache($task->diagnostic_issue_id); $tasks[$key]->name = $this->step_model->get_name($task->step_id) . ': ' . $this->part_type_model->get_name($diagnostic_issue->part_type_id); $step_past = $this->step_model->get_past_tense($task->step_id); $issue = $this->issue_type_model->get_name($diagnostic_issue->issue_type_id); if (strstr($step_past, '[[part]]')) { $step_past = str_replace('[[part]]', $this->part_type_model->get_name($diagnostic_issue->part_type_id), $step_past); $tasks[$key]->past_name = $step_past; } else { $tasks[$key]->past_name = $step_past . ' ' . $this->part_type_model->get_name($diagnostic_issue->part_type_id); } $tasks[$key]->past_name = strtolower($tasks[$key]->past_name); $tasks[$key]->issue_description = $issue . ' ' . $this->part_type_model->get_name($diagnostic_issue->part_type_id); } } if ($first_only || !is_array($id_or_fields)) { return reset($tasks); } return $tasks; }
private function _get_user_from_db($id) { $userObj = parent::get($id); if ($userObj) { return $this->_remove_sensitive_data($userObj); } return false; }
public function get_recent($limit = 3) { $limit = (int) $limit; $this->set_published(); $this->db->limit($limit); $this->db->order_by($this->_order_by, 'desc'); return parent::get(); }
public function get_recent($limit = 3) { // Fetch a limited number of recent brands $limit = (int) $limit; $this->set_published(); $this->db->limit($limit); return parent::get(); }
/** * Delete a file * * Deletes a single file by its id * * @params int The file id * @return bool */ public function delete_file($id) { $this->load->helper('file'); if (!($image = parent::get($id))) { return FALSE; } @unlink(FCPATH . '/' . $this->config->item('files_folder') . '/' . $image->filename); return TRUE; }
public function get($id = null, $single = FAlSE) { $this->db->select("{$this->_table_name}.* , post.post_title , post.post_name "); // $this->db->join('tbl_category cat'," $this->_table_name.category_id = cat.category_id"); $this->db->join('tbl_post post', " {$this->_table_name}.post_id = post.post_id"); /* $this->db->join('tbl_media media'," $this->_table_name.post_id = media.post_id", "left");*/ //$this->db->group_by("$this->_table_name.post_id"); return parent::get($id, $single); }
public function get_recent($limit = 4) { $this->db->select("posts.*,m.file_name as media_image"); $this->db->join("medias as m", "posts.image=m.id", 'left'); $limit = (int) $limit; $this->set_published(); $this->db->limit($limit); return parent::get(); }
public function get_with_author_names($id_or_fields = null, $first_only = false, $order_by = null, $select_fields = array()) { $messages = parent::get($id_or_fields, $first_only, $order_by, $select_fields); foreach ($messages as $key => $message) { $messages[$key]->author = $this->user_model->get_name($message->author_id); $messages[$key]->date = unix_to_human($message->creation_date); } return $messages; }
public function hapus_slide($id = 0) { $data = parent::get($id); if (file_exists($data->slide_image)) { unlink($data->slide_image); } if (file_exists($data->slide_thumb)) { unlink($data->slide_thumb); } parent::delete($id); }
public function get($id_or_fields = null, $first_only = false, $order_by = null, $select_fields = array()) { static $order_technician = array(); if (!empty($order_technician[serialize($id_or_fields)]) && $first_only && is_null($order_by) && empty($select_fields)) { return $order_technician[serialize($id_or_fields)]; } $result = parent::get($id_or_fields, $first_only, $order_by, $select_fields); if ($first_only && is_null($order_by) && empty($select_fields)) { $order_technician[serialize($id_or_fields)] = $result; } return $result; }
public function get($params = NULL) { $inventory = parent::get($params); if ($inventory and isset($params['group_by_type'])) { $tmp = $inventory; unset($inventory); foreach ($tmp as $item) { $inventory[$item->inventory_type][] = $item; } } return $inventory; }
public function get($params = NULL) { $invoices = parent::get($params); if (is_array($invoices)) { foreach ($invoices as $invoice) { $invoice = $this->set_invoice_additional($invoice, $params); } } else { $invoices = $this->set_invoice_additional($invoices, $params); } return $invoices; }
public function get_with_join($id = NULL, $single = NULL) { $this->db->select("category.*,p.slug as parent_slug, p.title as parent_title,m.file_name as media_image"); $this->db->join("category as p", "category.parent_id=p.id", 'left'); $this->db->join("medias as m", "category.image=m.id", 'left'); if ($id) { $where = array('category.id' => $id); return parent::$this->get_by($where, $single); } else { return parent::get(); } }
public function get($param = null) { if ($param) { return parent::get($param); } if ($this->input->get('task_id')) { $this->db->where('task_id', $this->input->get('task_id')); } if ($this->input->get('user_id')) { $this->db->where('user_id', $this->input->get('user_id')); } $this->db->order_by('creation_ts', 'asc'); return $this->db->get($this->table)->result_array(); }
function getAllButCurrentUser($ids = array('1')) { /* $this->data['users'] = $this->usermodel->get_by(array( "user_id NOT IN(".implode(", ", $ids).") "=>NULL , // $this->_table_name.".".$this->_primary_key." != "=>$id ), FALSE); */ $this->db->where_not_in($this->_table_name . "." . $this->_primary_key, $ids); $users = parent::get(); // echo "<spam>".$this->db->last_query()."</spam>"; return $users; }
public function get_array_id_name() { // Fetch pages without parents $this->db->select('category_id, category_name'); $categories = parent::get(); // Return key => value pair array $array = array(0 => ' -------- '); if (count($categories)) { foreach ($categories as $category) { $array[$category->category_id] = $category->category_name; } } return $array; }
public function get($params = NULL) { if (isset($params['active_clients_only']) and $params['active_clients_only']) { $this->db->where('mcb_clients.client_active', 1); } $invoices = parent::get($params); if (is_array($invoices)) { foreach ($invoices as $invoice) { $invoice = $this->set_invoice_additional($invoice, $params); } } else { $invoices = $this->set_invoice_additional($invoices, $params); } return $invoices; }
function create_invoice_from_tasks($task_ids) { $this->load->model('invoices/mdl_invoices'); $params = array('where_in' => array('mcb_tasks.task_id' => $task_ids)); $tasks = parent::get($params); foreach ($tasks as $task) { if (!isset($invoice_id)) { $invoice_id = $this->mdl_invoices->save($task->client_id, $task->start_date, FALSE); } $this->mdl_invoices->add_invoice_item($invoice_id, $task->title, $task->description, 1, 0); $db_array = array('task_id' => $task->task_id, 'invoice_id' => $invoice_id); $this->db->insert('mcb_tasks_invoices', $db_array); } return $invoice_id; }
public function get_no_parents() { /* Fetch pages without parents */ $this->db->select('id, title'); $this->db->where('parent_id', 0); $pages = parent::get(); /* Return key => value pair array */ $array = array(0 => 'No parent'); if (count($pages)) { foreach ($pages as $page) { $array[$page->id] = $page->title; } } return $array; }
function get($id_or_fields = null, $first_only = false, $order_by = null, $select_fields = array()) { $addresses = parent::get($id_or_fields, $first_only, $order_by, $select_fields); if (is_array($addresses)) { foreach ($addresses as $key => $address) { if (!empty($address->street_type)) { $addresses[$key]->street_type_short = $this->street_type_model->get_abbreviation($address->street_type); } } } else { if (!empty($addresses->street_type)) { $addresses->street_type_short = $this->street_type_model->get_abbreviation($addresses->street_type); } } return $addresses; }
public function get_with_join($id = NULL, $single = FALSE) { $this->db->select("packages.*, l.title as package_location, c.title as package_category,s.title as package_scheme,h.title as package_hotel,t.title as package_transport,m.file_name as media_image"); $this->db->join("locations as l", "packages.location_id=l.id", 'left'); $this->db->join("category as c", "packages.category_id=c.id", 'left'); $this->db->join("schemes as s", "packages.scheme_id=s.id", 'left'); $this->db->join("hotels as h", "packages.hotel_id=h.id", 'left'); $this->db->join("transports as t", "packages.transport_id=t.id", 'left'); $this->db->join("medias as m", "packages.image=m.id", 'left'); if ($id) { $where = array('packages.id' => $id); return parent::get_by($where, $single); } else { return parent::get(); } }
public function run($params = array()) { //dump($params); $this->db->select("packages.*, l.title as package_location,\n c.title as package_category,s.title as package_scheme,\n h.title as package_hotel,t.title as package_transport,\n m.file_name as media_image"); $this->db->join("locations as l", "packages.location_id=l.id", 'left'); $this->db->join("category as c", "packages.category_id=c.id", 'left'); $this->db->join("schemes as s", "packages.scheme_id=s.id", 'left'); $this->db->join("hotels as h", "packages.hotel_id=h.id", 'left'); $this->db->join("transports as t", "packages.transport_id=h.id", 'left'); $this->db->join("medias as m", "packages.image=m.id", 'left'); if (isset($params['category_id'])) { $where = array('packages.category_id' => $params['category_id']); $ARRs = parent::get_by($where); } else { $ARRs = parent::get(); } //isset($params['category_id']) ? $where = array('packages.category_id'=>$params['category_id']) : NULL; $str = ''; //dump($ARRs); foreach ($ARRs as $package) { $str .= '<div class="destination-places-grids">'; $str .= '<div class="destination-places-grid last-d-grid" onclick="location.href=\'/package/' . $package->id . '\';">'; $str .= '<div class="dest-place-pic main_box user_style4" data-hipop="two-horizontal">'; $str .= '<img src="' . base_url('wc-upload/gallery') . '/' . $package->media_image . '" title="' . $package->title . '" width="480" height="180" />'; $str .= '<a href="#" class="popup"> </a>'; $str .= '<a href="#" class="popup2"> </a>'; $str .= '</div>'; $str .= '<div class="dest-place-opt">'; $str .= '<ul class="dest-place-opt-fea">'; $str .= '<li><a class="hot" href="#"><span> </span>' . $package->package_hotel . '</a></li>'; $str .= '<li><a class="plain" href="#"><span> </span>' . $package->package_transport . '</a></li>'; $str .= '<li><a class="Breakfast" href="#"><span> </span>' . $package->package_scheme . '</a></li>'; $str .= '<div class="clear"></div>'; $str .= '</ul>'; $str .= '<ul class="dest-place-opt-cast">'; $str .= '<li><a class="d-place" href="#">' . $package->package_location . '</a></li>'; $str .= '<li><a class="d-price" href="#">Starting Form ' . $package->price . '</a></li>'; $str .= '<div class="clear"></div>'; $str .= '</ul>'; $str .= '</div>'; $str .= '</div>'; } $str .= '<div class="clear"></div>'; $str .= '</div>'; return $str; }
public function get($id_or_fields = null, $first_only = false, $order_by = null, $select_fields = array()) { $diagnostic_issues = parent::get($id_or_fields, $first_only, $order_by, $select_fields); if (!empty($diagnostic_issues) && !is_array($diagnostic_issues)) { $diagnostic_issues->part_type_name = $this->part_type_model->get($diagnostic_issues->part_type_id, true, null, array('name'))->name; $diagnostic_issues->issue_type_name = $this->issue_type_model->get($diagnostic_issues->issue_type_id, true, null, array('name'))->name; $diagnostic_issues->can_be_fixed_now_text = $diagnostic_issues->can_be_fixed_now ? 'Yes' : 'No'; } else { if (!empty($diagnostic_issues)) { foreach ($diagnostic_issues as $id => $issue) { $diagnostic_issues[$id]->part_type_name = $this->part_type_model->get($issue->part_type_id, true, null, array('name'))->name; $diagnostic_issues[$id]->issue_type_name = $this->issue_type_model->get($issue->issue_type_id, true, null, array('name'))->name; $diagnostic_issues[$id]->can_be_fixed_now_text = $issue->can_be_fixed_now ? 'Yes' : 'No'; } } } return $diagnostic_issues; }
public function get($params = NULL) { $tmp_invoices = parent::get($params); //for test purposes // $sql = $this->db->last_query(); // echo '<hr/><br/>'.$sql; if (is_array($tmp_invoices)) { $invoices = array(); foreach ($tmp_invoices as $invoice) { $invoice = $this->set_invoice_additional($invoice, $params); $invoices[] = $invoice; } } else { if (is_object($tmp_invoices)) { $invoices = $this->set_invoice_additional($tmp_invoices, $params); } else { return false; } } return $invoices; }
public function run($params = array()) { //dump($params); $this->db->select("locations.*, c.title as package_category,m.file_name as media_image"); $this->db->join("category as c", "locations.category_id=c.id", 'left'); $this->db->join("medias as m", "locations.image=m.id", 'left'); if (isset($params['category_id'])) { $where = array('locations.category_id' => $params['category_id']); $ARRs = parent::get_by($where); } else { $ARRs = parent::get(); } //isset($params['category_id']) ? $where = array('packages.category_id'=>$params['category_id']) : NULL; $str = ''; //dump($ARRs); foreach ($ARRs as $package) { $str .= '<div class="destination-places-grids">'; $str .= '<div class="destination-places-grid last-d-grid" onclick="location.href=\'/location/' . $package->id . '\';">'; $str .= '<div class="dest-place-pic main_box user_style4" data-hipop="two-horizontal">'; $str .= '<img src="' . base_url('wc-upload/gallery') . '/' . $package->media_image . '" title="' . $package->title . '" width="480" height="180" />'; $str .= '<a href="#" class="popup"> </a>'; $str .= '<a href="#" class="popup2"> </a>'; $str .= '</div>'; $str .= '<div class="dest-place-opt">'; $str .= '<ul class="dest-place-opt-cast">'; $str .= '<li><a class="d-place" href="#">' . $package->package_category . ' : </a></li>'; $str .= '<li><a class="d-place" href="#"> : ' . $package->title . '</a></li>'; $str .= '<div class="clear"></div>'; $str .= '</ul>'; $str .= '</div>'; $str .= '</div>'; } $str .= '<div class="clear"></div>'; $str .= '</div>'; return $str; }