Bug(バグ) #2426
Web への公開の許可を「表示しない」に設定しても「Web全体に公開」の選択肢が表示される
100%
Description
Overview (現象)¶
性別のプロフィール項目を Web への公開の許可を「表示しない」に設定しても、プロフィール編集ページで性別の公開範囲に「Web全体に公開」の選択肢が表示される
Environment (再現環境)¶
OpenPNE 3.6RC1 3.7.0-dev
Way to repro (再現手順)¶
- 管理画面プロフィール項目登録ページ(/pc_backend.php/profile/edit)にアクセスする
- 性別のプロフィール項目編集ページ(/pc_backend.php/profile/edit/id/1)にアクセスする
- 「Web への公開の許可」を「禁止」に設定する
- 「公開範囲設定の可否」を「メンバー選択」に設定する
- SNSログイン後、プロフィール編集ページ(/member/edit/profile)にアクセスする
- 性別の公開範囲選択を確認する
- Web への公開の許可を「表示しない」に設定しても「Web全体に公開」の選択肢が表示される
Way to fix (修正内容)¶
プロフィール項目編集ページで Web への公開の許可を「表示しない」に設定した場合、SNS側の公開範囲選択で「Web全体に公開」が存在しないように修正お願いします。
Related issues
Associated revisions
(fixed #2426) fixed not to display select item considering public web flag setting
(fixes #2426) fixed not to display public web flag in profile page considering the settings
(refs #2426) fixed for coding standard
History
#1
Updated by Shingo Yamada about 8 years ago
- Due date set to 2011-09-28
- Assignee set to Yuya Watanabe
- Priority changed from Normal(通常) to High(高め)
- Target version set to OpenPNE 3.7.0
- 360対象 set to 3.6.0
#2
Updated by Yuma Sakata about 8 years ago
- Subject changed from 管理画面プロフィール項目編集で「Web への公開の許可」の機能が動いていない to Web への公開の許可を「表示しない」に設定しても「Web全体に公開」の選択肢が表示される
- Description updated (diff)
#3
Updated by Yuma Sakata about 8 years ago
- Description updated (diff)
#4
Updated by Yuya Watanabe about 8 years ago
- Description updated (diff)
- Status changed from New(新規) to Accepted(着手)
#5
Updated by Yuya Watanabe about 8 years ago
- 環境
- PHPUnit 3.5.14
- SeleniumRC 2.7.0
<?php require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; class t2426Test extends PHPUnit_Extensions_SeleniumTestCase { public static $browsers = array( array( 'browser' => '*firefox', 'host' => 'localhost', 'port' => 4444, 'timeout' => 30000, ), ); protected function setUp() { $url = 'http://localhost'; $this->setBrowserUrl($url); } public function testT2426() { // 管理ページで管理者でログイン $this->open("/pc_backend.php/"); $this->type("admin_user_username", "admin"); $this->type("admin_user_password", "password"); $this->click("//input[@value=\"ログイン\"]"); $this->waitForPageToLoad(); // プロフィール項目登録で「性別」の項目を「Webへの公開の許可」を「禁止」にし、 // 「公開範囲変更の可否」を「メンバー選択」にする。 $this->open("/pc_backend.php/profile/edit/id/1"); $this->click("profile_is_public_web_0"); $this->click("profile_is_edit_public_flag_1"); $this->click("//input[@value=\"変更\"]"); $this->waitForPageToLoad(); // SNSログイン $this->open(); $this->type("authMailAddress_mail_address", "sns@example.com"); $this->type("authMailAddress_password", "password"); $this->click("//input[@value=\"ログイン\"]"); $this->waitForPageToLoad(); // 「プロフィール編集画面」で「性別」の項目の公開範囲設定で「Web全体に公開」の項目が存在していると失敗 $this->open("member/edit/profile"); $isExist = $this->isElementPresent("//select[@id=\"profile_op_preset_sex_public_flag\"]/option[@value=\"4\"]"); $this->assertFalse($isExist, "#2426 『Web への公開の許可を「表示しない」に設定しても「Web全体に公開」の選択肢が表示される』"); } } ?>
#6
Updated by Yuya Watanabe about 8 years ago
原因¶
「Web全体に公開」等の項目を含むかどうかを規定している部分は下記部分である.
lib/widget/opWidgetFormProfile.class.php 68行目
65 { 66 return $input; 67 } 68 $publicFlagWidget = new sfWidgetFormSelect(array('choices' => Doctrine::getTable('Profile')->getPublicFlags())); 69 70 return strtr($this->getOption('template'), array('%input%' => $input, '%public_flag%' =>$publicFlagWidget->render($name.'[public_flag]', $value['public_flag'], $attributes, $errors))); 71 } 72 }
Doctrine::getTable('Profile')->getPublicFlags()が返すのは「Web全体に公開」「全体に公開」「マイフレンドまで公開」「公開しない」のリストをそのまま返すだけであり,「Web全体に公開」を項目に含むかどうかの確認は行われていない.また同様に,バリデータについても下記の部分ように,同じメソッドを用いている.
lib/validator/opValidatorProfile.class.php 46行目
32 /** 33 * @see sfValidatorBase 34 */ 35 protected function doClean($value) 36 { 37 $clean = array(); 38 $clean['value'] = $this->getOption('validator')->clean($value['value']); 39 40 if ($this->getOption('is_edit_public_flag')) 41 { 42 if (!isset($value['public_flag'])) 43 { 44 throw new sfValidatorError($this, 'invalid'); 45 } 46 $validator = new sfValidatorChoice(array('choices' => array_keys(Doctrine::getTable('Profile')->getPublicFlags()))); 47 $clean['public_flag'] = $validator->clean($value['public_flag']); 48 } 49 50 return $clean; 51 }
また,プロフィール確認画面においても公開範囲に関しては考慮されているが「Web への公開の許可」の項目を考慮するコードではないと思われる.
apps/pc_frontend/modules/member/templates/_profileListBox.php 53行目 59行目
52 53 if ($member->getId() == $sf_user->getMemberId() && $profile->getPublicFlag() == ProfileTable::PUBLIC_FLAG_FRIEND) 54 { 55 $profileValue .= ' ('.__('Only Open to %my_friend%', array( 56 '%my_friend%' => $op_term['my_friend']->titleize()->pluralize(), 57 )).')'; 58 } 59 elseif ($member->getId() == $sf_user->getMemberId() && $profile->getPublicFlag() == ProfileTable::PUBLIC_FLAG_WEB) 60 { 61 $profileValue .= ' ('.__('All Users on the Web').')'; 62 } 63 $list[$caption] = $profileValue; 64 }
#7
Updated by Yuya Watanabe about 8 years ago
修正案¶
本チケットの問題を解決するには各プロフィール項目について「Web全体に公開」の設定を反映した公開範囲一覧を得る必要がある.
今回の場合,公開範囲一覧で表示しない設定が存在するというのは各プロフィール項目に固有であると考えられる.そのため,プロフィール項目に固有な情報を保持するlib/model/doctrine/Profile.class.phpから公開範囲一覧を取得できることが望ましい.
また,ウィジェットおよびバリデータ内では,それ自身が表示および検証するプロフィール項目を得る手段が必要となる.ウィジェットの場合は以下の方法でプロフィール項目名を取得することができることを確認した.
- opWidgetFormProfileクラスのrender()メソッドの第一引数である$nameから正規表現等を用いて識別名を取得し,ProfileTableからProfileを取得する.
- opWidgetFormProfileクラスのrender()メソッド内において$this->parent->getFields()の連想配列の$thisに相当する値と対応するキーが識別名となるため,その識別名を用いてProfileTableからProfileを取得する.
- opWidgetFormProfileクラスを呼び出す側でProfileクラスを渡してrender()メソッド内で$this->profileとして呼び出す.
しかし,バリデータ内でウィジェットと同様の方法でProfileを得る方法を検討したが1と2では得ることが出来なかった.
そのためウィジェットおよびバリデータ内でプロフィール情報を取得する部分の修正案は3の方法を検討する.
実装案¶
diff --git a/lib/form/doctrine/MemberProfileForm.class.php b/lib/form/doctrine/MemberProfileForm.class.php index ad45aa6..09dd0e4 100644 --- a/lib/form/doctrine/MemberProfileForm.class.php +++ b/lib/form/doctrine/MemberProfileForm.class.php @@ -163,6 +163,9 @@ class MemberProfileForm extends BaseForm $this->widgetSchema[$profile->getName()] = new opWidgetFormProfile($widgetOptions); $this->validatorSchema[$profile->getName()] = new opValidatorProfile($validatorOptions); + $this->widgetSchema[$profile->getName()]->profile = $profile; + $this->validatorSchema[$profile->getName()]->profile = $profile; + $this->widgetSchema->setHelp($profile->getName(), $profileWithI18n['info']); if ($profile->isPreset()) { diff --git a/lib/model/doctrine/Profile.class.php b/lib/model/doctrine/Profile.class.php index aa43dad..4d66565 100644 --- a/lib/model/doctrine/Profile.class.php +++ b/lib/model/doctrine/Profile.class.php @@ -133,4 +133,15 @@ class Profile extends BaseProfile ->orderBy('sort_order') ->execute(); } + + public function getPublicFlags($isI18n = true) + { + $publicFlags = Doctrine::getTable('profile')->getPublicFlags($isI18n); + if (!$this['is_public_web']) + { + unset($publicFlags[ProfileTable::PUBLIC_FLAG_WEB]); + } + + return $publicFlags; + } } diff --git a/lib/validator/opValidatorProfile.class.php b/lib/validator/opValidatorProfile.class.php index 9a4dcbf..dd47cd4 100644 --- a/lib/validator/opValidatorProfile.class.php +++ b/lib/validator/opValidatorProfile.class.php @@ -43,7 +43,7 @@ class opValidatorProfile extends sfValidatorBase { throw new sfValidatorError($this, 'invalid'); } - $validator = new sfValidatorChoice(array('choices' => array_keys(Doctrine::getTable('Profile')->getPublicFlags()))); + $validator = new sfValidatorChoice(array('choices' => array_keys($this->profile->getPublicFlags()))); $clean['public_flag'] = $validator->clean($value['public_flag']); } diff --git a/lib/widget/opWidgetFormProfile.class.php b/lib/widget/opWidgetFormProfile.class.php index 7126a91..eab3f2e 100644 --- a/lib/widget/opWidgetFormProfile.class.php +++ b/lib/widget/opWidgetFormProfile.class.php @@ -65,7 +65,8 @@ class opWidgetFormProfile extends sfWidgetForm { return $input; } - $publicFlagWidget = new sfWidgetFormSelect(array('choices' => Doctrine::getTable('Profile')->getPublicFlags())); + $publicFlagWidget = new sfWidgetFormSelect(array('choices' => $this->profile->getPublicFlags())); return strtr($this->getOption('template'), array('%input%' => $input, '%public_flag%' =>$publicFlagWidget->render($name.'[public_flag]', $value['public_flag'], $attributes, $errors))); }
#8
Updated by Kousuke Ebihara about 8 years ago
- 360対象 changed from 3.6.0 to RC2
#9
Updated by wa ta about 8 years ago
- Status changed from Accepted(着手) to Pending Review(レビュー待ち)
- % Done changed from 0 to 50
更新履歴 e0069192003e64a7ad070b15727b59c969b8ec96 で適用されました。
#10
Updated by Kousuke Ebihara about 8 years ago
- Status changed from Pending Review(レビュー待ち) to Pending Testing(テスト待ち)
- % Done changed from 50 to 70
#11
Updated by Mutsumi Imamura about 8 years ago
- Status changed from Pending Testing(テスト待ち) to Rejected(差し戻し)
- % Done changed from 70 to 50
テスト中に気になる点がありましたので、確認もこめて差し戻します。
/member/profileでプロフィール項目の横に(Web全体に公開)が表示されてしまいます。
再現手順は以下の通りです。
1.管理画面で任意のプロフィール項目をWebへの公開を許可し、公開設定変更の可否をメンバー選択にする
2.pc_frontendのプロフィール変更で手順1で設定変更したプロフィール項目をWeb全体に公開にする
3.管理画面で手順2で変更したプロフィール項目のWebへの公開を許可しないにする
4.pc_frontendのプロフィール確認ページ(member/profile)にアクセスする
5.プロフィール項目の横に(Web全体に公開)が表示される
また、このユーザーのプロフィール画面に未ログインでアクセスするとプロフィール画像と名前が表示される(プロフィール項目は表示されない)のも確認しています。
プロフィール項目の横の表示も(全体に公開)の表示にした方が良いのではないでしょうか?
また、この手順で未ログイン時にアクセスした際にプロフィール画像が表示されない方が良いのではないでしょうか?
#12
Updated by Kousuke Ebihara about 8 years ago
また、この手順で未ログイン時にアクセスした際にプロフィール画像が表示されない方が良いのではないでしょうか?
このチケットで検討されたことのない事項である以上、なぜそう思うかの理由を書いてください。
あと、「この手順で」とおっしゃいますが、では、どの手順であればプロフィール画像を表示してよいことになるのですか?
#13
Updated by Mutsumi Imamura about 8 years ago
Kousuke Ebihara は書きました:
また、この手順で未ログイン時にアクセスした際にプロフィール画像が表示されない方が良いのではないでしょうか?
このチケットで検討されたことのない事項である以上、なぜそう思うかの理由を書いてください。
あと、「この手順で」とおっしゃいますが、では、どの手順であればプロフィール画像を表示してよいことになるのですか?
この件について、管理画面のSNS設定ページで「メンバーのプロフィールページ公開範囲設定」が「 メンバーの設定を許可しない(Web全体に公開)」になっていたためで全く問題ないです。
これは不要な指摘でした。お騒がせしました。
#14
Updated by wa ta about 8 years ago
- Status changed from Rejected(差し戻し) to Pending Review(レビュー待ち)
更新履歴 49f91eec6beab15e543ef71200fcb150a96c4a87 で適用されました。
#15
Updated by Yuya Watanabe about 8 years ago
プロフィール画面で「Web全体に公開」の設定を反映するように修正を行いました.
#16
Updated by Kousuke Ebihara about 8 years ago
- Status changed from Pending Review(レビュー待ち) to Pending Testing(テスト待ち)
- % Done changed from 50 to 70
#17
Updated by isao sano about 8 years ago
- Status changed from Pending Testing(テスト待ち) to Fixed(完了)
- % Done changed from 70 to 100
テスト完了致しました。
問題ありませんでしたので、ステータスをFixed(完了)に致します。
#18
Updated by kaoru n about 4 years ago
- 3.6 で発生するか set to Unknown (未調査)
- 3.8 で発生するか set to Unknown (未調査)