From 213000c5c83baaf4857c809d02b9f21fa6f99cd0 Mon Sep 17 00:00:00 2001 From: Quitta Date: Tue, 3 Sep 2013 17:52:52 +0200 Subject: [PATCH] reworked the index.php page into the module's _ams_handler function, which will be the main function. Having some serialize/unserialize issues though.. --- .../ryzommanage/ryzommanage.module | 74 ++++++++++++++++--- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module index 4a812578a..e4ff17005 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module @@ -16,9 +16,9 @@ ini_set('display_startup_errors', TRUE); global $TOS_URL; global $cfg; -include 'ams_lib/libinclude.php'; +require 'ams_lib/libinclude.php'; spl_autoload_register('__autoload'); -include 'config.php'; +require 'config.php'; /* Drupal 7 ryzom core module @@ -236,12 +236,71 @@ function ryzommanage_block_view($delta = '') break; case 'ryzommanage_amsblock': - $block['subject'] = t("uppercase this please"); - $block['content'] = ams_handler(); + //$block['subject'] = t("Ryzom Account Management System"); + $block['content'] = _ams_handler(); break; } 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 @@ -415,7 +474,7 @@ function createUser($values, $user_id) function ryzommanage_user_login(&$edit, $account){ $_SESSION['user'] = $account->name; $_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) @@ -487,10 +546,7 @@ function top_bar() } } -function ams_handler() -{ - return "This is a placeholder."; -} + function ryzommanage_user_presave(&$edit, $account, $category) {