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

source: OpenPNE3/plugins/opOpenSocialPlugin/trunk/apps/pc_frontend/modules/application/actions/actions.class.php @ 9239

Last change on this file since 9239 was 9239, checked in by ShogoKawahara, 12 years ago

#3119:webのルートでなくても動作できるように変更

File size: 2.9 KB
Line 
1<?php
2
3/**
4 * application actions.
5 *
6 * @package    OpenPNE
7 * @subpackage saOpenSocialPlugin
8 * @author     Shogo Kawahara <kawahara@tejimaya.net>
9 */
10class applicationActions extends sfActions
11{
12 /**
13  * Executes canvas action
14  *
15  * @param sfRequest $request A request object
16  */
17  public function executeCanvas($request)
18  {
19    if (!$request->hasParameter('mid'))
20    {
21      return sfView::ERROR;
22    }
23    $this->member_app = MemberApplicationPeer::retrieveByPK($request->getParameter('mid'));
24    if (empty($this->member_app))
25    {
26      return sfView::ERROR; 
27    }
28    if($this->getUser()->getMemberId() != $this->member_app->getMemberId())
29    {
30      $request->setParameter('id', $this->member_app->getMemberId());
31      sfConfig::set('sf_navi_type', 'friend');
32    }
33    return sfView::SUCCESS;
34  }
35  /**
36   * Executes list action
37   *
38   * @param sfRequest $request A request object
39   */
40  public function executeList($request)
41  {
42    $memberId = $this->getUser()->getMemberId();
43    $ownerId  = $request->hasParameter('id') ? $request->getParameter('id') : $memberId;
44
45    if ($memberId == $ownerId)
46    {
47      $this->form = new AddApplicationForm();
48    }
49    else
50    {
51      sfConfig::set('sf_navi_type', 'friend');
52    }
53
54    $criteria = new Criteria();
55    $criteria->add(MemberApplicationPeer::MEMBER_ID, $ownerId);
56    $this->pager = new sfPropelPager('MemberApplication',20);
57    $this->pager->setCriteria($criteria);
58    $this->pager->setPage($request->getParameter('page', 1));
59    $this->pager->init();
60
61    if (!$request->isMethod('post'))
62    {
63      return $this->pager->getNbResults() ? sfView::SUCCESS : sfView::ERROR;
64    }
65
66    $contact = $request->getParameter('contact');
67    $this->form->bind($contact);
68    if (!$this->form->isValid())
69    {
70      return $this->pager->getNbResults() ? sfView::SUCCESS : sfView::ERROR;
71    }
72    $contact = $this->form->getValues();
73    try
74    {
75      $app = ApplicationPeer::addApplication($contact['application_url'],$this->getUser()->getCulture());
76    }
77    catch (Exception $e)
78    {
79      //TODO : add error action
80      return $this->pager->getNbResults() ? sfView::SUCCESS : sfView::ERROR;
81    }
82    $criteria = new Criteria();
83    $criteria->add(MemberApplicationPeer::MEMBER_ID,$memberId);
84    $criteria->add(MemberApplicationPeer::APPLICATION_ID,$app->getId());
85    $member_app = MemberApplicationPeer::doSelectOne($criteria);
86    if (!empty($member_app))
87    {
88      //TODO : redirect application page
89      return sfView::SUCCESS;
90    }
91    $member_app = new MemberApplication();
92    $member_app->setMemberId($memberId);
93    $member_app->setApplicationId($app->getId());
94    $member_app->save();
95    //TODO : redirect application page
96    return sfView::SUCCESS;
97  }
98  /**
99   * Executes js action
100   *
101   * @param sfRequest $request A request object
102   */
103  public function executeJs($request)
104  {
105    return sfView::SUCCESS;
106  }
107}
Note: See TracBrowser for help on using the repository browser.