PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/app/controllers/groups_controller.php

https://github.com/ata/steak
PHP | 73 lines | 65 code | 8 blank | 0 comment | 11 complexity | ba89212180f18dc42637c71939717e68 MD5 | raw file
  1. <?php
  2. class GroupsController extends AppController {
  3. var $name = 'Groups';
  4. var $helpers = array('Html', 'Form');
  5. var $uses = array();
  6. var $components = array('Jsax');
  7. function beforeFilter() {
  8. parent::beforeFilter();
  9. $this->loadModel('Group');
  10. }
  11. function index() {
  12. $this->Group->recursive = 0;
  13. $this->set('groups', $this->paginate());
  14. }
  15. function view($id = null) {
  16. if (!$id) {
  17. $this->Session->setFlash(__('Invalid Group.', true));
  18. $this->redirect(array('action'=>'index'));
  19. }
  20. $this->set('group', $this->Group->read(null, $id));
  21. }
  22. function add() {
  23. if (!empty($this->data)) {
  24. $this->Group->create();
  25. if ($this->Group->save($this->data)) {
  26. $this->Session->setFlash(__('The Group has been saved', true));
  27. $this->redirect(array('action'=>'index'));
  28. } else {
  29. $this->Session->setFlash(__('The Group could not be saved. Please, try again.', true));
  30. }
  31. }
  32. $links = $this->Group->Link->find('list');
  33. $this->set(compact('links'));
  34. }
  35. function edit($id = null) {
  36. if (!$id && empty($this->data)) {
  37. $this->Session->setFlash(__('Invalid Group', true));
  38. $this->redirect(array('action'=>'index'));
  39. }
  40. if (!empty($this->data)) {
  41. if ($this->Group->save($this->data)) {
  42. $this->Session->setFlash(__('The Group has been saved', true));
  43. $this->redirect(array('action'=>'index'));
  44. } else {
  45. $this->Session->setFlash(__('The Group could not be saved. Please, try again.', true));
  46. }
  47. }
  48. if (empty($this->data)) {
  49. $this->data = $this->Group->read(null, $id);
  50. }
  51. $links = $this->Group->Link->find('list');
  52. $this->set(compact('links'));
  53. }
  54. function delete($id = null) {
  55. if(!empty($this->data)){
  56. $this->Jsax->delete($this->data['Group']['id'], $this->Group);
  57. }else{
  58. $this->Jsax->confirmDelete($id, $this->Group);
  59. }
  60. }
  61. function deleteBulk () {
  62. $this->Jsax->deleteAll($this->Group, array("Group.id"=>$this->data['ids']));
  63. }
  64. }
  65. ?>