Index: cas.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cas/cas.module,v retrieving revision 1.26 diff -u -r1.26 cas.module --- cas.module 31 Jul 2007 22:30:21 -0000 1.26 +++ cas.module 7 Aug 2007 00:04:18 -0000 @@ -301,7 +301,7 @@ '#type' => 'radios', '#title' => t('Require CAS login for'), '#default_value' => variable_get('cas_access',0), - '#options' => array(t('specific pages'), t('all pages')), + '#options' => array(t('specific pages'), t('all pages except specific pages')), ); $form['pages']['cas_pages'] = array( @@ -495,9 +495,10 @@ } /** -* Provides login blog that only shows up when the user logs in. -*/ -function cas_block($op = 'list', $delta = 0, $edit = array()) { + * Provides login blog that only shows up when the user logs in. + */ +function cas_block($op = 'list', $delta = 0, $edit = array()) +{ global $user; if ($op == 'list') { $blocks[0]['info'] = t('CAS User login'); @@ -529,35 +530,51 @@ } /** -* Determines whether cas login should be enforced for this page load. -* This is done based on the redirection settings for this module. -*/ -function _cas_force_login() { + * Determines whether cas login should be enforced for this page load. + * This is done based on the redirection settings for this module. + */ +function _cas_force_login() +{ + list($arg0) = split('/',$_GET['q']); + // Don't even do the test if we're hitting the cas page if ($arg0=="cas") { return true; } - else if (variable_get('cas_access',0) == 1) { - return TRUE; + + // set the default behavior + if (variable_get('cas_access',0) == 1) { + $force_login = TRUE; } else { - $page_match = FALSE; - $pages = variable_get('cas_pages',''); - // This common page matching logic used throughout drupal. - if ($pages) { - $path = drupal_get_path_alias($_GET['q']); - $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. variable_get('site_frontpage', 'node') .'\2'), preg_quote($pages, '/')) .')$/'; - $page_match = preg_match($regexp, $path); + $force_login = FALSE; + } + + $pages = variable_get('cas_pages',''); + // This common page matching logic used throughout drupal. + if ($pages) { + $path = drupal_get_path_alias($_GET['q']); + $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. variable_get('site_frontpage', 'node') .'\2'), preg_quote($pages, '/')) .')$/'; + $path_match = preg_match($regexp, $path); + + // Alter the default + if ($path_match) + { + if ($force_login) + $force_login = false; + else + $force_login = true; } - return $page_match; } + + return $force_login; } /** -* implementation of hook_form_alter -* Overrides specific from settings based on user policy. -*/ + * implementation of hook_form_alter + * Overrides specific from settings based on user policy. + */ function cas_form_alter($form_id,&$form) { switch ($form_id){