Example #1
0
 public static function start()
 {
     global $avmod, $modulesNames, $targetmodule;
     $targetmoduleacces = true;
     $targetmodule = $_REQUEST['module'];
     $targetaction = $_REQUEST['action'];
     //Get a list of available module for this user
     $params = array($_SESSION["loggeduser"]['id']);
     $avmod = $GLOBALS["sclient"]->call('get_modules', $params);
     //echo '<h2>response</h2><pre>' . htmlspecialchars($GLOBALS["sclient"]->response, ENT_QUOTES) . '</pre>';
     //if no target module specified set HelpDesk as the default index module
     if (!isset($targetmodule) || $targetmodule == "") {
         $targetmodule = "HelpDesk";
     }
     //if a download for a file is requested call the function to retrieve the desired file
     if (isset($_REQUEST['downloadfile']) && $_REQUEST['downloadfile'] === "true") {
         User::download_file();
     }
     //Check if the requested module is Available
     foreach ($avmod as $key => $value) {
         if ($targetmodule == $value['name']) {
             $targetmoduleacces = false;
         }
         $modulesNames[$value['name']] = $value['translated_name'];
     }
     if ($targetmoduleacces && $targetmodule != 'Home') {
         $targetmodule = "HelpDesk";
         //die("Not Autorized!");
     }
     //Require the base module class
     require_once "modules/Module/index.php";
     //if isset a specific file and a specific class for the requested module include the extended class and create the object
     if (file_exists("modules/" . $targetmodule . "/index.php")) {
         require_once "modules/" . $targetmodule . "/index.php";
     }
     if (class_exists($targetmodule)) {
         $mod = new $targetmodule();
     } else {
         $mod = new BaseModule($targetmodule);
     }
     //if is pesent a target id show the corrispondent entity else show a list of entities for the target module
     if (isset($_REQUEST['id'])) {
         $mod->detail($_REQUEST['id']);
     } else {
         if (isset($_REQUEST['productid'])) {
             $mod->detail($_REQUEST['productid']);
         } else {
             if (isset($_REQUEST['faqid'])) {
                 $mod->detail($_REQUEST['faqid']);
             } else {
                 if ($targetmodule == "HelpDesk" && $targetaction == "new") {
                     $mod->create_new();
                 } else {
                     $mod->get_list();
                 }
             }
         }
     }
     //if there is a request for change password call the modal again and show the request resault
     if (isset($GLOBALS["opresult"]) && $GLOBALS["opresult"] != "") {
         echo "<script> \$(function(){ \$('#changePassModal').modal('show'); })</script>";
     }
 }
 public static function start()
 {
     global $avmod;
     $targetmodule = $_REQUEST['module'];
     $targetaction = $_REQUEST['action'];
     //Get a list of available module for this user
     $params = array($_SESSION["loggeduser"]['id']);
     $avmod = $GLOBALS["sclient"]->call('get_modules', $params);
     //If the dashboard is enabled show them as the index module of the portal
     if ($GLOBALS["show_dashboard"] == "true") {
         $avmod = array_merge(array("Home"), $avmod);
     }
     //If the vtlib api are configured add the configured module to the enabled modules array
     if (isset($GLOBALS['api_user']) && $GLOBALS['api_user'] != "" && isset($GLOBALS['api_pass']) && $GLOBALS['api_pass'] != "") {
         if (Api::connect() != 'API_LOGIN_FAILED') {
             if (isset($GLOBALS['api_modules']) && count($GLOBALS['api_modules']) > 0) {
                 foreach ($GLOBALS['api_modules'] as $modname => $modfields) {
                     if (isset($modfields["is_enabled"]) && $modfields["is_enabled"] == "true") {
                         $avmod[] = $modname;
                     }
                 }
             }
         }
         //if(in_array($modname, $GLOBALS['enabled_api_modules'])) $avmod[]=$modname;
     }
     Plugins::runall("PortalBase", "base", "preTemplateLoad", $_REQUEST);
     //if no target module specified set the first module defined in the CRM portal settings as the default index module
     if (!isset($targetmodule) || $targetmodule == "") {
         $targetmodule = $avmod[0];
     }
     //if a download for a file is requested call the function to retrieve the desired file
     if (isset($_REQUEST['downloadfile']) && $_REQUEST['downloadfile'] === "true") {
         User::download_file();
     }
     //Check if the requested module is Available
     if (!in_array($targetmodule, $avmod)) {
         Template::display($targetmodule, array(), 'not-authorized');
         die;
     }
     //Require the base module class
     require_once "modules/Module/index.php";
     //if isset a specific file and a specific class for the requested module include the extended class and create the object
     if (file_exists("modules/" . $targetmodule . "/index.php")) {
         require_once "modules/" . $targetmodule . "/index.php";
     }
     if (class_exists($targetmodule)) {
         $mod = new $targetmodule();
     } else {
         $mod = new BaseModule($targetmodule);
     }
     //if is pesent a target id show the corrispondent entity else show a list of entities for the target module
     if (isset($_REQUEST['ticketid'])) {
         $mod->detail($_REQUEST['ticketid']);
     } else {
         if (isset($_REQUEST['productid'])) {
             $mod->detail($_REQUEST['productid']);
         } else {
             if (isset($_REQUEST['faqid'])) {
                 $mod->detail($_REQUEST['faqid']);
             } else {
                 if (isset($_REQUEST['id'])) {
                     $mod->detail($_REQUEST['id']);
                 } else {
                     if ($targetmodule == "HelpDesk" && $targetaction == "new") {
                         $mod->create_new();
                     } else {
                         if ($targetmodule == "Home" || $targetaction == "dashboard") {
                             $mod->dashboard();
                         } else {
                             $mod->get_list();
                         }
                     }
                 }
             }
         }
     }
     //if there is a request for change password call the modal again and show the request resault
     if (isset($GLOBALS["opresult"]) && $GLOBALS["opresult"] != "") {
         echo "<script> \$(function(){ \$('#changePassModal').modal('show'); })</script>";
     }
 }