reworked the index.php page into the module's _ams_handler function, which will be the main function. Having some serialize/unserialize issues though..

This commit is contained in:
Quitta 2013-09-03 17:52:52 +02:00
parent 7eb7484e5b
commit b708fc3af3

View file

@ -16,9 +16,9 @@ ini_set('display_startup_errors', TRUE);
global $TOS_URL; global $TOS_URL;
global $cfg; global $cfg;
include 'ams_lib/libinclude.php'; require 'ams_lib/libinclude.php';
spl_autoload_register('__autoload'); spl_autoload_register('__autoload');
include 'config.php'; require 'config.php';
/* /*
Drupal 7 ryzom core module Drupal 7 ryzom core module
@ -236,12 +236,71 @@ function ryzommanage_block_view($delta = '')
break; break;
case 'ryzommanage_amsblock': case 'ryzommanage_amsblock':
$block['subject'] = t("uppercase this please"); //$block['subject'] = t("Ryzom Account Management System");
$block['content'] = ams_handler(); $block['content'] = _ams_handler();
break; break;
} }
return $block; return $block;
} }
function _ams_handler()
{
//Decide what page to load
if ( ! isset( $_GET["page"]) ){
if(isset($_SESSION['user'])){
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
$page = 'dashboard';
}else{
$page = 'show_user';
}
}else{
//default page
$page = 'login';
}
}else{
$page = $_GET["page"];
}
//perform an action in case one is specified
//else check if a php page is included in the inc folder, else just set page to the get param
if ( isset( $_POST["function"] ) ){
require( "func/" . $_POST["function"] . ".php" );
$return = $_POST["function"]();
}else{
$filename = 'inc/' . $page . '.php';
if(is_file($filename)){
require_once($filename);
$return = $page();
}
}
//add username to the return array in case logged in.
if(isset($_SESSION['user'])){
$return['username'] = $_SESSION['user'];
}
//Set permission
if(isset($_SESSION['ticket_user'])){
$return['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
}else{
//default permission
$return['permission'] = 0;
}
//handle error page
if($page == 'error'){
$return['permission'] = 0;
$return['no_visible_elements'] = 'FALSE';
}
return $page;
//helpers :: loadTemplate( $page , $return );
}
/** /**
* *
* Function _collect_register * Function _collect_register
@ -415,7 +474,7 @@ function createUser($values, $user_id)
function ryzommanage_user_login(&$edit, $account){ function ryzommanage_user_login(&$edit, $account){
$_SESSION['user'] = $account->name; $_SESSION['user'] = $account->name;
$_SESSION['id'] = $account->uid; $_SESSION['id'] = $account->uid;
$_SESSION['ticket_user'] = Ticket_User::constr_ExternId($_SESSION['id']); $_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id']));
} }
function login_form($login_form) function login_form($login_form)
@ -487,10 +546,7 @@ function top_bar()
} }
} }
function ams_handler()
{
return "This is a placeholder.";
}
function ryzommanage_user_presave(&$edit, $account, $category) function ryzommanage_user_presave(&$edit, $account, $category)
{ {