summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2009-08-07 01:18:17 +0800
committerJeffery To <jeffery.to@gmail.com>2009-08-07 01:18:17 +0800
commit93f585446ebaa4a9347b6e6f77f58ab023b5b51c (patch)
tree78579bf89c17cc946539568426f650ea70af6500
parentc8c2d9d7c93f40e7ac81c6211f8ba4c3f6ae91d9 (diff)
Added configuration options to enable/disable SMS and Twitter integration.
This disables the IM, SMS and Twitter settings pages and queue handlers depending on the config options.
-rw-r--r--README16
-rw-r--r--actions/imsettings.php6
-rw-r--r--actions/smssettings.php6
-rw-r--r--actions/twittersettings.php6
-rw-r--r--config.php.sample6
-rw-r--r--lib/action.php17
-rw-r--r--lib/common.php4
-rw-r--r--lib/connectsettingsaction.php30
-rwxr-xr-xscripts/getvaliddaemons.php8
9 files changed, 77 insertions, 22 deletions
diff --git a/README b/README
index ef5a13934..e4cae0e49 100644
--- a/README
+++ b/README
@@ -1228,6 +1228,22 @@ enabled: Set to true to enable. Default false.
server: a string with the hostname of the sphinx server.
port: an integer with the port number of the sphinx server.
+sms
+---
+
+For SMS integration.
+
+enabled: Whether to enable SMS integration. Defaults to true. Queues
+ should also be enabled.
+
+twitter
+-------
+
+For Twitter integration
+
+enabled: Whether to enable Twitter integration. Defaults to true.
+ Queues should also be enabled.
+
integration
-----------
diff --git a/actions/imsettings.php b/actions/imsettings.php
index e0f5ede3a..70a6f37d4 100644
--- a/actions/imsettings.php
+++ b/actions/imsettings.php
@@ -84,6 +84,12 @@ class ImsettingsAction extends ConnectSettingsAction
function showContent()
{
+ if (!common_config('xmpp', 'enabled')) {
+ $this->element('div', array('class' => 'error'),
+ _('IM is not available.'));
+ return;
+ }
+
$user = common_current_user();
$this->elementStart('form', array('method' => 'post',
'id' => 'form_settings_im',
diff --git a/actions/smssettings.php b/actions/smssettings.php
index 922bab9a4..33b54abf6 100644
--- a/actions/smssettings.php
+++ b/actions/smssettings.php
@@ -80,6 +80,12 @@ class SmssettingsAction extends ConnectSettingsAction
function showContent()
{
+ if (!common_config('sms', 'enabled')) {
+ $this->element('div', array('class' => 'error'),
+ _('SMS is not available.'));
+ return;
+ }
+
$user = common_current_user();
$this->elementStart('form', array('method' => 'post',
diff --git a/actions/twittersettings.php b/actions/twittersettings.php
index 2b742788e..3343dba95 100644
--- a/actions/twittersettings.php
+++ b/actions/twittersettings.php
@@ -85,6 +85,12 @@ class TwittersettingsAction extends ConnectSettingsAction
function showContent()
{
+ if (!common_config('twitter', 'enabled')) {
+ $this->element('div', array('class' => 'error'),
+ _('Twitter is not available.'));
+ return;
+ }
+
$user = common_current_user();
$profile = $user->getProfile();
diff --git a/config.php.sample b/config.php.sample
index c27645ff8..91be39f48 100644
--- a/config.php.sample
+++ b/config.php.sample
@@ -164,6 +164,12 @@ $config['sphinx']['port'] = 3312;
// $config['memcached']['server'] = 'localhost';
// $config['memcached']['port'] = 11211;
+// Disable SMS
+// $config['sms']['enabled'] = false;
+
+// Disable Twitter integration
+// $config['twitter']['enabled'] = false;
+
// Twitter integration source attribute. Note: default is Laconica
// $config['integration']['source'] = 'Laconica';
diff --git a/lib/action.php b/lib/action.php
index 1c6170693..326edf3a0 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -402,6 +402,14 @@ class Action extends HTMLOutputter // lawsuit
function showPrimaryNav()
{
$user = common_current_user();
+ $connect = '';
+ if (common_config('xmpp', 'enabled')) {
+ $connect = 'imsettings';
+ } else if (common_config('sms', 'enabled')) {
+ $connect = 'smssettings';
+ } else if (common_config('twitter', 'enabled')) {
+ $connect = 'twittersettings';
+ }
$this->elementStart('dl', array('id' => 'site_nav_global_primary'));
$this->element('dt', null, _('Primary site navigation'));
@@ -413,12 +421,9 @@ class Action extends HTMLOutputter // lawsuit
_('Home'), _('Personal profile and friends timeline'), false, 'nav_home');
$this->menuItem(common_local_url('profilesettings'),
_('Account'), _('Change your email, avatar, password, profile'), false, 'nav_account');
- if (common_config('xmpp', 'enabled')) {
- $this->menuItem(common_local_url('imsettings'),
- _('Connect'), _('Connect to IM, SMS, Twitter'), false, 'nav_connect');
- } else {
- $this->menuItem(common_local_url('smssettings'),
- _('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect');
+ if ($connect) {
+ $this->menuItem(common_local_url($connect),
+ _('Connect'), _('Connect to services'), false, 'nav_connect');
}
if (common_config('invite', 'enabled')) {
$this->menuItem(common_local_url('invite'),
diff --git a/lib/common.php b/lib/common.php
index b3d301862..12a7ac449 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -183,6 +183,10 @@ $config =
array('piddir' => '/var/run',
'user' => false,
'group' => false),
+ 'sms' =>
+ array('enabled' => false),
+ 'twitter' =>
+ array('enabled' => false),
'twitterbridge' =>
array('enabled' => false),
'integration' =>
diff --git a/lib/connectsettingsaction.php b/lib/connectsettingsaction.php
index 30629680e..02c468a35 100644
--- a/lib/connectsettingsaction.php
+++ b/lib/connectsettingsaction.php
@@ -99,25 +99,27 @@ class ConnectSettingsNav extends Widget
function show()
{
# action => array('prompt', 'title')
- $menu =
- array('imsettings' =>
- array(_('IM'),
- _('Updates by instant messenger (IM)')),
- 'smssettings' =>
- array(_('SMS'),
- _('Updates by SMS')),
- 'twittersettings' =>
- array(_('Twitter'),
- _('Twitter integration options')));
+ $menu = array();
+ if (common_config('xmpp', 'enabled')) {
+ $menu['imsettings'] =
+ array(_('IM'),
+ _('Updates by instant messenger (IM)'));
+ }
+ if (common_config('sms', 'enabled')) {
+ $menu['smssettings'] =
+ array(_('SMS'),
+ _('Updates by SMS'));
+ }
+ if (common_config('twitter', 'enabled')) {
+ $menu['twittersettings'] =
+ array(_('Twitter'),
+ _('Twitter integration options'));
+ }
$action_name = $this->action->trimmed('action');
$this->action->elementStart('ul', array('class' => 'nav'));
foreach ($menu as $menuaction => $menudesc) {
- if ($menuaction == 'imsettings' &&
- !common_config('xmpp', 'enabled')) {
- continue;
- }
$this->action->menuItem(common_local_url($menuaction),
$menudesc[0],
$menudesc[1],
diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php
index 1e4546dff..8b127bd20 100755
--- a/scripts/getvaliddaemons.php
+++ b/scripts/getvaliddaemons.php
@@ -43,7 +43,11 @@ if(common_config('twitterbridge','enabled')) {
echo "twitterstatusfetcher.php ";
}
echo "ombqueuehandler.php ";
-echo "twitterqueuehandler.php ";
+if (common_config('twitter', 'enabled')) {
+ echo "twitterqueuehandler.php ";
+}
echo "facebookqueuehandler.php ";
echo "pingqueuehandler.php ";
-echo "smsqueuehandler.php ";
+if (common_config('sms', 'enabled')) {
+ echo "smsqueuehandler.php ";
+}