Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function update() {
- $rules = array(
- array('field' => 'title', 'label' => 'Page Title', 'rules' => 'trim|required|xss_clean|callback_update_title_check'),
- );
- $this->form_validation->set_rules($rules);
- if ($this->form_validation->run()) {
- if (isAdmin()) {
- $allEditors = array();
- foreach ($this->data['allEditors'] as $editor) {
- $allEditors[] = $editor->id;
- }
- $editorsPosted = $this->input->post('editors');
- if (sizeof($editorsPosted) > 0) {
- $editorsNotPosted = array_diff($allEditors, $editorsPosted);
- if (sizeof($editorsNotPosted) > 0) {
- foreach ($editorsNotPosted as $editorNotPosted) {
- $this->xref_model->delete_by(array('user' => $editorNotPosted, 'page' => $this->input->post('pageid')));
- }
- }
- if (sizeof($editorsPosted) > 0) {
- foreach ($editorsPosted as $editorPosted) {
- $this->xref_model->insert(array('user' => $editorPosted, 'page' => $this->input->post('pageid')));
- }
- }
- }
- else {
- foreach ($editorsNotPosted as $editorNotPosted) {
- $this->xref_model->delete_by(array('page' => $this->input->post('pageid')));
- }
- }
- }
- $updatedPage = array('title' => $this->input->post('title'), 'slug' => url_title(strtolower($this->input->post('title')), 'underscore'), 'content' => $this->input->post('content'), 'lastupdate' => date('Y-m-d H:i:s'), 'lastupdateby' => $this->session->userdata('id'));
- if (isAdmin()) {
- if ($this->input->post('index')) {
- foreach ($this->page_model->get_many_by(array('idx' => '1')) as $indexPage) {
- $this->page_model->update_by('id', $indexPage->id, array('idx' => 0));
- }
- $updatedPage['idx'] = 1;
- }
- }
- if (($this->input->post('published')) | ($this->page_model->get($this->input->post('pageid'))->idx == '1') | ($this->input->post('index'))) {
- $updatedPage['published'] = 1;
- }
- else {
- $updatedPage['published'] = 0;
- }
- $this->page_model->update_by('id', $this->input->post('pageid'), $updatedPage);
- $this->session->set_flashdata('information', '<p class="green">Your Changes To ' . $this->input->post('title') . ' were saved</p>');
- redirect(site_url('admin/pages'));
- }
- else {
- $this->data['editPage'] = $this->page_model->get($this->input->post('pageid'));
- $this->template->set_breadcrumb('Edit Page: ' . $this->data['editPage']->title, site_url('admin/pages/edit/' . $this->data['editPage']->id));
- $this->message->set('error', explode("\n", trim(strip_tags(validation_errors()))));
- $this->template->write_view('content', 'desktop/views/' . $this->data['viewbase'] . '/pages/edit', $this->data);
- $this->template->render();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement