Newer
Older
* This file is part of Maarch Framework.
*
* Maarch Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
/****************************************************************************/
/* */
/* */
/* THIS PAGE CAN NOT BE OVERWRITTEN IN A CUSTOM */
/* */
/* */
/* **************************************************************************/
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* @defgroup core Framework core
*/
/**
* @brief Contains all the functions to load core and modules
*
* @file
* @author Laurent Giovannoni <dev@maarch.org>
* @date $date$
* @version $Revision$
* @ingroup core
*/
/**
* @brief Contains all the functions to load core and modules
*
* <ul>
* <li>Loads core tables into session</li>
* <li>Loads modules settings into session</li>
* <li>Builds the application menu</li>
* <li>Management and building the framework</li>
* <li>Modules services loading</li>
* <li>Execution of the module services </li>
*</ul>
*
* @ingroup core
*/
class core_tools extends functions
{
/**
* Load Maarch core configuration into sessions vars from the core/xml/config.xml file
*/
public function build_core_config($pathtoxmlcore)
{
$xmlconfig = simplexml_load_file($pathtoxmlcore);
// Loads core tables into session ($_SESSION['tablename'] array)
$TABLENAME = $xmlconfig->TABLENAME ;
$_SESSION['tablename']['actions'] = (string) $TABLENAME->actions;
$_SESSION['tablename']['authors'] = (string) $TABLENAME->authors;
$_SESSION['tablename']['docservers'] = (string) $TABLENAME->docservers;
$_SESSION['tablename']['doctypes'] = (string) $TABLENAME->doctypes;
$_SESSION['tablename']['ext_docserver'] = (string) $TABLENAME->extdocserver;
$_SESSION['tablename']['fulltext'] = (string) $TABLENAME->fulltext;
$_SESSION['tablename']['groupsecurity'] = (string) $TABLENAME->groupsecurity;
$_SESSION['tablename']['history'] = (string) $TABLENAME->history;
$_SESSION['tablename']['history_batch'] = (string) $TABLENAME->history_batch;
$_SESSION['tablename']['param'] = (string) $TABLENAME->param;
$_SESSION['tablename']['resgroups'] = (string) $TABLENAME->resgroups;
$_SESSION['tablename']['resgroup_content'] = (string) $TABLENAME->resgroup_content;
$_SESSION['tablename']['security'] = (string) $TABLENAME->security;
$_SESSION['tablename']['status'] = (string) $TABLENAME->status;
$_SESSION['tablename']['usergroups'] = (string) $TABLENAME->usergroups;
$_SESSION['tablename']['usergroup_content'] = (string) $TABLENAME->usergroupcontent;
$_SESSION['tablename']['usergroup_services'] = (string) $TABLENAME->usergroups_services;
$_SESSION['tablename']['users'] = (string) $TABLENAME->users;
}
/**
* Load Maarch modules configuration into sessions vars from modules/module_name/xml/config.xml files
*
* @param $modules array Enabled modules of the application
*/
public function load_modules_config($modules, $mode_batch=false)
{
require_once "core/class/class_request.php";
for ($i = 0; $i < count($modules); $i ++) {
if (file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
. 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR
. "config.xml"
)
) {
$configPath = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
. DIRECTORY_SEPARATOR . "config.xml";
} else {
$configPath = 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
. DIRECTORY_SEPARATOR . "config.xml";
if (file_exists('modules'.DIRECTORY_SEPARATOR.$modules[$i]['moduleid'].DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.$_SESSION['config']['lang'].'.php')) {
include_once 'modules'.DIRECTORY_SEPARATOR.$modules[$i]['moduleid'].DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.$_SESSION['config']['lang'].'.php';
}
if (file_exists($configPath)) {
// Reads the config.xml file of the current module
$xmlconfig = simplexml_load_file($configPath);
// Loads into $_SESSION['modules_loaded'] module's informations
foreach ($xmlconfig->CONFIG as $CONFIG) {
$_SESSION['modules_loaded'][$modules[$i]['moduleid']]['name'] =
(string) $CONFIG->name;
$_SESSION['modules_loaded'][$modules[$i]['moduleid']]['path'] =
'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR;
$comment = (string) $CONFIG->comment;
if ( !empty($comment) && defined($comment)
&& constant($comment) <> NULL
) {
$comment = constant($comment);
}
$_SESSION['modules_loaded'][$modules[$i]['moduleid']]['comment'] =
$comment;
$_SESSION['modules_loaded'][$modules[$i]['moduleid']]['fileprefix'] = (string) $CONFIG->fileprefix;
$_SESSION['modules_loaded'][$modules[$i]['moduleid']]['loaded'] = (string) $CONFIG->loaded;
}
if (file_exists(
$_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
. DIRECTORY_SEPARATOR . "class_modules_tools.php"
)
) {
$path_module_tools = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
. DIRECTORY_SEPARATOR . "class_modules_tools.php";
} else {
$path_module_tools = 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
. DIRECTORY_SEPARATOR . "class_modules_tools.php";
}
if (file_exists($path_module_tools)) {
require_once($path_module_tools);
$modules_tools = new $modules[$i]['moduleid'];
//Loads the tables of the module into session
$modules_tools->build_modules_tables();
//Loads log keywords of the module
}
foreach ($xmlconfig->KEYWORDS as $keyword) {
$tmp = (string) $keyword->label;
if ( !empty($tmp) && defined($tmp) && constant($tmp) <> NULL ) {
if (! $this->is_var_in_history_keywords_tab($id)) {
array_push(
$_SESSION['history_keywords'],
array(
'id' => $id,
'label' => $tmp
)
"select id, label_action from "
. $_SESSION['tablename']['actions']
. " where enabled = 'Y' and history = 'Y'"
array_push(
$_SESSION['history_keywords'],
array(
'id' =>'ACTION#' . $res->id,
'label' => $this->show_string($res->label_action)
)
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
}
}
}
/**
* Check if the log keyword is known in the apps
*
* @param $id string Log keyword to check
* @return bool True if the keyword is found, False otherwise
*/
public function is_var_in_history_keywords_tab($id)
{
$found = false;
for($i=0;$i<count($_SESSION['history_keywords']);$i++)
{
if($_SESSION['history_keywords'][$i]['id'] == $id)
{
$found = $_SESSION['history_keywords'][$i]['label'];
break;
}
}
return $found;
}
/**
* Loads the modules specific vars into session
*
* @param $modules Enabled modules of the application
*/
public function load_var_session($modules, $userData)
{
for ($i = 0;$i < count($modules); $i ++) {
if (file_exists(
$_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
. DIRECTORY_SEPARATOR . "class_modules_tools.php"
)
) {
$path_module_tools = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
. DIRECTORY_SEPARATOR . "class_modules_tools.php";
} else {
$path_module_tools = 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
. DIRECTORY_SEPARATOR . "class_modules_tools.php";
}
if (file_exists($path_module_tools)) {
require_once $path_module_tools;
$modules_tools = new $modules[$i]['moduleid'];
if (method_exists(
$modules[$i]['moduleid'], 'load_module_var_session'
)
) {
$modules_tools->load_module_var_session($userData);
}
}
//$this->show_array($_SESSION['user']['baskets']);
public static function load_lang($lang = 'fr', $maarch_directory = '', $maarch_apps = '')
{
if(isset($_SESSION['config']['lang']) && !empty($_SESSION['config']['lang']))
{
$lang = $_SESSION['config']['lang'];
}
if(isset($_SESSION['config']['corepath']) && !empty($_SESSION['config']['corepath']))
{
$maarch_directory = $_SESSION['config']['corepath'];
}
if(isset($_SESSION['config']['app_id']) && !empty($_SESSION['config']['app_id']))
{
$maarch_apps = $_SESSION['config']['app_id'];
}
//Loading custom lang file if present, this means that language constants are defined in the custom language file before other language files
if (isset($_SESSION['custom_override_id']) && !empty($_SESSION['custom_override_id']))
self::load_lang_custom_override($_SESSION['custom_override_id']);
if(isset($lang) && file_exists($maarch_directory.'apps/maarch_entreprise/lang'.DIRECTORY_SEPARATOR.$lang.'.php'))
include($maarch_directory.'apps/maarch_entreprise/lang'.DIRECTORY_SEPARATOR.$lang.'.php');
$_SESSION['error'] = "Language file missing";
}
if(isset($_SESSION['modules']))
{
self::load_lang_modules($_SESSION['modules']);
}
}
/**
* Loads language variables of each module
*
* @param $modules array Enabled modules of the application
private static function load_lang_modules($modules)
for ($i=0;$i<count($modules);$i++) {
$file_path = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR
. 'lang' . DIRECTORY_SEPARATOR
. $_SESSION['config']['lang'] . '.php';
if (!file_exists($file_path)) {
$file_path = $_SESSION['config']['corepath'] . 'modules'
. DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR
. $_SESSION['config']['lang'] . '.php';
if (isset($_SESSION['config']['lang']) && file_exists($file_path)) {
include($file_path);
} else if ($_SESSION['config']['debug'] === "true") {
$_SESSION['info'] .= "Language file missing for module : "
private static function load_lang_custom_override($custom_id)
{
$pathname = $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$custom_id.DIRECTORY_SEPARATOR.$_SESSION['config']['lang'].'.php';
if (file_exists($pathname)) {
include($pathname);
}
}
/**
* Loads menu items of each module and the application into session from menu.xml files
*
* @param $modules array Enabled modules of the application
*/
public function load_menu($modules)
{
$k = 0;
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
if (file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps'
. DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'menu.xml'
)
) {
$path = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR
. $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml'
. DIRECTORY_SEPARATOR . 'menu.xml';
} else {
$path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'menu.xml';
}
// Reads the apps/apps_name/xml/menu.xml file and loads into session
$xmlconfig = simplexml_load_file($path);
foreach ($xmlconfig->MENU as $MENU2) {
$_SESSION['menu'][$k]['id'] = (string) $MENU2->id;
if (isset($_SESSION['menu'][$k]['id'])
&& isset($_SESSION['user']['services'][$_SESSION['menu'][$k]['id']])
&& $_SESSION['user']['services'][$_SESSION['menu'][$k]['id']] == true
) { // Menu Identifier must be equal to the Service identifier
$libmenu = (string) $MENU2->libconst;
if ( !empty($libmenu) && defined($libmenu)
&& constant($libmenu) <> NULL
) {
$libmenu = constant($libmenu);
}
$_SESSION['menu'][$k]['libconst'] = $libmenu;
$_SESSION['menu'][$k]['url'] = $_SESSION['config']['businessappurl']
. (string) $MENU2->url;
if (trim((string) $MENU2->target) <> "") {
$tmp = preg_replace(
'/\/core\/$/', '/', $_SESSION['urltocore']
);
$_SESSION['menu'][$k]['url'] = $tmp. (string) $MENU2->url;
$_SESSION['menu'][$k]['target'] = (string) $MENU2->target;
}
$_SESSION['menu'][$k]['style'] = (string) $MENU2->style;
$_SESSION['menu'][$k]['show'] = true;
} else {
$_SESSION['menu'][$k]['libconst'] ='';
$_SESSION['menu'][$k]['url'] ='';
$_SESSION['menu'][$k]['style'] = '';
$_SESSION['menu'][$k]['show'] = false;
}
$k ++;
}
// Browses the enabled modules array
for ($i = 0; $i < count($modules); $i ++) {
if (file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
. 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "menu.xml"
)
) {
$menuPath = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
. DIRECTORY_SEPARATOR . "menu.xml";
} else {
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
. DIRECTORY_SEPARATOR . "menu.xml";
if (file_exists(
$_SESSION['config']['corepath'] . 'modules'
. DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "menu.xml"
) || file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
. 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "menu.xml"
)
) {
$xmlconfig = simplexml_load_file($menuPath);
foreach ($xmlconfig->MENU as $MENU) {
if (isset(
$_SESSION['user']['services'][$_SESSION['menu'][$k]['id']]
&& $_SESSION['user']['services'][$_SESSION['menu'][$k]['id']] == true
) {
$libmenu = (string) $MENU->libconst;
if ( !empty($libmenu) && defined($libmenu)
&& constant($libmenu) <> NULL
) {
$libmenu = constant($libmenu);
}
$_SESSION['menu'][$k]['libconst'] = $libmenu;
$_SESSION['menu'][$k]['url'] = $_SESSION['config']['businessappurl']
if (trim((string) $MENU->target) <> "") {
$tmp = preg_replace(
'/\/core\/$/', '/', $_SESSION['urltocore']
$_SESSION['menu'][$k]['target'] = (string) $MENU->target;
}
$_SESSION['menu'][$k]['style'] = (string) $MENU->style;
$_SESSION['menu'][$k]['show'] = true;
} else {
$_SESSION['menu'][$k]['libconst'] = '';
$_SESSION['menu'][$k]['url'] = '';
$_SESSION['menu'][$k]['style'] = '';
$_SESSION['menu'][$k]['show'] = false;
}
$this->load_quicklaunch($modules);
}
/**
* Builds the application menu from the session var menu
*
* @param $menu array Enabled menu items

Florian Azizian
committed
* @param $myProfil boolean Enabled my profil item
* @param $logout boolean Enabled logout item

Florian Azizian
committed
public function build_menu($menu, $myProfil = true, $logout = true)
//menu tri
$i=0;
foreach ($menu as $key => $row) {
$label[$i] = $row['libconst'];
$i++;
}
// Trie les données par volume décroissant, edition croissant
// Ajoute $data en tant que dernier paramètre, pour trier par la clé commune
array_multisort($label, SORT_ASC, $label, SORT_ASC, $menu);
// Browses the menu items
for($i=0;$i<count($menu);$i++)
{
if($menu[$i]['show'] == true)
{
$tmp = $menu[$i]['url'];
if(preg_match('/php$/', $tmp))
{
$tmp .= "?reinit=true";
}
else
{
$tmp .= "&reinit=true";
}
$tmp = htmlentities ( $tmp,ENT_COMPAT, 'UTF-8', true); // Encodes
?>
<li onmouseover="this.className='on';" onmouseout="this.className='';">
<a href="#" onclick="window.open('<?php echo($tmp);?>', '<?php
if(isset($menu[$i]['target']) && $menu[$i]['target'] <> '') {
echo $menu[$i]['target'];
} else {
echo '_self';
}?>');"><span><span style="width:30px;height:30px;display:inline-block;text-align:center;"><i class="<?php
echo $menu[$i]['style'] . ' fa-2x';
echo trim($menu[$i]['libconst']);?></span></span></a></li>
<?php
}
}
// Menu items always displayed

Florian Azizian
committed
if ($myProfil) {
echo '<li onmouseover="this.className=\'on\';" onmouseout="this.className=\'\';">
<a href="'.$_SESSION['config']['businessappurl']
. 'index.php?page=modify_user&admin=users&reinit=true"><span><span style="width:30px;height:30px;display:inline-block;text-align:center;"><i class="fa fa-user fa-2x"></i></span><span>'._MY_INFO.'</span></span></a></li>';

Florian Azizian
committed
}
if ($logout) {
echo '<li onmouseover="this.className=\'on\';" onmouseout="this.className=\'\';">
<a href="'.$_SESSION['config']['businessappurl']
. 'index.php?display=true&page=logout&logout=true"><span><span style="width:30px;height:30px;display:inline-block;text-align:center;"><i class="fa fa-power-off fa-2x"></i></span><span>'._LOGOUT.'</span></span></a></li>';

Florian Azizian
committed
}
}
/**
* Loads menu items of each module and the application into session from menu.xml files
*
* @param $modules array Enabled modules of the application
*/
public function load_quicklaunch($modules)
{
$k = 0;
if (file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps'
. DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'menu.xml'
)
) {
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR
. $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml'
. DIRECTORY_SEPARATOR . 'menu.xml';
} else {
$path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'menu.xml';
}
// Reads the apps/apps_name/xml/menu.xml file and loads into session
$xmlconfig = simplexml_load_file($path);
foreach ($xmlconfig->MENU as $MENU2) {
$_SESSION['quicklaunch'][$k]['id'] = (string) $MENU2->id;
if (isset($_SESSION['quicklaunch'][$k]['id'])
&& isset($_SESSION['user']['services'][$_SESSION['quicklaunch'][$k]['id']])
&& $_SESSION['user']['services'][$_SESSION['quicklaunch'][$k]['id']] == true
$libmenu = (string) $MENU2->libconst;
&& constant($libmenu) <> NULL
$libmenu = constant($libmenu);
$_SESSION['quicklaunch'][$k]['libconst'] = $libmenu;
$_SESSION['quicklaunch'][$k]['url'] = $_SESSION['config']['businessappurl']
if (trim((string) $MENU2->target) <> "") {
$tmp = preg_replace(
$_SESSION['quicklaunch'][$k]['url'] = $tmp. (string) $MENU2->url;
$_SESSION['quicklaunch'][$k]['target'] = (string) $MENU2->target;
$_SESSION['quicklaunch'][$k]['style'] = (string) $MENU2->style;
$_SESSION['quicklaunch'][$k]['show'] = true;
} else {
$_SESSION['quicklaunch'][$k]['libconst'] ='';
$_SESSION['quicklaunch'][$k]['url'] ='';
$_SESSION['quicklaunch'][$k]['style'] = '';
$_SESSION['quicklaunch'][$k]['show'] = false;
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
// Browses the enabled modules array
for ($i = 0; $i < count($modules); $i ++) {
if (file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
. 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "menu.xml"
)
) {
$menuPath = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
. DIRECTORY_SEPARATOR . "menu.xml";
} else {
$menuPath = 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
. DIRECTORY_SEPARATOR . "menu.xml";
}
if (file_exists(
$_SESSION['config']['corepath'] . 'modules'
. DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "menu.xml"
) || file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
. 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "menu.xml"
)
) {
$xmlconfig = simplexml_load_file($menuPath);
foreach ($xmlconfig->MENU as $MENU) {
$_SESSION['quicklaunch'][$k]['id'] = (string) $MENU->id;
if (isset(
$_SESSION['user']['services'][$_SESSION['quicklaunch'][$k]['id']]
)
&& $_SESSION['user']['services'][$_SESSION['quicklaunch'][$k]['id']] == true
) {
$libmenu = (string) $MENU->libconst;
if ( !empty($libmenu) && defined($libmenu)
&& constant($libmenu) <> NULL
) {
$libmenu = constant($libmenu);
}
$_SESSION['quicklaunch'][$k]['libconst'] = $libmenu;
$_SESSION['quicklaunch'][$k]['url'] = $_SESSION['config']['businessappurl']
. (string) $MENU->url;
if (trim((string) $MENU->target) <> "") {
$tmp = preg_replace(
'/\/core\/$/', '/', $_SESSION['urltocore']
);
$_SESSION['quicklaunch'][$k]['url'] = $tmp
. (string) $MENU->url;
$_SESSION['quicklaunch'][$k]['target'] = (string) $MENU->target;
}
$_SESSION['quicklaunch'][$k]['style'] = (string) $MENU->style;
$_SESSION['quicklaunch'][$k]['show'] = true;
} else {
$_SESSION['quicklaunch'][$k]['libconst'] = '';
$_SESSION['quicklaunch'][$k]['url'] = '';
$_SESSION['quicklaunch'][$k]['style'] = '';
$_SESSION['quicklaunch'][$k]['show'] = false;
}
$k ++;
}
}
}
* Builds the application quicklaunch from the session var quicklaunch
* @param $quicklaunch array Enabled quicklaunch items
public function build_quicklaunch($quicklaunch)
//$this->show_array($quicklaunch);
// Browses the quicklaunch items
$arrTmpQuicklaunch = array();
for ($i=0;$i<count($quicklaunch);$i++) {
if ($quicklaunch[$i]['show'] == true) {
array_push($arrTmpQuicklaunch, $quicklaunch[$i]);
}
}
echo '<div style="width: 85%;margin: auto;">';
for ($i=0;$i<count($arrTmpQuicklaunch);$i++) {
if ($arrTmpQuicklaunch[$i]['show'] == true) {
$tmp = $arrTmpQuicklaunch[$i]['url'];
if (preg_match('/php$/', $tmp)) {
$tmp .= "?reinit=true";
} else {
$tmp = htmlentities($tmp, ENT_COMPAT, 'UTF-8', true); // Encodes
<a href="#" style="display: inline-block;width: 45%;float:left;" onclick="window.open('<?php
echo $tmp;
?>', '<?php
if(
isset($arrTmpQuicklaunch[$i]['target'])
&& $arrTmpQuicklaunch[$i]['target'] <> ''
) {
echo $arrTmpQuicklaunch[$i]['target'];
} else {
echo '_self';
}?>');">
<span>
<span style="width:30px;height:30px;display:inline-block;text-align:center;" id="<?php
echo $arrTmpQuicklaunch[$i]['style'];
?>" >
<i style="width:30px;height:30px;" class="<?php
echo $arrTmpQuicklaunch[$i]['style'] . ' fa-2x'
</span>
<span>
<?php
echo trim($arrTmpQuicklaunch[$i]['libconst']);
?>
</span>
</span>
</a>
} else {
//$this->show_array($arrTmpQuicklaunch[$i]);
if($i%2){
echo '<div style="clear:both;"></div>';
}
echo '</div>';
echo '<div style="clear:both;"></div>';
// quicklaunch items always displayed
echo '<div style="width: 85%;margin: auto;">';
echo '<a style="display: inline-block;width: 45%;float: left;" href="' . $_SESSION['config']['businessappurl']
. 'index.php?page=modify_user&admin=users&reinit=true">';
echo '<span>';
echo '<span style="width:30px;height:30px;display:inline-block;text-align:center;">'
.'<i class="fa fa-user fa-2x mCdarkGrey"></i></span>';
echo '<span>'. _MY_INFO . '</span>';
echo '</a>';
echo '<a style="display: inline-block;width: 45%;float: left;" href="' . $_SESSION['config']['businessappurl']
. 'index.php?display=true&page=logout&logout=true">';
echo '<span style="width:30px;height:30px;display:inline-block;text-align:center;">'
.'<i class="fa fa-power-off fa-2x mCdarkGrey"></i></span>';
echo '<span>'. _LOGOUT . '</span>';
echo '</a>';
echo '<div style="clear:both;"></div>';
echo '</div>';
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
}
/**
* Loads application services into session
*/
public function load_app_services()
{
// Reads the application config.xml file
if (file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps'
. DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'services.xml'
)
) {
$path = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR
. $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml'
. DIRECTORY_SEPARATOR . 'services.xml';
} else {
$path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR
. 'services.xml';
}
$xmlconfig = simplexml_load_file($path);
$k = 0;
$m = 0;
include_once 'apps/' .$_SESSION['config']['app_id']. '/lang/' . $_SESSION['config']['lang'].'.php' ;
// Browses the services in that file and loads $_SESSION['app_services']
foreach ($xmlconfig->SERVICE as $service) {
$_SESSION['app_services'][$k] = array();
$_SESSION['app_services'][$k]['id'] = (string) $service->id;
$name = (string) $service->name;
if ( !empty($name) && defined($name) && constant($name) <> NULL ) {
$_SESSION['app_services'][$k]['name'] = $name;
$comment = (string) $service->comment;
&& constant($comment) <> NULL
$comment = constant($comment);
$_SESSION['app_services'][$k]['comment'] = $comment;
if (isset($service->servicepage)) {
$_SESSION['app_services'][$k]['servicepage'] = (string) $service->servicepage;
$_SESSION['app_services'][$k]['servicepage'] = preg_replace(
'/&admin/', '&admin',
$_SESSION['app_services'][$k]['servicepage']
);
$_SESSION['app_services'][$k]['servicepage'] = preg_replace(
'/&module/', '&module',
$_SESSION['app_services'][$k]['servicepage']
);
}
$_SESSION['app_services'][$k]['servicetype'] = (string) $service->servicetype;
if (isset($service->style)) {
$_SESSION['app_services'][$k]['style'] = (string) $service->style;
}
$systemService = (string) $service->system_service;
if ($systemService == "false") {
$_SESSION['app_services'][$k]['system_service'] = false;
} else {
$_SESSION['app_services'][$k]['system_service'] = true;
}
$_SESSION['app_services'][$k]['enabled'] = (string) $service->enabled;
$l = 0;
foreach ($service->WHEREAMIUSED as $whereAmIUsed) {
if (isset($whereAmIUsed)) {
$_SESSION['app_services'][$k]['whereamiused'][$l]['page'] = (string) $whereAmIUsed->page;
$_SESSION['app_services'][$k]['whereamiused'][$l]['nature'] = (string) $whereAmIUsed->nature;
if (isset($whereAmIUsed->button_label)) {
$_SESSION['app_services'][$k]['whereamiused'][$l]['button_label'] = (string) $whereAmIUsed->button_label;
}
if (isset($whereAmIUsed->tab_label)) {
$label = (string) $whereAmIUsed->tab_label;
if ( !empty($label) && defined($label)
&& constant($label) <> NULL
) {
$label = constant($label);
}
$_SESSION['app_services'][$k]['whereamiused'][$l]['tab_label'] = $label;
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
}
if (isset($whereAmIUsed->tab_order)) {
$_SESSION['app_services'][$k]['whereamiused'][$l]['tab_order'] = (string) $whereAmIUsed->tab_order;
}
if (isset($whereAmIUsed->width)) {
$_SESSION['app_services'][$k]['whereamiused'][$l]['width'] = (string) $whereAmIUsed->width;
}
if (isset($whereAmIUsed->frame_id)) {
$_SESSION['app_services'][$k]['whereamiused'][$l]['frame_id'] = (string) $whereAmIUsed->frame_id;
}
if (isset($whereAmIUsed->height)) {
$_SESSION['app_services'][$k]['whereamiused'][$l]['height'] = (string) $whereAmIUsed->height;
}
if (isset($whereAmIUsed->scrolling)){
$_SESSION['app_services'][$k]['whereamiused'][$l]['scrolling'] = (string) $whereAmIUsed->scrolling;
}
if (isset($whereAmIUsed->style)) {
$_SESSION['app_services'][$k]['whereamiused'][$l]['style'] = (string) $whereAmIUsed->style;
}
if (isset($whereAmIUsed->border)) {
$_SESSION['app_services'][$k]['whereamiused'][$l]['border'] = (string) $whereAmIUsed->border;
}
$l ++;
}
}
$m = 0;
// Loads preprocess and postprocess
foreach ($service->PROCESSINBACKGROUND as $processInBackground) {
$_SESSION['app_services'][$k]['processinbackground'][$m]['page'] = (string) $processInBackground->page;
if ((string) $processInBackground->preprocess <> "") {
$_SESSION['app_services'][$k]['processinbackground'][$m]['preprocess'] = (string) $processInBackground->preprocess;
}
if ((string) $processInBackground->postprocess <> "") {
$_SESSION['app_services'][$k]['processinbackground'][$m]['postprocess'] = (string) $processInBackground->postprocess;
}
$_SESSION['app_services'][$k]['processinbackground'][$m]['processorder'] = (string) $processInBackground->processorder;
$m++;
}
$k ++;
}
}
/**
* Loads the services of each module into session
*
* @param $modules array Enabled modules of the application
*/
public function load_modules_services($modules)
{
// Browses the enabled modules array
for ($i = 0; $i < count($modules); $i ++) {
if (file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
. 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
. DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR
. "services.xml"
)
) {
$path = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
. DIRECTORY_SEPARATOR . "services.xml";
} else {
. $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
. DIRECTORY_SEPARATOR . "services.xml";
foreach ($xmlconfig->SERVICE as $service) {
if ((string) $service->enabled == "true") {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['id'] = (string) $service->id;
$name = (string) $service->name;
if ( !empty($name) && defined($name)
&& constant($name) <> NULL
) {
$name = constant($name);
}
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['name'] =
$name;
$comment = (string) $service->comment;
if ( !empty($comment) && defined($comment)
&& constant($comment) <> NULL
) {
$comment = constant($comment);
}
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['comment'] =
if (isset($service->servicepage)) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['servicepage'] = (string) $service->servicepage;
}
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['servicetype'] = (string) $service->servicetype;
if (isset($service->style)) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['style'] = (string) $service->style;
}
$systemService = (string) $service->system_service;
if ($systemService == "false") {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['system_service'] = false;
} else {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['system_service'] = true;
}
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['enabled'] = (string) $service->enabled;
$l = 0;
foreach ($service->WHEREAMIUSED as $whereAmIUsed) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['page'] = (string) $whereAmIUsed->page;
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['nature'] = (string) $whereAmIUsed->nature;
if (isset($whereAmIUsed->button_label)) {
$label = (string) $whereAmIUsed->button_label;
if ( !empty($label) && defined($label)
&& constant($label) <> NULL
) {
$label = constant($label);
}
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['button_label'] =
if (isset($whereAmIUsed->tab_label)) {
$label = (string) $whereAmIUsed->tab_label;
if ( !empty($label) && defined($label)
&& constant($label) <> NULL
) {
$label = constant($label);
}
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['tab_label'] =
if (isset($whereAmIUsed->tab_order)) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['tab_order'] = (string) $whereAmIUsed->tab_order;
}
if (isset($whereAmIUsed->frame_id)) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['frame_id'] = (string) $whereAmIUsed->frame_id;
}
if (isset($whereAmIUsed->width)) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['width'] = (string) $whereAmIUsed->width;
}
if (isset($whereAmIUsed->height)) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['height'] = (string) $whereAmIUsed->height;
}
if (isset($whereAmIUsed->scrolling)) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['scrolling'] = (string) $whereAmIUsed->scrolling;
}
if (isset($whereAmIUsed->style)) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['style'] = (string) $whereAmIUsed->style;
}
if (isset($whereAmIUsed->border)) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['border'] = (string) $whereAmIUsed->border;
}
$m = 0;
foreach ($service->PROCESSINBACKGROUND as $processInBackground) {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['processinbackground'][$m]['page'] = (string) $processInBackground->page;
if ((string) $processInBackground->preprocess <> "") {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['processinbackground'][$m]['preprocess'] = (string) $processInBackground->preprocess;
}
if ((string) $processInBackground->postprocess <> "") {
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['processinbackground'][$m]['postprocess'] = (string) $processInBackground->postprocess;
}
$_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['processinbackground'][$m]['processorder'] = (string) $processInBackground->processorder;