Permalink
Browse files

added backend setting "Use open diary" for the owners who want to dis…

…able the feature (refs #2096)
  • Loading branch information...
balibali committed May 16, 2011
1 parent e8cafb8 commit 82a87fafa3c733834b45968582826b23e1f5f2e1
@@ -58,6 +58,14 @@
<source>Please input the number of days that reflects to the diary search.</source>
<target>検索に反映する日数を入力してください。</target>
</trans-unit>
+ <trans-unit id="">
+ <source>Use open diary</source>
+ <target>Web全体に公開機能使用設定</target>
+ </trans-unit>
+ <trans-unit id="">
+ <source>If this is used, members can select the "All Users on the Web" public flag. If not used, anonymous users can't view any diary pages.</source>
+ <target>使用するに設定した場合、メンバーは「Web全体に公開」の日記を作成することができます。使用しないに設定した場合、すべての日記関連ページに非ログイン状態ではアクセスできないようになります。</target>
+ </trans-unit>
</body>
</file>
</xliff>
@@ -21,6 +21,11 @@ public function initialize($context, $moduleName, $actionName)
{
parent::initialize($context, $moduleName, $actionName);
+ if (!Doctrine::getTable('SnsConfig')->get('op_diary_plugin_use_open_diary', true))
+ {
+ $this->security = array();
+ }
+
$this->security['all'] = array('is_secure' => true, 'credentials' => 'SNSMember');
}
@@ -21,6 +21,11 @@ public function configure()
{
$choices = array('1' => 'Use', '0' => 'Not use');
+ $this->setWidget('use_open_diary', new sfWidgetFormSelectRadio(array('choices' => $choices)));
+ $this->setValidator('use_open_diary', new sfValidatorChoice(array('choices' => array_keys($choices))));
+ $this->setDefault('use_open_diary', Doctrine::getTable('SnsConfig')->get('op_diary_plugin_use_open_diary', '1'));
+ $this->widgetSchema->setHelp('use_open_diary', 'If this is used, members can select the "All Users on the Web" public flag. If not used, anonymous users can\'t view any diary pages.');
+
$this->setWidget('use_email_post', new sfWidgetFormSelectRadio(array('choices' => $choices)));
$this->setValidator('use_email_post', new sfValidatorChoice(array('choices' => array_keys($choices))));
$this->setDefault('use_email_post', Doctrine::getTable('SnsConfig')->get('op_diary_plugin_use_email_post', '1'));
@@ -51,7 +56,7 @@ public function configure()
public function save()
{
- $names = array('use_email_post', 'update_activity', 'search_enable', 'search_period_enable', 'search_period');
+ $names = array('use_open_diary', 'use_email_post', 'update_activity', 'search_enable', 'search_period_enable', 'search_period');
foreach ($names as $name)
{
@@ -30,7 +30,8 @@
public function getPublicFlags()
{
- if (!sfConfig::get('app_op_diary_plugin_is_open', true))
+ if (!Doctrine::getTable('SnsConfig')->get('op_diary_plugin_use_open_diary', true)
+ || !sfConfig::get('app_op_diary_plugin_is_open', true))
{
unset(self::$publicFlags[self::PUBLIC_FLAG_OPEN]);
}
@@ -0,0 +1,37 @@
+<?php
+
+include dirname(__FILE__).'/../../bootstrap/functional.php';
+
+$test = new opTestFunctional(new sfBrowser());
+$test->setMobile();
+
+include dirname(__FILE__).'/../../bootstrap/database.php';
+
+$test->setCulture('en');
+
+Doctrine::getTable('SnsConfig')->set('op_diary_plugin_use_open_diary', '0');
+
+$test->info('isSecure Test')
+ ->get('/diary')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/list')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/search', array('keyword' => 'hoge'))
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/3')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/listMember/5')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/listMember/5/2009/6')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/listMember/5/2009/6/1')
+ ->isForwardedTo('member', 'login')
+;
+
+Doctrine::getTable('SnsConfig')->set('op_diary_plugin_use_open_diary', '1');
@@ -0,0 +1,36 @@
+<?php
+
+include dirname(__FILE__).'/../../bootstrap/functional.php';
+
+$test = new opTestFunctional(new sfBrowser());
+
+include dirname(__FILE__).'/../../bootstrap/database.php';
+
+$test->setCulture('en');
+
+Doctrine::getTable('SnsConfig')->set('op_diary_plugin_use_open_diary', '0');
+
+$test->info('isSecure Test')
+ ->get('/diary')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/list')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/search', array('keyword' => 'hoge'))
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/3')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/listMember/5')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/listMember/5/2009/6')
+ ->isForwardedTo('member', 'login')
+
+ ->get('/diary/listMember/5/2009/6/1')
+ ->isForwardedTo('member', 'login')
+;
+
+Doctrine::getTable('SnsConfig')->set('op_diary_plugin_use_open_diary', '1');

0 comments on commit 82a87fa

Please sign in to comment.