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

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

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

#3119:added application module on pc_frontend

File size: 2.7 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(MemberApplicationPeer::DATABASE_NAME);
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 (!$this->pager->getNbResults())
62    {
63      return sfView::ERROR;
64    }
65    if (!$request->isMethod('post'))
66    {
67      return sfView::SUCCESS;
68    }
69
70    $contact = $request->getParameter('contact');
71    $this->form->bind($contact);
72    if (!$this->form->isValid())
73    {
74      return sfView::SUCCESS;
75    }
76    $contact = $this->form->getValues();
77    try
78    {
79      $app = ApplicationPeer::addApplication($contact['application_url'],$this->getUser()->getCulture());
80    }
81    catch (Exception $e)
82    {
83      //TODO : add error action
84    }
85    $criteria = new Criteria(MemberApplicationPeer::DATABASE_NAME);
86    $criteria->add(MemberApplicationPeer::MEMBER_ID,$memberId);
87    $criteria->add(MemberApplicationPeer::APPLICATION_ID,$app->getId());
88    $member_app = MemberApplicationPeer::doSelectOne($criteria);
89    if (!empty($member_app))
90    {
91      //TODO : redirect application page
92      return sfView::SUCCESS;
93    }
94    $member_app = new MemberApplication();
95    $member_app->setMemberId($memberId);
96    $member_app->setApplicationId($app->getId());
97    $member_app->save();
98    //TODO : redirect application page
99    return sfView::SUCCESS;
100  }
101}
Note: See TracBrowser for help on using the repository browser.