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

Changeset 10832


Ignore:
Timestamp:
Feb 23, 2009, 8:00:14 PM (12 years ago)
Author:
ShogoKawahara
Message:

opOpenSocialPlugin:added MemberApplicationPeer::addApplicationToMember() and ApplicationPeer::updateApplication()

Location:
OpenPNE3/plugins/opOpenSocialPlugin/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opOpenSocialPlugin/trunk/apps/pc_backend/modules/opOpenSocialPlugin/actions/actions.class.php

    r10824 r10832  
    175175    $application = ApplicationPeer::retrieveByPk($request->getParameter('id'));
    176176    $this->forward404Unless($application);
    177 
    178     try
    179     {
    180       ApplicationPeer::addApplication($application->getUrl(), $this->getUser()->getCulture(),true);
    181     }
    182     catch (Exception $e)
    183     {
    184     }
     177   
     178    ApplicationPeer::updateApplication($request->getParameter('id'), $this->getUser()->getCulture());
    185179
    186180    $this->redirect('opOpenSocialPlugin/info?id='.$application->getId());
  • OpenPNE3/plugins/opOpenSocialPlugin/trunk/apps/pc_frontend/modules/application/actions/actions.class.php

    r10652 r10832  
    1919{
    2020  /**
    21    * add application to member
    22    *
    23    * @param Application  $application The application instalce
    24    * @param integer      $memberId    A member id
    25    */
    26   protected function addApplicationToMember(Application $application, $memberId)
    27   {
    28     $criteria = new Criteria();
    29     $criteria->add(MemberApplicationPeer::IS_GADGET, false);
    30     $memberApp = MemberApplicationPeer::retrieveByApplicationIdAndMemberId($application->getId(), $memberId, $criteria);
    31     if ($memberApp)
    32     {
    33       return $memberApp;
    34     }
    35 
    36     $memberApp = new MemberApplication();
    37     $memberApp->setMemberId($memberId);
    38     $memberApp->setApplicationId($application->getId());
    39     $memberApp->setIsDispOther(true);
    40     $memberApp->setIsDispHome(true);
    41     $memberApp->save();
    42     return $memberApp;
    43   }
    44 
    45   /**
    4621   * Executes index action
    4722   *
     
    12095        return sfView::ERROR;
    12196      }
    122       $memberApp = self::addApplicationToMember($application, $memberId);
     97      $memberApp = MemberApplicationPeer::addApplicationToMember($application, $memberId);
    12398      $this->redirect('application/canvas?id='.$memberApp->getId());
    12499    }
     
    218193    $memberId = $this->getUser()->getMemberId();
    219194
    220     $memberApp = self::addApplicationToMember($application, $memberId);
     195    $memberApp = MemberApplicationPeer::addApplicationToMember($application, $memberId);
    221196    $this->redirect('application/canvas?id='.$memberApp->getId());
    222197  }
  • OpenPNE3/plugins/opOpenSocialPlugin/trunk/lib/model/ApplicationPeer.php

    r10014 r10832  
    3535    return (object)$array;
    3636  }
     37
    3738  /**
    3839   * add or update application
     
    151152    return self::doSelectOne($criteria);
    152153  }
     154
     155  /**
     156   * update application
     157   *
     158   * @param integer $modId
     159   * @param string  $culture
     160   * @return Application The application instance
     161   */
     162  public static function updateApplication($modId, $culture = 'en_US')
     163  {
     164    $app = self::retrieveByPk($modId);
     165    if (!$app)
     166    {
     167      return false;
     168    }
     169
     170    try
     171    {
     172      return self::addApplication($app->getUrl(), $culture, true);
     173    }
     174    catch (Exception $e)
     175    {
     176      return false;
     177    }
     178  }
    153179}
  • OpenPNE3/plugins/opOpenSocialPlugin/trunk/lib/model/MemberApplicationPeer.php

    r10261 r10832  
    7979    return self::doSelect($criteria);
    8080  }
     81
     82  /**
     83   * add application to member
     84   *
     85   * @param Application $application
     86   * @param integer     $memberId
     87   * @return MemberApplication
     88   */
     89  public function addApplicationToMember(Application $application, $memberId)
     90  {
     91    $criteria = new Criteria();
     92    $criteria->add(self::IS_GADGET, false);
     93
     94    $culture = sfContext::getInstance()->getUser()->getCulture();
     95    ApplicationPeer::updateApplication($application->getId(), $culture);
     96    $memberApp = self::retrieveByApplicationIdAndMemberId($application->getId(), $memberId, $criteria);
     97    if ($memberApp)
     98    {
     99      return $memberApp;
     100    }
     101
     102    $memberApp = new MemberApplication();
     103    $memberApp->setMemberId($memberId);
     104    $memberApp->setApplicationId($application->getId());
     105    $memberApp->setIsDispOther(true);
     106    $memberApp->setIsDispHome(true);
     107    $memberApp->save();
     108    return $memberApp;
     109  }
     110
     111
     112
    81113}
Note: See TracChangeset for help on using the changeset viewer.