diff --git a/profiles/wcm_base/CHANGELOG.txt b/profiles/wcm_base/CHANGELOG.txt index da973bd6690caa88063d526b12cc1733cd4d9704..755927e04b11a3b5dd547b9ac67878acd4bb7eaf 100644 --- a/profiles/wcm_base/CHANGELOG.txt +++ b/profiles/wcm_base/CHANGELOG.txt @@ -1,3 +1,8 @@ +WCM Base 7.x-1.11-rc3, 2019-02-04 +--------------------------------- +- WCM Base: Patched SMTP module to fix errors on webforms with multiple recipients. +- WCM News Client: Updated metatag settings to be enabled by default. + WCM Base 7.x-1.11-rc2, 2019-01-24 --------------------------------- - WCM Base: Updated Panopoly to 1.60 per SA-CONTRIB-2019-004. diff --git a/profiles/wcm_base/modules/contrib/smtp/PATCHES.txt b/profiles/wcm_base/modules/contrib/smtp/PATCHES.txt index 0a6e5579f075e3dd208653c63d1b08cfbccac1c3..24e25e7a1a6ab23b3174b7e34c3414149689a106 100644 --- a/profiles/wcm_base/modules/contrib/smtp/PATCHES.txt +++ b/profiles/wcm_base/modules/contrib/smtp/PATCHES.txt @@ -1,4 +1,5 @@ The following patches have been applied to this project: - https://www.drupal.org/files/issues/2018-11-13/smtp-filepath_uri-2966816-27-D7_0.patch +- https://www.drupal.org/files/issues/2018-06-04/2753115-41-smtp-multiple-to-addresses-error.patch This file was automatically generated by Drush Make (http://drupal.org/project/drush). diff --git a/profiles/wcm_base/modules/contrib/smtp/smtp.mail.inc b/profiles/wcm_base/modules/contrib/smtp/smtp.mail.inc index 69617f6fce0e0c23407406c8bf61f9c82b7923b3..f2a5d5e4bb034e50c858d4ad9dfe02e23211e816 100644 --- a/profiles/wcm_base/modules/contrib/smtp/smtp.mail.inc +++ b/profiles/wcm_base/modules/contrib/smtp/smtp.mail.inc @@ -765,6 +765,7 @@ class SmtpMailSystem implements MailSystemInterface { * An array containing a name and an email address. */ protected function _get_components($input) { + $input = trim($input); $components = array( 'input' => $input, 'name' => '', @@ -774,7 +775,7 @@ class SmtpMailSystem implements MailSystemInterface { // If the input is a valid email address in its entirety, then there is // nothing to do, just return that. if (valid_email_address($input)) { - $components['email'] = trim($input); + $components['email'] = $input; return $components; } diff --git a/profiles/wcm_base/modules/contrib/smtp/tests/smtp.unit.test b/profiles/wcm_base/modules/contrib/smtp/tests/smtp.unit.test index 88f9ad4a64a5be29775680c2eed0a77c5850ed49..64a63634b09fc8b1a28e3d6f9ec5db9b3f02b8b3 100644 --- a/profiles/wcm_base/modules/contrib/smtp/tests/smtp.unit.test +++ b/profiles/wcm_base/modules/contrib/smtp/tests/smtp.unit.test @@ -165,6 +165,50 @@ class SmtpUnitTest extends DrupalWebTestCase { $this->assertEqual($queue_count, 0, 'An email was not found in the failure queue.'); } + /** + * Tests email address parsing. + */ + public function testAddressParsing() { + $mail_sytem = new class() extends SmtpMailSystem { + + /** + * Exposes the protected _get_components method, returning an array of name and email address from a string. + * + * @param $input + * A string that contains different possible combinations of names and + * email address. + * @return + * An array containing a name and an email address. + */ + public function getComponents($input) { + return $this->_get_components($input); + } + + }; + + $valid_addresses = array( + 'to_test@example.com', + 'to_test@example.com,to_test2@example.com', + 'to_test@example.com, to_test2@example.com', + ); + + foreach ($valid_addresses as $address) { + $recipients = explode(',', $address); + foreach ($recipients as $recipient) { + // We create a new PHPMailer instance for each recipient so errors can be cleared out. + $mailer = new PHPMailer(); + $components = $mail_sytem->getComponents($recipient); + $this->assertTrue(strlen($components['email']) > 0, format_string('Parsing address "%address" resulted in a non-zero length value', array( + '%address' => $components['email'], + ))); + $mailer->AddAddress($components['email'], $components['name']); + $this->assertFalse($mailer->IsError(), format_string('PHPMailer has no errors for address "%address"', array( + '%address' => $components['email'], + ))); + } + } + } + /** * Gets the latest Maillog entry. * diff --git a/profiles/wcm_base/modules/custom/news_client/news_client.metatag.inc b/profiles/wcm_base/modules/custom/news_client/news_client.metatag.inc new file mode 100644 index 0000000000000000000000000000000000000000..b99847f657e0c6894f26314198078a550d4c1f86 --- /dev/null +++ b/profiles/wcm_base/modules/custom/news_client/news_client.metatag.inc @@ -0,0 +1,48 @@ +<?php +/** + * @file news_client.metatag.inc + * Defines metatag defaults for news_client. + */ + + +/** + * Implements hook_metatag_config_default(). + */ +function news_client_metatag_config_default() { + $configs = array(); + + $config = new stdClass(); + $config->disabled = FALSE; /* Edit this to true to make a default config disabled initially */ + $config->api_version = 1; + $config->instance = 'node:news_client_cached_article'; + $config->config = array( + 'description' => array( + 'value' => '[node:news_client_body_summary]', + ), + 'image_src' => array( + 'value' => '[node:news_client_social_image_url]', + ), + 'og:description' => array( + 'value' => '[node:news_client_body_summary]', + ), + 'og:image' => array( + 'value' => '[node:news_client_social_image_url]', + ), + 'twitter:card' => array( + 'value' => 'summary_large_image', + ), + 'twitter:description' => array( + 'value' => '[node:news_client_body_summary]', + ), + 'twitter:image' => array( + 'value' => '[node:news_client_social_image_url]', + ), + 'twitter:image:alt' => array( + 'value' => '[node:news_client_social_image_alt]', + ), + ); + + $configs[$config->instance] = $config; + + return $configs; +} diff --git a/profiles/wcm_base/modules/custom/news_client/news_client.module b/profiles/wcm_base/modules/custom/news_client/news_client.module index dffab8fefb865024524dcad4f3721bcec7e8609a..73e05ba6265b035f9a3b4a3f3cede3fa2d8da5e3 100644 --- a/profiles/wcm_base/modules/custom/news_client/news_client.module +++ b/profiles/wcm_base/modules/custom/news_client/news_client.module @@ -25,6 +25,15 @@ function news_client_views_api() { ); } +/** + * Implements hook_ctools_plugin_api(). + */ +function news_client_ctools_plugin_api($owner, $api) { + if ($owner == 'metatag' && $api == 'metatag') { + return array('version' => 1); + } +} + /** * Implements hook_views_data(). */ diff --git a/profiles/wcm_base/modules/custom/ocio_simplesamlphp_auth/ocio_simplesamlphp_auth.module b/profiles/wcm_base/modules/custom/ocio_simplesamlphp_auth/ocio_simplesamlphp_auth.module index fca1b80a205843c2442947c866afc7e4fa14368b..dc9266dbc4f940fb7e81107c215ba3018df24b7b 100644 --- a/profiles/wcm_base/modules/custom/ocio_simplesamlphp_auth/ocio_simplesamlphp_auth.module +++ b/profiles/wcm_base/modules/custom/ocio_simplesamlphp_auth/ocio_simplesamlphp_auth.module @@ -1,7 +1,8 @@ <?php /** - * @file Main module file for the ocio_simplesamlphp_auth module + * @file + * Main module file for the ocio_simplesamlphp_auth module. */ include_once 'ocio_simplesamlphp_auth.features.inc'; @@ -18,7 +19,7 @@ function ocio_simplesamlphp_auth_permission() { } /** - * Implements hook_entity_info + * Implements hook_entity_info(). */ function ocio_simplesamlphp_auth_entity_info() { $return['ocio_simplesamlphp_auth_whitelist'] = array( @@ -50,7 +51,7 @@ function ocio_simplesamlphp_auth_whitelist_form_access($op, $profile = NULL, $ac } /** - * custom page to display login blocked message + * Custom page to display login blocked message. */ function ocio_simplesamlphp_auth_login_blocked_msg() { $content['raw_markup'] = array( @@ -61,7 +62,7 @@ function ocio_simplesamlphp_auth_login_blocked_msg() { } /** - * form for authmap fix utility + * Form for authmap fix utility. */ function ocio_simplesamlphp_auth_authmap_fix_form($form, &$form_state) { $form['simplesamlphp_auth_authmapfix'] = array( @@ -73,14 +74,16 @@ function ocio_simplesamlphp_auth_authmap_fix_form($form, &$form_state) { ); $form['simplesamlphp_auth_authmapfix']['infoblob'] = array( '#type' => 'item', - '#description' => 'This utitliy will search for registered users and set their authmap entry to authenticate using the simepleSAMLphp_auth module. This is useful for updating a site with existing users that previously authenticated through a local Drupal account.' + '#description' => 'This utitliy will search for registered users and set their authmap entry + to authenticate using the simepleSAMLphp_auth module. This is useful for updating a site with + existing users that previously authenticated through a local Drupal account.', ); $form['simplesamlphp_auth_authmapfix']['authmapfix_search_string'] = array( '#type' => 'textfield', '#title' => 'Search String', '#required' => TRUE, '#description' => 'Full or partical username to search for and update/insert authmap entry.', - '#default_value' => 'osu.edu' + '#default_value' => 'osu.edu', ); $form['simplesamlphp_auth_authmapfix']['authmap_submit'] = array( '#type' => 'submit', @@ -90,17 +93,17 @@ function ocio_simplesamlphp_auth_authmap_fix_form($form, &$form_state) { } /** - * submit handler for authmap fix utility + * Submit handler for authmap fix utility. */ function ocio_simplesamlphp_auth_authmap_fix_form_submit($form, &$form_state) { - if(isset($form_state['values']['authmapfix_search_string'])) { + if (isset($form_state['values']['authmapfix_search_string'])) { _ocio_simplesamlphp_auth_fix_authmap($form_state['values']['authmapfix_search_string']); } return $form; } /** - * Implements hook_menu() + * Implements hook_menu(). */ function ocio_simplesamlphp_auth_menu() { $items = array(); @@ -121,24 +124,25 @@ function ocio_simplesamlphp_auth_menu() { } /** - * Implements hook_menu_alter() + * Implements hook_menu_alter(). */ function ocio_simplesamlphp_auth_menu_alter(&$items) { - // add tab placeholder + // Add tab placeholder. $items['admin/config/people/simplesamlphp_auth']['type'] = MENU_NORMAL_ITEM; $items['admin/config/people/simplesamlphp_auth/general']['type'] = MENU_DEFAULT_LOCAL_TASK; $items['admin/config/people/simplesamlphp_auth/general']['title'] = 'SimpleSAMLphp Auth Settings'; - // whitelist entity form as tab + // Whitelist entity form as tab. $items['admin/config/people/simplesamlphp_auth/ocio_simplesamlphp_auth_whitelist']['type'] = MENU_LOCAL_TASK; $items['admin/config/people/simplesamlphp_auth/ocio_simplesamlphp_auth_whitelist']['title'] = 'Whitelist'; } /** - * Implements hook_form_FORM_ID_alter() - * FORM_ID = simplesamlphp_auth_settings + * Implements hook_form_FORM_ID_alter(). + * + * FORM_ID = simplesamlphp_auth_settings. */ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_alter(&$form, &$form_state) { - // check for pantheon environment; display path if found + // Check for pantheon environment; display path if found. $pantheon_environment = _ocio_simplesamlphp_auth_get_pantheon_env(); $path_note = ''; if ($pantheon_environment) { @@ -146,12 +150,12 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_alter(&$form, $path_note = '</br>Pantheon environment detected (' . $pantheon_environment . '). ' . $envPath . ' will be prepended to your path.'; } - // hide the automatic role population section as it can cause problems with shibboleth auth + // Hide the automatic role population section to avoid conflicts. $form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_rolepopulation']['#access'] = FALSE; $form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_roleevaleverytime']['#access'] = FALSE; - - // -- -- alter user provisioning section - // default role setting + + // -- -- Alter user provisioning section. + // Default role setting. $form['simplesamlphp_auth_grp_reg']['ocio_simplesamlphp_auth_default_role_id'] = array( '#title' => 'Default Role', '#description' => 'The default role to assign auto-provisioned users.', @@ -165,7 +169,7 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_alter(&$form, 'disabled' => array(':input[name="ocio_simplesamlphp_auth_whitelist_only"]' => array('checked' => TRUE)), ), ); - // whitelist restriction + // Whitelist restriction. $form['simplesamlphp_auth_grp_reg']['ocio_simplesamlphp_auth_whitelist_only'] = array( '#type' => 'checkbox', '#title' => 'Restrict to Whitelisted Users', @@ -176,7 +180,7 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_alter(&$form, 'visible' => array(':input[name="simplesamlphp_auth_registerusers"]' => array('checked' => TRUE)), ), ); - // custom login blocked message + // Custom login blocked message. $form['simplesamlphp_auth_grp_reg']['ocio_simplesamlphp_auth_login_block_msg'] = array( '#type' => 'textarea', '#title' => 'Blocked Message', @@ -188,14 +192,14 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_alter(&$form, ), ); - // -- -- create metadata refresh section + // -- -- Create metadata refresh section. $form['metadata_refresh'] = array( '#type' => 'fieldset', '#title' => 'Metadata Refresh', '#collapsible' => TRUE, '#collapsed' => TRUE, ); - // cron key + // Cron key setting. $form['metadata_refresh']['ocio_simplesamlphp_auth_cron_key'] = array( '#type' => 'textfield', '#title' => t('Cron Access Key'), @@ -205,7 +209,7 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_alter(&$form, '#description' => t('Cron access key for simpleSAMLphp.'), '#required' => TRUE, ); - // cron path + // Cron path setting. $form['metadata_refresh']['ocio_simplesamlphp_auth_cron_path'] = array( '#type' => 'textfield', '#title' => t('Cron Path'), @@ -215,17 +219,17 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_alter(&$form, '#description' => t('Path to simpleSAMLphp cron.php.'), '#required' => TRUE, ); - // metadata path + // Metadata path setting. $form['metadata_refresh']['ocio_simplesamlphp_auth_metadata_path'] = array( '#type' => 'textfield', '#title' => t('IDP Metadata File Path'), '#default_value' => variable_get('ocio_simplesamlphp_auth_metadata_path', 'sites/default/files/private/simplesamlphp/metadata/'), '#size' => 50, '#maxlength' => 100, - '#description' => t('Path to IDP metadata files.' . $path_note), + '#description' => t('Path to IDP metadata files. @path_note', array('@path_note' => $path_note)), '#required' => TRUE, ); - // metadata files + // Metadata files setting. $form['metadata_refresh']['ocio_simplesamlphp_auth_metadata_files'] = array( '#type' => 'textfield', '#title' => t('IDP Metadata Files'), @@ -236,53 +240,60 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_alter(&$form, '#required' => TRUE, ); - // -- -- create require login section + // -- -- Create require login section. $form['require_login'] = array( '#type' => 'fieldset', '#title' => 'Require Login', '#collapsible' => TRUE, '#collapsed' => TRUE, ); - // enable checkbox + // Enable checkbox. $form['require_login']['ocio_simplesamlphp_auth_require_login_enabled'] = array( '#type' => 'checkbox', '#title' => t('Require Login'), '#description' => t('Require all users to login to access this site.'), '#default_value' => variable_get('ocio_simplesamlphp_auth_require_login_enabled', 0), ); - // login path + // Login path. $form['require_login']['ocio_simplesamlphp_auth_require_login_auth_path'] = array( '#type' => 'textfield', '#title' => t('User Login Path'), '#description' => t('Relative login redirect path for anonymous users.'), '#default_value' => variable_get('ocio_simplesamlphp_auth_require_login_auth_path', '/saml_login'), ); - // require login message + // Require login message. $form['require_login']['ocio_simplesamlphp_auth_require_login_msg'] = array( '#type' => 'textarea', '#title' => t('Blocked Message'), '#description' => t('Message to display when user is required to login.'), '#default_value' => variable_get('ocio_simplesamlphp_auth_login_required_msg', 'You must log in to use this site.'), - ); - // excluded paths + ); + // Excluded paths. $excludeInstructions = array( t('Use <front> to exclude the front page.'), t('Use relative path to exclude content and other internal Drupal pages. <em>Example: /about/contact</em>'), t('Use absolute path to exclude Drupal bootstrap enabled PHP scripts. <em>Example: /path/to/drupal/script/filename.php</em>'), ); + $themedExcludeInstructions = theme('item_list', array('items' => $excludeInstructions)); $form['require_login']['ocio_simplesamlphp_auth_require_login_excluded_paths'] = array( '#type' => 'textarea', '#title' => t('Excluded Paths'), - '#description' => t('Use the excluded paths setting to disable user authentication in specific areas. Enter one exclusion per line using the following formats:') . - theme('item_list', array('items' => $excludeInstructions)), + '#description' => t( + 'Use the excluded paths setting to disable user authentication in specific areas. + Enter one exclusion per line using the following formats: @list', + array('@list' => $themedExcludeInstructions) + ), '#default_value' => variable_get('ocio_simplesamlphp_auth_require_login_excluded_paths', ''), ); } -function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_validate($form, &$form_state) -{ +/** + * Implements hook_form_FORM_ID_alter(). + * + * FORM_ID = simplesamlphp_auth_settings. + */ +function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_validate($form, &$form_state) { $absolutes = array(); - // Add leading slash to paths (except for <front>). Trims extra whitespace // and prepares exclusions for saving. $exclude_paths = explode(PHP_EOL, $form_state['values']['ocio_simplesamlphp_auth_require_login_excluded_paths']); @@ -299,8 +310,8 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_validate($form } // Confirm leading forward slash presence. - else if (substr($exclude_path, 0, 1) != '/') { - $exclude_paths[$key] = '/'. $exclude_path; + elseif (substr($exclude_path, 0, 1) != '/') { + $exclude_paths[$key] = '/' . $exclude_path; } // Trim unnecessary whitespace from ends. @@ -312,9 +323,13 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_validate($form // Throw error if absolute paths were detected. if ($absolutes) { - form_set_error('require_login_excluded_paths', t('Excluded paths shouldn\'t include protocol or domain name. Invalid paths:<br />!paths', array( - '!paths' => implode('<br />', $absolutes), - ))); + form_set_error( + 'require_login_excluded_paths', + t( + "Excluded paths shouldn't include protocol or domain name. Invalid paths:<br />@paths", + array('@paths' => implode('<br />', $absolutes)) + ) + ); } // Add leading slash to user login path. Trims extra whitespace and prepares @@ -329,8 +344,8 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_validate($form } // Confirm leading forward slash presence. - else if (substr($auth_path, 0, 1) != '/') { - $form_state['values']['ocio_simplesamlphp_auth_require_login_auth_path'] = '/'. $auth_path; + elseif (substr($auth_path, 0, 1) != '/') { + $form_state['values']['ocio_simplesamlphp_auth_require_login_auth_path'] = '/' . $auth_path; } // Trim unnecessary whitespace from ends. @@ -341,62 +356,64 @@ function ocio_simplesamlphp_auth_form_simplesamlphp_auth_settings_validate($form } /** - * Implements hook_form_FORM_ID_alter - * FORM_ID = user_register_form + * Implements hook_form_FORM_ID_alter(). + * + * FORM_ID = user_register_form. */ function ocio_simplesamlphp_auth_form_user_register_form_alter(&$form, &$form_state) { - // weight mail and pass inputs so we can order new inputs + // Weight mail and pass inputs so we can order new inputs. $form['account']['mail']['#weight'] = -9; $form['account']['pass']['#weight'] = -8; - // add authentication method option to profile form - if (user_access('administer simpleSAMLphp authentication') || user_access('change user authentication type')) { - $authOptions = array('drupal' => t('Drupal'), 'simplesamlphp' => 'SimpleSAML'); - $form['account']['authenticationType']= array( - '#type' => 'radios', - '#title' => t('Authentication Method'), - '#description' => t('Select the method that this user will use to authenticate.'), - '#required' => TRUE, - '#options' => $authOptions, - '#default_value' => 'simplesamlphp', - '#weight' => -7, - ); - } - // add whitelist check to registration validation + // Add authentication method option to profile form. + if (user_access('administer simpleSAMLphp authentication') || user_access('change user authentication type')) { + $authOptions = array('drupal' => t('Drupal'), 'simplesamlphp' => 'SimpleSAML'); + $form['account']['authenticationType'] = array( + '#type' => 'radios', + '#title' => t('Authentication Method'), + '#description' => t('Select the method that this user will use to authenticate.'), + '#required' => TRUE, + '#options' => $authOptions, + '#default_value' => 'simplesamlphp', + '#weight' => -7, + ); + } + // Add whitelist check to registration validation. $form['#validate'][] = 'ocio_simplesamlphp_auth_registration_form_whitelist_validate'; } /** - * Implements hook_form_FORM_ID_alter - * FORM_ID = user_profile_form + * Implements hook_form_FORM_ID_alter(). + * + * FORM_ID = user_profile_form. */ function ocio_simplesamlphp_auth_form_user_profile_form_alter(&$form, &$form_state) { - // check for authmap entry; set form default value for field + // Check for authmap entry; set form default value for field. $hasAuthmap = _ocio_simplesamlphp_auth_has_authmap($form['account']['name']['#default_value']); $authenticationType = $hasAuthmap ? 'simplesamlphp' : 'drupal'; - // weight mail and pass inputs so we can order new inputs + // Weight mail and pass inputs so we can order new inputs. $form['account']['mail']['#weight'] = -9; $form['account']['pass']['#weight'] = -8; $form['account']['pass']['#access'] = TRUE; - // disable username and email address for simplesaml users + // Disable username and email address for simplesaml users. if ($authenticationType == 'simplesamlphp') { $form['account']['name']['#disabled'] = TRUE; $form['account']['name']['#description'] = 'Username can not be changed for users authenticating via SimpleSAML.'; $form['account']['mail']['#disabled'] = TRUE; $form['account']['mail']['#description'] = 'Email can not be changed for users authenticating via SimpleSAML.'; - // Allow saml users to set password if global setting allows + // Allow saml users to set password if global setting allows. $password_access = variable_get('simplesamlphp_auth_allowsetdrupalpwd'); $form['account']['pass']['#access'] = $password_access; $form['account']['current_pass']['#access'] = $password_access; } - // add authentication method option to profile form + // Add authentication method option to profile form. if (user_access('administer simpleSAMLphp authentication') || user_access('change user authentication type')) { $authOptions = array('drupal' => t('Drupal'), 'simplesamlphp' => 'SimpleSAML'); - $form['account']['authenticationType']= array( + $form['account']['authenticationType'] = array( '#type' => 'radios', '#title' => t('Authentication Method'), '#description' => t('Select the method that this user will use to authenticate.'), @@ -409,15 +426,16 @@ function ocio_simplesamlphp_auth_form_user_profile_form_alter(&$form, &$form_sta } /** - * Implements hook_form_FORM_ID_alter - * FORM_ID = user_cancel_confirm_form + * Implements hook_form_FORM_ID_alter(). + * + * FORM_ID = user_cancel_confirm_form. */ function ocio_simplesamlphp_auth_form_user_cancel_confirm_form_alter(&$form, &$form_state) { - // get whitelist entry + // Get whitelist entry. $whitelist_entry = _ocio_simplesamlphp_auth_get_whitelist_entry($form['_account']['#value']->name); - // has whitelist entry; add elements to form + // Has whitelist entry; add elements to form. if (isset($whitelist_entry->wid)) { - // weight the existing form elements so we can control order + // Weight the existing form elements so we can control order. $form['user_cancel_method']['#weight'] = -10; $form['user_cancel_confirm']['#weight'] = -7; $form['user_cancel_notify']['#weight'] = -7; @@ -428,7 +446,8 @@ function ocio_simplesamlphp_auth_form_user_cancel_confirm_form_alter(&$form, &$f '#weight' => -8, '#attributes' => array('checked' => 'checked'), ); - // hook_user_delete doesn't get passed confirm form values so add submit handler to this form to catch whitelist delete requests + // Hook_user_delete doesn't get passed confirm form values so add submit + // handler to this form to catch whitelist delete requests. $form['#submit'][] = 'ocio_simplesamlphp_auth_cancel_delete_user_submit'; } } @@ -439,12 +458,13 @@ function ocio_simplesamlphp_auth_form_user_cancel_confirm_form_alter(&$form, &$f function ocio_simplesamlphp_auth_form_alter(&$form, $form_state, $form_id) { switch ($form_id) { case 'user_login_block': - case 'user_login' : + case 'user_login': case 'user_pass': - // If shib users are not allowed to set their own passwords, make sure they cannot login with or reset the passwords for their accounts. - if (!variable_get('simplesamlphp_auth_allowsetdrupalpwd')) { - $form['#validate'][] = 'ocio_simplesamlphp_auth_login_form_validate'; - } + // If shib users are not allowed to set their own passwords, make sure + // they cannot login with or reset the passwords for their accounts. + if (!variable_get('simplesamlphp_auth_allowsetdrupalpwd')) { + $form['#validate'][] = 'ocio_simplesamlphp_auth_login_form_validate'; + } } } @@ -459,18 +479,18 @@ function ocio_simplesamlphp_auth_login_form_validate(&$form, $form_state) { } /** - * custom validation function for user forms + * Custom validation function for user forms. */ function ocio_simplesamlphp_auth_registration_form_whitelist_validate($form, &$form_state) { - // only enforce the whitelist for simpleSAMLphp authenticated users + // Only enforce the whitelist for simpleSAMLphp authenticated users. if ($form_state['values']['authenticationType'] == 'simplesamlphp') { - // get whitelist restriction setting + // Get whitelist restriction setting. $whitelist_only = variable_get('ocio_simplesamlphp_auth_whitelist_only', 0); - // enforce the whitelist + // Enforce the whitelist. if ($whitelist_only) { - // get whitelist entry + // Get whitelist entry. $whitelist_entry = _ocio_simplesamlphp_auth_get_whitelist_entry($form_state['values']['name']); - // no whitelist entry; set error + // No whitelist entry; set error. if (!isset($whitelist_entry->wid)) { form_set_error('name', 'User creation is set to whitelist only. User is not whitelisted and can not be created.'); } @@ -479,14 +499,17 @@ function ocio_simplesamlphp_auth_registration_form_whitelist_validate($form, &$f } /** - * submit handler for the cancel user confirmation form - * - hook_user_cancel doesn't get called for user_cancel_delete cancelation method, hook_user_delete is called - * - hook_user_delete doesn't get form values passed to it - * - this catches the whitelist remove request from the confirm form for the user_cancel_delete cancelation method + * Submit handler for the cancel user confirmation form. + * + * NOTE: Hook_user_cancel doesn't get called for user_cancel_delete, + * hook_user_delete is called instead. Hook_user_delete doesn't get + * form values passed to it. This function catches the whitelist + * remove request from the confirm form for the user_cancel_delete + * cancelation method. */ function ocio_simplesamlphp_auth_cancel_delete_user_submit($form, &$form_state) { if (isset($form_state['values']['whitelist_remove']) && $form_state['values']['whitelist_remove'] == 1) { - // remove whitelist + // Remove whitelist. $whitelist_entry = _ocio_simplesamlphp_auth_get_whitelist_entry($form['_account']['#value']->name); entity_delete('ocio_simplesamlphp_auth_whitelist', $whitelist_entry->wid); } @@ -494,55 +517,70 @@ function ocio_simplesamlphp_auth_cancel_delete_user_submit($form, &$form_state) } /** - * Implements hook_user_login() - * NOTE: the simplesamlphp_auth module will clear out all role assignments made during user creation if you are not using the - * attribute->role mapping feature. It passes an empty array to the role assignment method _after_ the user has been created during - * its init hook. To avoid having to modify that module, we check for whitelist assigned roles on login and assign them if they - * are not already assigned. + * Implements hook_user_login(). + * + * NOTE: The simplesamlphp_auth module will clear out all role assignments + * made during user creation if you are not using the attribute->role + * mapping feature. It passes an empty array to the role assignment + * method _after_ the user has been created during its init hook. To + * avoid having to modify that module, we check for whitelist + * assigned roles on login and assign them if they are not already assigned. */ function ocio_simplesamlphp_auth_user_login(&$edit, $account) { - watchdog('ocio_simplesamlphp_auth', 'user login hook fired for ' . $account->name); - // check for whitelist entry for the user logging in + $msg = t('User login hook fired for @name.', array('@name' => $account->name)); + watchdog('ocio_simplesamlphp_auth', $msg); + // Check for whitelist entry for the user logging in. $whitelist_entry = _ocio_simplesamlphp_auth_get_whitelist_entry($account->name); - // user is whitelisted + // User is whitelisted. if (isset($whitelist_entry->username)) { - // check if they have the role assigned by the whitelist + // Check if they have the role assigned by the whitelist. if (!is_array($account->roles) || !array_key_exists($whitelist_entry->roleid, $account->roles)) { - // assign whitelist role + // Assign whitelist role. user_multiple_role_edit(array($account->uid), 'add_role', $whitelist_entry->roleid); - watchdog('ocio_simplesamlphp_auth', 'Whitelisted user ' . $account->name . ' logged in. RoleID ' . $whitelist_entry->roleid . ' assigned.'); + $msg = t( + 'Whitelisted user @name logged in. RoleID @role assigned.', + array('@name' => $account->name, '@role' => $whitelist_entry->roleid) + ); + watchdog('ocio_simplesamlphp_auth', $msg); } } - // user is not whitelisted + // User is not whitelisted. else { - // check for whitelist restriction + // Check for whitelist restriction. $whitelist_only = variable_get('ocio_simplesamlphp_auth_whitelist_only', 0); - // only whitelisted users are allowed + // Only whitelisted users are allowed. if ($whitelist_only) { - // only whitelisted users are allowed to login; delete user + // Only whitelisted users are allowed to login; delete user. user_delete($account->uid); - // log them out and forward to feedback page + // Log them out and forward to feedback page. global $_simplesamlphp_auth_as; $_simplesamlphp_auth_as->logout(base_path() . 'saml_login_blocked'); } - // non-whitelist users are allowed + // Non-whitelist users are allowed. else { - // assign the default role + // Assign the default role. user_multiple_role_edit(array($account->uid), 'add_role', variable_get('ocio_simplesamlphp_auth_default_role_id', 2)); - watchdog('ocio_simplesamlphp_auth', 'Non-whitelisted user' . $account->name . ' logged in. Default roleid' . variable_get('ocio_simplesamlphp_auth_default_role_id', 2) . ' assigned.'); + $msg = t( + 'Non-whitelisted user @name logged in. Default roleid @role assigned.', + array( + '@name' => $account->name, + '@role' => variable_get('ocio_simplesamlphp_auth_default_role_id', 2), + ) + ); + watchdog('ocio_simplesamlphp_auth', $msg); } } } /** - * Implements hook_user_update() + * Implements hook_user_update(). */ function ocio_simplesamlphp_auth_user_update(&$edit, $account, $category) { _ocio_simplesamlphp_auth_set_user_auth_type($edit, $account); } /** - * Implements hook_user_update() + * Implements hook_user_update(). */ function ocio_simplesamlphp_auth_user_insert(&$edit, $account, $category) { _ocio_simplesamlphp_auth_set_user_auth_type($edit, $account); @@ -552,18 +590,20 @@ function ocio_simplesamlphp_auth_user_insert(&$edit, $account, $category) { * Set auth type when creating or updating a user. */ function _ocio_simplesamlphp_auth_set_user_auth_type(&$edit, $account) { - // check for the user form values for manually inserted users + // Check for the user form values for manually inserted users. if (isset($edit['authenticationType'])) { - // remove authmap if drupal is selected + // Remove authmap if drupal is selected. if ($edit['authenticationType'] == 'drupal') { - _ocio_simplesamlphp_auth_remove_authmap($account->name); - watchdog('ocio_simplesamlphp_auth', 'User ' . $account->name . ' set to Drupal authentication.'); - } - // set authmap if simplesaml is selected - elseif ($edit['authenticationType'] == 'simplesamlphp') { - user_set_authmaps($account, array('authname_simplesamlphp_auth' => $account->name)); - watchdog('ocio_simplesamlphp_auth', 'User ' . $account->name . ' set to simplesamlphp_auth authentication.'); - } + _ocio_simplesamlphp_auth_remove_authmap($account->name); + $msg = t('User @name set to Drupal authentication.', array('@name' => $account->name)); + watchdog('ocio_simplesamlphp_auth', $msg); + } + // Set authmap if simplesaml is selected. + elseif ($edit['authenticationType'] == 'simplesamlphp') { + user_set_authmaps($account, array('authname_simplesamlphp_auth' => $account->name)); + $msg = t('User @name set to simplesamlphp_auth authentication.', array('@name' => $account->name)); + watchdog('ocio_simplesamlphp_auth', $msg); + } } } @@ -574,48 +614,54 @@ function ocio_simplesamlphp_auth_cron() { _ocio_simplesamlphp_auth_refresh_metadata($request_options); } - /** * Implements hook_init(). */ function ocio_simplesamlphp_auth_init() { global $base_url; - - // check for expired metadata + + // Check for expired metadata. if (current_path() == 'user/login' || current_path() == 'saml_login') { $metaExpire = _ocio_simplesamlphp_auth_get_metadata_expire(); if (time() > $metaExpire) { - watchdog('ocio_simplesamlphp_auth', 'Expired metadata detected. Expires: ' . date('Y-m-d h:i:s a', $metaExpire) - . '. Current: ' . date('Y-m-d h:i:s a', time()) . '. Refreshing.'); + $msg = t( + 'Expired metadata detected. Expires: @expire. Current: @current. Refreshing.', + array( + '@expire' => date('Y-m-d h:i:s a', $metaExpire), + '@current' => date('Y-m-d h:i:s a', time()), + ) + ); + watchdog('ocio_simplesamlphp_auth', $msg); _ocio_simplesamlphp_auth_refresh_metadata(); } } - // when logging in with simplesaml, fix broken paths to simplesaml application. + // When logging in with simplesaml fix broken paths to simplesaml application. if (current_path() == 'saml_login' && !is_dir(variable_get('simplesamlphp_auth_installdir'))) { $saml_path = _ocio_simplesamlphp_auth_get_env_path() . '/code/private/simplesaml'; - // update var + // Update var. if (is_dir($saml_path)) { variable_set('simplesamlphp_auth_installdir', $saml_path); } } - // get login required setting + // Get login required setting. $loginRequired = variable_get('ocio_simplesamlphp_auth_require_login_enabled', '0'); - // check user authentication status if enabled; redirect non-authenticated users to configured login path + // Check user authentication status if enabled. + // Redirect non-authenticated users to configured login path. if ($loginRequired && !_ocio_simplesamlphp_auth_authcheck()) { $query = array('destination' => $_GET['q']); - // display access denied message. + // Display access denied message. $deny_message = filter_xss_admin(trim(variable_get('ocio_simplesamlphp_auth_require_login_msg', 'You must login to use this site.'))); - drupal_set_message(t($deny_message), 'warning'); + drupal_set_message($deny_message, 'warning'); - // exclude external PHP scripts from destination query. + // Exclude external PHP scripts from destination query. if (preg_match('/^.*\.php$/i', request_uri())) { $query = array(); } - // prepare authentication redirect path. + // Prepare authentication redirect path. $redirect = array( 'path' => '/user/login', 'query' => $query, @@ -624,7 +670,7 @@ function ocio_simplesamlphp_auth_init() { $redirect = drupal_parse_url($auth_path); } - // support for simpleSAMLphp returnTo query param + // Support for simpleSAMLphp returnTo query param. $returnTo = base_path() . request_path(); if (strlen($returnTo)) { $redirect['query']['ReturnTo'] = $base_url . $returnTo; @@ -637,71 +683,64 @@ function ocio_simplesamlphp_auth_init() { } } -/** *************************** +/* ----------------- * Private Functions - ***************************** */ - +----------------- */ /** - * helper function to update previously existing authmap entries to use the simpleSAMLphp module for authentication - * @param $authnameStringToMatch - * authname search string; matches will have their authmap entry updated to simplesamlphp_auth + * Update existing authmap entries to use simpleSAMLphp module for auth. */ function _ocio_simplesamlphp_auth_fix_authmap($authnameStringToMatch) { - // get the uids and username that already have an authmap entry + // Get the uids and username that already have an authmap entry. $authmapUsers = db_select('authmap', 'a') ->fields('a', array('uid')) ->condition('module', 'simplesamlphp_auth', '=') ->execute() ->fetchCol('uid'); - // find users matching the search string; exclude uid 1 and existing authmap uids + // Find users matching the search string. + // Exclude uid 1 and existing authmap uids. $usersToInsert = db_select('users', 'u') ->fields('u', array('uid', 'name')) ->condition('u.uid', 1, '!=') - ->condition('u.name', '%' . $authnameStringToMatch . '%' , 'LIKE'); - if (count($authmapUsers)) { - $usersToInsert->condition('u.uid', $authmapUsers, 'NOT IN'); - } + ->condition('u.name', '%' . $authnameStringToMatch . '%', 'LIKE'); + if (count($authmapUsers)) { + $usersToInsert->condition('u.uid', $authmapUsers, 'NOT IN'); + } $result = $usersToInsert->execute(); $insert_count = $result->rowCount(); - // insert any missing authmap entries + // Insert any missing authmap entries. foreach ($result as $u) { _ocio_simplesamlphp_auth_set_authmap($u->name); } - // log - watchdog('ocio_simplesamlphp_auth', 'Authmap fix ran. ' . $insert_count . ' entries created.'); - // set message - $msg = t("Authmap Fix inserted " . $insert_count . " entrie(s)."); + // Log and display message. + $msg = t('Authmap fix complete. @insert entries created.', array('@insert', $insert_count)); + watchdog('ocio_simplesamlphp_auth', $msg); drupal_set_message(check_plain($msg)); } /** - * helper function to determine if a user is in the authmap - * @param $username - * the user to search for in the authmap + * Determine if a user is in the authmap. */ function _ocio_simplesamlphp_auth_has_authmap($username) { - // query authmap table + // Query authmap table. $query = db_select('authmap', 'a') - ->fields('a', array('authname')) - ->condition('authname', $username, '=') - ->condition('module', 'simplesamlphp_auth', '='); - $result = $query->execute()->fetchCol('authname'); - // return boolean + ->fields('a', array('authname')) + ->condition('authname', $username, '=') + ->condition('module', 'simplesamlphp_auth', '='); + $result = $query->execute()->fetchCol('authname'); + // Return boolean. return count($result) ? TRUE : FALSE; } /** - * helper function to add/update a user to the authmap - * @param $username - * the username to add/update from the authmap + * Add/update a user's authmap. */ function _ocio_simplesamlphp_auth_set_authmap($username) { - // check if they already have an authmap entry + // Check if they already have an authmap entry. $hasAuthmap = _ocio_simplesamlphp_auth_has_authmap($username); if (!$hasAuthmap) { $updateUser = user_load_by_name($username); - // insert authmap entry + // Insert authmap entry. $insertQuery = db_insert('authmap') ->fields(array( 'uid' => $updateUser->uid, @@ -709,7 +748,7 @@ function _ocio_simplesamlphp_auth_set_authmap($username) { 'module' => 'simplesamlphp_auth', )) ->execute(); - // clear drupal password + // Clear drupal password. $updateQuery = db_update('users') ->fields(array('pass' => '')) ->condition('uid', $updateUser->uid, '=') @@ -718,9 +757,7 @@ function _ocio_simplesamlphp_auth_set_authmap($username) { } /** - * helper function to remove a user from the authmap - * @param $username - * the username to remove from the authmap + * Remove a user from the authmap. */ function _ocio_simplesamlphp_auth_remove_authmap($username) { $query = db_delete('authmap') @@ -730,18 +767,17 @@ function _ocio_simplesamlphp_auth_remove_authmap($username) { } /** - * helper function to retrieve a single whitelist entry for the passed username - * @param $username - * the username to search for in the whitelist + * Retrieve a single whitelist entry for the passed username. */ function _ocio_simplesamlphp_auth_get_whitelist_entry($username) { $query = new EntityFieldQuery(); + // Execute as admin user. $query->entityCondition('entity_type', 'ocio_simplesamlphp_auth_whitelist') ->propertyCondition('username', $username, '=') - ->addMetaData('account', user_load(1)); // execute as admin user + ->addMetaData('account', user_load(1)); $result = $query->execute(); $e = FALSE; - if(isset($result['ocio_simplesamlphp_auth_whitelist'])) { + if (isset($result['ocio_simplesamlphp_auth_whitelist'])) { $id_list = array_keys($result['ocio_simplesamlphp_auth_whitelist']); $e = entity_load_single('ocio_simplesamlphp_auth_whitelist', $id_list[0]); } @@ -749,15 +785,13 @@ function _ocio_simplesamlphp_auth_get_whitelist_entry($username) { } /** - * helper function that actually executes the refresh of the metadata; called from the cron hook - * @param $httpOptions - * additional options to pass during the http request for metadata refresh + * Executes the refresh of the metadata; called from the cron hook. */ -function _ocio_simplesamlphp_auth_refresh_metadata($httpOptions = array()){ - // get settings +function _ocio_simplesamlphp_auth_refresh_metadata($httpOptions = array()) { + // Get settings. $cron_key = variable_get('ocio_simplesamlphp_auth_cron_key', ''); $cron_path = variable_get('ocio_simplesamlphp_auth_cron_path', 'simplesaml/module.php/cron/cron.php'); - // format request + // Format request. $urlOptions = array( 'query' => array( 'key' => $cron_key, @@ -767,45 +801,48 @@ function _ocio_simplesamlphp_auth_refresh_metadata($httpOptions = array()){ 'https' => TRUE, ); $urlString = url($cron_path, $urlOptions); - // use curl to hit refresh URL + // Use curl to hit refresh URL. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $urlString); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); - // log + // Log. $metaExpire = _ocio_simplesamlphp_auth_get_metadata_expire(); - watchdog('ocio_simplesamlphp_auth', 'SimpleSAMLphp metadata refreshed. Expires at ' . date('Y-m-d h:i:s a', $metaExpire)); + $msg = t('SimpleSAMLphp metadata refreshed. Expires at @expire.', array('@expire' => date('Y-m-d h:i:s a', $metaExpire))); + watchdog('ocio_simplesamlphp_auth', $msg); } - /** - * helper function that reads the expire date from the current metadata + * Reads the expire date from the current metadata. */ function _ocio_simplesamlphp_auth_get_metadata_expire() { $metaPath = variable_get('ocio_simplesamlphp_auth_metadata_path', '/files/private/simplesamlphp/metadata/'); $metaFile = $metaPath . 'shib13-idp-remote.php'; - include($metaFile); + include_once $metaFile; return $metadata['urn:mace:incommon:osu.edu']['expire']; } /** - * helper function to check if we're in a pantheon environment - * returns dev, test, or live if a pantheon environment exists; otherwise returns false + * Check if we're in a pantheon environment. + * + * Returns dev, test, live or multi-dev name if a pantheon environment exists. + * Otherwise returns false. */ function _ocio_simplesamlphp_auth_get_pantheon_env() { return (isset($_ENV['PANTHEON_ENVIRONMENT'])) ? $_ENV['PANTHEON_ENVIRONMENT'] : FALSE; } /** - * helper function to handle environment specific paths - * currently only handles pantheon environments but additional environment checks can be added here + * Handle environment specific paths. + * + * Currently only handles pantheon envs but additional env checks can be added. */ function _ocio_simplesamlphp_auth_get_env_path() { $envPath = ''; - // pantheon check + // Pantheon check. $pantheon_environment = _ocio_simplesamlphp_auth_get_pantheon_env(); - // assemble pantheon path + // Assemble Pantheon path. if ($pantheon_environment) { $pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE); $envPath = '/srv/bindings/' . $pressflow_settings['conf']['pantheon_binding']; @@ -814,68 +851,84 @@ function _ocio_simplesamlphp_auth_get_env_path() { } /** - * helper function to find simplesamlphp cron key - * generates new key if one is not found on the server. + * Find and validate simplesamlphp cron key. + * + * Generates new key if one is not found on the server. */ function _ocio_simplesamlphp_auth_check_cron_key() { - $file = '/private/simplesaml/config/config.php'; - $path = DRUPAL_ROOT . $file; + // Init cron_key as empty. $cron_key = ''; - - // look for the config file - if (file_exists($path)) { - // parse out the cron key line + // Set paths potential config locations. + $parametersFile = DRUPAL_ROOT . '/private/simplesaml_config/parameters.php'; + $configFile = DRUPAL_ROOT . '/private/simplesaml/config/config.php'; + // Check for setup using a parameters file. + if (file_exists($parametersFile)) { + $activeConfig = $parametersFile; + // Param file exists. Include it and grab the cron key. + require $parametersFile; + $cron_key = $cronKey; + } + // Check for default setup. + elseif (file_exists($configFile)) { + $activeConfig = $configFile; + // Parse out the cron key line. $line = preg_grep('/cronkey/', file($path)); - // grab the value of cron key if it exists + // Grab the value of cron key if it exists. if (preg_match("/(?!'cronkey'\s*=>\s*')\w+(?=',)/", array_pop($line), $matches)) { $cron_key = $matches[0]; } } - // check for parsed cron key + // No key found or its empty. if (empty($cron_key)) { - // generate/get a valid key - $cron_key = variable_get('ocio_simplesamlphp_auth_cron_key', user_password(54)); + // Generate a valid key. + $cron_key = variable_get('ocio_simplesamlphp_auth_cron_key', user_password(54)); variable_set('ocio_simplesamlphp_auth_cron_key', $cron_key); - // feedback msg - drupal_set_message(t('The cron key could not be found in %file. Add or update the value inside the $config array in %file using the key below<br><br>@cron_key', array('@cron_key' => $cron_key, '%file' => $file)), 'warning'); + // Feedback msg. + drupal_set_message( + t('The cron key could not be found in %file. Add or update the value inside + the $config array in %file using the key below<br><br>@cron_key', + array('@cron_key' => $cron_key, '%file' => $activeConfig)), 'warning'); } - // check key length + // Check key length. if (strlen($cron_key) != 54) { - // generate/get a valid key - $cron_key = variable_get('ocio_simplesamlphp_auth_cron_key', user_password(54)); + // Generate a valid key. + $cron_key = variable_get('ocio_simplesamlphp_auth_cron_key', user_password(54)); variable_set('ocio_simplesamlphp_auth_cron_key', $cron_key); - // feedback msg - drupal_set_message(t('The cron key detected in the simpleSAMLphp config is not 54 characters in length. Add or update the value inside the $config array in %file using the key below<br><br>@cron_key ', array('@cron_key' => $cron_key, '%file' => $file)), 'warning'); + // Feedback msg. + drupal_set_message( + t('The cron key detected in the simpleSAMLphp config is not 54 characters in length. + Add or update the value inside the $config array in %file using the key below<br><br>@cron_key ', + array('@cron_key' => $cron_key, '%file' => $activeConfig)), 'warning'); } - // check for illegal characters + // Check for illegal characters. if (!base64_decode($cron_key)) { - // generate/get a valid key + // Generate a valid key. $cron_key = variable_get('ocio_simplesamlphp_auth_cron_key', user_password(54)); variable_set('ocio_simplesamlphp_auth_cron_key', $cron_key); - // feedback msg - drupal_set_message(t('The cron key detected in the simpleSAMLphp config contains illegal characters. Add or update the value inside the $config array in %file using the key below<br><br>@cron_key ', array('@cron_key' => $cron_key, '%file' => $file)), 'warning'); + // Feedback msg. + drupal_set_message( + t('The cron key detected in the simpleSAMLphp config contains illegal characters. + Add or update the value inside the $config array in %file using the key below<br><br>@cron_key ', + array('@cron_key' => $cron_key, '%file' => $activeConfig)), 'warning'); } return $cron_key; } /** - * helper function to determine if user is authenticated - * - * @return boolean - * Returns TRUE if authenticated and FALSE otherwise. + * Determine if user is authenticated. */ function _ocio_simplesamlphp_auth_authcheck() { global $base_path, $base_url; - $path = '/'. drupal_get_path_alias($_GET['q']); + $path = '/' . drupal_get_path_alias($_GET['q']); // Isolate request path from subdirectory when present. $raw_uri = request_uri(); if ($base_path != '/') { - $current_uri = '/'. str_replace($base_path, '', $raw_uri); + $current_uri = '/' . str_replace($base_path, '', $raw_uri); } else { $current_uri = $raw_uri; @@ -893,7 +946,7 @@ function _ocio_simplesamlphp_auth_authcheck() { foreach ($exclude_paths as $key => $exclude_path) { $exclude_paths[$key] = trim($exclude_path); if ($exclude_paths[$key] == '<front>') { - $exclude_paths[$key] = '/'. drupal_get_path_alias(variable_get('site_frontpage', 'node')); + $exclude_paths[$key] = '/' . drupal_get_path_alias(variable_get('site_frontpage', 'node')); } } if ($auth_path = filter_xss_admin(trim(variable_get('ocio_simplesamlphp_auth_require_login_auth_path', '')))) { @@ -907,14 +960,22 @@ function _ocio_simplesamlphp_auth_authcheck() { // Various checks to determine exceptions for current page. Returns TRUE // when at least one check has evaluated as TRUE. $checks = array( - (user_is_logged_in()), // Authentication - (variable_get('maintenance_mode', 0)), // Maintenance Mode - (isset($_SESSION['openid'])), // OpenID - (preg_match('/^\/cron.php/i', $current_uri)), // Cron - (preg_match('/\/update.php/i', request_uri())), // Update - (preg_match('/\/install.php/i', request_uri())), // Install - (arg(0) == 'user' && (!arg(1) || !is_numeric(arg(1)))), // User Pages - (function_exists('drupal_is_cli') && drupal_is_cli()), // Drush + // Authentication. + (user_is_logged_in()), + // Maintenance Mode. + (variable_get('maintenance_mode', 0)), + // OpenID. + (isset($_SESSION['openid'])), + // Cron. + (preg_match('/^\/cron.php/i', $current_uri)), + // Update. + (preg_match('/\/update.php/i', request_uri())), + // Install. + (preg_match('/\/install.php/i', request_uri())), + // User Pages. + (arg(0) == 'user' && (!arg(1) || !is_numeric(arg(1)))), + // Drush. + (function_exists('drupal_is_cli') && drupal_is_cli()), ); foreach ($checks as $check) { if ($check) { @@ -925,4 +986,3 @@ function _ocio_simplesamlphp_auth_authcheck() { // Return FALSE when checks have all passed. return FALSE; } - diff --git a/profiles/wcm_base/wcm_base.make b/profiles/wcm_base/wcm_base.make index e722e05cc0618f1d19737766497bdfab0fd6d883..33d0cc29d9a9818295011072fc70105b35225445 100644 --- a/profiles/wcm_base/wcm_base.make +++ b/profiles/wcm_base/wcm_base.make @@ -157,6 +157,7 @@ projects[smart_trim][subdir] = contrib projects[smtp][version] = 1.7 projects[smtp][subdir] = contrib projects[smtp][patch][2966816] = https://www.drupal.org/files/issues/2018-11-13/smtp-filepath_uri-2966816-27-D7_0.patch +projects[smtp][patch][2753115] = https://www.drupal.org/files/issues/2018-06-04/2753115-41-smtp-multiple-to-addresses-error.patch projects[special_menu_items][version] = 2.0 projects[special_menu_items][subdir] = contrib