Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ArticleVersionsController extends AppController {
- var $name = 'ArticleVersions';
- function index() {
- $this->ArticleVersion->recursive = 0;
- $this->set('articleVersions', $this->paginate());
- }
- function view($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid ArticleVersion.', true));
- $this->redirect(array('action'=>'index'));
- }
- $this->set('articleVersion', $this->ArticleVersion->read(null, $id));
- }
- function admin_index() {
- $this->ArticleVersion->recursive = 0;
- $this->set('articleVersions', $this->paginate());
- }
- function admin_view($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid ArticleVersion.', true));
- $this->redirect(array('action'=>'index'));
- }
- $this->set('articleVersion', $this->ArticleVersion->read(null, $id));
- }
- function admin_add() {
- if (!empty($this->data)) {
- $this->ArticleVersion->create();
- debug($Auth);
- if ($this->ArticleVersion->save($this->data)) {
- $this->Session->setFlash(__('The ArticleVersion has been saved', true));
- $this->redirect(array('action'=>'index'));
- } else {
- $this->Session->setFlash(__('The ArticleVersion could not be saved. Please, try again.', true));
- }
- }
- $articles = $this->ArticleVersion->Article->find('list');
- $users = $this->ArticleVersion->User->find('list');
- $this->set(compact('articles', 'users'));
- }
- function admin_edit($id = null) {
- if (!$id && empty($this->data)) {
- $this->Session->setFlash('Invalid ArticleVersion');
- $this->redirect(array('action'=>'index'));
- }
- if (!empty($this->data)) {
- $this->data['ArticleVersion']['id'] = null;
- $this->ArticleVersion->create();
- if ($this->ArticleVersion->save($this->data)) {
- $this->Session->setFlash('Successfully Created Article Revision');
- $this->redirect(array('controller' => 'articles', 'action'=>'view', $this->data['ArticleVersion']['article_id']));
- } else {
- $this->Session->setFlash('The Article Version could not be created.');
- }
- }
- if (empty($this->data)) {
- $this->data = $this->ArticleVersion->read(null, $id);
- }
- }
- function admin_delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for ArticleVersion', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->ArticleVersion->del($id)) {
- $this->Session->setFlash(__('ArticleVersion deleted', true));
- $this->redirect(array('action'=>'index'));
- }
- }
- function admin_make_current() {
- $this->ArticleVersion->save();
- $this->render(false);
- $this->Session->setFlash('This Version has been made current.');
- $this->redirect(array('controller'=>'articles', 'action'=>'view', $this->params['named']['article_id']));
- }
- function get_current($id = null) {
- return $this->ArticleVersion->find('first', array(
- 'conditions' => array('article_id' => $id)));
- }
- function get_section_featured($section) {
- return $this->ArticleVersion->find('first', array(
- 'conditions' => array('section_id' => $section)));
- }
- }
- ?>
Add Comment
Please, Sign In to add comment