Guest User

Untitled

a guest
Jun 14th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. <?php
  2. class ArticleVersionsController extends AppController {
  3. var $name = 'ArticleVersions';
  4.  
  5. function index() {
  6. $this->ArticleVersion->recursive = 0;
  7. $this->set('articleVersions', $this->paginate());
  8. }
  9.  
  10. function view($id = null) {
  11. if (!$id) {
  12. $this->Session->setFlash(__('Invalid ArticleVersion.', true));
  13. $this->redirect(array('action'=>'index'));
  14. }
  15. $this->set('articleVersion', $this->ArticleVersion->read(null, $id));
  16. }
  17.  
  18. function admin_index() {
  19. $this->ArticleVersion->recursive = 0;
  20. $this->set('articleVersions', $this->paginate());
  21. }
  22.  
  23. function admin_view($id = null) {
  24. if (!$id) {
  25. $this->Session->setFlash(__('Invalid ArticleVersion.', true));
  26. $this->redirect(array('action'=>'index'));
  27. }
  28. $this->set('articleVersion', $this->ArticleVersion->read(null, $id));
  29. }
  30.  
  31. function admin_add() {
  32. if (!empty($this->data)) {
  33. $this->ArticleVersion->create();
  34. debug($Auth);
  35. if ($this->ArticleVersion->save($this->data)) {
  36. $this->Session->setFlash(__('The ArticleVersion has been saved', true));
  37. $this->redirect(array('action'=>'index'));
  38. } else {
  39. $this->Session->setFlash(__('The ArticleVersion could not be saved. Please, try again.', true));
  40. }
  41. }
  42. $articles = $this->ArticleVersion->Article->find('list');
  43. $users = $this->ArticleVersion->User->find('list');
  44. $this->set(compact('articles', 'users'));
  45. }
  46.  
  47. function admin_edit($id = null) {
  48. if (!$id && empty($this->data)) {
  49. $this->Session->setFlash('Invalid ArticleVersion');
  50. $this->redirect(array('action'=>'index'));
  51. }
  52. if (!empty($this->data)) {
  53. $this->data['ArticleVersion']['id'] = null;
  54. $this->ArticleVersion->create();
  55. if ($this->ArticleVersion->save($this->data)) {
  56. $this->Session->setFlash('Successfully Created Article Revision');
  57. $this->redirect(array('controller' => 'articles', 'action'=>'view', $this->data['ArticleVersion']['article_id']));
  58. } else {
  59. $this->Session->setFlash('The Article Version could not be created.');
  60. }
  61. }
  62. if (empty($this->data)) {
  63. $this->data = $this->ArticleVersion->read(null, $id);
  64. }
  65. }
  66.  
  67. function admin_delete($id = null) {
  68. if (!$id) {
  69. $this->Session->setFlash(__('Invalid id for ArticleVersion', true));
  70. $this->redirect(array('action'=>'index'));
  71. }
  72. if ($this->ArticleVersion->del($id)) {
  73. $this->Session->setFlash(__('ArticleVersion deleted', true));
  74. $this->redirect(array('action'=>'index'));
  75. }
  76. }
  77.  
  78. function admin_make_current() {
  79. $this->ArticleVersion->save();
  80. $this->render(false);
  81. $this->Session->setFlash('This Version has been made current.');
  82. $this->redirect(array('controller'=>'articles', 'action'=>'view', $this->params['named']['article_id']));
  83. }
  84.  
  85. function get_current($id = null) {
  86. return $this->ArticleVersion->find('first', array(
  87. 'conditions' => array('article_id' => $id)));
  88. }
  89.  
  90. function get_section_featured($section) {
  91. return $this->ArticleVersion->find('first', array(
  92. 'conditions' => array('section_id' => $section)));
  93. }
  94.  
  95. }
  96. ?>
Add Comment
Please, Sign In to add comment