From 1585150ba2d6c566a646a036d44cd5a07847a5f2 Mon Sep 17 00:00:00 2001 From: Marton Kiss Date: Tue, 16 Dec 2014 10:34:17 +0100 Subject: [PATCH] Update group registration form Simplify the group registration form, add scss and make the layout wizard-like. Change-Id: If5539e5da9083b6d181b0cc1198f5ba2a43527a8 --- .../groups/groups_groups/groups_groups.module | 106 ++++++++++++++++++ .../groups-groups--group-node-form.tpl.php | 25 +++++ .../partials/_group_node_form.scss | 30 +++++ .../custom-sass/style.scss | 1 + 4 files changed, 162 insertions(+) create mode 100644 modules/groups/groups_groups/templates/groups-groups--group-node-form.tpl.php create mode 100644 themes/openstack_bootstrap/custom-sass/partials/_group_node_form.scss diff --git a/modules/groups/groups_groups/groups_groups.module b/modules/groups/groups_groups/groups_groups.module index 1943e2f..6577ceb 100644 --- a/modules/groups/groups_groups/groups_groups.module +++ b/modules/groups/groups_groups/groups_groups.module @@ -75,3 +75,109 @@ function groups_groups_node_presave($node) { } } } + +/** + * Implements hook_theme() + * + * Define theme template for group node form. + */ +function groups_groups_theme() { + $path = drupal_get_path('module', 'groups_groups').'/templates'; + return array( + 'groups_groups_group_node_form' => array( + 'arguments' => array('form' => NULL), + 'template' => 'groups-groups--group-node-form', + 'render element' => 'form', + 'path' => $path, + ), + ); +} + +/** + * Implements hook_element_info_alter() + * + * Override filter_process_format. + * + * @see _groups_groups_set_default_format() + */ +function groups_groups_element_info_alter(&$type) { + if (isset($type['text_format']['#process'])) { + foreach ($type['text_format']['#process'] as &$callback) { + if ($callback === 'filter_process_format') { + $callback = '_groups_groups_set_default_format'; + } + } + } +} + +/** + * Callback to set body text format of group content type + * to markdown, and hide text filter form elements. + */ +function _groups_groups_set_default_format($element) { + // set body filter default to 'markdown' + $element = filter_process_format($element); + if (($element['#bundle'] == 'group') && ($element['#field_name'] == 'body')) { + // set default value to markdown + $element['format']['format']['#default_value'] = 'markdown'; + // hide text format filter + $element['format']['#access'] = FALSE; + } + return $element; +} + +/** + * Implements hook_form_alter(). + * + * Override group node form. + */ +function groups_groups_form_alter(&$form, &$form_state, $form_id) { + global $user; + if ($form_id == 'group_node_form') { + $node = $form_state['node']; + $is_administrator = in_array('administrator', array_values($user->roles)); + // hide group status field + $form['field_group_status']['#access'] = $is_administrator; + // hide location geofield + $form['field_geofield']['#access'] = $is_administrator; + // hide privacy settings field + $form['field_og_subscribe_settings']['#access'] = $is_administrator; + // hide group logo + $form['field_group_logo']['#access'] = false; + + $form['field_group_location']['und'][0]['location']['#title'] = 'City (optional)'; + // reorder resource links, group location + $form['field_resource_links']['#weight'] = 21; + $form['revision_information']['#access'] = $is_administrator; + $form['topics_wrapper']['#access'] = $is_administrator; + $form['actions']['preview']['#access'] = false; + if (!isset($node->nid) || isset($node->is_new)) { + $form['#theme'] = 'groups_groups_group_node_form'; + $form['actions']['submit']['#value'] = t('Register user group'); + $form['field_resource_links']['#access'] = false; + $form['accept_terms'] = array( + '#type' => 'checkbox', + '#title' => t('I have read and agree the !termsurl and !eventurl', array( + '!termsurl' => l(t('Terms and Conditions'), '#'), // TODO: specify url here + '!eventurl' => l(t('OpenStack Event Policy'), 'http://www.openstack.org/brand/event-policy/'), + )), + '#weight' => 22, + ); + $form['field_group_location']['und'][0]['#title'] = ''; + $form['title_field']['und'][0]['#title'] = 'Name of the User Group'; + $form['body']['und'][0]['#title'] = 'Tell a few words about your User Group'; + } + $form['#validate'][] = 'groups_groups_group_node_form_validate'; + } +} + +/** + * Group node form validate callback. + * + * Validate the Terms and Conditions checkbox status. + */ +function groups_groups_group_node_form_validate($form, &$form_state) { + if ((isset($form_state['values']['accept_terms'])) && ($form_state['values']['accept_terms'] != 1)) { + form_set_error('accept_terms', t('You must accept the Terms and Conditions.')); + } +} \ No newline at end of file diff --git a/modules/groups/groups_groups/templates/groups-groups--group-node-form.tpl.php b/modules/groups/groups_groups/templates/groups-groups--group-node-form.tpl.php new file mode 100644 index 0000000..8051371 --- /dev/null +++ b/modules/groups/groups_groups/templates/groups-groups--group-node-form.tpl.php @@ -0,0 +1,25 @@ + + +
+

Register your new OpenStack User Group in 3 easy steps, answer the simple questions. +We'll help you to establish your local community and join you into a world-wide network of +OpenStack User Group leaders.

+
+

What is your User Group's location?

+ + +

Share some basic information

+ + +

Accept Our Terms and Conditions

+ + + \ No newline at end of file diff --git a/themes/openstack_bootstrap/custom-sass/partials/_group_node_form.scss b/themes/openstack_bootstrap/custom-sass/partials/_group_node_form.scss new file mode 100644 index 0000000..5971935 --- /dev/null +++ b/themes/openstack_bootstrap/custom-sass/partials/_group_node_form.scss @@ -0,0 +1,30 @@ +.node-group-form { + // set question styles + h3 { + color: #2A4E68; + font-weight: 300; + margin-bottom: 25px; + margin-top: 20px; + text-align: left; + } + //highlight the terms and conditions links + a { + color: #30739C; + text-decoration: underline; + } + //set description textarea rows from stylesheet + .form-item-body-und-0-value textarea { + height: 5.8em; + line-height: 1.2em; + } +} + +.registration-lead { + font-size: 16px; + color: #888; + line-height: 1.4; + a { + color: #30739C; + text-decoration: underline; + } +} \ No newline at end of file diff --git a/themes/openstack_bootstrap/custom-sass/style.scss b/themes/openstack_bootstrap/custom-sass/style.scss index 4a45243..68ad940 100644 --- a/themes/openstack_bootstrap/custom-sass/style.scss +++ b/themes/openstack_bootstrap/custom-sass/style.scss @@ -14,6 +14,7 @@ @import 'partials/navbar'; @import 'partials/footer'; @import 'partials/social_icons'; +@import 'partials/group_node_form'; /* Custom override */