View source
<?php
include_once 'panopoly_users.features.inc';
function panopoly_users_apps_app_info() {
return array(
'configure form' => 'panopoly_users_configure_form',
);
}
function panopoly_users_configure_form($form, &$form_state) {
$form = array();
$form['panopoly_users_login_destination'] = array(
'#title' => t('Login Destination'),
'#type' => 'textfield',
'#required' => TRUE,
'#default_value' => variable_get('panopoly_users_login_destination', '<front>'),
'#description' => t('Where do you want to redirect users when the login using the standard login link? Use <front> for the Drupal frontpage.'),
);
$form['panopoly_users_remove_tabs'] = array(
'#title' => t('Remove User Tabs'),
'#type' => 'select',
'#required' => TRUE,
'#options' => array(
0 => t('Do Not Remove'),
1 => t('Remove'),
),
'#default_value' => variable_get('panopoly_users_remove_tabs', 1),
'#description' => t('Do you want to remove the login, reset password, and register tabs on the user page? These links will be transferred into the relevant field descriptions instead.'),
);
return system_settings_form($form);
}
function panopoly_users_ctools_plugin_directory($module, $plugin) {
return 'plugins/' . $plugin;
}
function panopoly_users_menu_alter(&$items) {
if (variable_get('panopoly_users_remove_tabs', TRUE)) {
$items['user/login']['type'] = MENU_CALLBACK;
$items['user/register']['type'] = MENU_CALLBACK;
$items['user/password']['type'] = MENU_CALLBACK;
}
}
function panopoly_users_form_alter(&$form, $form_state, $form_id) {
if (variable_get('panopoly_users_remove_tabs', TRUE)) {
if ($form_id == 'user_login' && variable_get('user_register')) {
$form['name']['#description'] .= '<br />' . t("If you don't have an username, !create.", array(
'!create' => l(t("create an account"), 'user/register'),
));
}
if ($form_id == 'user_login') {
$form['pass']['#description'] .= '<br />' . t('If you forgot your password, !request.', array(
'!request' => l(t('request a new password'), 'user/password'),
));
}
}
}
function panopoly_users_form_user_admin_settings_alter(&$form, &$form_state) {
$hidden_fields = array(
'user_picture_path',
'user_picture_dimensions',
'user_picture_file_size',
'user_picture_guidelines',
);
foreach ($hidden_fields as $name) {
$form['personalization']['pictures'][$name]['#access'] = FALSE;
}
}
function panopoly_users_user_login(&$edit, $account) {
$edit['redirect'] = variable_get('panopoly_users_login_destination', '<front>');
}