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

Changeset 11019


Ignore:
Timestamp:
Mar 13, 2009, 10:39:28 PM (10 years ago)
Author:
ShogoKawahara
Message:

#3248:added ability to set register policy of the community

Location:
OpenPNE3/trunk
Files:
6 added
13 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/mobile_frontend/i18n/messages.ja.xml

    r10939 r11019  
    123123        <target>コミュニティメンバー</target>
    124124      </trans-unit>
     125      <trans-unit>
     126        <source>Register poricy</source>
     127        <target>参加条件</target>
     128      </trans-unit>
     129      <trans-unit>
     130        <source>Everyone can join</source>
     131        <target>誰でも参加できる</target>
     132      </trans-unit>
     133      <trans-unit id="">
     134        <source>Community's admin authorization needed</source>
     135        <target>コミュニティ管理者の承認が必要</target>
     136      </trans-unit>
     137      <trans-unit id="">
     138        <source>Description</source>
     139        <target>説明文</target>
     140      </trans-unit>
    125141      <trans-unit id="">
    126142        <source>Login Failed.</source>
     
    198214        <source>Received from the friend link message from %1%!</source>
    199215        <target>%1%からフレンド申請がきています!</target>
     216      </trans-unit>
     217      <trans-unit id="">
     218        <source>%1% send request for participation to %2%.</source>
     219        <target>%1%から%2%への参加申請がきています</target>
    200220      </trans-unit>
    201221      <trans-unit id="">
  • OpenPNE3/trunk/apps/mobile_frontend/modules/member/config/view.yml

    r8969 r11019  
    55      parts   : [information]
    66      target  : [bottom]
     7    cautionAboutCommunityMemberPre:
     8      template    : [community, cautionAboutCommunityMemberPre]
     9      parts       : [information]
     10      target      : [bottom]
     11      is_component: true
  • OpenPNE3/trunk/apps/pc_frontend/i18n/messages.ja.xml

    r10980 r11019  
    124124      </trans-unit>
    125125      <trans-unit id="">
     126        <source>%1% send request for participation to %2%.</source>
     127        <target>%1%さんが%2%への参加を希望しています。</target>
     128      </trans-unit>
     129      <trans-unit id="">
    126130        <source>Permits</source>
    127131        <target>許可する</target>
     
    526530        <source>Remove the current photo</source>
    527531        <target>この写真を削除する</target>
     532      </trans-unit>
     533      <trans-unit id="">
     534        <source>Register poricy</source>
     535        <target>参加条件</target>
     536      </trans-unit>
     537      <trans-unit id="">
     538        <source>Everyone can join</source>
     539        <target>誰でも参加可能</target>
     540      </trans-unit>
     541      <trans-unit id="">
     542        <source>Community's admin authorization needed</source>
     543        <target>コミュニティ管理者の承認が必要</target>
    528544      </trans-unit>
    529545    </body>
  • OpenPNE3/trunk/apps/pc_frontend/modules/community/actions/actions.class.php

    r10270 r11019  
    2727    $result = parent::executeEdit($request);
    2828
    29     if (!$this->community) {
     29    if ($this->community->isNew()) {
    3030      sfConfig::set('sf_nav_type', 'default');
    3131    }
  • OpenPNE3/trunk/apps/pc_frontend/modules/community/actions/components.class.php

    r10906 r11019  
    99 */
    1010
    11 class communityComponents extends sfComponents
     11class communityComponents extends sfOpenPNECommunityComponents
    1212{
    1313  public function executeJoinListBox()
  • OpenPNE3/trunk/apps/pc_frontend/modules/friend/actions/components.class.php

    r10260 r11019  
    99 */
    1010
    11 class friendComponents extends sfComponents
     11class friendComponents extends sfOpenPNEFriendComponents
    1212{
    1313  public function executeFriendListBox()
  • OpenPNE3/trunk/apps/pc_frontend/modules/member/config/view.yml

    r10800 r11019  
    77      parts   : [information]
    88      target  : [bodyBottom]
     9    cautionAboutCommunityMemberPre:
     10      template    : [community, cautionAboutCommunityMemberPre]
     11      parts       : [information]
     12      target      : [bodyBottom]
     13      is_component: true
    914
    1015profileSuccess:
  • OpenPNE3/trunk/lib/action/sfOpenPNECommunityAction.class.php

    r11014 r11019  
    2222    $this->id = $this->getRequestParameter('id');
    2323
    24     $this->isCommunityMember = CommunityMemberPeer::isMember($this->getUser()->getMemberId(), $this->id);
    25     $this->isAdmin = CommunityMemberPeer::isAdmin($this->getUser()->getMemberId(), $this->id);
     24    $memberId = $this->getUser()->getMemberId();
     25    $this->isCommunityMember = CommunityMemberPeer::isMember($memberId, $this->id);
     26    $this->isCommunityPreMember = CommunityMemberPeer::isPreMember($memberId, $this->id);
     27    $this->isAdmin = CommunityMemberPeer::isAdmin($memberId, $this->id);
    2628    $this->isEditCommunity = $this->isAdmin;
    2729  }
     
    6466    {
    6567      $this->community = new Community();
    66     }
    67 
     68     
     69    }
    6870
    6971    $this->communityForm       = new CommunityForm($this->community);
     
    150152  public function executeJoin($request)
    151153  {
    152     if ($this->isCommunityMember) {
    153       return sfView::ERROR;
    154     }
    155 
    156     CommunityMemberPeer::join($this->getUser()->getMemberId(), $this->id);
     154    if ($this->isCommunityMember || $this->isCommunityPreMember) {
     155      return sfView::ERROR;
     156    }
     157
     158    $community = CommunityPeer::retrieveByPk($this->id);
     159    $this->forward404Unless($community);
     160
     161    CommunityMemberPeer::join($this->getUser()->getMemberId(), $this->id, $community->getConfig('register_poricy'));
    157162    $this->redirect('community/home?id=' . $this->id);
     163  }
     164
     165  /**
     166   * Executes joinAccept action
     167   *
     168   * @param sfRequest $request A request object
     169   */
     170  public function executeJoinAccept($request)
     171  {
     172    $this->forward404Unless($this->isAdmin);
     173   
     174    $communityMember = CommunityMemberPeer::retrieveByMemberIdAndCommunityId($request->getParameter('member_id'), $this->id);
     175    $this->forward404Unless($communityMember);
     176
     177    if ($communityMember->getPosition() == 'pre')
     178    {
     179      $communityMember->setPosition('');
     180      $communityMember->save();
     181    }
     182    $this->redirect('community/home?id='.$this->id);
     183  }
     184
     185  /**
     186   * Executes joinReject action
     187   *
     188   * @param sfRequest $request A request object
     189   */
     190  public function executeJoinReject($request)
     191  {
     192    $this->forward404Unless($this->isAdmin);
     193   
     194    $communityMember = CommunityMemberPeer::retrieveByMemberIdAndCommunityId($request->getParameter('member_id'), $this->id);
     195    $this->forward404Unless($communityMember);
     196
     197    if ($communityMember->getPosition() == 'pre')
     198    {
     199      $communityMember->delete();
     200    }
     201    $this->redirect('community/home?id='.$this->id);   
    158202  }
    159203
  • OpenPNE3/trunk/lib/config/config/community_config.yml

    r9610 r11019  
    11general:
     2  register_poricy:
     3    Name:       "register_poricy"
     4    Caption:    "Register poricy"
     5    FormType:   "radio"
     6    Default:    "open"
     7    Choices:
     8      open:     "Everyone can join"
     9      close:    "Community's admin authorization needed"
     10    IsUnique:   false
     11    IsRequired: true
    212  description:
    313    Name:       "description"
    4     Caption:    "説明文"
     14    Caption:    "Description"
    515    FormType:   "textarea"
    616    ValueType:  "string"
  • OpenPNE3/trunk/lib/model/Community.php

    r10356 r11019  
    4949    }
    5050    $c->add(CommunityMemberPeer::COMMUNITY_ID, $this->getId());
     51    $c->add(CommunityMemberPeer::POSITION, 'pre', Criteria::NOT_EQUAL);
    5152    $c->addJoin(MemberPeer::ID, CommunityMemberPeer::MEMBER_ID);
    5253    return MemberPeer::doSelect($c);
     
    6566    $c = new Criteria();
    6667    $c->add(CommunityMemberPeer::MEMBER_ID, $memberId);
     68    $c->add(CommunityMemberPeer::POSITION, 'pre', Criteria::NOT_EQUAL);
    6769
    6870    return (bool)$this->getCommunityMembers($c);
     
    7779    return (bool)$this->getCommunityMembers($c);
    7880  }
     81
     82  public function countCommunityMembers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
     83  {
     84    if (is_null($criteria))
     85    {
     86      $criteria = new Criteria();
     87    }
     88    $criteria->add(CommunityMemberPeer::POSITION, 'pre', Criteria::NOT_EQUAL);
     89    return parent::countCommunityMembers($criteria, $distinct, $con);
     90  }
    7991}
  • OpenPNE3/trunk/lib/model/CommunityMemberPeer.php

    r10906 r11019  
    2828  public static function isMember($memberId, $communityId)
    2929  {
    30     return (bool)self::retrieveByMemberIdAndCommunityId($memberId, $communityId);
     30    $communityMember = self::retrieveByMemberIdAndCommunityId($memberId, $communityId);
     31    if (!$communityMember)
     32    {
     33      return false;
     34    }
     35    return ($communityMember->getPosition() != 'pre');
     36  }
     37
     38  public static function isPreMember($memberId, $communityId)
     39  {
     40    $communityMember = self::retrieveByMemberIdAndCommunityId($memberId, $communityId);
     41    if (!$communityMember)
     42    {
     43      return false;
     44    }
     45    return ($communityMember->getPosition() == 'pre');
    3146  }
    3247
     
    4560  }
    4661
    47   public static function join($memberId, $communityId)
     62  public static function join($memberId, $communityId, $isRegisterPoricy = 'open')
    4863  {
    49     if (self::isMember($memberId, $communityId)) {
     64    if (self::isPreMember($memberId, $communityId))
     65    {
     66      throw new Exception('This member has already applied this community.');
     67    }
     68
     69    if (self::isMember($memberId, $communityId))
     70    {
    5071      throw new Exception('This member has already joined this community.');
    5172    }
     
    5475    $communityMember->setMemberId($memberId);
    5576    $communityMember->setCommunityId($communityId);
     77    if ($isRegisterPoricy == 'close')
     78    {
     79      $communityMember->setPosition('pre');
     80    }
    5681    $communityMember->save();
    5782  }
     
    95120    return $result;
    96121  }
     122
     123  public static function getCommunityMembersPre($memberId)
     124  {
     125    $adminCommunityIds = self::getCommunityIdsOfAdminByMemberId($memberId);
     126   
     127    if (count($adminCommunityIds))
     128    {
     129      $c = new Criteria();
     130      $c->add(self::COMMUNITY_ID, $adminCommunityIds, Criteria::IN);
     131      $c->add(self::POSITION, 'pre');
     132      return self::doSelect($c);
     133    }
     134    return array();
     135  }
    97136}
  • OpenPNE3/trunk/lib/model/CommunityPeer.php

    r10003 r11019  
    2525    }
    2626    $c->add(CommunityMemberPeer::MEMBER_ID, $memberId);
     27    $c->add(CommunityMemberPeer::POSITION, 'pre', Criteria::NOT_EQUAL);
    2728    $c->addJoin(self::ID, CommunityMemberPeer::COMMUNITY_ID);
    2829    $c->setLimit($limit);
     
    3536    $c = new Criteria();
    3637    $c->add(CommunityMemberPeer::MEMBER_ID, $memberId);
     38    $c->add(CommunityMemberPeer::POSITION, 'pre', Criteria::NOT_EQUAL);
    3739    $c->addJoin(self::ID, CommunityMemberPeer::COMMUNITY_ID);
    3840
     
    4951    $c = new Criteria();
    5052    $c->add(CommunityMemberPeer::COMMUNITY_ID, $communityId);
     53    $c->add(CommunityMemberPeer::POSITION, 'pre', Criteria::NOT_EQUAL);
    5154    $c->addJoin(MemberPeer::ID, CommunityMemberPeer::MEMBER_ID);
    5255
     
    6669    $c->clearSelectColumns()->addSelectColumn(self::ID);
    6770    $c->add(CommunityMemberPeer::MEMBER_ID, $memberId);
     71    $c->add(CommunityMemberPeer::POSITION, 'pre', Criteria::NOT_EQUAL);
    6872    $c->addJoin(self::ID, CommunityMemberPeer::COMMUNITY_ID);
    6973    $stmt = self::doSelectStmt($c);
  • OpenPNE3/trunk/lib/util/opFormItemGenerator.class.php

    r10969 r11019  
    3232      case 'select' :
    3333      case 'radio' :
    34         $params['choices'] = $choices;
    35         if (!empty($field['Choices']))
    36         {
    37           $params['choices'] = $field['Choices'];
     34        $params['choices'] = array_map(array(sfContext::getInstance()->getI18N(), '__'), $choices);
     35        if (!empty($field['Choices']) && is_array($field['Choices']))
     36        {
     37          $params['choices'] = array_map(array(sfContext::getInstance()->getI18N(), '__'), $field['Choices']);
    3838        }
    3939    }
Note: See TracChangeset for help on using the changeset viewer.