' . var_export($library, TRUE) . ''); @@ -306,10 +263,24 @@ class LibrariesTestCase extends DrupalWebTestCase { $this->assertEqual($library['variants']['example_variant']['installed'], TRUE, 'Existing variant found.'); } + /** + * Tests libraries_detect() without a $name parameter. + */ + public function testLibrariesDetectAll() { + // Test that an array with all library information is returned and that the + // libraries are properly detected. + $libraries = libraries_detect(); + $this->verbose('
' . var_export($libraries, TRUE) . ''); + $this->assertEqual($libraries['example_missing']['error'], 'not found'); + $this->assertEqual($libraries['example_undetected_version']['error'], 'not detected'); + $this->assertEqual($libraries['example_unsupported_version']['error'], 'not supported'); + $this->assertEqual($libraries['example_supported_version']['installed'], TRUE); + } + /** * Tests libraries_load(). */ - function testLibrariesLoad() { + public function testLibrariesLoad() { // Test dependencies. $library = libraries_load('example_dependency_missing'); $this->verbose('
' . var_export($library, TRUE) . ''); @@ -334,7 +305,7 @@ class LibrariesTestCase extends DrupalWebTestCase { /** * Tests the applying of callbacks. */ - function testCallbacks() { + public function testCallbacks() { $expected = array( 'name' => 'Example callback', 'library path' => drupal_get_path('module', 'libraries') . '/tests/libraries/example', @@ -453,7 +424,7 @@ class LibrariesTestCase extends DrupalWebTestCase { * * @see _libraries_test_module_load() */ - function testLibrariesOutput() { + public function testLibrariesOutput() { // Test loading of a simple library with a top-level files property. $this->drupalGet('libraries-test-module/files'); $this->assertLibraryFiles('example_1', 'File loading'); @@ -527,7 +498,7 @@ class LibrariesTestCase extends DrupalWebTestCase { * (optional) The expected file extensions of $name. Defaults to * array('js', 'css', 'php'). */ - function assertLibraryFiles($name, $label = '', $extensions = array('js', 'css', 'php')) { + public function assertLibraryFiles($name, $label = '', $extensions = array('js', 'css', 'php')) { $label = ($label !== '' ? "$label: " : ''); // Test that the wrong files are not loaded... @@ -570,4 +541,3 @@ class LibrariesTestCase extends DrupalWebTestCase { } } - diff --git a/sites/all/modules/contrib/dev/libraries/tests/LibrariesUnitTest.test b/sites/all/modules/contrib/dev/libraries/tests/LibrariesUnitTest.test new file mode 100644 index 00000000..cd5d30a2 --- /dev/null +++ b/sites/all/modules/contrib/dev/libraries/tests/LibrariesUnitTest.test @@ -0,0 +1,78 @@ + 'Libraries API unit tests', + 'description' => 'Tests basic functions provided by Libraries API.', + 'group' => 'Libraries API', + ); + } + + /** + * {@inheritdoc} + */ + protected function setUp() { + drupal_load('module', 'libraries'); + parent::setUp(); + } + + /** + * Tests libraries_get_path(). + */ + public function testLibrariesGetPath() { + // Note that, even though libraries_get_path() doesn't find the 'example' + // library, we are able to make it 'installed' by specifying the 'library + // path' up-front. This is only used for testing purposed and is strongly + // discouraged as it defeats the purpose of Libraries API in the first + // place. + $this->assertEqual(libraries_get_path('example'), FALSE, 'libraries_get_path() returns FALSE for a missing library.'); + } + + /** + * Tests libraries_prepare_files(). + */ + public function testLibrariesPrepareFiles() { + $expected = array( + 'files' => array( + 'js' => array('example.js' => array()), + 'css' => array('example.css' => array()), + 'php' => array('example.php' => array()), + ), + ); + $library = array( + 'files' => array( + 'js' => array('example.js'), + 'css' => array('example.css'), + 'php' => array('example.php'), + ), + ); + libraries_prepare_files($library, NULL, NULL); + $this->assertEqual($expected, $library, 'libraries_prepare_files() works correctly.'); + } + +} diff --git a/sites/all/modules/contrib/dev/libraries/tests/LibrariesWebTestBase.test b/sites/all/modules/contrib/dev/libraries/tests/LibrariesWebTestBase.test new file mode 100644 index 00000000..094534ce --- /dev/null +++ b/sites/all/modules/contrib/dev/libraries/tests/LibrariesWebTestBase.test @@ -0,0 +1,64 @@ +drupalGetContent(). + * + * @see \DrupalWebTestCase::drupalGet() + * @see \DrupalWebTestCase::drupalCreateUser() + */ + protected function getWithPermissions(array $permissions, $path, array $options = array(), array $headers = array()) { + $this->drupalGet($path, $options, $headers); + $this->assertResponse(403); + + $this->drupalLogin($this->drupalCreateUser($permissions)); + $this->drupalGet($path, $options, $headers); + $this->assertResponse(200); + } + +} diff --git a/sites/all/modules/contrib/dev/libraries/tests/libraries/example_info_file.libraries.info b/sites/all/modules/contrib/dev/libraries/tests/libraries/example_info_file.libraries.info index 59475b4e..11152731 100644 --- a/sites/all/modules/contrib/dev/libraries/tests/libraries/example_info_file.libraries.info +++ b/sites/all/modules/contrib/dev/libraries/tests/libraries/example_info_file.libraries.info @@ -2,9 +2,9 @@ name = Example info file -; Information added by Drupal.org packaging script on 2014-02-09 -version = "7.x-2.2" +; Information added by Drupal.org packaging script on 2016-05-12 +version = "7.x-2.3" core = "7.x" project = "libraries" -datestamp = "1391965716" +datestamp = "1463077450" diff --git a/sites/all/modules/contrib/dev/libraries/tests/modules/libraries_test_module/libraries_test_module.info b/sites/all/modules/contrib/dev/libraries/tests/modules/libraries_test_module/libraries_test_module.info index 450a0a20..7ad319a2 100644 --- a/sites/all/modules/contrib/dev/libraries/tests/modules/libraries_test_module/libraries_test_module.info +++ b/sites/all/modules/contrib/dev/libraries/tests/modules/libraries_test_module/libraries_test_module.info @@ -5,9 +5,9 @@ package = Testing dependencies[] = libraries hidden = TRUE -; Information added by Drupal.org packaging script on 2014-02-09 -version = "7.x-2.2" +; Information added by Drupal.org packaging script on 2016-05-12 +version = "7.x-2.3" core = "7.x" project = "libraries" -datestamp = "1391965716" +datestamp = "1463077450" diff --git a/sites/all/modules/contrib/dev/libraries/tests/modules/libraries_test_module/libraries_test_module.module b/sites/all/modules/contrib/dev/libraries/tests/modules/libraries_test_module/libraries_test_module.module index 65f412ec..51d07c98 100644 --- a/sites/all/modules/contrib/dev/libraries/tests/modules/libraries_test_module/libraries_test_module.module +++ b/sites/all/modules/contrib/dev/libraries/tests/modules/libraries_test_module/libraries_test_module.module @@ -18,6 +18,9 @@ function libraries_test_module_libraries_info() { // Test library detection. $libraries['example_missing'] = array( 'name' => 'Example missing', + // Provide a vendor and download URL to test that the UI links to it. + 'vendor url' => 'http://example.com', + 'download url' => 'http://example.com/download', 'library path' => drupal_get_path('module', 'libraries') . '/tests/libraries/missing', ); $libraries['example_undetected_version'] = array( @@ -28,6 +31,8 @@ function libraries_test_module_libraries_info() { ); $libraries['example_unsupported_version'] = array( 'name' => 'Example unsupported version', + // Provide a download URL to test that the UI links to it. + 'download url' => 'http://example.com/download', 'library path' => drupal_get_path('module', 'libraries') . '/tests/libraries/example', 'version callback' => '_libraries_test_module_return_version', 'version arguments' => array('1'), diff --git a/sites/all/modules/contrib/dev/libraries/tests/themes/libraries_test_theme/libraries_test_theme.info b/sites/all/modules/contrib/dev/libraries/tests/themes/libraries_test_theme/libraries_test_theme.info index 7528416b..255d1040 100644 --- a/sites/all/modules/contrib/dev/libraries/tests/themes/libraries_test_theme/libraries_test_theme.info +++ b/sites/all/modules/contrib/dev/libraries/tests/themes/libraries_test_theme/libraries_test_theme.info @@ -3,9 +3,9 @@ description = Tests that themes can provide and alter library information. core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2014-02-09 -version = "7.x-2.2" +; Information added by Drupal.org packaging script on 2016-05-12 +version = "7.x-2.3" core = "7.x" project = "libraries" -datestamp = "1391965716" +datestamp = "1463077450" diff --git a/sites/all/modules/contrib/users/login_destination/login_destination.admin.inc b/sites/all/modules/contrib/users/login_destination/login_destination.admin.inc index 076379ef..684bda51 100644 --- a/sites/all/modules/contrib/users/login_destination/login_destination.admin.inc +++ b/sites/all/modules/contrib/users/login_destination/login_destination.admin.inc @@ -11,7 +11,6 @@ * Shows list of all login destination. */ function login_destination_overview_form($form, &$form_state) { - // Get all login destination rules from the database. $result = db_select('login_destination', 'l') ->fields('l', array( @@ -23,8 +22,7 @@ function login_destination_overview_form($form, &$form_state) { 'destination', 'weight', 'enabled', - ) - ) + )) ->orderBy('weight') ->execute() ->fetchAll(); @@ -33,7 +31,6 @@ function login_destination_overview_form($form, &$form_state) { // Loop through the categories and add them to the table. foreach ($result as $data) { - $triggers = array_map('check_plain', unserialize($data->triggers)); if (empty($triggers)) { $triggers = array(); @@ -46,7 +43,10 @@ function login_destination_overview_form($form, &$form_state) { $form[$data->id]['destination']['#markup'] = theme('login_destination_destination', array('destination' => $data->destination)); $form[$data->id]['triggers']['#markup'] = theme('login_destination_triggers', array('items' => $triggers)); - $form[$data->id]['pages']['#markup'] = theme('login_destination_pages', array('pages' => $data->pages, 'pages_type' => $data->pages_type)); + $form[$data->id]['pages']['#markup'] = theme('login_destination_pages', array( + 'pages' => $data->pages, + 'pages_type' => $data->pages_type, + )); $form[$data->id]['roles']['#markup'] = theme('login_destination_roles', array('items' => $roles)); $form[$data->id]['weight'] = array( @@ -77,9 +77,7 @@ function login_destination_overview_form($form, &$form_state) { '#title' => t('delete'), '#href' => 'admin/config/people/login-destination/delete/' . $data->id, ); - $form[$data->id]['operations'] = $operations; - } if (element_children($form)) { @@ -104,6 +102,8 @@ function login_destination_overview_form($form, &$form_state) { * - form: A render element representing the form. * * @ingroup themeable + * + * @return string */ function theme_login_destination_overview_form($variables) { $form = $variables['form']; @@ -122,38 +122,42 @@ function theme_login_destination_overview_form($variables) { $rows = array(); foreach (element_children($form) as $ldid) { - if (isset($form[$ldid]['enabled'])) { - - $element = &$form[$ldid]; - - $operations = array(); - foreach (element_children($element['operations']) as $op) { - $operations[] = array('data' => drupal_render($element['operations'][$op]), 'class' => array('login-destination-operations')); - } - while (count($operations) < 2) { - $operations[] = ''; - } - - $row = array(); - $row[] = drupal_render($element['destination']); - $row[] = drupal_render($element['triggers']); - $row[] = drupal_render($element['pages']); - $row[] = drupal_render($element['roles']); - $row[] = array( - 'data' => drupal_render($element['enabled']), - 'class' => array( - 'checkbox', 'login-destination-enabled', - ), - ); - - $form[$ldid]['weight']['#attributes']['class'] = array('login-destination-weight'); - - $row[] = drupal_render($element['weight']); - $row = array_merge($row, $operations); - $row = array_merge(array('data' => $row), array()); - $row['class'][] = 'draggable'; - $rows[] = $row; + if (!isset($form[$ldid]['enabled'])) { + continue; } + $element = &$form[$ldid]; + $operations = array(); + + foreach (element_children($element['operations']) as $op) { + $operations[] = array( + 'data' => drupal_render($element['operations'][$op]), + 'class' => array('login-destination-operations'), + ); + } + while (count($operations) < 2) { + $operations[] = ''; + } + + $row = array(); + $row[] = drupal_render($element['destination']); + $row[] = drupal_render($element['triggers']); + $row[] = drupal_render($element['pages']); + $row[] = drupal_render($element['roles']); + $row[] = array( + 'data' => drupal_render($element['enabled']), + 'class' => array( + 'checkbox', + 'login-destination-enabled', + ), + ); + + $form[$ldid]['weight']['#attributes']['class'] = array('login-destination-weight'); + + $row[] = drupal_render($element['weight']); + $row = array_merge($row, $operations); + $row = array_merge(array('data' => $row), array()); + $row['class'][] = 'draggable'; + $rows[] = $row; } $output = ''; @@ -175,7 +179,6 @@ function theme_login_destination_overview_form($variables) { ); $output .= theme('table', $table_arguments); - $output .= drupal_render_children($form); return $output; @@ -220,15 +223,20 @@ function login_destination_overview_form_submit($form, &$form_state) { */ function _login_destination_update_rules($login_destination_rule) { - if (!(isset($login_destination_rule['enabled']) && isset($login_destination_rule['weight']) && isset($login_destination_rule['ldid']))) { + if (!(isset($login_destination_rule['enabled']) && + isset($login_destination_rule['weight']) && + isset($login_destination_rule['ldid'])) + ) { return FALSE; } - if ($login_destination_rule['enabled'] != 0 && $login_destination_rule['enabled'] != 1) { + if ($login_destination_rule['enabled'] != 0 && + $login_destination_rule['enabled'] != 1 + ) { return FALSE; } - $login_destination_rule['weight'] = intval($login_destination_rule['weight']); + $login_destination_rule['weight'] = (int) $login_destination_rule['weight']; if (!is_int($login_destination_rule['weight'])) { return FALSE; @@ -367,21 +375,20 @@ function login_destination_edit_form($form, &$form_state, array $rule = array()) LOGIN_DESTINATION_STATIC => t('Internal page or external URL'), ); $description = t("Specify page by using its path. Example path is %blog for the blog page. %front is the front page. %current is the current page. Precede with http:// for an external URL. Leave empty to redirect to a default page.", array( - '%blog' => 'blog', - '%front' => '
TRUE
(experts only)'));
- $description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => ''));
+ $description .= ' ' .
+ t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => ''));
}
$form['pages_type'] = array(
@@ -489,16 +499,25 @@ function login_destination_edit_form($form, &$form_state, array $rule = array())
*/
function login_destination_edit_form_validate($form, &$form_state) {
$destination = $form_state['values']['destination'];
- $destination_type = $form_state['values']['destination_type'];
+ $destination_type = $form_state['values']['destination_type'];
// Check user has enter any path.
- if (!empty($destination) && $destination_type == 0) {
- $destination = preg_replace("/\?.+/", "", $destination);
- if (!drupal_valid_path($destination)) {
- form_set_error('destination', t('Incorrect path, Please Enter valid Path'));
- }
+ $available_urls = array('' . t('The Login Destination module allows you to customize the destination that the user is redirected to after logging in, registering to the site, using a one-time login link or logging out. The destination can be an internal page or an external URL. You may specify certain conditions like pages or user roles and make the destination depend upon them. You may also use a PHP snippets to provide custom conditions and destinations. Note that PHP Filter module has to be enabled and you have to be granted the "Use PHP for settings" permissions to be able to enter PHP code.') . '
'; + $output .= '' . + t('The Login Destination module allows you to customize the destination that the user is redirected to after logging in, registering to the site, using a one-time login link or logging out. The destination can be an internal page or an external URL. You may specify certain conditions like pages or user roles and make the destination depend upon them. You may also use a PHP snippets to provide custom conditions and destinations. Note that PHP Filter module has to be enabled and you have to be granted the "Use PHP for settings" permissions to be able to enter PHP code.') . + '
'; return $output; case 'admin/config/people/login-destination': - return '' . t('Login destination rules are evaluated each time a user logs in, registers to the site, uses a one-time login link or logs out. Each rule consists of the destination, path conditions and user roles conditions. First matching rule gets executed.') . '
'; + return '' . + t('Login destination rules are evaluated each time a user logs in, registers to the site, uses a one-time login link or logs out. Each rule consists of the destination, path conditions and user roles conditions. First matching rule gets executed.') . + '
'; } } +/** + * Implements hook_permission(). + */ +function login_destination_permission() { + return array( + 'administer login destination settings' => array( + 'title' => t('Administer Login Destination settings'), + ), + ); +} + /** * Implements hook_menu(). */ @@ -39,7 +54,7 @@ function login_destination_menu() { 'description' => 'Customize the destination that the user is redirected to after login.', 'page callback' => 'drupal_get_form', 'page arguments' => array('login_destination_overview_form'), - 'access arguments' => array('administer users'), + 'access arguments' => array('administer login destination settings'), 'file' => 'login_destination.admin.inc', 'weight' => 10, ); @@ -47,7 +62,7 @@ function login_destination_menu() { 'title' => 'Add login destination rule', 'page callback' => 'drupal_get_form', 'page arguments' => array('login_destination_edit_form'), - 'access arguments' => array('administer users'), + 'access arguments' => array('administer login destination settings'), 'type' => MENU_LOCAL_ACTION, 'weight' => 1, 'file' => 'login_destination.admin.inc', @@ -56,14 +71,14 @@ function login_destination_menu() { 'title' => 'Edit login destination rule', 'page callback' => 'drupal_get_form', 'page arguments' => array('login_destination_edit_form', 5), - 'access arguments' => array('administer users'), + 'access arguments' => array('administer login destination settings'), 'file' => 'login_destination.admin.inc', ); $items['admin/config/people/login-destination/delete/%login_destination'] = array( 'title' => 'Delete login destination rule', 'page callback' => 'drupal_get_form', 'page arguments' => array('login_destination_delete_form', 5), - 'access arguments' => array('administer users'), + 'access arguments' => array('administer login destination settings'), 'file' => 'login_destination.admin.inc', ); $items['admin/config/people/login-destination/list'] = array( @@ -76,7 +91,7 @@ function login_destination_menu() { 'description' => 'Change Login Destination settings.', 'page callback' => 'drupal_get_form', 'page arguments' => array('login_destination_settings'), - 'access arguments' => array('administer users'), + 'access arguments' => array('administer login destination settings'), 'type' => MENU_LOCAL_TASK, 'file' => 'login_destination.admin.inc', 'weight' => 10, @@ -141,14 +156,14 @@ function login_destination_theme() { */ function login_destination_form_alter(&$form, &$form_state, $form_id) { // We redirect by using the drupal_goto_alter hook. If we simply - // call drupal_goto() it may break compability with other modules. If we set + // call drupal_goto() it may break compatibility with other modules. If we set // the $_GET['destination'] variable we will loose the possibility to redirect // to an external URL. // Please note the the system_goto_action() calls drupal_goto() // More on this issue http://drupal.org/node/732542. - // If we add the $form_state['redirect'] here it will be overriden by the + // If we add the $form_state['redirect'] here it will be overridden by the // user_login_submit(). So we add a submit handler instead and will set the // redirect later. Our submit handler will be executed after the execution // of user_login_submit(). This is because form_submit() functions are @@ -203,7 +218,6 @@ function login_destination_validate($form, &$form_state) { $_GET['current'] = $_GET['destination']; } } - } /** @@ -230,11 +244,16 @@ function login_destination_menu_link_alter(&$item) { * Implements hook_translated_menu_link_alter(). */ function login_destination_translated_menu_link_alter(&$item, $map) { - global $user; $paths = array('user/login', 'user'); // Append the current path to URL. - if ($item['link_path'] == 'user/logout' || (in_array($item['link_path'], $paths) && user_is_anonymous())) { - $item['localized_options']['query'] = array('current' => $_GET['q']); + if ($item['link_path'] == 'user/logout' || + (in_array($item['link_path'], $paths) && user_is_anonymous()) + ) { + $current = $_GET['q']; + if ($current == '