public function edit($id = 0) { $id or redirect('admin/portfolio'); $project = $this->portfolio_m->get($id); $this->form_validation->set_rules($this->validation_rules); $created_on = $project->when_added; $updated_on = now(); if ($this->form_validation->run()) { if ($project->status != 'live' and $this->input->post('status') == 'live') { role_or_die('portfolio', 'put_live'); } $result = $this->portfolio_m->update($id, array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'category' => $this->input->post('category'), 'services' => $this->input->post('services'), 'thumb' => $this->input->post('thumb'), 'refurl' => $this->input->post('refurl'), 'overview1' => $this->input->post('overview1'), 'overview2' => $this->input->post('overview2'), 'screenshots' => $this->input->post('screenshots'), 'delivered_month' => $this->input->post('delivered_month'), 'delivered_year' => $this->input->post('delivered_year'), 'status' => $this->input->post('status'), 'when_added' => $created_on, 'last_updated' => $updated_on, 'added_by' => $this->current_user->id)); if ($result) { $this->session->set_flashdata('success', $this->lang->line('portfolio.edit_success')); } else { $this->session->set_flashdata('error', $this->lang->line('portfolio.edit_error')); } $this->input->post('btnAction') == 'save_exit' ? redirect('admin/portfolio') : redirect('admin/portfolio/edit/' . $id); } foreach ($this->validation_rules as $key => $field) { if (isset($_POST[$field['field']])) { $project->{$field}['field'] = set_value($field['field']); } } $this->template->title($this->module_details['name'])->append_js('module::portfolio.js')->set('project', $project)->build('admin/form'); }
public function __construct() { parent::__construct(); $this->load->driver('streams'); // If they cannot administer profile fields, // then they can't access anythere here. role_or_die('users', 'admin_profile_fields'); }
public function __construct() { parent::__construct(); // If they cannot administer profile fields, // then they can't access anythere here. role_or_die('users', 'admin_movieslider_fields'); $this->load->driver('streams'); $this->lang->load(array('movieslider', 'categories')); }
function __construct() { parent::__construct(); // If you are going to admin fields you gotta // pass the test! role_or_die('streams', 'admin_fields'); $this->load->config('streams/streams'); $this->lang->load('streams/pyrostreams'); $this->load->helper('streams/streams'); streams_constants(); admin_resources(); $this->data->types = $this->type->types; // Gather stream data. // Each one of our functions requires we are within a stream. $this->data->stream_id = $this->uri->segment(5); if (!($this->data->stream = $this->streams_m->get_stream($this->data->stream_id))) { show_error(lang('streams.invalid_stream_id')); } }
/** * Delete a field * * @access public * @return void */ public function delete() { role_or_die('streams', 'admin_fields'); $field_id = $this->uri->segment(5); if (!$this->fields_m->delete_field($field_id)) { $this->session->set_flashdata('notice', lang('streams.field_delete_error')); } else { $this->session->set_flashdata('success', lang('streams.field_delete_success')); } redirect('admin/streams/fields'); }
/** * Delete a page type * * @param int $id The id of the page type to delete. */ public function delete($id = 0) { role_or_die('pages', 'delete_types'); empty($id) and redirect('admin/pages/types'); $page_type = $this->page_type_m->get($id); // if the page type doesn't exist or if they somehow bypassed // our front-end checks and are deleting 'default' directly if (!$page_type or $page_type->slug === 'default') { show_error('Invalid ID'); } // Will we be neededing to delete a stream as well? // We will only be deleting a stream if: // - It is in the pages namespace // - It is not being used by any other page types // Even then, we will have warned them. $delete_stream = false; $this->load->driver('Streams'); $stream = $this->streams_m->get_stream($page_type->stream_id); if ($stream->stream_namespace == 'pages') { // Are any other page types using this? if ($this->page_type_m->count_by('stream_id', $page_type->stream_id) <= 1) { $delete_stream = true; } } if ($this->input->post('do_delete') == 'y') { // Delete page $this->page_type_m->delete($id, $delete_stream); // Guess what, we have to delete ALL the pages using this // page type. This is necessary since the data for that page // type in streams and elsewhere is essentially useless. $pages = $this->db->where('type_id', $id)->get('pages')->result(); foreach ($pages as $page) { $this->page_m->delete($page->id); } // Wipe cache for this model, the content has changd $this->pyrocache->delete_all('page_type_m'); $this->session->set_flashdata('success', sprintf(lang('page_types:delete_success'), $id)); Events::trigger('page_type_deleted', $id); redirect('admin/pages/types'); } // Count number of pages that will be deleted. $this->template->set('num_of_pages', $this->page_m->count_by('type_id', $page_type->id)); $this->template->title($this->module_details['name'])->set('delete_stream', $delete_stream)->set('stream_name', $stream->stream_name)->build('admin/types/delete_form'); }
/** * Delete a page. * * @param int $id The id of the page to delete. */ public function delete($id = 0) { $this->load->model('comments/comments_m'); // The user needs to be able to delete pages. role_or_die('pages', 'delete_live'); // @todo Error of no selection not handled yet. $ids = $id ? array($id) : $this->input->post('action_to'); // Go through the array of slugs to delete if (!empty($ids)) { foreach ($ids as $id) { if ($id !== 1) { $deleted_ids = $this->page_m->delete($id); $this->comments_m->where('module', 'pages')->delete_by('module_id', $id); // Wipe cache for this model, the content has changd $this->pyrocache->delete_all('page_m'); $this->pyrocache->delete_all('navigation_m'); } else { $this->session->set_flashdata('error', lang('pages_delete_home_error')); } } // Some pages have been deleted if (!empty($deleted_ids)) { Events::trigger('page_deleted', $deleted_ids); // Only deleting one page if (count($deleted_ids) == 1) { $this->session->set_flashdata('success', sprintf(lang('pages_delete_success'), $deleted_ids[0])); } else { $this->session->set_flashdata('success', sprintf(lang('pages_mass_delete_success'), count($deleted_ids))); } } else { $this->session->set_flashdata('notice', lang('pages_delete_none_notice')); } } redirect('admin/pages'); }
/** * Delete blog post * @access public * @param int $id the ID of the blog post to delete * @return void */ public function delete($id = 0) { $this->load->model('comments/comments_m'); role_or_die('blog', 'delete_live'); // Delete one $ids = $id ? array($id) : $this->input->post('action_to'); // Go through the array of slugs to delete if (!empty($ids)) { $post_titles = array(); $deleted_ids = array(); foreach ($ids as $id) { // Get the current page so we can grab the id too if ($post = $this->blog_m->get($id)) { if ($this->blog_m->delete($id)) { $this->comments_m->where('module', 'blog')->delete_by('module_id', $id); // Wipe cache for this model, the content has changed $this->pyrocache->delete('blog_m'); $post_titles[] = $post->title; $deleted_ids[] = $id; } } } // Fire an event. We've deleted one or more blog posts. Events::trigger('blog_article_deleted', $deleted_ids); } // Some pages have been deleted if (!empty($post_titles)) { // Only deleting one page if (count($post_titles) == 1) { $this->session->set_flashdata('success', sprintf($this->lang->line('blog_delete_success'), $post_titles[0])); } else { $this->session->set_flashdata('success', sprintf($this->lang->line('blog_mass_delete_success'), implode('", "', $post_titles))); } } else { $this->session->set_flashdata('notice', lang('blog_delete_error')); } redirect('admin/blog'); }
/** * Publish blog post * @access public * @param int $id the ID of the blog post to make public * @return void */ public function publish($id = 0) { role_or_die('blog', 'put_live'); // Publish one $ids = $id ? array($id) : $this->input->post('action_to'); if (!empty($ids)) { // Go through the array of slugs to publish $post_titles = array(); foreach ($ids as $id) { // Get the current page so we can grab the id too if ($post = $this->blog_m->get($id)) { $this->blog_m->publish($id); // Wipe cache for this model, the content has changed $this->pyrocache->delete('blog_m'); $post_titles[] = $post->title; } } } // Some posts have been published if (!empty($post_titles)) { // Only publishing one post if (count($post_titles) == 1) { $this->session->set_flashdata('success', sprintf($this->lang->line('blog_publish_success'), $post_titles[0])); } else { $this->session->set_flashdata('success', sprintf($this->lang->line('blog_mass_publish_success'), implode('", "', $post_titles))); } } else { $this->session->set_flashdata('notice', $this->lang->line('blog_publish_error')); } redirect('admin/blog'); }
/** * Helper method to determine what to do with selected items from form post * @access public * @return void */ public function action() { switch ($this->input->post('btnAction')) { case 'delete': role_or_die('calendar', 'delete_live', 'admin/calendar/list_calendar', 'Sorry. You are not allowed to delete event.'); $this->delete(); break; default: redirect('admin/calendar/list_calendar'); break; } }
/** * Delete movieslider post * * @param int $id The ID of the movieslider post to delete */ public function delete($id = 0, $image = '') { $this->load->model('comments/comment_m'); $this->load->library('files/files'); role_or_die('movieslider', 'delete_live'); // Delete one $ids = $id ? array($id) : $this->input->post('action_to'); $id_file = $image ? array($id => $image) : $this->input->post('id_file'); // Go through the array of slugs to delete if (!empty($ids)) { $post_titles = array(); $deleted_ids = array(); foreach ($ids as $id) { // Get the current page so we can grab the id too if ($post = $this->movieslider_m->get($id)) { if ($this->movieslider_m->delete($id)) { $this->comment_m->where('module', 'movieslider')->delete_by('entry_id', $id); $this->files->delete_file($id_file[$id]); // Wipe cache for this model, the content has changed $this->pyrocache->delete('movieslider_m'); $post_titles[] = $post->title; $deleted_ids[] = $id; } } } // Fire an event. We've deleted one or more movieslider posts. Events::trigger('post_deleted', array_merge($deleted_ids, array('table' => 'movieslider'))); } // Some pages have been deleted if (!empty($post_titles)) { // Only deleting one page if (count($post_titles) == 1) { $this->session->set_flashdata('success', sprintf($this->lang->line('movieslider:delete_success'), $post_titles[0])); } else { $this->session->set_flashdata('success', sprintf($this->lang->line('movieslider:mass_delete_success'), implode('", "', $post_titles))); } } else { $this->session->set_flashdata('notice', lang('movieslider:delete_error')); } redirect('admin/movieslider'); }
public function edit($id) { // Does the user have access? role_or_die('firesale', 'edit_orders'); // Get row if ($row = $this->row_m->get_row($id, $this->stream, FALSE)) { // Load form $this->create($id, $row); } else { $this->session->set_flashdata('error', lang('firesale:order_not_found')); redirect('admin/firesale/orders/create'); } }
public function edit($slug) { // Does the user have access? role_or_die('firesale', 'edit_gateways'); $query = $this->db->get_where('firesale_gateways', array('slug' => $slug)); if ($query->num_rows()) { $values['name'] = $query->row()->name; $values['desc'] = $query->row()->desc; $fields = $this->gateways->get_setting_fields($slug); $rules = array(array('field' => 'name', 'label' => lang('firesale:gateways:labels:name'), 'rules' => 'trim|htmlspecialchars|required|max_length[100]', 'type' => 'string'), array('field' => 'desc', 'label' => lang('firesale:gateways:labels:desc'), 'rules' => 'trim|xss_clean|required', 'type' => 'text')); if (is_array($fields)) { foreach ($fields as $field) { $values[$field['slug']] = $this->gateways->setting($slug, $field['slug']); $field_data['field'] = $field['slug']; $field_data['label'] = $field['name']; if ($field['type'] == 'boolean') { $field_data['rules'] = 'required|callback__valid_bool'; $field_data['type'] = 'boolean'; } else { $field_data['rules'] = 'required|xss_clean|trim'; $field_data['type'] = 'string'; } $rules[] = $field_data; $additional_fields[] = $field_data; } $this->form_validation->set_rules($rules); if ($this->form_validation->run()) { $data = array('name' => set_value('name'), 'desc' => set_value('desc')); $gateway_id = $this->db->get_where('firesale_gateways', array('slug' => $slug))->row()->id; $this->db->trans_begin(); $this->db->update('firesale_gateways', $data, array('id' => $gateway_id)); foreach ($additional_fields as $field) { if ($this->db->get_where('firesale_gateway_settings', array('id' => $gateway_id, 'key' => $field['field']))->num_rows()) { $this->db->update('firesale_gateway_settings', array('value' => set_value($field['field'])), array('id' => $gateway_id, 'key' => $field['field'])); } else { $this->db->insert('firesale_gateway_settings', array('id' => $gateway_id, 'key' => $field['field'], 'value' => set_value($field['field']))); } } if ($this->db->trans_status() !== FALSE) { $this->db->trans_commit(); $this->session->set_flashdata('success', lang('firesale:gateways:updated_success')); redirect('admin/firesale/gateways'); } else { $this->db->trans_rollback(); $this->session->set_flashdata('error', lang('firesale:gateways:updated_fail')); redirect('admin/firesale/gateways'); } } else { $this->template->build('admin/gateways/edit', array('fields' => $rules, 'values' => $values)); } } else { show_404(); } } }
/** * Streams Backup * * Backs up and downloads a GZip file of the stream table */ public function backup() { role_or_die('streams', 'admin_streams'); $this->_gather_stream_data(); $this->load->dbutil(); $tables = array(PYROSTREAMS_DB_PRE . STR_PRE . $this->data->stream->stream_slug); $filename = $this->data->stream->stream_slug . '_backup_' . date('Y-m-d'); $backup_prefs = array('tables' => $tables, 'format' => 'zip', 'filename' => $filename . '.sql', 'add_drop' => TRUE, 'add_insert' => TRUE, 'newline' => "\n"); $backup =& $this->dbutil->backup($backup_prefs); $this->load->helper('download'); force_download($filename . '.zip', $backup); }
/** * Delete an existing page * @access public * @param int $id The ID of the page to delete * @return void */ public function delete($id = 0) { role_or_die('pages', 'delete_live'); // Attention! Error of no selection not handeled yet. $ids = ($id) ? array($id) : $this->input->post('action_to'); // Go through the array of slugs to delete foreach ($ids as $id) { if ($id !== 1) { $deleted_ids = $this->pages_m->delete($id); // Wipe cache for this model, the content has changd $this->pyrocache->delete_all('pages_m'); $this->pyrocache->delete_all('navigation_m'); } else { $this->session->set_flashdata('error', lang('pages_delete_home_error')); } } // Some pages have been deleted if ( ! empty($deleted_ids)) { // Only deleting one page if ( count($deleted_ids) == 1 ) { $this->session->set_flashdata('success', sprintf(lang('pages_delete_success'), $deleted_ids[0])); } else // Deleting multiple pages { $this->session->set_flashdata('success', sprintf(lang('pages_mass_delete_success'), count($deleted_ids))); } } else // For some reason, none of them were deleted { $this->session->set_flashdata('notice', lang('pages_delete_none_notice')); } redirect('admin/pages'); }
/** * Delete a snippet * */ function delete_snippet($snippet_id = 0) { // If you can't admin snippets, you can't delete them role_or_die('snippets', 'admin_snippets'); if (!$this->snippets_m->delete_snippet($snippet_id)) { $this->session->set_flashdata('notice', lang('snippets.delete_snippet_error')); } else { $this->session->set_flashdata('success', lang('snippets.delete_snippet_success')); } redirect('admin/snippets'); }