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

source: OpenPNE3/branches/goto_doctrine/apps/pc_frontend/modules/member/actions/actions.class.php @ 11219

Last change on this file since 11219 was 11219, checked in by ebihara, 13 years ago

#3765:imported new models for Doctrine from some old models for Propel to enable to login

File size: 5.2 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 * member actions.
13 *
14 * @package    OpenPNE
15 * @subpackage member
16 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
17 */
18class memberActions extends sfOpenPNEMemberAction
19{
20 /**
21  * Executes home action
22  *
23  * @param sfRequest $request A request object
24  */
25  public function executeHome($request)
26  {
27    $this->gadgetConfig = sfConfig::get('op_gadget_list');
28    $layout = Doctrine::getTable('SnsConfig')->get('home_layout');
29    if ($layout)
30    {
31      $this->setLayout($layout->getValue());
32    }
33
34    if (!$layout || $layout->getValue() === 'layoutA')
35    {
36      $this->topGadgets = Doctrine::getTable('Gadget')->retrieveTopGadgets();
37    }
38    if (!$layout || $layout->getValue() === 'layoutA' || $layout->getValue() === 'layoutB')
39    {
40      $this->sideMenuGadgets = Doctrine::getTable('Gadget')->retrieveSideMenuGadgets();
41    }
42    $this->contentsGadgets = Doctrine::getTable('Gadget')->retrieveContentsGadgets();
43    $this->bottomGadgets = Doctrine::getTable('Gadget')->retrieveBottomGadgets();
44
45    return parent::executeHome($request);
46  }
47
48 /**
49  * Executes login action
50  *
51  * @param sfRequest $request A request object
52  */
53  public function executeLogin($request)
54  {
55    $this->gadgetConfig = sfConfig::get('op_login_gadget_list');
56    $layout = Doctrine::getTable('SnsConfig')->get('login_layout');
57    if ($layout)
58    {
59      $this->setLayout($layout->getValue());
60    }
61
62    if (!$layout || $layout->getValue() === 'layoutA')
63    {
64      $this->topGadgets = Doctrine::getTable('Gadget')->retrieveLoginTopGadgets();
65    }
66    if (!$layout || $layout->getValue() === 'layoutA' || $layout->getValue() === 'layoutB')
67    {
68      $this->sideMenuGadgets = Doctrine::getTable('Gadget')->retrieveLoginSideMenuGadgets();
69    }
70    $this->contentsGadgets = Doctrine::getTable('Gadget')->retrieveLoginContentsGadgets();
71    $this->bottomGadgets = Doctrine::getTable('Gadget')->retrieveLoginBottomGadgets();
72
73    return parent::executeLogin($request);
74  }
75
76 /**
77  * Executes search action
78  *
79  * @param sfRequest $request A request object
80  */
81  public function executeSearch($request)
82  {
83    $params = $request->getParameter('member', array());
84    if ($request->hasParameter('search_query'))
85    {
86      $params['name']['text'] = $request->getParameter('search_query');
87    }
88
89    $this->filters = new MemberFormFilter();
90    $this->filters->bind($params);
91
92    $this->pager = new sfDoctrinePager('Member', 20);
93    $q = $this->pager->getQuery()->orderBy('id');
94    $this->pager->setQuery($q);
95    $this->pager->setPage($request->getParameter('page', 1));
96    $this->pager->init();
97
98    return sfView::SUCCESS;
99  }
100
101
102 /**
103  * Executes profile action
104  *
105  * @param sfRequest $request A request object
106  */
107  public function executeProfile($request)
108  {
109    $id = $request->getParameter('id', $this->getUser()->getMemberId());
110    if ($id != $this->getUser()->getMemberId())
111    {
112      sfConfig::set('sf_nav_type', 'friend');
113    }
114
115    $result = parent::executeProfile($request);
116    return $result;
117  }
118
119 /**
120  * Executes configImage action
121  *
122  * @param sfRequest $request A request object
123  */
124  public function executeConfigImage($request)
125  {
126    $options = array('member' => $this->getUser()->getMember());
127    $this->form = new MemberImageForm(array(), $options);
128
129    if ($request->isMethod(sfWebRequest::POST))
130    {
131      try
132      {
133        if (!$this->form->bindAndSave($request->getParameter('member_image'), $request->getFiles('member_image')))
134        {
135          $errors = $this->form->getErrorSchema()->getErrors();
136          if (isset($errors['file']))
137          {
138            $error = $errors['file'];
139            $i18n = $this->getContext()->getI18N();
140            $this->getUser()->setFlash('error', $i18n->__($error->getMessageFormat(), $error->getArguments()));
141          }
142        }
143      }
144      catch (opRuntimeException $e)
145      {
146        $this->getUser()->setFlash('error', $e->getMessage());
147      }
148    }
149  }
150
151 /**
152  * Executes registerMobileToRegisterEnd action
153  *
154  * @param sfRequest $request A request object
155  */
156  public function executeRegisterMobileToRegisterEnd(sfWebRequest $request)
157  {
158    $this->form = new registerMobileForm($this->getUser()->getMember());
159    if ($request->isMethod(sfWebRequest::POST))
160    {
161      $this->form->bind($request->getParameter('member_config'));
162      if ($this->form->isValid())
163      {
164        $this->form->save();
165        $this->redirect('member/registerMobileToRegisterEnd');
166      }
167    }
168
169    return sfView::SUCCESS;
170  }
171
172  /**
173   * Executes changeLanguage action
174   *
175   * @param sfWebRequest $request a request object
176   */
177  public function executeChangeLanguage(sfWebRequest $request)
178  {
179    if ($request->isMethod(sfWebRequest::POST))
180    {
181      $form = new opLanguageSelecterForm();
182      $form->bind($request->getParameter('language'));
183      if ($form->isValid())
184      {
185        $form->setCulture();
186        $this->redirect($form->getValue('next_uri'));
187      }
188    }
189    $this->redirect('@homepage');
190  }
191}
Note: See TracBrowser for help on using the repository browser.