function front_page in Front Page 5
Same name and namespace in other branches
- 6.2 front_page.module \front_page()
- 6 front_page.module \front_page()
- 7.2 front_page.module \front_page()
- 7 front_page.module \front_page()
2 string references to 'front_page'
- front_page_menu in ./
front_page.module - this function sets the necessary paths etc. so drupal knows where to find the front_page
- uninstall_front_page in ./
front_page.module - this function uninstalls the front page module
File
- ./
front_page.module, line 193
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. This default prevents this
*/
$output = 'node';
/* Set the time to check against the last access of the user by the variable set in settings.*/
switch (variable_get('front_special_notice_time', '')) {
case 'one day':
$check_time = time() - 24 * 60 * 60;
break;
case 'one week':
$check_time = time() - 7 * 24 * 60 * 60;
break;
case 'one month':
$check_time = time() - 30 * 24 * 60 * 60;
break;
case 'three months':
$check_time = time() - 90 * 24 * 60 * 60;
break;
case 'six months':
$check_time = time() - 180 * 24 * 60 * 60;
break;
case 'one year':
$check_time = time() - 360 * 24 * 60 * 60;
break;
}
//this checks to see if you are overriding HOME links on the site
if (variable_get('front_page_breadcrumb', 0)) {
// This checks to see if the referer is an internal HOME link or not.
$newhome = variable_get('front_page_breadcrumb_redirect', 'node');
$ref = $_SERVER["HTTP_REFERER"];
global $user, $base_url;
$parsed_url = parse_url($base_url);
$domain = $parsed_url['host'];
if (stristr($ref, $domain)) {
drupal_goto($path = $newhome, $query = NULL, $fragment = NULL);
}
}
// the following is the code that loads the front_page settings
global $user;
/*
* show this if the user is not logged in or if the authenticated user is to get the same output as
* anonymous users
*/
$authenticated_user_text_setting = variable_get("front_2_text", "");
if (!$user->uid || variable_get("front_2_type", "same") == "same" || empty($authenticated_user_text_setting)) {
$output = variable_get("front_1_text", "drupal");
/* if PHP code execution is allowed then use eval */
if (variable_get('front_1_php', 0)) {
$output = drupal_eval($output);
}
$fptype = variable_get("front_1_type", "drupal");
switch ($fptype) {
case "themed":
print theme('page', $output);
return;
case "full":
print $output;
return;
case "redirect":
$output = variable_get("front_1_redirect", "drupal");
break;
}
}
else {
if ($user->uid) {
$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.
foreach ($roles as $role_id => $role_name) {
// run through each role type starting at the most recent working backwards
if (array_key_exists($role_id, $user->roles) && trim(variable_get("front_" . $role_id . "_text", "")) != "") {
// if the current visitor has a role type that matches and if the front page setting for that role type is not empty.
if (variable_get("special_notice_text", "") != "" && $user->access < $check_time) {
$output = '<div id="mission">';
$output .= variable_get("special_notice_text", "");
$output .= '</div>';
$output .= variable_get("front_" . $role_id . "_text", "");
}
else {
$output = variable_get("front_" . $role_id . "_text", "");
}
/* if PHP code execution is allowed then use eval */
if (variable_get('front_". $role_id ."_php', 0)) {
$output = drupal_eval($output);
}
$fptype = variable_get("front_" . $role_id . "_type", "drupal");
//check whether it is a themed or full front page.
switch ($fptype) {
case "themed":
print theme('page', $output);
return;
case "full":
print $output;
return;
case "redirect":
$output = variable_get("front_" . $role_id . "_redirect", "drupal");
drupal_goto($path = $output, $query = NULL, $fragment = NULL);
break;
}
}
}
}
}
}