public function getEmptyItem() { $item = parent::getEmptyItem(); $item['type'] = $this->table; $item['options'] = array('display_profiler' => 0); return $item; }
public function update($fields) { $update_item = parent::update($fields); // Everytime you update a value, let's publish it. CI()->load->model('publish_queue_model'); CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item); return $update_item; }
public function update($fields) { $fields['group_key'] = strtolower(preg_replace("/[^a-z\\-_\\d]/i", "", underscore($fields['group_title']))); $update_item = parent::update($fields); // Everytime you update a group, let's publish it. CI()->load->model('publish_queue_model'); CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item); return $update_item; }
public function update($fields) { if (!empty($fields['value']) && is_array($fields['value'])) { $fields['value'] = json_encode($fields['value']); } $update_fields = parent::update($fields); if ($this->ADMIN_CONF['publish']['publish_method'] != 'local_table') { // Queue template for publish CI()->load->model('publish_queue_model'); CI()->publish_queue_model->publish($this->table, $update_fields[$this->id_field], $update_fields); } return $update_fields; }
public function get($fields = null, $relations = false) { $result = parent::get($fields, $relations); $result_updated = array(); // Make module specific updates to result array foreach ($result as $row) { // options: Create array from JSON string if (!empty($row['template_options'])) { $row['template_options'] = json_decode($row['template_options'], TRUE); } $result_updated[] = $row; } return $result_updated; }
public function get($fields = array()) { $item = parent::get($fields); $item_updated = array(); if (count($item)) { // Make model specific updates to result array for ($i = 0; $i < count($item); $i++) { $row = $item[$i]; if (!empty($row['options']['multi']) && $row['options']['multi'] == 'yes') { // Make sure its a json string if (substr($row['value'], 0, 1) == '[' && substr($row['value'], -1) == ']') { $row['value'] = json_decode($row['value'], true); } } $item_updated[] = $row; } } return $item_updated; }
public function update($fields = array()) { $exists = $this->db->select($this->id_field)->where($this->id_field, $fields[$this->id_field])->get($this->table)->row_array(); if (count($exists)) { parent::update($fields); } else { // This is an almost mirror of parent::insert, but we don't strip id_field // Transform array fields into json if (count($this->json_fields)) { foreach ($this->json_fields as $_field) { if (isset($fields[$_field])) { $fields[$_field] = json_encode($fields[$_field]); } } } // Get fields, this needs to happen after any field transformations $this->_getMatchingFields($fields); // Create query & run $this->_addQueryValues(); $this->_addQueryDateValue('update'); $this->_addQueryDateValue('insert'); $this->db->insert($this->table); } }
public function get($fields, $select_set = FALSE) { if (!empty($fields['params']) && is_array($fields['params'])) { $fields['params'] = $this->_formatParams($fields['params']); } $this->db->where('expire_date > ', 'NOW()', FALSE); return parent::get($fields, $select_set); }
public function update($fields = array()) { $row = parent::update($fields); if (empty($row['ext'])) { $sub = $this->getById($row[$this->id_field]); $row = $sub[0]; } $var_length = (int) $this->FILE_CONF['file_dir_depth'] * 3; $path_array = str_split(str_pad($row[$this->id_field], $var_length, '0', STR_PAD_LEFT), 3); $upload_path = implode('/', $path_array); // Add file paths $row['server_path'] = DOCROOT . zonepath($this->FILE_CONF['file_directory'], 'local') . '/' . $upload_path . $row['ext']; $row['app_path'] = $upload_path . $row['ext']; // Queue file for publish //CI()->load->model('publish_queue_model'); //CI()->publish_queue_model->publish($this->table, $row[$this->id_field], $row); return $row; }
public function getEmptyItem() { $item = parent::getEmptyItem(); $item['page_id'] = $this->current_id; $item['start_time'] = array('hour' => '', 'min' => '', 'ampm' => ''); $item['end_time'] = array('hour' => '', 'min' => '', 'ampm' => ''); $item['ignore_end'] = 1; return $item; }
public function deleteQueue($id) { return parent::delete($id); }
public function delete($id) { // Queue template for publish CI()->load->model('publish_queue_model'); CI()->publish_queue_model->delete($this->table, $id); return parent::delete($id); }
public function delete($id) { // We do not actually delete items in this model. Just change their status to deleted. if (!($id > 1)) { show_error(__METHOD__ . ' Invalid id: ' . $id); } $fields = array(); $fields[$this->id_field] = $id; $fields['status'] = 99; parent::update($fields); if ($this->ADMIN_CONF['publish']['publish_method'] == 'local_table') { // Delete from local table CI()->load->model('page_published_model'); CI()->page_published_model->delete($id); } else { // Queue page for delete on remote CI()->load->model('publish_queue_model'); CI()->publish_queue_model->delete($this->table, $id, $fields); } log_message('debug', 'Deleted ' . $this->id_field . ' #' . $id); $children = $this->selectSet('basic')->get(array('parent_id' => $id)); if (count($children)) { foreach ($children as $child) { $this->delete($child[$this->id_field]); } } return true; }
public function delete($one, $two = NULL) { $id = $one; if (!($id > 1)) { show_error(__METHOD__ . ' Invalid id: ' . $id); } $item = CI()->file_model->first()->getById($id); if (parent::delete($id)) { if (!empty($item[$this->id_field])) { // Queue file for delete CI()->load->model('publish_queue_model'); CI()->publish_queue_model->delete($this->table, $id); $children = $this->get(array('parent_id' => $id)); if (count($children)) { foreach ($children as $child) { $this->delete($child[$this->id_field]); } } // Only perform the following if this is a file if ($item['type'] == 'file' && !empty($item['base_path'])) { // TODO: Should we add checks to make sure base_path starts with doc_root? // TODO: Should we check to make sure id_field is valid? $rm_result = shell_exec('rm -fv ' . $item['base_path'] . '*' . $item['ext']); log_message('debug', 'Deleting file ' . $item[$this->id_field] . ' (' . $rm_result . ')'); } } } return true; }
public function get($fields, $select_set = false) { // Selecting more then one item if (!empty($fields[$this->id_field]) && is_array($fields[$this->id_field])) { $fields[$this->id_field] = array_unique(array_map("trim", $fields[$this->id_field])); } else { if (!empty($fields[$this->id_field]) && strpos($fields[$this->id_field], ',')) { $fields[$this->id_field] = explode(',', $fields[$this->id_field]); $fields[$this->id_field] = array_unique(array_map("trim", $fields[$this->id_field])); } } if (!empty($fields['template_id']) && strpos($fields['template_id'], ',')) { // Selecting more then one item $fields['template_id'] = explode(',', $fields['template_id']); $fields['template_id'] = array_unique(array_map("trim", $fields['template_id'])); } if (in_array('status', $this->db_fields)) { // Do not get deleted items $this->param('WHERE', array($this->table . '.status <', 90)); } return parent::get($fields, $select_set); }
public function get($fields = null, $select_set = false) { // Always set the select_set so we can specify which fields from auto_join'd table to fetch $this->selectSet('basic'); return parent::get($fields, $select_set); }