ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE3/trunk/apps/pc_backend/modules/admin/actions/actions.class.php @ 10463

Last change on this file since 10463 was 10463, checked in by ebihara, 14 years ago

#3244:added ability to change the user's culture of the pc_backend application

File size: 2.9 KB
Line 
1<?php
2
3/**
4 * This file is part of the OpenPNE package.
5 * (c) OpenPNE Project (http://www.openpne.jp/)
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file and the NOTICE file that were distributed with this source code.
9 */
10
11/**
12 * admin actions.
13 *
14 * @package    OpenPNE
15 * @subpackage admin
16 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
17 */
18class adminActions extends sfActions
19{
20 /**
21  * Executes index action
22  *
23  * @param sfRequest $request A request object
24  */
25  public function executeIndex(sfWebRequest $request)
26  {
27    $this->forward('admin', 'manageUser');
28  }
29
30 /**
31  * Executes manageUser action
32  *
33  * @param sfRequest $request A request object
34  */
35  public function executeManageUser(sfWebRequest $request)
36  {
37    $this->users = AdminUserPeer::retrievesAll();
38  }
39
40 /**
41  * Executes adminUser action
42  *
43  * @param sfRequest $request A request object
44  */
45  public function executeAddUser(sfWebRequest $request)
46  {
47    $this->form = new AdminUserForm();
48    if ($request->isMethod(sfWebRequest::POST))
49    {
50      $params = $request->getParameter('admin_user');
51      $this->redirectIf($this->form->bindAndSave($params), 'admin/manageUser');
52    }
53  }
54
55 /**
56  * Executes deleteUser action
57  *
58  * @param sfRequest $request A request object
59  */
60  public function executeDeleteUser(sfWebRequest $request)
61  {
62    $this->user = AdminUserPeer::retrieveByPk($request->getParameter('id'));
63    $this->forward404Unless($this->user);
64    $this->forward404If($this->user->getId() == $this->getUser()->getId());
65    $this->forward404If($this->user->getId() == 1);
66
67    $this->form = new sfForm();
68    if ($request->isMethod(sfWebRequest::POST))
69    {
70      $field = $this->form->getCSRFFieldName();
71      $this->form->bind(array($field => $request->getParameter($field)));
72      if ($this->form->isValid())
73      {
74        $this->user->delete();
75        $this->redirect('admin/manageUser');
76      }
77    }
78  }
79
80 /**
81  * Executes editPassword action
82  *
83  * @param sfRequest $request A request object
84  */
85  public function executeEditPassword(sfWebRequest $request)
86  {
87    $user = AdminUserPeer::retrieveByPk($this->getUser()->getId());
88    $this->form = new AdminUserEditPasswordForm($user);
89    if ($request->isMethod(sfWebRequest::POST))
90    {
91      $params = $request->getParameter('admin_user');
92      $this->redirectIf($this->form->bindAndSave($params), 'admin/manageUser');
93    }
94  }
95
96 /**
97  * Executes changeLanguage action
98  *
99  * @param sfRequest $request A request object
100  */
101  public function executeChangeLanguage(sfWebRequest $request)
102  {
103    $this->form = new opLanguageSelecterForm();
104    if ($request->isMethod(sfWebRequest::POST))
105    {
106      $this->form->bind($request->getParameter('language'));
107      if ($this->form->isValid())
108      {
109        $this->form->setCulture();
110        $this->getUser()->setFlash('notice', 'Changed configuration for your culture.');
111        $this->redirect('admin/changeLanguage');
112      }
113    }
114  }
115}
Note: See TracBrowser for help on using the repository browser.