Пример #1
0
 private function _add(ORM $page)
 {
     $page_data = $this->request->post('page');
     // Сохраняем полученые данные в сесиию
     Flash::set('page::add::data', $page_data);
     // Создаем новую страницу
     try {
         $page = $page->values($page_data)->create();
         // Если есть права на управление ролями
         if (ACL::check('page.permissions')) {
             $page->save_permissions($this->request->post('page_permissions'));
         }
         Messages::success(__('Page has been saved!'));
         Flash::clear('page::add::data');
     } catch (ORM_Validation_Exception $e) {
         Messages::errors($e->errors('validation'));
         $this->go_back();
     } catch (Kohana_Exception $e) {
         Messages::errors(__('Something went wrong!'));
         $this->go_back();
     }
     // save and quit or save and continue editing ?
     if ($this->request->post('commit') !== NULL) {
         $this->go();
     } else {
         $this->go(array('action' => 'edit', 'id' => $page->id));
     }
 }
Пример #2
0
 private function _edit($job)
 {
     $data = $this->request->post();
     $this->auto_render = FALSE;
     $job->values($data);
     try {
         if ($job->update()) {
             Kohana::$log->add(Log::INFO, 'Job :job has been updated by :user', array(':job' => HTML::anchor(Route::get('backend')->uri(array('controller' => 'scheduler', 'action' => 'edit', 'id' => $job->id)), $job->name)))->write();
             Flash::clear('post_data');
             Messages::success(__('Job has been saved!'));
         }
     } catch (ORM_Validation_Exception $e) {
         Messages::errors($e->errors('validation'));
         $this->go_back();
     }
     // save and quit or save and continue editing?
     if ($this->request->post('commit') !== NULL) {
         $this->go(Route::get('backend')->uri(array('controller' => 'jobs')));
     } else {
         $this->go(Route::get('backend')->uri(array('controller' => 'jobs', 'action' => 'edit', 'id' => $job->id)));
     }
 }
        //CREATE PAGE PART
        $slideshow = '<?php echo new SSP_Slideshow(' . $ssid . ');?>';
        $sql = "INSERT INTO wolfpage_part (name, filter_id, content, content_html, page_id) VALUES ('ssp_slideshow', null, '" . $slideshow . "', '" . $slideshow . "', " . $pageId . ");";
        $query = Record::query($sql);
        if ($query) {
            $status_message = 'Successfully created Slideshow';
            $status_type = 'success';
            Flash::set('page', $pageId);
        } else {
            $status_message = 'Could not create Slideshow';
            $status_type = 'errors';
        }
        break;
    case 'delete':
        $sql = "DELETE FROM wolf_ssp WHERE page_id=" . $pageId . "; DELETE FROM wolf_page_part WHERE name='ssp_slideshow' AND page_id=" . $pageId . ";";
        $query = Record::query($sql);
        if ($query) {
            $status_message = 'Successfully deleted Slideshow';
            $status_type = 'success';
            Flash::clear();
        } else {
            $status_message = 'Could not delete Slideshow';
            $status_type = 'errors';
        }
        break;
    default:
        break;
}
//COMPLETE. REDIRECT
Flash::set($status_type, $status_message);
header('Location:' . URL_PUBLIC . 'admin/plugin/ssp/manage');