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

Changeset 11001


Ignore:
Timestamp:
Mar 11, 2009, 10:07:27 PM (10 years ago)
Author:
ShogoKawahara
Message:

#3293:changed Profile and MemberProfile? model to profile's access authority

Location:
OpenPNE3/trunk
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/mobile_frontend/modules/member/templates/profileSuccess.php

    r10900 r11001  
    2323</td>
    2424<td valign="top">
    25 <?php foreach ($member->getProfiles() as $profile) : ?>
     25<?php foreach ($member->getProfiles(true) as $profile) : ?>
    2626<font color="#999966"><?php echo $profile->getCaption() ?>:</font><br>
    2727<?php echo $profile ?><br>
  • OpenPNE3/trunk/apps/pc_backend/modules/profile/templates/editSuccess.php

    r10969 r11001  
    2424<?php echo $form['name']->renderRow() ?>
    2525<?php echo $form['is_required']->renderRow() ?>
     26<?php echo $form['is_public_flag_edit']->renderRow() ?>
     27<?php echo $form['default_public_flag']->renderRow() ?>
    2628<?php echo $form['is_unique']->renderRow() ?>
    2729<?php echo $form['is_disp_regist']->renderRow() ?>
  • OpenPNE3/trunk/apps/pc_backend/modules/profile/templates/listSuccess.php

    r10928 r11001  
    1111<th>識別名</th>
    1212<th>必須</th>
     13<th>公開設定変更の可否</th>
     14<th>公開設定デフォルト値</th>
    1315<th>重複の可否</th>
    1416<th>フォームタイプ</th>
     
    2628<td><?php echo $value->getCaption() ?></td>
    2729<td><?php echo $value->getName() ?></td>
    28 <td><?php echo ($value->getIsRequired() ? '○' : '×') ?></td>
     30<td><?php echo ($value->getIsRequired() ? '○' : '×') ?></t
     31<td><?php echo ($value->getIsEditPublicFlag() ? '○' :'×') ?></>
     32<td><?php echo (ProfilePeer::getPublicFlag($value->getDefaultPublicFlag())) ?> </td>
    2933<td><?php echo ($value->getIsUnique() ? '×' :'○') ?></td>
    3034<td><?php echo $value->getFormType() ?></td>
     
    3640<?php endif; ?>
    3741</td>
    38 <td><?php echo ($value->getIsDispRegist() ? '○' : '×') ?></td>
    39 <td><?php echo ($value->getIsDispConfig() ? '○' : '×') ?></td>
    40 <td><?php echo ($value->getIsDispSearch() ? '○' : '×') ?></td>
     42<td><?php echo ($value->getIsDispRegist() ? '○' :'×') ?></td>
     43<td><?php echo ($value->getIsDispConfig() ? '○' :'×') ?></td>
     44<td><?php echo ($value->getIsDispSearch() ? '○' : '') ?></td>
    4145</tr>
    4246</tbody>
  • OpenPNE3/trunk/apps/pc_frontend/modules/member/templates/profileSuccess.php

    r10924 r11001  
    6666<?php
    6767$list = array();
    68 foreach ($member->getProfiles() as $profile)
     68foreach ($member->getProfiles(true) as $profile)
    6969{
    7070  $caption = $profile->getCaption();
  • OpenPNE3/trunk/config/schema.yml

    r10969 r11001  
    4444    is_required: { type: boolean, required: true, defaultValue: 0 }
    4545    is_unique: { type: boolean, required: true, defaultValue: 0 }
     46    is_edit_public_flag: { type: boolean, required: true, defaultValue: 0 }
     47    default_public_flag: { type: tinyint, required: true, defaultValue: 1 }
    4648    form_type: { type: varchar(32), required: true, defaultValue: "" }
    4749    value_type: { type: varchar(32), required: true, defaultValue: "" }
     
    7678    profile_option_id: { type: integer, required: false, foreignTable: profile_option, foreignReference: id, onDelete: cascade }
    7779    value: { type: longvarchar }
     80    public_flag: { type: tinyint, required: false }
    7881
    7982  community:
  • OpenPNE3/trunk/data/fixtures/000_revision.yml

    r10973 r11001  
    22  current_revision:
    33    name:  "OpenPNE_revision"
    4     value: 3
     4    value: 4
  • OpenPNE3/trunk/data/fixtures/001_import_profile.yml

    r10969 r11001  
    88    is_disp_config: 1
    99    is_disp_search: 1
     10    is_public_flag_edit: 0
     11    default_public_flag: 1
    1012    sort_order: 110
    1113
     
    2022    value_min: "-100years"
    2123    value_max: "now"
     24    is_public_flag_edit: 0
     25    default_public_flag: 1
    2226    sort_order: 120
    2327
     
    3034    is_disp_config: 1
    3135    is_disp_search: 1
     36    is_public_flag_edit: 0
     37    default_public_flag: 1
    3238    sort_order: 130
    3339
  • OpenPNE3/trunk/data/fixtures/002_import_first_member.yml

    r10078 r11001  
    1212    profile_id: profile_sex
    1313    profile_option_id: profile_option_sex_man
     14    public_flag: 1
    1415
    1516  first_member_profile_birthday:
     
    1920    member_id: first_member
    2021    profile_id: profile_birthday
     22    public_flag: 1
    2123
    2224  first_member_profile_birthday_year:
     
    5355    profile_id: profile_self_intro
    5456    value: "よろしくお願いします。"
     57    public_flag: 1
    5558
    5659MemberConfig:
  • OpenPNE3/trunk/lib/form/ProfileForm.class.php

    r10969 r11001  
    2121  {
    2222    $isDispOption = array('choices' => array('1' => '表示する', '0' => '表示しない'));
    23 
    2423    $this->setWidgets(array(
    2524      'name' => new sfWidgetFormInput(),
     25      'is_public_flag_edit' => new sfWidgetFormSelectRadio(array('choices' => array('0' => '固定', '1' => 'メンバー選択'))),
     26      'default_public_flag' => new sfWidgetFormSelect(array('choices' => ProfilePeer::getPublicFlags())),
    2627      'is_disp_regist' => new sfWidgetFormSelectRadio($isDispOption),
    2728      'is_disp_config' => new sfWidgetFormSelectRadio($isDispOption),
     
    5354
    5455    $this->mergePostValidator(new sfValidatorCallback(array('callback' => array('ProfileForm', 'advancedValidator'))));
     56    $this->setValidator('default_public_flag', new sfValidatorChoice(array('choices' => array_keys(ProfilePeer::getPublicFlags()))));
    5557    $this->setValidator('value_min', new sfValidatorPass());
    5658    $this->setValidator('value_max', new sfValidatorPass());
     
    6062      'name' => '識別名',
    6163      'is_required' => '必須',
     64      'is_public_flag_edit' => '公開設定の選択',
     65      'default_public_flag' => '公開設定デフォルト値',
    6266      'is_unique' => '重複の可否',
    6367      'form_type' => 'フォームタイプ',
     
    6872      'is_disp_regist' => '新規登録',
    6973      'is_disp_config' => 'プロフィール変更',
    70       'is_disp_search' => 'メンバー検索',
    71     ));
     74      'is_disp_search' => 'メンバー検索'
     75   ));
    7276
    7377    $this->setDefaults($this->getDefaults() + array(
  • OpenPNE3/trunk/lib/model/Member.php

    r10971 r11001  
    1818class Member extends BaseMember
    1919{
    20   public function getProfiles()
    21   {
     20  public function getProfiles($viewableCheck = false, $myMemberId = null)
     21  {
     22    if ($viewableCheck)
     23    {
     24      return MemberProfilePeer::getViewableProfileListByMemberId($this->getId(), $myMemberId);
     25    }
    2226    return MemberProfilePeer::getProfileListByMemberId($this->getId());
    2327  }
  • OpenPNE3/trunk/lib/model/MemberProfile.php

    r10966 r11001  
    137137    return parent::setValue($v);
    138138  }
     139
     140  public function isViewable($memberId = null)
     141  {
     142    if (is_null($memberId))
     143    {
     144      $memberId = sfContext::getInstance()->getUser()->getMemberId();
     145    }
     146
     147    switch ($this->getPublicFlag())
     148    {
     149      case ProfilePeer::PUBLIC_FLAG_PRIVATE:
     150        return ($this->getMemberId == $memberId);
     151     
     152      case ProfilePeer::PUBLIC_FLAG_FRIEND:
     153        $relation = MemberRelationshipPeer::retrieveByFromAndTo($this->getMemberId(), $memberId);
     154        return ($relation && $relation->isFriend());
     155     
     156      case ProfilePeer::PUBLIC_FLAG_SNS:
     157        return true;
     158    }
     159  }
    139160}
  • OpenPNE3/trunk/lib/model/MemberProfilePeer.php

    r10462 r11001  
    4848  }
    4949
     50  public static function getViewableProfileListByMemberId($memberId, $myMemberId = null)
     51  {
     52    if(is_null($myMemberId))
     53    {
     54      $myMemberId = sfContext::getInstance()->getUser()->getMemberId();
     55    }
     56
     57    $profiles = self::getProfileListByMemberId($memberId);
     58    foreach ($profiles as $key => $profile)
     59    {
     60      if (!$profile->isViewable($myMemberId))
     61      {
     62        unset($profiles[$key]);
     63      }
     64    }
     65
     66    return $profiles;
     67  }
     68
    5069  public static function retrieveByMemberIdAndProfileId($memberId, $profileId)
    5170  {
  • OpenPNE3/trunk/lib/model/ProfilePeer.php

    r10078 r11001  
    1818class ProfilePeer extends BaseProfilePeer
    1919{
     20  const PUBLIC_FLAG_SNS = 1;
     21  const PUBLIC_FLAG_FRIEND = 2;
     22  const PUBLIC_FLAG_PRIVATE = 3;
     23
     24  protected static $publicFlags = array(
     25    self::PUBLIC_FLAG_SNS     => 'All Members',
     26    self::PUBLIC_FLAG_FRIEND  => 'My Friends',
     27    self::PUBLIC_FLAG_PRIVATE => 'Private',
     28  );
     29
     30  public static function getPublicFlags()
     31  {
     32    return array_map(array(sfContext::getInstance()->getI18N(), '__'), self::$publicFlags);
     33  }
     34
     35  public static function getPublicFlag($flag)
     36  {
     37    return sfContext::getInstance()->getI18N()->__(self::$publicFlags[$flag]);
     38  }
     39
    2040  public static function retrievesAll()
    2141  {
Note: See TracChangeset for help on using the changeset viewer.