|
Revision 19938, 1.7 kB
(checked in by gen, 5 years ago)
|
|
テンプレートtwitterからパクってきた
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | class UserController extends ApplicationController |
|---|
| 4 | { |
|---|
| 5 | function home() |
|---|
| 6 | { |
|---|
| 7 | } |
|---|
| 8 | |
|---|
| 9 | function index() |
|---|
| 10 | { |
|---|
| 11 | $this->redirectToAction('listing'); |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | function listing() |
|---|
| 15 | { |
|---|
| 16 | $this->user_pages = $this->pagination_helper->getPaginator($this->User, array('items_per_page' => 10)); |
|---|
| 17 | $options = $this->pagination_helper->getFindOptions($this->User); |
|---|
| 18 | $this->users =& $this->User->find('all', $options); |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | function show() |
|---|
| 22 | { |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | function add() |
|---|
| 26 | { |
|---|
| 27 | if(!empty($this->params['user'])){ |
|---|
| 28 | $this->User->setAttributes($this->params['user']); |
|---|
| 29 | if ($this->Request->isPost() && $this->User->save()){ |
|---|
| 30 | $this->flash['notice'] = $this->t('User was successfully created.'); |
|---|
| 31 | $this->redirectTo(array('action' => 'show', 'id' => $this->User->getId())); |
|---|
| 32 | } |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | function edit() |
|---|
| 37 | { |
|---|
| 38 | if (empty($this->params['id'])){ |
|---|
| 39 | $this->redirectToAction('listing'); |
|---|
| 40 | } |
|---|
| 41 | if(!empty($this->params['user']) && !empty($this->params['id'])){ |
|---|
| 42 | $this->user->setAttributes($this->params['user']); |
|---|
| 43 | if($this->Request->isPost() && $this->user->save()){ |
|---|
| 44 | $this->flash['notice'] = $this->t('User was successfully updated.'); |
|---|
| 45 | $this->redirectTo(array('action' => 'show', 'id' => $this->user->getId())); |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | function destroy() |
|---|
| 51 | { |
|---|
| 52 | if(!empty($this->params['id'])){ |
|---|
| 53 | $this->user =& $this->User->find($this->params['id']); |
|---|
| 54 | if($this->Request->isPost()){ |
|---|
| 55 | $this->user->destroy(); |
|---|
| 56 | $this->redirectTo(array('action' => 'listing')); |
|---|
| 57 | } |
|---|
| 58 | } |
|---|
| 59 | } |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | ?> |
|---|