function invite_settings in Invite 5
Same name and namespace in other branches
- 5.2 invite.module \invite_settings()
- 6.2 invite_admin.inc \invite_settings()
- 7.2 invite.admin.inc \invite_settings()
Menu callback; display invite settings form.
Return value
A form definition array.
1 string reference to 'invite_settings'
- invite_menu in ./
invite.module - Implementation of hook_menu().
File
- ./
invite.module, line 304 - Allows your users to send and track invitations to join your site.
Code
function invite_settings() {
include drupal_get_path('module', 'invite') . '/invite_token.inc';
$roles = user_roles(0, 'send invitations');
if (count($roles) == 0) {
drupal_set_message(t('Please enable the <em>send invitations</em> permission for at least one role. This can be done on the <a href="!admin-user-access">Access control page</a>.', array(
'!admin-user-access' => url('admin/user/access'),
)));
}
$target_roles = user_roles(1);
// General settings
$form['general'] = array(
'#type' => 'fieldset',
'#title' => t('General settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['general']['invite_target_role_default'] = array(
'#type' => 'select',
'#title' => t('Default target role'),
'#default_value' => variable_get('invite_target_role_default', DRUPAL_AUTHENTICATED_RID),
'#options' => $target_roles,
'#description' => t('Choose the default role that invited users will be added to when they register. For example, <em>authenticated user</em>.'),
'#required' => TRUE,
);
$form['general']['invite_expiry'] = array(
'#type' => 'select',
'#title' => t('Invitation expiry'),
'#default_value' => variable_get('invite_expiry', 30),
'#options' => drupal_map_assoc(array(
1,
3,
7,
14,
30,
60,
)),
'#description' => t('Set the expiry period for user invitations, in days.'),
'#multiple' => FALSE,
'#required' => TRUE,
);
// Role settings
$form['role'] = array(
'#type' => 'fieldset',
'#title' => t('Role settings'),
'#description' => t('Note: Permission related settings can be found at the <a href="!admin-user-access">Access control page</a>.', array(
'!admin-user-access' => url('admin/user/access'),
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
foreach ($roles as $role) {
$role_no_space = str_replace(' ', '_', $role);
$form['role'][$role_no_space] = array(
'#type' => 'fieldset',
'#title' => t('@role settings', array(
'@role' => ucfirst($role),
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['role'][$role_no_space]['invite_target_role_' . $role_no_space] = array(
'#type' => 'select',
'#title' => t('Target role'),
'#default_value' => variable_get('invite_target_role_' . $role_no_space, DRUPAL_AUTHENTICATED_RID),
'#options' => $target_roles,
'#description' => t('You may choose to add invited users to another role (in addition to the default role set in the general section) when they have been invited by a member of %role.', array(
'%role' => $role,
)),
'#required' => TRUE,
);
$form['role'][$role_no_space]['invite_maxnum_' . $role_no_space] = array(
'#type' => 'select',
'#title' => t('Invitation limit'),
'#default_value' => variable_get('invite_maxnum_' . $role_no_space, INVITE_UNLIMITED_INVITES),
'#options' => array(
5 => 5,
10 => 10,
20 => 20,
50 => 50,
100 => 100,
500 => 500,
1000 => 1000,
INVITE_UNLIMITED_INVITES => t('unlimited'),
),
'#description' => t('Allows to limit the total number of invitations members of %role can send.', array(
'%role' => $role,
)),
'#multiple' => FALSE,
'#required' => TRUE,
);
}
// E-mail settings
$form['email'] = array(
'#type' => 'fieldset',
'#title' => t('E-mail settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['email']['invite_subject'] = array(
'#type' => 'textfield',
'#title' => t('Subject'),
'#default_value' => variable_get('invite_subject', t('[inviter-raw] has sent you an invite!')),
'#size' => 30,
'#maxlength' => 64,
'#description' => t('Type the default subject of the invitation e-mail.') . ' ' . t('Use the syntax [token] if you want to insert a replacement pattern.'),
'#required' => TRUE,
);
$form['email']['invite_subject_editable'] = array(
'#type' => 'checkbox',
'#title' => t('Editable subject'),
'#description' => t('Choose whether users should be able to customize the subject.'),
'#default_value' => variable_get('invite_subject_editable', FALSE),
);
$form['email']['invite_default_mail_template'] = array(
'#type' => 'textarea',
'#title' => t('Mail template'),
'#default_value' => _invite_get_mail_template(),
'#required' => TRUE,
'#description' => t('Use the syntax [token] if you want to insert a replacement pattern.'),
);
$form['email']['token_help'] = array(
'#title' => t('Replacement patterns'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['email']['token_help']['help'] = array(
'#value' => theme('invite_token_help', array(
'user',
'profile',
'invite',
)),
);
$form['email']['invite_use_users_email'] = array(
'#type' => 'radios',
'#title' => t('<em>From</em> e-mail address'),
'#description' => t('Choose which e-mail address will be in the From: header for the invitation mails sent; <em>site</em> or <em>inviter</em>. <em>Site</em> will use the default e-mail address of the site, whereas <em>inviter</em> will use the e-mail address of the user who is sending the invitation. Alternatively, you can set this value manually by clicking on <em>advanced settings</em> below.'),
'#options' => array(
t('site'),
t('inviter'),
),
'#default_value' => variable_get('invite_use_users_email', 0),
);
$form['email']['invite_use_users_email_replyto'] = array(
'#type' => 'radios',
'#title' => t('<em>Reply-To</em> e-mail address'),
'#description' => t('Choose which e-mail address will be in the Reply-To: header for the invitation mails sent; <em>site</em> or <em>inviter</em>. <em>Site</em> will use the default e-mail address of the site, whereas <em>inviter</em> will use the e-mail address of the user who is sending the invitation. Alternatively, you can set this value manually by clicking on <em>advanced settings</em> below.'),
'#options' => array(
t('site'),
t('inviter'),
),
'#default_value' => variable_get('invite_use_users_email_replyto', 0),
);
$form['email']['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('<strong>Note:</strong> unless these fields are blank, they will override the radio button choices above.'),
);
$form['email']['advanced']['invite_manual_from'] = array(
'#type' => 'textfield',
'#title' => t('Manually override <em>From</em> e-mail address'),
'#default_value' => variable_get('invite_manual_from', NULL),
'#description' => t('The e-mail address the invitation e-mail is sent from.'),
);
$form['email']['advanced']['invite_manual_reply_to'] = array(
'#type' => 'textfield',
'#title' => t('Manually override <em>Reply-To</em> e-mail address'),
'#default_value' => variable_get('invite_manual_reply_to', NULL),
'#description' => t('The e-mail address you want recipients to reply to.'),
);
// Invite page customization
$form['custom'] = array(
'#type' => 'fieldset',
'#title' => t('Invite page customization'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['custom']['invite_page_title'] = array(
'#type' => 'textfield',
'#title' => t('Invite page title'),
'#default_value' => variable_get('invite_page_title', t('Invite your friends and colleagues')),
'#description' => t('The title of the page where users invite friends.'),
'#required' => TRUE,
);
return system_settings_form($form);
}