function front_page in Front Page 7
Same name and namespace in other branches
- 5 front_page.module \front_page()
- 6.2 front_page.module \front_page()
- 6 front_page.module \front_page()
- 7.2 front_page.module \front_page()
1 string reference to 'front_page'
- front_page_menu in ./
front_page.module - Implements hook_menu().
File
- ./
front_page.module, line 213
Code
function front_page() {
// Set a default value for landing zone if no front_page variables are filled.
// If the module is turned on but empty in certain areas then a redirection loop will occur.
// Defaulting to 'node' prevents this.
$output = 'node';
//this checks to see if you are overriding HOME links on the site
if (variable_get('front_page_breadcrumb', 0) && isset($_SERVER['HTTP_REFERER'])) {
// This checks to see if the referer is an internal HOME link or not.
$ref = $_SERVER['HTTP_REFERER'];
global $user, $base_url;
$parsed_url = parse_url($base_url);
$domain = $parsed_url['host'];
if (stristr($ref, $domain)) {
$url = front_page_parse_url(variable_get('front_page_breadcrumb_redirect', 'node'));
drupal_goto($url['path'], $url['options']);
}
}
// the following is the code that loads the front_page settings
global $user;
// if the user is not logged in load up the page for anonymous users
if (!$user->uid) {
$output = variable_get('front_1_text', 'drupal');
// If PHP code execution is allowed then use eval.
if (variable_get('front_1_php', 0)) {
if (module_exists('php')) {
$output = php_eval($output);
}
}
$fptype = variable_get('front_1_type', 'drupal');
switch ($fptype) {
case 'themed':
// Removed theme('page', $output) wrapper from $output as
// discussed at http://drupal.org/node/224333#theme_page.
return $output;
case 'full':
print $output;
exit;
case 'redirect':
$url = front_page_parse_url(variable_get('front_1_redirect', 'drupal'));
drupal_goto($url['path'], $url['options']);
break;
}
}
$roles = "";
//make sure the roles variable is clear
$roles = user_roles();
//load up the user roles for the site
krsort($roles);
//reverse the order of role types so it checks the highest or more recent role type first.
$siteroles = count($roles);
/* this is where the front page by role stuff happens */
if ($user->uid) {
//if the user is logged in and the site has more than 2 roles setup
foreach ($roles as $role_id => $role_name) {
// run through each role type starting at the most recent working backwards
// if the current visitor has a role type that matches and if the front page setting for that role type is not empty.
if (array_key_exists($role_id, $user->roles)) {
$output = variable_get('front_' . $role_id . '_text', '');
// if PHP code execution is allowed then use eval
if (variable_get('front_' . $role_id . '_php', 0)) {
if (module_exists('php')) {
$output = php_eval($output);
}
}
$fptype = variable_get('front_' . $role_id . '_type', 'drupal');
//check whether it is a themed or full front page.
switch ($fptype) {
case 'themed':
// Removed theme('page', $output) wrapper from $output as
// discussed at http://drupal.org/node/224333#theme_page.
return $output;
case 'full':
print $output;
exit;
case 'same_as_anon':
$output = variable_get('front_1_text', 'drupal');
// If PHP code execution is allowed then use eval.
if (variable_get('front_1_php', 0)) {
if (module_exists('php')) {
$output = php_eval($output);
}
}
$fptype = variable_get('front_1_type', 'drupal');
switch ($fptype) {
case 'themed':
// Removed theme('page', $output) wrapper from $output as
// discussed at http://drupal.org/node/224333#theme_page.
return $output;
case 'full':
print $output;
exit;
case 'redirect':
$url = front_page_parse_url(variable_get('front_1_redirect', 'drupal'));
drupal_goto($url['path'], $url['options']);
break;
}
case 'sameasauth':
$output = variable_get('front_2_text', 'drupal');
// If PHP code execution is allowed then use eval.
if (variable_get('front_2_php', 0)) {
if (module_exists('php')) {
$output = php_eval($output);
}
}
$fptype = variable_get('front_2_type', 'drupal');
switch ($fptype) {
case 'themed':
// Removed theme('page', $output) wrapper from $output as
// discussed at http://drupal.org/node/224333#theme_page.
return $output;
case 'full':
print $output;
exit;
case 'redirect':
$url = front_page_parse_url(variable_get('front_2_redirect', 'drupal'));
drupal_goto($url['path'], $url['options']);
break;
}
case 'redirect':
$url = front_page_parse_url(variable_get('front_' . $role_id . '_redirect', 'drupal'));
drupal_goto($url['path'], $url['options']);
break;
}
}
}
}
}