From bc02052b0e465bb816037743be5e238d70f7b10d Mon Sep 17 00:00:00 2001 From: Marton Kiss Date: Thu, 27 Aug 2015 20:15:03 +0200 Subject: [PATCH] Add ambassador application form Add an ambassador application form, registered users can apply to the position. The submit hook will save the registration form data to content management and invoke a notification message to ambassadors. Change-Id: Ia702ae80f44b1289c164dcca8e70f993b98c346f --- .../groups_ambassador.features.field_base.inc | 144 ++++++++ ...ups_ambassador.features.field_instance.inc | 311 ++++++++++++++++++ .../groups_ambassador.features.inc | 84 +++++ ...ps_ambassador.features.user_permission.inc | 49 +++ .../groups_ambassador/groups_ambassador.info | 46 +++ .../groups_ambassador.module | 24 ++ .../groups_ambassador.strongarm.inc | 110 +++++++ .../groups_ambassador.views_default.inc | 57 ++++ .../groups_ambassador/includes/apply.form.inc | 131 ++++++++ .../groups_ambassador_apply_confirm.tpl.php | 4 + 10 files changed, 960 insertions(+) create mode 100644 modules/groups/groups_ambassador/groups_ambassador.features.field_base.inc create mode 100644 modules/groups/groups_ambassador/groups_ambassador.features.field_instance.inc create mode 100644 modules/groups/groups_ambassador/groups_ambassador.features.user_permission.inc create mode 100644 modules/groups/groups_ambassador/includes/apply.form.inc create mode 100644 modules/groups/groups_ambassador/templates/groups_ambassador_apply_confirm.tpl.php diff --git a/modules/groups/groups_ambassador/groups_ambassador.features.field_base.inc b/modules/groups/groups_ambassador/groups_ambassador.features.field_base.inc new file mode 100644 index 0000000..7a147d1 --- /dev/null +++ b/modules/groups/groups_ambassador/groups_ambassador.features.field_base.inc @@ -0,0 +1,144 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_applicant', + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'base', + 'handler_settings' => array( + 'behaviors' => array( + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array(), + ), + 'target_type' => 'user', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + // Exported field_base: 'field_collaboration' + $field_bases['field_collaboration'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_collaboration', + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'text_long', + ); + + // Exported field_base: 'field_ideas' + $field_bases['field_ideas'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_ideas', + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'text_long', + ); + + // Exported field_base: 'field_participation' + $field_bases['field_participation'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_participation', + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'text_long', + ); + + // Exported field_base: 'field_reason' + $field_bases['field_reason'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_reason', + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'text_long', + ); + + // Exported field_base: 'field_region' + $field_bases['field_region'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_region', + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array( + 'max_length' => 255, + ), + 'translatable' => 0, + 'type' => 'text', + ); + + return $field_bases; +} diff --git a/modules/groups/groups_ambassador/groups_ambassador.features.field_instance.inc b/modules/groups/groups_ambassador/groups_ambassador.features.field_instance.inc new file mode 100644 index 0000000..9ebaa55 --- /dev/null +++ b/modules/groups/groups_ambassador/groups_ambassador.features.field_instance.inc @@ -0,0 +1,311 @@ + 'comment_node_ambassador_application', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 0, + ), + ), + 'entity_type' => 'comment', + 'field_name' => 'comment_body', + 'label' => 'Comment', + 'required' => TRUE, + 'settings' => array( + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 0, + ), + ); + + // Exported field_instance: 'node-ambassador_application-field_applicant' + $field_instances['node-ambassador_application-field_applicant'] = array( + 'bundle' => 'ambassador_application', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 0, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_applicant', + 'label' => 'Applicant', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 4, + ), + ); + + // Exported field_instance: 'node-ambassador_application-field_collaboration' + $field_instances['node-ambassador_application-field_collaboration'] = array( + 'bundle' => 'ambassador_application', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => 'Collaboration plans of the applicant.', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 5, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_collaboration', + 'label' => 'Collaboration', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 10, + ), + ); + + // Exported field_instance: 'node-ambassador_application-field_ideas' + $field_instances['node-ambassador_application-field_ideas'] = array( + 'bundle' => 'ambassador_application', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => 'New ideas of the applicant', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 4, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_ideas', + 'label' => 'Ideas', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 10, + ), + 'type' => 'text_textarea', + 'weight' => 9, + ), + ); + + // Exported field_instance: 'node-ambassador_application-field_participation' + $field_instances['node-ambassador_application-field_participation'] = array( + 'bundle' => 'ambassador_application', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => 'Level of the previous participation.', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 3, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_participation', + 'label' => 'Participation', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 8, + ), + ); + + // Exported field_instance: 'node-ambassador_application-field_reason' + $field_instances['node-ambassador_application-field_reason'] = array( + 'bundle' => 'ambassador_application', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => 'Reason of the application.', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_reason', + 'label' => 'Reason', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 10, + ), + 'type' => 'text_textarea', + 'weight' => 7, + ), + ); + + // Exported field_instance: 'node-ambassador_application-field_region' + $field_instances['node-ambassador_application-field_region'] = array( + 'bundle' => 'ambassador_application', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => 'Region where the application resides.', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 1, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_region', + 'label' => 'Region', + 'required' => 1, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'size' => 60, + ), + 'type' => 'text_textfield', + 'weight' => 6, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Applicant'); + t('Collaboration'); + t('Collaboration plans of the applicant.'); + t('Comment'); + t('Ideas'); + t('Level of the previous participation.'); + t('New ideas of the applicant'); + t('Participation'); + t('Reason'); + t('Reason of the application.'); + t('Region'); + t('Region where the application resides.'); + + return $field_instances; +} diff --git a/modules/groups/groups_ambassador/groups_ambassador.features.inc b/modules/groups/groups_ambassador/groups_ambassador.features.inc index 8071750..e94849a 100644 --- a/modules/groups/groups_ambassador/groups_ambassador.features.inc +++ b/modules/groups/groups_ambassador/groups_ambassador.features.inc @@ -22,3 +22,87 @@ function groups_ambassador_ctools_plugin_api($module = NULL, $api = NULL) { function groups_ambassador_views_api($module = NULL, $api = NULL) { return array("api" => "3.0"); } + +/** + * Implements hook_node_info(). + */ +function groups_ambassador_node_info() { + $items = array( + 'ambassador_application' => array( + 'name' => t('Ambassador application'), + 'base' => 'node_content', + 'description' => t('Holds the ambassador application data.'), + 'has_title' => '1', + 'title_label' => t('Title'), + 'help' => '', + ), + ); + drupal_alter('node_info', $items); + return $items; +} + +/** + * Implements hook_rdf_default_mappings(). + */ +function groups_ambassador_rdf_default_mappings() { + $schemaorg = array(); + + // Exported RDF mapping: ambassador_application + $schemaorg['node']['ambassador_application'] = array( + 'rdftype' => array( + 0 => 'sioc:Item', + 1 => 'foaf:Document', + ), + 'title' => array( + 'predicates' => array( + 0 => 'dc:title', + ), + ), + 'created' => array( + 'predicates' => array( + 0 => 'dc:date', + 1 => 'dc:created', + ), + 'datatype' => 'xsd:dateTime', + 'callback' => 'date_iso8601', + ), + 'changed' => array( + 'predicates' => array( + 0 => 'dc:modified', + ), + 'datatype' => 'xsd:dateTime', + 'callback' => 'date_iso8601', + ), + 'body' => array( + 'predicates' => array( + 0 => 'content:encoded', + ), + ), + 'uid' => array( + 'predicates' => array( + 0 => 'sioc:has_creator', + ), + 'type' => 'rel', + ), + 'name' => array( + 'predicates' => array( + 0 => 'foaf:name', + ), + ), + 'comment_count' => array( + 'predicates' => array( + 0 => 'sioc:num_replies', + ), + 'datatype' => 'xsd:integer', + ), + 'last_activity' => array( + 'predicates' => array( + 0 => 'sioc:last_activity_date', + ), + 'datatype' => 'xsd:dateTime', + 'callback' => 'date_iso8601', + ), + ); + + return $schemaorg; +} diff --git a/modules/groups/groups_ambassador/groups_ambassador.features.user_permission.inc b/modules/groups/groups_ambassador/groups_ambassador.features.user_permission.inc new file mode 100644 index 0000000..b26891d --- /dev/null +++ b/modules/groups/groups_ambassador/groups_ambassador.features.user_permission.inc @@ -0,0 +1,49 @@ + 'create ambassador_application content', + 'roles' => array(), + 'module' => 'node', + ); + + // Exported permission: 'delete any ambassador_application content'. + $permissions['delete any ambassador_application content'] = array( + 'name' => 'delete any ambassador_application content', + 'roles' => array(), + 'module' => 'node', + ); + + // Exported permission: 'delete own ambassador_application content'. + $permissions['delete own ambassador_application content'] = array( + 'name' => 'delete own ambassador_application content', + 'roles' => array(), + 'module' => 'node', + ); + + // Exported permission: 'edit any ambassador_application content'. + $permissions['edit any ambassador_application content'] = array( + 'name' => 'edit any ambassador_application content', + 'roles' => array(), + 'module' => 'node', + ); + + // Exported permission: 'edit own ambassador_application content'. + $permissions['edit own ambassador_application content'] = array( + 'name' => 'edit own ambassador_application content', + 'roles' => array(), + 'module' => 'node', + ); + + return $permissions; +} diff --git a/modules/groups/groups_ambassador/groups_ambassador.info b/modules/groups/groups_ambassador/groups_ambassador.info index 12305da..b5e0c25 100644 --- a/modules/groups/groups_ambassador/groups_ambassador.info +++ b/modules/groups/groups_ambassador/groups_ambassador.info @@ -6,7 +6,9 @@ version = 7.x-1.0 project = groups_ambassador dependencies[] = ds dependencies[] = groups_user_profile +dependencies[] = node dependencies[] = strongarm +dependencies[] = text dependencies[] = views features[ctools][] = ds:ds:1 features[ctools][] = strongarm:strongarm:1 @@ -15,7 +17,51 @@ features[ds_field_settings][] = user|user|profile_teaser features[ds_layout_settings][] = user|user|profile_teaser features[ds_view_modes][] = profile_teaser features[features_api][] = api:2 +features[field_base][] = field_applicant +features[field_base][] = field_collaboration +features[field_base][] = field_ideas +features[field_base][] = field_participation +features[field_base][] = field_reason +features[field_base][] = field_region +features[field_instance][] = comment-comment_node_ambassador_application-comment_body +features[field_instance][] = node-ambassador_application-field_applicant +features[field_instance][] = node-ambassador_application-field_collaboration +features[field_instance][] = node-ambassador_application-field_ideas +features[field_instance][] = node-ambassador_application-field_participation +features[field_instance][] = node-ambassador_application-field_reason +features[field_instance][] = node-ambassador_application-field_region +features[node][] = ambassador_application +features[schemaorg][] = node-ambassador_application +features[user_permission][] = create ambassador_application content +features[user_permission][] = delete any ambassador_application content +features[user_permission][] = delete own ambassador_application content +features[user_permission][] = edit any ambassador_application content +features[user_permission][] = edit own ambassador_application content +features[variable][] = additional_settings__active_tab_ambassador_application +features[variable][] = comment_ambassador_application +features[variable][] = comment_anonymous_ambassador_application +features[variable][] = comment_default_mode_ambassador_application +features[variable][] = comment_default_per_page_ambassador_application +features[variable][] = comment_form_location_ambassador_application +features[variable][] = comment_preview_ambassador_application +features[variable][] = field_bundle_settings_node__ambassador_application features[variable][] = field_bundle_settings_user__user +features[variable][] = language_content_type_ambassador_application +features[variable][] = node_options_ambassador_application +features[variable][] = node_preview_ambassador_application +features[variable][] = node_submitted_ambassador_application +features[variable][] = pathauto_node_ambassador_application_pattern +features[views_view][] = ambassador_applications features[views_view][] = groups_ambassador_list features_exclude[dependencies][ctools] = ctools +features_exclude[dependencies][commons_bw] = commons_bw +features_exclude[dependencies][date] = date +features_exclude[dependencies][entityreference] = entityreference +features_exclude[dependencies][features] = features +features_exclude[dependencies][metatag] = metatag +features_exclude[dependencies][rdf] = rdf +features_exclude[dependencies][schemaorg] = schemaorg +features_exclude[variable][comment_subject_field_ambassador_application] = comment_subject_field_ambassador_application +features_exclude[variable][menu_options_ambassador_application] = menu_options_ambassador_application +features_exclude[variable][menu_parent_ambassador_application] = menu_parent_ambassador_application no autodetect = 1 diff --git a/modules/groups/groups_ambassador/groups_ambassador.module b/modules/groups/groups_ambassador/groups_ambassador.module index 43d6a1b..e24cf0d 100644 --- a/modules/groups/groups_ambassador/groups_ambassador.module +++ b/modules/groups/groups_ambassador/groups_ambassador.module @@ -18,6 +18,13 @@ function groups_ambassador_menu() { 'access callback' => 'user_is_logged_in', 'file' => 'includes/ask.form.inc', ); + $items['ambassador-program/apply'] = array( + 'title' => 'OpenStack Ambassador Application', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('groups_ambassador_apply_form'), + 'access callback' => 'user_is_logged_in', + 'file' => 'includes/apply.form.inc', + ); return $items; } @@ -111,6 +118,10 @@ function groups_ambassador_theme() { 'template' => 'groups_ambassador_submission', 'variables' => array(), ), + 'groups_ambassador_apply_confirm' => $base + array( + 'template' => 'groups_ambassador_apply_confirm', + 'variables' => array(), + ), ); } @@ -128,4 +139,17 @@ function _groups_ambassador_get_ambassador_list() { $uids[] = $row->uid; } return user_load_multiple($uids); +} + +/** + * Convert standard user array into _privatemsg recipient format. + */ +function groups_ambassador_get_privatemsg_recipients($recipient_users) { + $recipients = array(); + foreach ($recipient_users as $user) { + $user->type = 'user'; + $user->recipient = $user->uid; + $recipients['user_'.$user->uid] = $user; + } + return $recipients; } \ No newline at end of file diff --git a/modules/groups/groups_ambassador/groups_ambassador.strongarm.inc b/modules/groups/groups_ambassador/groups_ambassador.strongarm.inc index ef0d61e..f23cdf3 100644 --- a/modules/groups/groups_ambassador/groups_ambassador.strongarm.inc +++ b/modules/groups/groups_ambassador/groups_ambassador.strongarm.inc @@ -10,6 +10,81 @@ function groups_ambassador_strongarm() { $export = array(); + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'additional_settings__active_tab_ambassador_application'; + $strongarm->value = 'edit-panelizer'; + $export['additional_settings__active_tab_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_ambassador_application'; + $strongarm->value = '1'; + $export['comment_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_ambassador_application'; + $strongarm->value = 0; + $export['comment_anonymous_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_ambassador_application'; + $strongarm->value = 1; + $export['comment_default_mode_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_ambassador_application'; + $strongarm->value = '50'; + $export['comment_default_per_page_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_ambassador_application'; + $strongarm->value = 1; + $export['comment_form_location_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_ambassador_application'; + $strongarm->value = '1'; + $export['comment_preview_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_node__ambassador_application'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array( + 'metatags' => array( + 'weight' => '3', + ), + 'title' => array( + 'weight' => '0', + ), + 'path' => array( + 'weight' => '2', + ), + 'redirect' => array( + 'weight' => '1', + ), + ), + 'display' => array(), + ), + ); + $export['field_bundle_settings_node__ambassador_application'] = $strongarm; + $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -60,5 +135,40 @@ function groups_ambassador_strongarm() { ); $export['field_bundle_settings_user__user'] = $strongarm; + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'language_content_type_ambassador_application'; + $strongarm->value = '0'; + $export['language_content_type_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_ambassador_application'; + $strongarm->value = array(); + $export['node_options_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_ambassador_application'; + $strongarm->value = '1'; + $export['node_preview_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_ambassador_application'; + $strongarm->value = 0; + $export['node_submitted_ambassador_application'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'pathauto_node_ambassador_application_pattern'; + $strongarm->value = 'ambassador-applicants/[node:nid]'; + $export['pathauto_node_ambassador_application_pattern'] = $strongarm; + return $export; } diff --git a/modules/groups/groups_ambassador/groups_ambassador.views_default.inc b/modules/groups/groups_ambassador/groups_ambassador.views_default.inc index 5644b99..06c24f0 100644 --- a/modules/groups/groups_ambassador/groups_ambassador.views_default.inc +++ b/modules/groups/groups_ambassador/groups_ambassador.views_default.inc @@ -10,6 +10,63 @@ function groups_ambassador_views_default_views() { $export = array(); + $view = new view(); + $view->name = 'ambassador_applications'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Ambassador applications'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Ambassador applications'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '5'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'ambassador_application' => 'ambassador_application', + ); + + /* Display: Block */ + $handler = $view->new_display('block', 'Block', 'block'); + $translatables['ambassador_applications'] = array( + t('Master'), + t('Ambassador applications'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Block'), + ); + $export['ambassador_applications'] = $view; + $view = new view(); $view->name = 'groups_ambassador_list'; $view->description = ''; diff --git a/modules/groups/groups_ambassador/includes/apply.form.inc b/modules/groups/groups_ambassador/includes/apply.form.inc new file mode 100644 index 0000000..21c2820 --- /dev/null +++ b/modules/groups/groups_ambassador/includes/apply.form.inc @@ -0,0 +1,131 @@ + theme('groups_ambassador_apply_confirm', array()), + ); + } else { + $form = _groups_ambassador_apply_form_build($form, $form_state); + } + return $form; +} + +/** + * Build Ambassador Application form elements + */ +function _groups_ambassador_apply_form_build($form, &$form_state) { + $form['region'] = array( + '#type' => 'textfield', + '#title' => t('Where do you reside'), + '#description' => t('Please enter one location as best you can. A helpful '. + 'way to think is where you will spend >6 months out of the next year'), + '#required' => TRUE, + ); + $form['reason'] = array( + '#type' => 'textarea', + '#title' => t('Why are you applying to become an OpenStack Ambassador?'), + '#description' => t('Tell us about your passion and your vision!'), + '#required' => TRUE, + '#resizable' => FALSE, + '#rows' => 10, + ); + $form['participation'] = array( + '#type' => 'textarea', + '#title' => t('How have you participated in the OpenStack Community to '. + 'date?'), + '#description' => t('Are you an ATC? Are you running User Groups? '. + 'Have you setup OpenStack Mini-confs? What\'s your track record...'), + '#required' => TRUE, + '#resizable' => FALSE, + '#rows' => 10, + ); + $form['ideas'] = array( + '#type' => 'textarea', + '#title' => t('What ideas do you have for your community, that you wish '. + 'you had time or resources to implement?'), + '#description' => t('We\'re practical people - do you have any concrete, '. + 'implementable ideas derived from that passion or vision above?'), + '#required' => TRUE, + '#resizable' => FALSE, + '#rows' => 10, + ); + $form['collaboration'] = array( + '#type' => 'textarea', + '#title' => t('How will you work with others to achieve your goals?'), + '#description' => t('A great leader doesn\'t work alone, and we\'re keen '. + 'for you to demonstrate how you intend to work with others both in your '. + 'local area and abroad.'), + '#required' => TRUE, + '#resizable' => FALSE, + '#rows' => 10, + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit'), + ); + return $form; +} + +/** + * Implements hook_form_submit() + */ +function groups_ambassador_apply_form_submit($form, &$form_state) { + $form_state['rebuild'] = TRUE; + $node = _groups_ambassador_create_application_node($form_state['values']); + _groups_ambassador_application_node_send_notification($node); +} + +/** + * Create a new ambassador application node entry. + */ +function _groups_ambassador_create_application_node($values) { + $current_user = user_uid_optional_load(); + $n = entity_create('node', array('type' => 'ambassador_application')); + $n->uid = $current_user->uid; + $node = entity_metadata_wrapper('node', $n); + $node->title = t('@name ambassador application - @date', + array( + '@name' => $current_user->name, + '@date' => date('m/d/Y', time()), + )); + $node->field_applicant->set($current_user->uid); + $node->field_region->set($values['region']); + $node->field_reason->set($values['reason']); + $node->field_participation->set($values['participation']); + $node->field_ideas->set($values['ideas']); + $node->field_collaboration->set($values['collaboration']); + $node->save(); + return $node; +} + +/** + * Send notification to ambassadors about new application. + */ +function _groups_ambassador_application_node_send_notification($node) { + $node_url = $GLOBALS['base_url'].'/'. + drupal_lookup_path('alias',"node/".$node->nid->value()); + + $current_user = user_uid_optional_load(); + $admin_user = user_load(1); + $ambassadors = _groups_ambassador_get_ambassador_list(); + $recipients = groups_ambassador_get_privatemsg_recipients($ambassadors); + $message = (object)array( + 'author' => $admin_user, + 'format' => 'filtered_html', + 'timestamp' => time(), + 'recipients' => $recipients, + 'has_tokens' => false, + ); + + $message->subject = t('[Ambassador] New ambassador application: @name', + array('@name' => $current_user->name)); + + $message->body = t('A new ambassador application has arrived.

'. + 'Check the link below for details:.
@url', + array('@url' => $node_url)); + $message = _privatemsg_send($message); +} \ No newline at end of file diff --git a/modules/groups/groups_ambassador/templates/groups_ambassador_apply_confirm.tpl.php b/modules/groups/groups_ambassador/templates/groups_ambassador_apply_confirm.tpl.php new file mode 100644 index 0000000..71da777 --- /dev/null +++ b/modules/groups/groups_ambassador/templates/groups_ambassador_apply_confirm.tpl.php @@ -0,0 +1,4 @@ +
+

Thank you for your Ambassador application.

+ +
\ No newline at end of file