diff --git a/commons.profile b/commons.profile index 64ecac7..e726d0a 100644 --- a/commons.profile +++ b/commons.profile @@ -13,3 +13,52 @@ function commons_form_install_configure_form_alter(&$form, $form_state) { // Pre-populate the site name with the server name. $form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME']; } + +/** + * Implements hook_install_tasks(). + * + * Allows the user to set a welcome message for anonymous users + */ +function commons_install_tasks() { + + return array( + 'commons_anonymous_message_homepage' => array( + 'display_name' => st('Anonymous front page text'), + 'display' => TRUE, + 'type' => 'form', + 'function' => 'commons_anonymous_welcome_text_form' + ) + ); +} + +/** + * Configuration form for set welcome text for anonymous users + */ +function commons_anonymous_welcome_text_form() { + $form['commons_anonymous_welcome_title'] = array( + '#type' => 'textfield', + '#title' => 'Anonymous front page title' + ); + + $form['commons_anonymous_welcome_body'] = array( + '#type' => 'textarea', + '#title' => 'Anonymous front page body' + ); + + $form['commons_anonymous_welcome_submit'] = array( + '#type' => 'submit', + '#value' => st('Save and continue') + ); + + return $form; +} + +/** + * Save the configuration form for set welcome text for anonymous users + * @see commons_anonymous_welcome_text_form() + */ +function commons_anonymous_welcome_text_form_submit($form_id, &$form_state) { + + variable_set('commons_anonymous_welcome_title', $form_state['values']['commons_anonymous_welcome_title']); + variable_set('commons_anonymous_welcome_body', $form_state['values']['commons_anonymous_welcome_body']); +}