Adds $config['invite']['enabled'] to enable/disable invites.

The invite function may not applicable for private and/or closed installs. This adds a configuration option to enable/disable invites (defaulting to enabled), hides the "Invite" nav item when necessary, and adds a check to actions/invite.php.

Note that I haven't tried the Facebook application so I didn't add any checks to actions/facebookinvite.php.
This commit is contained in:
Jeffery To 2009-06-14 16:17:22 +08:00
parent 77c94c44a6
commit 6d308f6ffe
8 changed files with 38 additions and 18 deletions

7
README
View File

@ -1067,6 +1067,13 @@ debug: if turned on, this will make the XMPP library blurt out all of
public: an array of JIDs to send _all_ notices to. This is useful for
participating in third-party search and archiving services.
invite
------
For configuring invites.
enabled: Whether to allow users to send invites. Default true.
tag
---

View File

@ -35,7 +35,9 @@ class InviteAction extends Action
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
if (!common_config('invite', 'enabled')) {
$this->clientError(_('Invites have been disabled.'));
} else if (!common_logged_in()) {
$this->clientError(sprintf(_('You must be logged in to invite other users to use %s'),
common_config('site', 'name')));
return;

View File

@ -86,6 +86,9 @@ $config['sphinx']['port'] = 3312;
// $config['xmpp']['public'][] = 'someindexer@example.net';
// $config['xmpp']['debug'] = false;
// Turn off invites
// $config['invite']['enabled'] = false;
// Default locale info
// $config['site']['timezone'] = 'Pacific/Auckland';
// $config['site']['language'] = 'en_NZ';

View File

@ -422,11 +422,13 @@ class Action extends HTMLOutputter // lawsuit
$this->menuItem(common_local_url('smssettings'),
_('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect');
}
$this->menuItem(common_local_url('invite'),
_('Invite'),
sprintf(_('Invite friends and colleagues to join you on %s'),
common_config('site', 'name')),
false, 'nav_invitecontact');
if (common_config('invite', 'enabled')) {
$this->menuItem(common_local_url('invite'),
_('Invite'),
sprintf(_('Invite friends and colleagues to join you on %s'),
common_config('site', 'name')),
false, 'nav_invitecontact');
}
$this->menuItem(common_local_url('logout'),
_('Logout'), _('Logout from the site'), false, 'nav_logout');
}

View File

@ -130,6 +130,8 @@ $config =
'host' => null, # only set if != server
'debug' => false, # print extra debug info
'public' => array()), # JIDs of users who want to receive the public stream
'invite' =>
array('enabled' => true),
'sphinx' =>
array('enabled' => false,
'server' => 'localhost',

View File

@ -213,12 +213,14 @@ class FacebookAction extends Action
array('href' => 'index.php', 'title' => _('Home')), _('Home'));
$this->elementEnd('li');
$this->elementStart('li',
array('class' =>
($this->action == 'facebookinvite') ? 'current' : 'facebook_invite'));
$this->element('a',
array('href' => 'invite.php', 'title' => _('Invite')), _('Invite'));
$this->elementEnd('li');
if (common_config('invite', 'enabled')) {
$this->elementStart('li',
array('class' =>
($this->action == 'facebookinvite') ? 'current' : 'facebook_invite'));
$this->element('a',
array('href' => 'invite.php', 'title' => _('Invite')), _('Invite'));
$this->elementEnd('li');
}
$this->elementStart('li',
array('class' =>

View File

@ -100,7 +100,7 @@ class SubGroupNav extends Widget
$this->user->nickname),
$action == 'usergroups',
'nav_usergroups');
if (!is_null($cur) && $this->user->id === $cur->id) {
if (common_config('invite', 'enabled') && !is_null($cur) && $this->user->id === $cur->id) {
$this->out->menuItem(common_local_url('invite'),
_('Invite'),
sprintf(_('Invite friends and colleagues to join you on %s'),

View File

@ -200,11 +200,13 @@ class FBConnectPlugin extends Plugin
$action->menuItem(common_local_url('smssettings'),
_('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect');
}
$action->menuItem(common_local_url('invite'),
_('Invite'),
sprintf(_('Invite friends and colleagues to join you on %s'),
common_config('site', 'name')),
false, 'nav_invitecontact');
if (common_config('invite', 'enabled')) {
$action->menuItem(common_local_url('invite'),
_('Invite'),
sprintf(_('Invite friends and colleagues to join you on %s'),
common_config('site', 'name')),
false, 'nav_invitecontact');
}
// Need to override the Logout link to make it do FB stuff
if ($flink && $fbuid > 0) {