2012-06-04 16:58:40 +02:00
< ? php
/*
FusionPBX
Version : MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 ( the " License " ); you may not use this file except in compliance with
the License . You may obtain a copy of the License at
http :// www . mozilla . org / MPL /
Software distributed under the License is distributed on an " AS IS " basis ,
WITHOUT WARRANTY OF ANY KIND , either express or implied . See the License
for the specific language governing rights and limitations under the
License .
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane < markjcrane @ fusionpbx . com >
2023-06-07 00:27:16 +02:00
Copyright ( C ) 2010 - 2023
2012-06-04 16:58:40 +02:00
All Rights Reserved .
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
*/
2019-12-19 07:24:22 +01:00
/**
* menu class
*
* @ method null delete
* @ method null toggle
* @ method null copy
*/
2016-04-15 07:23:14 +02:00
if ( ! class_exists ( 'menu' )) {
2012-06-04 16:58:40 +02:00
class menu {
2019-11-23 23:34:48 +01:00
2019-12-19 07:24:22 +01:00
/**
* declare the variables
*/
private $app_name ;
private $app_uuid ;
private $name ;
private $table ;
private $toggle_field ;
private $toggle_values ;
private $description_field ;
private $location ;
public $menu_uuid ;
public $menu_language ;
2020-03-18 03:31:29 +01:00
public $text ;
2019-12-19 07:24:22 +01:00
2024-08-05 17:53:11 +02:00
/**
* Set in the constructor . Must be a database object and cannot be null .
* @ var database Database Object
*/
private $database ;
2019-12-19 07:24:22 +01:00
/**
* called when the object is created
*/
2024-08-05 17:53:11 +02:00
public function __construct ( $setting_array = []) {
2019-12-19 07:24:22 +01:00
//assign the variables
2024-08-05 17:53:11 +02:00
$this -> app_name = 'menus' ;
$this -> app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7' ;
$this -> location = 'menus.php' ;
//open a database connection
if ( empty ( $setting_array [ 'database' ])) {
$this -> database = database :: new ();
} else {
$this -> database = $setting_array [ 'database' ];
}
2019-12-19 07:24:22 +01:00
}
/**
* delete rows from the database
*/
public function delete ( $records ) {
2020-02-11 04:46:08 +01:00
//assign the variables
$this -> name = 'menu' ;
$this -> table = 'menus' ;
2019-12-19 07:24:22 +01:00
if ( permission_exists ( $this -> name . '_delete' )) {
2017-07-01 22:13:51 +02:00
2019-12-19 07:24:22 +01:00
//add multi-lingual support
$language = new text ;
$text = $language -> get ();
//validate the token
$token = new token ;
if ( ! $token -> validate ( $_SERVER [ 'PHP_SELF' ])) {
message :: add ( $text [ 'message-invalid_token' ], 'negative' );
header ( 'Location: ' . $this -> location );
exit ;
}
//delete multiple records
if ( is_array ( $records ) && @ sizeof ( $records ) != 0 ) {
//build the delete array
$x = 0 ;
foreach ( $records as $record ) {
2023-05-27 20:00:02 +02:00
if ( ! empty ( $record [ 'checked' ]) && $record [ 'checked' ] == 'true' && is_uuid ( $record [ 'uuid' ])) {
2020-02-11 04:46:08 +01:00
//remove menu languages
$array [ 'menu_languages' ][ $x ][ $this -> name . '_uuid' ] = $record [ 'uuid' ];
2019-12-19 07:24:22 +01:00
2020-02-11 04:46:08 +01:00
//remove menu item groups
$array [ 'menu_item_groups' ][ $x ][ $this -> name . '_uuid' ] = $record [ 'uuid' ];
2019-12-19 07:24:22 +01:00
2020-02-11 04:46:08 +01:00
//remove menu items
$array [ 'menu_items' ][ $x ][ $this -> name . '_uuid' ] = $record [ 'uuid' ];
2019-12-19 07:24:22 +01:00
2020-02-11 04:46:08 +01:00
//build array to remove the menu
$array [ $this -> table ][ $x ][ $this -> name . '_uuid' ] = $record [ 'uuid' ];
2019-12-19 07:24:22 +01:00
2020-02-11 04:46:08 +01:00
//increment
$x ++ ;
}
2019-12-19 07:24:22 +01:00
}
//delete the checked rows
if ( is_array ( $array ) && @ sizeof ( $array ) != 0 ) {
2020-02-18 02:19:40 +01:00
//grant temporary permissions
$p = new permissions ;
$p -> add ( 'menu_item_delete' , 'temp' );
$p -> add ( 'menu_item_group_delete' , 'temp' );
$p -> add ( 'menu_language_delete' , 'temp' );
2019-12-19 07:24:22 +01:00
//execute delete
2024-08-05 17:53:11 +02:00
$this -> database -> app_name = $this -> app_name ;
$this -> database -> app_uuid = $this -> app_uuid ;
$this -> database -> delete ( $array );
2019-12-19 07:24:22 +01:00
unset ( $array );
2020-02-18 02:19:40 +01:00
//revoke temporary permissions
$p -> delete ( 'menu_item_delete' , 'temp' );
$p -> delete ( 'menu_item_group_delete' , 'temp' );
$p -> delete ( 'menu_language_delete' , 'temp' );
2019-12-19 07:24:22 +01:00
//set message
message :: add ( $text [ 'message-delete' ]);
}
unset ( $records );
}
}
}
2020-02-11 04:46:08 +01:00
public function delete_items ( $records ) {
//assign the variables
$this -> name = 'menu_item' ;
$this -> table = 'menu_items' ;
if ( permission_exists ( $this -> name . '_delete' )) {
2019-12-19 07:24:22 +01:00
//add multi-lingual support
$language = new text ;
$text = $language -> get ();
//validate the token
$token = new token ;
2020-02-11 04:46:08 +01:00
if ( ! $token -> validate ( '/core/menu/menu_item_list.php' )) {
2019-12-19 07:24:22 +01:00
message :: add ( $text [ 'message-invalid_token' ], 'negative' );
header ( 'Location: ' . $this -> location );
exit ;
}
2020-02-11 04:46:08 +01:00
//delete multiple records
2019-12-19 07:24:22 +01:00
if ( is_array ( $records ) && @ sizeof ( $records ) != 0 ) {
2020-02-11 04:46:08 +01:00
//build the delete array
$x = 0 ;
foreach ( $records as $record ) {
2023-05-27 20:00:02 +02:00
if ( ! empty ( $record [ 'checked' ]) && $record [ 'checked' ] == 'true' && is_uuid ( $record [ 'uuid' ])) {
2020-02-11 04:46:08 +01:00
//build array
$uuids [] = " ' " . $record [ 'uuid' ] . " ' " ;
//remove menu languages
$array [ 'menu_languages' ][ $x ][ $this -> name . '_uuid' ] = $record [ 'uuid' ];
//remove menu item groups
$array [ 'menu_item_groups' ][ $x ][ $this -> name . '_uuid' ] = $record [ 'uuid' ];
//remove menu items
$array [ $this -> table ][ $x ][ $this -> name . '_uuid' ] = $record [ 'uuid' ];
//increment
$x ++ ;
2019-12-19 07:24:22 +01:00
}
2017-11-17 22:44:31 +01:00
}
2020-02-11 04:46:08 +01:00
//include child menu items
2023-05-27 20:00:02 +02:00
if ( ! empty ( $uuids ) && @ sizeof ( $uuids ) != 0 ) {
2020-02-11 04:46:08 +01:00
$sql = " select menu_item_uuid as uuid from v_ " . $this -> table . " " ;
$sql .= " where menu_item_parent_uuid in ( " . implode ( ', ' , $uuids ) . " ) " ;
2024-08-05 17:53:11 +02:00
$rows = $this -> database -> select ( $sql , null , 'all' );
2023-05-27 20:00:02 +02:00
if ( ! empty ( $rows ) && @ sizeof ( $rows ) != 0 ) {
2019-12-19 07:24:22 +01:00
foreach ( $rows as $row ) {
2020-02-11 04:46:08 +01:00
//remove menu languages
$array [ 'menu_languages' ][ $x ][ $this -> name . '_uuid' ] = $row [ 'uuid' ];
//remove menu item groups
$array [ 'menu_item_groups' ][ $x ][ $this -> name . '_uuid' ] = $row [ 'uuid' ];
//remove menu items
$array [ $this -> table ][ $x ][ $this -> name . '_uuid' ] = $row [ 'uuid' ];
//increment
$x ++ ;
2019-12-19 07:24:22 +01:00
}
}
2017-11-17 22:44:31 +01:00
}
2019-12-19 07:24:22 +01:00
2020-02-11 04:46:08 +01:00
//delete the checked rows
2023-06-07 00:27:16 +02:00
if ( ! empty ( $array ) && is_array ( $array ) && @ sizeof ( $array ) != 0 ) {
2019-12-19 07:24:22 +01:00
2020-02-11 04:46:08 +01:00
//grant temporary permissions
$p = new permissions ;
$p -> add ( 'menu_language_delete' , 'temp' );
$p -> add ( 'menu_item_group_delete' , 'temp' );
2019-12-19 07:24:22 +01:00
2020-02-11 04:46:08 +01:00
//execute delete
2024-08-05 17:53:11 +02:00
$this -> database -> app_name = $this -> app_name ;
$this -> database -> app_uuid = $this -> app_uuid ;
$this -> database -> delete ( $array );
2019-12-19 07:24:22 +01:00
unset ( $array );
2020-02-11 04:46:08 +01:00
//revoke temporary permissions
$p -> delete ( 'menu_language_delete' , 'temp' );
$p -> delete ( 'menu_item_group_delete' , 'temp' );
2019-12-19 07:24:22 +01:00
//set message
2020-02-11 04:46:08 +01:00
message :: add ( $text [ 'message-delete' ]);
2019-12-19 07:24:22 +01:00
}
2020-02-11 04:46:08 +01:00
unset ( $records );
2012-06-04 16:58:40 +02:00
}
2019-12-19 07:24:22 +01:00
}
}
/**
2020-02-11 04:46:08 +01:00
* toggle a field between two values
2019-12-19 07:24:22 +01:00
*/
2020-02-11 04:46:08 +01:00
public function toggle_items ( $records ) {
//assign the variables
$this -> name = 'menu_item' ;
$this -> table = 'menu_items' ;
$this -> toggle_field = 'menu_item_protected' ;
$this -> toggle_values = [ 'true' , 'false' ];
if ( permission_exists ( $this -> name . '_edit' )) {
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
//add multi-lingual support
2017-06-01 18:21:21 +02:00
$language = new text ;
2019-12-19 07:24:22 +01:00
$text = $language -> get ();
//validate the token
$token = new token ;
2020-02-11 04:46:08 +01:00
if ( ! $token -> validate ( '/core/menu/menu_item_list.php' )) {
2019-12-19 07:24:22 +01:00
message :: add ( $text [ 'message-invalid_token' ], 'negative' );
header ( 'Location: ' . $this -> location );
exit ;
}
2023-05-27 20:00:02 +02:00
2020-02-11 04:46:08 +01:00
//toggle the checked records
2019-12-19 07:24:22 +01:00
if ( is_array ( $records ) && @ sizeof ( $records ) != 0 ) {
2020-02-11 04:46:08 +01:00
//get current toggle state
foreach ( $records as $record ) {
2023-05-27 20:00:02 +02:00
if ( ! empty ( $record [ 'checked' ]) && $record [ 'checked' ] == 'true' && is_uuid ( $record [ 'uuid' ])) {
2019-12-19 07:24:22 +01:00
$uuids [] = " ' " . $record [ 'uuid' ] . " ' " ;
}
}
2023-06-07 00:27:16 +02:00
if ( ! empty ( $uuids ) && is_array ( $uuids ) && @ sizeof ( $uuids ) != 0 ) {
2020-02-11 04:46:08 +01:00
$sql = " select " . $this -> name . " _uuid as uuid, " . $this -> toggle_field . " as toggle from v_ " . $this -> table . " " ;
2019-12-19 07:24:22 +01:00
$sql .= " where " . $this -> name . " _uuid in ( " . implode ( ', ' , $uuids ) . " ) " ;
2023-05-27 20:00:02 +02:00
$parameters = null ;
2024-08-05 17:53:11 +02:00
$rows = $this -> database -> select ( $sql , $parameters , 'all' );
2019-12-19 07:24:22 +01:00
if ( is_array ( $rows ) && @ sizeof ( $rows ) != 0 ) {
foreach ( $rows as $row ) {
2020-02-11 04:46:08 +01:00
$states [ $row [ 'uuid' ]] = $row [ 'toggle' ] == '' ? $this -> toggle_values [ 1 ] : $row [ 'toggle' ];
2019-12-19 07:24:22 +01:00
}
2019-10-12 23:37:22 +02:00
}
2019-12-19 07:24:22 +01:00
unset ( $sql , $parameters , $rows , $row );
2019-10-12 23:37:22 +02:00
}
2019-12-19 07:24:22 +01:00
2020-02-11 04:46:08 +01:00
//build update array
$x = 0 ;
2023-06-07 00:27:16 +02:00
if ( ! empty ( $states ) && is_array ( $states ) && @ sizeof ( $states ) != 0 ) {
foreach ( $states as $uuid => $state ) {
//create the array
$array [ $this -> table ][ $x ][ $this -> name . '_uuid' ] = $uuid ;
$array [ $this -> table ][ $x ][ $this -> toggle_field ] = $state == $this -> toggle_values [ 0 ] ? $this -> toggle_values [ 1 ] : $this -> toggle_values [ 0 ];
2020-02-11 04:46:08 +01:00
2023-06-07 00:27:16 +02:00
//increment
$x ++ ;
}
2020-02-11 04:46:08 +01:00
}
//save the changes
2023-06-07 00:27:16 +02:00
if ( ! empty ( $array ) && is_array ( $array ) && @ sizeof ( $array ) != 0 ) {
2019-12-19 07:24:22 +01:00
//save the array
2024-08-05 17:53:11 +02:00
$this -> database -> app_name = $this -> app_name ;
$this -> database -> app_uuid = $this -> app_uuid ;
$this -> database -> save ( $array );
2019-12-19 07:24:22 +01:00
unset ( $array );
//set message
2020-02-11 04:46:08 +01:00
message :: add ( $text [ 'message-toggle' ]);
2019-12-19 07:24:22 +01:00
}
2020-02-11 04:46:08 +01:00
unset ( $records , $states );
2019-12-19 07:24:22 +01:00
}
}
}
/**
* delete items in the menu that are not protected
*/
public function delete_unprotected () {
//remove existing menu languages
$sql = " delete from v_menu_languages " ;
$sql .= " where menu_uuid = :menu_uuid " ;
$sql .= " and menu_item_uuid in ( " ;
$sql .= " select menu_item_uuid " ;
$sql .= " from v_menu_items " ;
$sql .= " where menu_uuid = :menu_uuid " ;
$sql .= " and ( " ;
$sql .= " menu_item_protected <> 'true' " ;
$sql .= " or menu_item_protected is null " ;
$sql .= " ) " ;
$sql .= " ) " ;
$parameters [ 'menu_uuid' ] = $this -> menu_uuid ;
2024-08-05 17:53:11 +02:00
$this -> database -> execute ( $sql , $parameters );
2019-12-19 07:24:22 +01:00
unset ( $sql , $parameters );
//remove existing unprotected menu item groups
$sql = " delete from v_menu_item_groups " ;
$sql .= " where menu_uuid = :menu_uuid " ;
$sql .= " and menu_item_uuid in ( " ;
$sql .= " select menu_item_uuid " ;
$sql .= " from v_menu_items " ;
$sql .= " where menu_uuid = :menu_uuid " ;
$sql .= " and ( " ;
$sql .= " menu_item_protected <> 'true' " ;
$sql .= " or menu_item_protected is null " ;
$sql .= " ) " ;
$sql .= " ) " ;
$parameters [ 'menu_uuid' ] = $this -> menu_uuid ;
2024-08-05 17:53:11 +02:00
$this -> database -> execute ( $sql , $parameters );
2019-12-19 07:24:22 +01:00
unset ( $sql , $parameters );
//remove existing unprotected menu items
$sql = " delete from v_menu_items " ;
$sql .= " where menu_uuid = :menu_uuid " ;
$sql .= " and ( " ;
$sql .= " menu_item_protected <> 'true' " ;
$sql .= " or menu_item_protected is null " ;
$sql .= " ) " ;
$parameters [ 'menu_uuid' ] = $this -> menu_uuid ;
2024-08-05 17:53:11 +02:00
$this -> database -> execute ( $sql , $parameters );
2019-12-19 07:24:22 +01:00
unset ( $sql , $parameters );
}
/**
* restore the menu
*/
public function restore () {
//get the $apps array from the installed apps from the core and mod directories
$config_list = glob ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . " /*/*/app_menu.php " );
$x = 0 ;
if ( is_array ( $config_list )) {
2020-03-03 07:47:17 +01:00
foreach ( $config_list as $config_path ) {
2019-12-19 07:24:22 +01:00
$app_path = dirname ( $config_path );
$app_path = preg_replace ( '/\A.*(\/.*\/.*)\z/' , '$1' , $app_path );
$y = 0 ;
try {
//echo "[".$x ."] ".$config_path."\n";
include ( $config_path );
$x ++ ;
}
catch ( Exception $e ) {
echo 'exception caught: ' . $e -> getMessage () . " \n " ;
exit ;
2019-10-12 23:37:22 +02:00
}
}
2019-12-19 07:24:22 +01:00
}
2019-10-12 23:37:22 +02:00
2019-12-19 07:24:22 +01:00
//get the list of languages
$language = new text ;
//create a uuid array of the original uuid used as the key and new uuid as the value
if ( is_array ( $apps )) {
$x = 0 ;
foreach ( $apps as $row ) {
if ( is_array ( $row [ 'menu' ])) {
foreach ( $row [ 'menu' ] as $menu ) {
$uuid_array [ $menu [ 'uuid' ]] = uuid ();
}
}
}
}
//if the item uuid is not currently in the db then add it
$sql = " select * from v_menu_items " ;
$sql .= " where menu_uuid = :menu_uuid " ;
$parameters [ 'menu_uuid' ] = $this -> menu_uuid ;
2024-08-05 17:53:11 +02:00
$menu_items = $this -> database -> select ( $sql , $parameters , 'all' );
2019-12-19 07:24:22 +01:00
//use the app array to restore the default menu
if ( is_array ( $apps )) {
$x = 0 ;
foreach ( $apps as $row ) {
if ( is_array ( $row [ 'menu' ])) {
foreach ( $row [ 'menu' ] as $menu ) {
//set the variables
2023-05-05 18:46:37 +02:00
if ( ! empty ( $menu [ 'title' ][ $this -> menu_language ])) {
2019-12-19 07:24:22 +01:00
$menu_item_title = $menu [ 'title' ][ $this -> menu_language ];
}
else {
$menu_item_title = $menu [ 'title' ][ 'en-us' ];
}
$uuid = $menu [ 'uuid' ];
$menu_item_uuid = $uuid_array [ $menu [ 'uuid' ]];
2023-05-17 22:36:14 +02:00
$menu_item_parent_uuid = $uuid_array [ $menu [ 'parent_uuid' ]] ? ? null ;
2019-12-19 07:24:22 +01:00
$menu_item_category = $menu [ 'category' ];
2023-05-17 22:36:14 +02:00
$menu_item_icon = $menu [ 'icon' ] ? ? null ;
2019-12-19 07:24:22 +01:00
$menu_item_path = $menu [ 'path' ];
2023-05-17 22:36:14 +02:00
$menu_item_order = $menu [ 'order' ] ? ? null ;
$menu_item_description = $menu [ 'desc' ] ? ? null ;
2019-12-19 07:24:22 +01:00
2022-07-09 02:38:13 +02:00
//sanitize the menu link
2022-12-16 02:29:46 +01:00
$menu_item_path = preg_replace ( '#[^a-zA-Z0-9_:\-\.\&\=\?\/]#' , '' , $menu_item_path );
2022-07-09 02:38:13 +02:00
2019-12-19 07:24:22 +01:00
//check if the menu item exists and if it does set the row array
$menu_item_exists = false ;
foreach ( $menu_items as $item ) {
if ( $item [ 'uuid' ] == $menu [ 'uuid' ]) {
$menu_item_exists = true ;
$row = $item ;
2017-11-17 22:44:31 +01:00
}
2019-12-19 07:24:22 +01:00
}
//item exists in the database
if ( $menu_item_exists ) {
//get parent_menu_item_protected
2019-10-13 23:44:21 +02:00
foreach ( $menu_items as $item ) {
2019-12-19 07:24:22 +01:00
if ( $item [ 'uuid' ] == $menu [ 'parent_uuid' ]) {
$parent_menu_item_protected = $item [ 'menu_item_protected' ];
2019-10-13 23:44:21 +02:00
}
}
2019-12-19 07:24:22 +01:00
//parent is not protected so the parent uuid needs to be updated
if ( is_uuid ( $menu_item_parent_uuid ) && $menu_item_parent_uuid != $row [ 'menu_item_parent_uuid' ] && $parent_menu_item_protected != 'true' ) {
$array [ 'menu_items' ][ $x ][ 'menu_item_uuid' ] = $row [ 'menu_item_uuid' ];
$array [ 'menu_items' ][ $x ][ 'menu_item_parent_uuid' ] = $menu_item_parent_uuid ;
$x ++ ;
}
}
2019-09-03 17:59:37 +02:00
2019-12-19 07:24:22 +01:00
//item does not exist in the database
if ( ! $menu_item_exists ) {
if ( $menu_item_uuid != $menu_item_parent_uuid ) {
$array [ 'menu_items' ][ $x ][ 'menu_item_uuid' ] = $menu_item_uuid ;
$array [ 'menu_items' ][ $x ][ 'menu_uuid' ] = $this -> menu_uuid ;
$array [ 'menu_items' ][ $x ][ 'uuid' ] = $uuid ;
$array [ 'menu_items' ][ $x ][ 'menu_item_title' ] = $menu_item_title ;
$array [ 'menu_items' ][ $x ][ 'menu_item_link' ] = $menu_item_path ;
$array [ 'menu_items' ][ $x ][ 'menu_item_category' ] = $menu_item_category ;
$array [ 'menu_items' ][ $x ][ 'menu_item_icon' ] = $menu_item_icon ;
2023-05-05 18:46:37 +02:00
if ( ! empty ( $menu_item_order )) {
2019-12-19 07:24:22 +01:00
$array [ 'menu_items' ][ $x ][ 'menu_item_order' ] = $menu_item_order ;
}
if ( is_uuid ( $menu_item_parent_uuid )) {
$array [ 'menu_items' ][ $x ][ 'menu_item_parent_uuid' ] = $menu_item_parent_uuid ;
}
$array [ 'menu_items' ][ $x ][ 'menu_item_description' ] = $menu_item_description ;
2019-10-13 23:44:21 +02:00
$x ++ ;
2017-11-17 22:44:31 +01:00
}
2019-12-19 07:24:22 +01:00
}
unset ( $field , $parameters , $num_rows );
//set the menu languages
if ( ! $menu_item_exists && is_array ( $language -> languages )) {
foreach ( $language -> languages as $menu_language ) {
//set the menu item title
2023-05-17 22:36:14 +02:00
if ( ! empty ( $menu [ " title " ][ $menu_language ])) {
$menu_item_title = $menu [ " title " ][ $menu_language ];
}
else {
2019-12-19 07:24:22 +01:00
$menu_item_title = $menu [ " title " ][ 'en-us' ];
}
2019-10-13 23:44:21 +02:00
2019-12-19 07:24:22 +01:00
//build insert array
$array [ 'menu_languages' ][ $x ][ 'menu_language_uuid' ] = uuid ();
$array [ 'menu_languages' ][ $x ][ 'menu_item_uuid' ] = $menu_item_uuid ;
$array [ 'menu_languages' ][ $x ][ 'menu_uuid' ] = $this -> menu_uuid ;
$array [ 'menu_languages' ][ $x ][ 'menu_language' ] = $menu_language ;
$array [ 'menu_languages' ][ $x ][ 'menu_item_title' ] = $menu_item_title ;
$x ++ ;
2017-07-02 00:05:25 +02:00
}
2019-12-19 07:24:22 +01:00
}
2017-11-17 22:44:31 +01:00
}
2013-07-29 20:55:51 +02:00
}
2013-09-27 06:15:43 +02:00
}
2019-12-19 07:24:22 +01:00
if ( is_array ( $array ) && @ sizeof ( $array ) != 0 ) {
//grant temporary permissions
$p = new permissions ;
$p -> add ( 'menu_item_add' , 'temp' );
$p -> add ( 'menu_language_add' , 'temp' );
//execute insert
2024-08-05 17:53:11 +02:00
$this -> database -> app_name = 'menu' ;
$this -> database -> app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7' ;
$this -> database -> save ( $array );
2019-12-19 07:24:22 +01:00
unset ( $array );
//revoke temporary permissions
$p -> delete ( 'menu_item_add' , 'temp' );
$p -> delete ( 'menu_language_add' , 'temp' );
}
}
2013-11-24 01:15:02 +01:00
2019-12-19 07:24:22 +01:00
//make sure the default user groups exist
$group = new groups ;
$group -> defaults ();
//get default global group_uuids
$sql = " select group_uuid, group_name from v_groups " ;
$sql .= " where domain_uuid is null " ;
2024-08-05 17:53:11 +02:00
$result = $this -> database -> select ( $sql , null , 'all' );
2019-12-19 07:24:22 +01:00
if ( is_array ( $result ) && @ sizeof ( $result ) != 0 ) {
foreach ( $result as $row ) {
$group_uuids [ $row [ 'group_name' ]] = $row [ 'group_uuid' ];
2015-05-12 05:03:09 +02:00
}
2019-12-19 07:24:22 +01:00
}
unset ( $sql , $result , $row );
//if there are no groups listed in v_menu_item_groups under menu_item_uuid then add the default groups
if ( is_array ( $apps )) {
$x = 0 ;
foreach ( $apps as $app ) {
if ( is_array ( $apps )) {
foreach ( $app [ 'menu' ] as $sub_row ) {
if ( isset ( $sub_row [ 'groups' ])) {
foreach ( $sub_row [ 'groups' ] as $group ) {
$sql = " select count(*) from v_menu_item_groups " ;
$sql .= " where menu_item_uuid = :menu_item_uuid " ;
$sql .= " and menu_uuid = :menu_uuid " ;
$sql .= " and group_name = :group_name " ;
$sql .= " and group_uuid = :group_uuid " ;
$parameters [ 'menu_item_uuid' ] = $uuid_array [ $sub_row [ 'uuid' ]];
$parameters [ 'menu_uuid' ] = $this -> menu_uuid ;
$parameters [ 'group_name' ] = $group ;
2023-06-07 00:27:16 +02:00
$parameters [ 'group_uuid' ] = $group_uuids [ $group ] ? ? null ;
2024-08-05 17:53:11 +02:00
$num_rows = $this -> database -> select ( $sql , $parameters , 'column' );
2019-12-19 07:24:22 +01:00
if ( $num_rows == 0 ) {
//no menu item groups found, build insert array for defaults
$array [ 'menu_item_groups' ][ $x ][ 'menu_item_group_uuid' ] = uuid ();
$array [ 'menu_item_groups' ][ $x ][ 'menu_uuid' ] = $this -> menu_uuid ;
$array [ 'menu_item_groups' ][ $x ][ 'menu_item_uuid' ] = $uuid_array [ $sub_row [ 'uuid' ]];
$array [ 'menu_item_groups' ][ $x ][ 'group_name' ] = $group ;
2023-06-07 00:27:16 +02:00
$array [ 'menu_item_groups' ][ $x ][ 'group_uuid' ] = $group_uuids [ $group ] ? ? null ;
2019-12-19 07:24:22 +01:00
$x ++ ;
2017-11-17 22:44:31 +01:00
}
2019-12-19 07:24:22 +01:00
unset ( $sql , $parameters , $num_rows );
2017-11-17 22:44:31 +01:00
}
2013-07-29 19:22:40 +02:00
}
}
}
}
2013-11-24 01:15:02 +01:00
2019-12-19 07:24:22 +01:00
if ( is_array ( $array ) && @ sizeof ( $array ) != 0 ) {
//grant temporary permissions
$p = new permissions ;
$p -> add ( 'menu_item_group_add' , 'temp' );
//execute insert
2024-08-05 17:53:11 +02:00
$this -> database -> app_name = 'menu' ;
$this -> database -> app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7' ;
$this -> database -> save ( $array );
2019-12-19 07:24:22 +01:00
unset ( $array );
//revoke temporary permissions
$p -> delete ( 'menu_item_group_add' , 'temp' );
}
}
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
}
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
/**
* create the menu
*/
public function build_html ( $menu_item_level = 0 ) {
2015-07-30 19:49:51 +02:00
2019-12-19 07:24:22 +01:00
$menu_html_full = '' ;
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
$menu_array = $this -> menu_array ();
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
if ( ! isset ( $_SESSION [ 'groups' ])) {
$_SESSION [ 'groups' ][ 0 ][ 'group_name' ] = 'public' ;
}
2013-02-09 21:30:36 +01:00
2019-12-19 07:24:22 +01:00
if ( is_array ( $menu_array )) {
foreach ( $menu_array as $menu_field ) {
//set the variables
$menu_item_link = $menu_field [ 'menu_item_link' ];
$menu_item_category = $menu_field [ 'menu_item_category' ];
$menu_items = $menu_field [ 'menu_items' ];
//prepare the protected menus
$menu_item_title = ( $menu_field [ 'menu_item_protected' ] == " true " ) ? $menu_field [ 'menu_item_title' ] : $menu_field [ 'menu_language_title' ];
//prepare the menu_tags according to the category
$menu_tags = '' ;
switch ( $menu_item_category ) {
case " internal " :
$menu_tags = " href=' " . PROJECT_PATH . $submenu_item_link . " ' " ;
break ;
case " external " :
if ( substr ( $submenu_item_link , 0 , 1 ) == " / " ) {
$submenu_item_link = PROJECT_PATH . $submenu_item_link ;
2017-11-17 22:44:31 +01:00
}
2019-12-19 07:24:22 +01:00
$menu_tags = " href=' " . $submenu_item_link . " ' target='_blank' " ;
break ;
case " email " :
$menu_tags = " href='mailto: " . $submenu_item_link . " ' " ;
break ;
}
if ( $menu_item_level == 0 ) {
$menu_html = " <ul class='menu_main'> \n " ;
$menu_html .= " <li> \n " ;
if ( ! isset ( $_SESSION [ " username " ])) {
$_SESSION [ " username " ] = '' ;
}
2023-05-05 18:46:37 +02:00
if ( empty ( $_SESSION [ " username " ])) {
2019-12-19 07:24:22 +01:00
$menu_html .= " <a $menu_tags style='padding: 0px 0px; border-style: none; background: none;'><h2 align='center' style=''> " . $menu_item_title . " </h2></a> \n " ;
}
else {
if ( $submenu_item_link == " /login.php " || $submenu_item_link == " /users/signup.php " ) {
//hide login and sign-up when the user is logged in
2012-06-04 16:58:40 +02:00
}
else {
2023-05-05 18:46:37 +02:00
if ( empty ( $submenu_item_link )) {
2019-12-19 07:24:22 +01:00
$menu_html .= " <h2 align='center' style=''> " . $menu_item_title . " </h2> \n " ;
2015-01-09 21:57:40 +01:00
}
else {
2019-12-19 07:24:22 +01:00
$menu_html .= " <a " . $menu_tags . " style='padding: 0px 0px; border-style: none; background: none;'><h2 align='center' style=''> " . $menu_item_title . " </h2></a> \n " ;
2015-01-09 21:57:40 +01:00
}
2012-06-04 16:58:40 +02:00
}
}
2019-12-19 07:24:22 +01:00
}
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
if ( is_array ( $menu_field [ 'menu_items' ]) && count ( $menu_field [ 'menu_items' ]) > 0 ) {
$menu_html .= $this -> build_child_html ( $menu_item_level , $menu_field [ 'menu_items' ]);
}
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
if ( $menu_item_level == 0 ) {
$menu_html .= " </li> \n " ;
$menu_html .= " </ul> \n \n " ;
}
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
$menu_html_full .= $menu_html ;
} //end for each
2019-09-03 17:59:37 +02:00
}
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
return $menu_html_full ;
}
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
/**
* create the sub menus
*/
private function build_child_html ( $menu_item_level , $submenu_array ) {
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
$menu_item_level = $menu_item_level + 1 ;
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
if ( count ( $_SESSION [ 'groups' ]) == 0 ) {
$_SESSION [ 'groups' ][ 0 ][ 'group_name' ] = 'public' ;
}
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
if ( is_array ( $submenu_array )) {
//child menu found
$submenu_html = " <ul class='menu_sub'> \n " ;
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
foreach ( $submenu_array as $submenu_field ) {
//set the variables
$menu_item_link = $submenu_field [ 'menu_item_link' ];
$menu_item_category = $submenu_field [ 'menu_item_category' ];
$menu_items = $submenu_field [ 'menu_items' ];
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
//prepare the protected menus
$menu_item_title = ( $submenu_field [ 'menu_item_protected' ] == " true " ) ? $submenu_field [ 'menu_item_title' ] : $submenu_field [ 'menu_language_title' ];
2012-06-04 16:58:40 +02:00
2019-12-19 07:24:22 +01:00
//prepare the menu_tags according to the category
switch ( $menu_item_category ) {
case " internal " :
$menu_tags = " href=' " . PROJECT_PATH . $menu_item_link . " ' " ;
break ;
case " external " :
if ( substr ( $menu_item_link , 0 , 1 ) == " / " ) {
$menu_item_link = PROJECT_PATH . $menu_item_link ;
}
$menu_tags = " href=' " . $menu_item_link . " ' target='_blank' " ;
break ;
case " email " :
$menu_tags = " href='mailto: " . $menu_item_link . " ' " ;
break ;
2012-06-04 16:58:40 +02:00
}
2015-06-22 19:56:40 +02:00
2019-12-19 07:24:22 +01:00
$submenu_html .= " <li> " ;
2015-06-22 19:56:40 +02:00
2019-12-19 07:24:22 +01:00
//get sub menu for children
if ( is_array ( $menu_items ) && count ( $menu_items ) > 0 ) {
$str_child_menu = $this -> build_child_html ( $menu_item_level , $menu_items );
}
2016-03-26 19:22:15 +01:00
2019-12-19 07:24:22 +01:00
if ( strlen ( $str_child_menu ) > 1 ) {
$submenu_html .= " <a " . $menu_tags . " > " . $menu_item_title . " </a> " ;
$submenu_html .= $str_child_menu ;
unset ( $str_child_menu );
2019-09-03 17:59:37 +02:00
}
2019-12-19 07:24:22 +01:00
else {
$submenu_html .= " <a " . $menu_tags . " > " . $menu_item_title . " </a> " ;
2016-03-26 19:22:15 +01:00
}
2019-12-19 07:24:22 +01:00
$submenu_html .= " </li> \n " ;
}
unset ( $submenu_array );
2016-03-26 19:22:15 +01:00
2019-12-19 07:24:22 +01:00
$submenu_html .= " </ul> \n " ;
2016-03-26 19:22:15 +01:00
2019-12-19 07:24:22 +01:00
return $submenu_html ;
2019-09-03 17:59:37 +02:00
}
2019-12-19 07:24:22 +01:00
}
2016-03-26 19:22:15 +01:00
2019-12-19 07:24:22 +01:00
/**
* create the menu array
*/
public function menu_array ( $menu_item_level = 0 ) {
2016-03-26 19:22:15 +01:00
2019-12-19 07:24:22 +01:00
//if there are no groups then set the public group
if ( ! isset ( $_SESSION [ 'groups' ][ 0 ][ 'group_name' ])) {
$_SESSION [ 'groups' ][ 0 ][ 'group_name' ] = 'public' ;
}
2016-03-26 19:22:15 +01:00
2019-12-19 07:24:22 +01:00
//get the menu from the database
$sql = " select i.menu_item_link, l.menu_item_title as menu_language_title, " ;
$sql .= " i.menu_item_title, i.menu_item_protected, i.menu_item_category, " ;
$sql .= " i.menu_item_icon, i.menu_item_uuid, i.menu_item_parent_uuid " ;
$sql .= " from v_menu_items as i, v_menu_languages as l " ;
$sql .= " where i.menu_item_uuid = l.menu_item_uuid " ;
$sql .= " and l.menu_language = :menu_language " ;
$sql .= " and l.menu_uuid = :menu_uuid " ;
$sql .= " and i.menu_uuid = :menu_uuid " ;
$sql .= " and i.menu_item_parent_uuid is null " ;
$sql .= " and i.menu_item_uuid in " ;
$sql .= " ( " ;
$sql .= " select menu_item_uuid " ;
$sql .= " from v_menu_item_groups " ;
$sql .= " where menu_uuid = :menu_uuid " ;
$x = 0 ;
foreach ( $_SESSION [ 'groups' ] as $row ) {
$sql_where_or [] = " group_name = :group_name_ " . $x ;
$parameters [ 'group_name_' . $x ] = $row [ 'group_name' ];
$x ++ ;
}
if ( is_array ( $sql_where_or ) && @ sizeof ( $sql_where_or ) != 0 ) {
$sql .= " and ( " ;
$sql .= implode ( ' or ' , $sql_where_or );
$sql .= " ) " ;
}
$sql .= " and menu_item_uuid is not null " ;
$sql .= " ) " ;
$sql .= " order by i.menu_item_order asc " ;
2024-05-13 22:19:34 +02:00
$parameters [ 'menu_language' ] = $_SESSION [ 'domain' ][ 'language' ][ 'code' ] ? ? null ;
2019-12-19 07:24:22 +01:00
$parameters [ 'menu_uuid' ] = $this -> menu_uuid ;
2024-08-05 17:53:11 +02:00
$result = $this -> database -> select ( $sql , $parameters , 'all' );
2019-12-19 07:24:22 +01:00
unset ( $sql , $parameters );
//save the menu into an array
$x = 0 ;
$a = Array ();
if ( is_array ( $result ) && @ sizeof ( $result ) != 0 ) {
foreach ( $result as $row ) {
//add the row to the array
$a [ $x ] = $row ;
//add the sub menus to the array
$menu_item_level = 0 ;
2023-05-05 18:46:37 +02:00
if ( ! empty ( $row [ 'menu_item_uuid' ])) {
2019-12-19 07:24:22 +01:00
$a [ $x ][ 'menu_items' ] = $this -> menu_child_array ( $menu_item_level , $row [ 'menu_item_uuid' ]);
}
2017-11-17 22:44:31 +01:00
2019-12-19 07:24:22 +01:00
//increment the row number
$x ++ ;
2015-06-22 19:56:40 +02:00
}
2019-12-19 07:24:22 +01:00
}
unset ( $result , $row );
2015-06-22 19:56:40 +02:00
2019-12-19 07:24:22 +01:00
//return the array
return $a ;
}
2015-06-22 19:56:40 +02:00
2019-12-19 07:24:22 +01:00
/**
* create the sub menus
*/
private function menu_child_array ( $menu_item_level , $menu_item_uuid ) {
2019-09-03 17:59:37 +02:00
2019-12-19 07:24:22 +01:00
//set the level
$menu_item_level = $menu_item_level + 1 ;
2016-03-27 05:18:02 +02:00
2019-12-19 07:24:22 +01:00
//if there are no groups then set the public group
if ( ! isset ( $_SESSION [ 'groups' ][ 0 ][ 'group_name' ])) {
$_SESSION [ 'groups' ][ 0 ][ 'group_name' ] = 'public' ;
}
2019-09-03 17:59:37 +02:00
2019-12-19 07:24:22 +01:00
//get the child menu from the database
$sql = " select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_icon, i.menu_item_uuid, i.menu_item_parent_uuid " ;
$sql .= " from v_menu_items as i, v_menu_languages as l " ;
$sql .= " where i.menu_item_uuid = l.menu_item_uuid " ;
$sql .= " and l.menu_language = :menu_language " ;
$sql .= " and l.menu_uuid = :menu_uuid " ;
$sql .= " and i.menu_uuid = :menu_uuid " ;
$sql .= " and i.menu_item_parent_uuid = :menu_item_parent_uuid " ;
$sql .= " and i.menu_item_uuid in " ;
$sql .= " ( " ;
$sql .= " select menu_item_uuid " ;
$sql .= " from v_menu_item_groups " ;
$sql .= " where menu_uuid = :menu_uuid " ;
$x = 0 ;
foreach ( $_SESSION [ 'groups' ] as $row ) {
$sql_where_or [] = " group_name = :group_name_ " . $x ;
$parameters [ 'group_name_' . $x ] = $row [ 'group_name' ];
$x ++ ;
}
if ( is_array ( $sql_where_or ) && @ sizeof ( $sql_where_or ) != 0 ) {
$sql .= " and ( " ;
$sql .= implode ( ' or ' , $sql_where_or );
$sql .= " ) " ;
}
$sql .= " ) " ;
$sql .= " order by l.menu_item_title, i.menu_item_order asc " ;
$parameters [ 'menu_language' ] = $_SESSION [ 'domain' ][ 'language' ][ 'code' ];
$parameters [ 'menu_uuid' ] = $this -> menu_uuid ;
$parameters [ 'menu_item_parent_uuid' ] = $menu_item_uuid ;
2024-08-05 17:53:11 +02:00
$sub_result = $this -> database -> select ( $sql , $parameters , 'all' );
2019-12-19 07:24:22 +01:00
unset ( $sql , $parameters );
//save the child menu into an array
$x = 0 ;
$a = Array ();
if ( is_array ( $sub_result ) && @ sizeof ( $sub_result ) != 0 ) {
foreach ( $sub_result as $row ) {
//set the variables
$menu_item_link = $row [ 'menu_item_link' ];
$menu_item_category = $row [ 'menu_item_category' ];
$menu_item_icon = $row [ 'menu_item_icon' ];
$menu_item_uuid = $row [ 'menu_item_uuid' ];
$menu_item_parent_uuid = $row [ 'menu_item_parent_uuid' ];
2019-09-03 17:59:37 +02:00
2019-12-19 07:24:22 +01:00
//add the row to the array
$a [ $x ] = $row ;
2019-09-03 17:59:37 +02:00
2019-12-19 07:24:22 +01:00
//prepare the protected menus
if ( $row [ 'menu_item_protected' ] == " true " ) {
$a [ $x ][ 'menu_item_title' ] = $row [ 'menu_item_title' ];
}
else {
$a [ $x ][ 'menu_item_title' ] = $row [ 'menu_language_title' ];
}
2016-03-27 05:18:02 +02:00
2019-12-19 07:24:22 +01:00
//get sub menu for children
2023-05-05 18:46:37 +02:00
if ( ! empty ( $menu_item_uuid )) {
2019-12-19 07:24:22 +01:00
$a [ $x ][ 'menu_items' ] = $this -> menu_child_array ( $menu_item_level , $menu_item_uuid );
}
//increment the row
$x ++ ;
2016-03-27 05:18:02 +02:00
}
2019-12-19 07:24:22 +01:00
}
unset ( $sub_result , $row );
//return the array
return $a ;
}
/**
* add the default menu when no menu exists
*/
public function menu_default () {
//set the default menu_uuid
$this -> menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ;
//check to see if any menu exists
$sql = " select count(*) as count from v_menus " ;
$sql .= " where menu_uuid = :menu_uuid " ;
$parameters [ 'menu_uuid' ] = $this -> menu_uuid ;
2024-08-05 17:53:11 +02:00
$num_rows = $this -> database -> select ( $sql , $parameters , 'column' );
2019-12-19 07:24:22 +01:00
if ( $num_rows == 0 ) {
//built insert array
$array [ 'menus' ][ 0 ][ 'menu_uuid' ] = $this -> menu_uuid ;
$array [ 'menus' ][ 0 ][ 'menu_name' ] = 'default' ;
$array [ 'menus' ][ 0 ][ 'menu_language' ] = 'en-us' ;
$array [ 'menus' ][ 0 ][ 'menu_description' ] = 'Default Menu' ;
//grant temporary permissions
$p = new permissions ;
$p -> add ( 'menu_add' , 'temp' );
//execute insert
2024-08-05 17:53:11 +02:00
$this -> database -> app_name = 'menu' ;
$this -> database -> app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7' ;
$this -> database -> save ( $array );
2019-12-19 07:24:22 +01:00
unset ( $array );
//revoke temporary permissions
$p -> delete ( 'menu_add' , 'temp' );
//add the menu items
$this -> restore ();
}
unset ( $sql , $parameters , $result , $row );
}
2020-03-18 03:31:29 +01:00
/**
* build the fixed , static or inline horizontal menu html
*/
public function menu_horizontal ( $menu_array ) {
//determine menu behavior
2023-05-27 20:00:02 +02:00
$menu_style = ! empty ( $_SESSION [ 'theme' ][ 'menu_style' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'menu_style' ][ 'text' ] : 'fixed' ;
2020-03-18 03:31:29 +01:00
switch ( $menu_style ) {
case 'inline' :
$menu_type = 'default' ;
$menu_width = 'calc(100% - 20px)' ;
$menu_brand = false ;
$menu_corners = null ;
break ;
case 'static' :
$menu_type = 'static-top' ;
$menu_width = 'calc(100% - 40px)' ;
$menu_brand = true ;
$menu_corners = " style='-webkit-border-radius: 0 0 4px 4px; -moz-border-radius: 0 0 4px 4px; border-radius: 0 0 4px 4px;' " ;
break ;
case 'fixed' :
default :
2023-05-10 02:39:24 +02:00
$menu_type = 'fixed-' . ( ! empty ( $_SESSION [ 'theme' ][ 'menu_position' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'menu_position' ][ 'text' ] : 'top' );
2020-03-18 03:31:29 +01:00
if ( ! http_user_agent ( 'mobile' )) {
2023-05-10 02:39:24 +02:00
$menu_width = ! empty ( $_SESSION [ 'theme' ][ 'menu_width_fixed' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'menu_width_fixed' ][ 'text' ] : 'calc(90% - 20px)' ;
2020-03-18 03:31:29 +01:00
}
$menu_brand = true ;
$menu_corners = null ;
}
//begin navbar code
$html = " <nav class='navbar navbar-expand-sm " . $menu_type . " ' " . $menu_corners . " > \n " ;
2023-07-11 22:26:38 +02:00
$html .= " <div class='container-fluid' style='width: " . ( $menu_width ? ? '100%' ) . " ; padding: 0;'> \n " ;
2020-03-18 03:31:29 +01:00
$html .= " <div class='navbar-brand'> \n " ;
if ( $menu_brand ) {
//define menu brand mark
2023-05-10 02:39:24 +02:00
$menu_brand_text = ( ! empty ( $_SESSION [ 'theme' ][ 'menu_brand_text' ][ 'text' ])) ? escape ( $_SESSION [ 'theme' ][ 'menu_brand_text' ][ 'text' ]) : " FusionPBX " ;
2023-05-11 00:17:19 +02:00
switch ( $_SESSION [ 'theme' ][ 'menu_brand_type' ][ 'text' ] ? ? null ) {
2020-03-18 03:31:29 +01:00
case 'text' :
2020-05-21 05:24:19 +02:00
$html .= " <a class='navbar-brand-text' href=' " . PROJECT_PATH . " /'> " . $menu_brand_text . " </a> \n " ;
2020-03-18 03:31:29 +01:00
break ;
case 'image_text' :
2023-05-27 20:00:02 +02:00
$menu_brand_image = ( ! empty ( $_SESSION [ 'theme' ][ 'menu_brand_image' ][ 'text' ])) ? escape ( $_SESSION [ 'theme' ][ 'menu_brand_image' ][ 'text' ]) : PROJECT_PATH . " /themes/default/images/logo.png " ;
2020-03-18 03:31:29 +01:00
$html .= " <a href=' " . PROJECT_PATH . " /'> " ;
$html .= " <img id='menu_brand_image' class='navbar-logo' src=' " . $menu_brand_image . " ' title= \" " . escape ( $menu_brand_text ) . " \" > " ;
2023-05-27 20:00:02 +02:00
if ( ! empty ( $_SESSION [ 'theme' ][ 'menu_brand_image_hover' ][ 'text' ])) {
2020-03-18 03:31:29 +01:00
$html .= " <img id='menu_brand_image_hover' class='navbar-logo' style='display: none;' src=' " . $_SESSION [ 'theme' ][ 'menu_brand_image_hover' ][ 'text' ] . " ' title= \" " . escape ( $menu_brand_text ) . " \" > " ;
}
$html .= " </a> \n " ;
$html .= " <a class='navbar-brand-text' href=' " . PROJECT_PATH . " /'> " . $menu_brand_text . " </a> \n " ;
break ;
case 'none' :
break ;
case 'image' :
default :
2023-05-11 00:17:19 +02:00
$menu_brand_image = ! empty ( $_SESSION [ 'theme' ][ 'menu_brand_image' ][ 'text' ]) ? escape ( $_SESSION [ 'theme' ][ 'menu_brand_image' ][ 'text' ]) : PROJECT_PATH . " /themes/default/images/logo.png " ;
2020-03-18 03:31:29 +01:00
$html .= " <a href=' " . PROJECT_PATH . " /'> " ;
$html .= " <img id='menu_brand_image' class='navbar-logo' src=' " . $menu_brand_image . " ' title= \" " . escape ( $menu_brand_text ) . " \" > " ;
2023-05-27 20:00:02 +02:00
if ( isset ( $_SESSION [ 'theme' ][ 'menu_brand_image_hover' ][ 'text' ]) && ! empty ( $_SESSION [ 'theme' ][ 'menu_brand_image_hover' ][ 'text' ])) {
2020-03-18 03:31:29 +01:00
$html .= " <img id='menu_brand_image_hover' class='navbar-logo' style='display: none;' src=' " . $_SESSION [ 'theme' ][ 'menu_brand_image_hover' ][ 'text' ] . " ' title= \" " . escape ( $menu_brand_text ) . " \" > " ;
}
$html .= " </a> \n " ;
$html .= " <a style='margin: 0;'></a> \n " ;
}
}
$html .= " </div> \n " ;
$html .= " <button type='button' class='navbar-toggler' data-toggle='collapse' data-target='#main_navbar' aria-expanded='false' aria-controls='main_navbar' aria-label='Toggle Menu'> \n " ;
2024-08-10 02:14:52 +02:00
$html .= " <span class='fa-solid fa-bars'></span> \n " ;
2020-03-18 03:31:29 +01:00
$html .= " </button> \n " ;
$html .= " <div class='collapse navbar-collapse' id='main_navbar'> \n " ;
$html .= " <ul class='navbar-nav'> \n " ;
2023-05-27 20:00:02 +02:00
if ( ! empty ( $menu_array ) && sizeof ( $menu_array ) != 0 ) {
2020-03-18 03:31:29 +01:00
foreach ( $menu_array as $index_main => $menu_parent ) {
$mod_li = " nav-item " ;
$mod_a_1 = " " ;
$submenu = false ;
2023-05-27 20:00:02 +02:00
if ( ! empty ( $menu_parent [ 'menu_items' ]) && sizeof ( $menu_parent [ 'menu_items' ]) > 0 ) {
2020-03-18 03:31:29 +01:00
$mod_li = " nav-item dropdown " ;
$mod_a_1 = " data-toggle='dropdown' " ;
$submenu = true ;
}
2023-05-27 20:00:02 +02:00
$mod_a_2 = ( ! empty ( $menu_parent [ 'menu_item_link' ]) && ! $submenu ) ? $menu_parent [ 'menu_item_link' ] : '#' ;
2020-03-18 03:31:29 +01:00
$mod_a_3 = ( $menu_parent [ 'menu_item_category' ] == 'external' ) ? " target='_blank' " : null ;
if ( isset ( $_SESSION [ 'theme' ][ 'menu_main_icons' ][ 'boolean' ]) && $_SESSION [ 'theme' ][ 'menu_main_icons' ][ 'boolean' ] == 'true' ) {
2024-08-10 02:14:52 +02:00
if ( ! empty ( $menu_parent [ 'menu_item_icon' ]) && substr ( $menu_parent [ 'menu_item_icon' ], 0 , 3 ) == 'fa-' ) { // font awesome icon
$menu_main_icon = " <span class=' " . escape ( $menu_parent [ 'menu_item_icon' ]) . " ' title= \" " . escape ( $menu_parent [ 'menu_language_title' ]) . " \" ></span> " ;
2020-03-18 03:31:29 +01:00
}
else {
$menu_main_icon = null ;
}
2023-10-18 15:13:39 +02:00
$menu_main_item = " <span class='d-sm-none d-md-none d-lg-inline' style='margin-left: 5px;'> " . $menu_parent [ 'menu_language_title' ] . " </span> \n " ;
2020-03-18 03:31:29 +01:00
}
else {
$menu_main_item = $menu_parent [ 'menu_language_title' ];
}
$html .= " <li class=' " . $mod_li . " '> \n " ;
$html .= " <a class='nav-link' " . $mod_a_1 . " href=' " . $mod_a_2 . " ' " . $mod_a_3 . " > \n " ;
$html .= " " . $menu_main_icon . $menu_main_item ;
$html .= " </a> \n " ;
if ( $submenu ) {
2023-10-17 02:27:59 +02:00
$columns = @ sizeof ( $menu_parent [ 'menu_items' ]) > 20 ? 2 : 1 ;
$column_current = 1 ;
$mod_ul = $columns > 1 ? 'multi-column' : null ;
$html .= " <ul class='dropdown-menu " . $mod_ul . " '> \n " ;
if ( $columns > 1 ) {
$html .= " <div class='row'> \n " ;
$html .= " <div class='col-12 col-sm-6 pr-sm-0'> \n " ;
$html .= " <ul class='multi-column-dropdown'> \n " ;
}
2020-03-18 03:31:29 +01:00
foreach ( $menu_parent [ 'menu_items' ] as $index_sub => $menu_sub ) {
$mod_a_2 = $menu_sub [ 'menu_item_link' ];
if ( $mod_a_2 == '' ) {
$mod_a_2 = '#' ;
}
$mod_a_3 = ( $menu_sub [ 'menu_item_category' ] == 'external' ) ? " target='_blank' " : null ;
2020-05-16 00:24:23 +02:00
$menu_sub_icon = null ;
2020-03-18 03:31:29 +01:00
if ( $_SESSION [ 'theme' ][ 'menu_sub_icons' ][ 'boolean' ] != 'false' ) {
2024-08-10 02:14:52 +02:00
if ( ! empty ( $menu_sub [ 'menu_item_icon' ]) && substr ( $menu_sub [ 'menu_item_icon' ], 0 , 3 ) == 'fa-' ) { // font awesome icon
$menu_sub_icon = " <span class=' " . escape ( $menu_sub [ 'menu_item_icon' ]) . " '></span> " ;
2020-03-18 03:31:29 +01:00
}
else {
$menu_sub_icon = null ;
}
}
2024-08-10 02:14:52 +02:00
$html .= " <li class='nav-item'><a class='nav-link' href=' " . $mod_a_2 . " ' " . $mod_a_3 . " > " . ( $_SESSION [ 'theme' ][ 'menu_sub_icons' ][ 'boolean' ] != 'false' ? " <span class='fa-solid fa-minus d-inline-block d-sm-none float-left' style='margin: 4px 10px 0 25px;'></span> " : null ) . escape ( $menu_sub [ 'menu_language_title' ]) . $menu_sub_icon . " </a></li> \n " ;
2023-10-17 02:27:59 +02:00
if ( $columns > 1 && $column_current == 1 && ( $index_sub + 1 ) > ( ceil ( @ sizeof ( $menu_parent [ 'menu_items' ]) / 2 ) - 1 )) {
$html .= " </ul> \n " ;
$html .= " </div> \n " ;
$html .= " <div class='col-12 col-sm-6 pl-sm-0'> \n " ;
$html .= " <ul class='multi-column-dropdown'> \n " ;
$column_current = 2 ;
}
}
if ( $columns > 1 ) {
$html .= " </ul> \n " ;
$html .= " </div> \n " ;
$html .= " </div> \n " ;
2020-03-18 03:31:29 +01:00
}
$html .= " </ul> \n " ;
}
$html .= " </li> \n " ;
}
}
$html .= " </ul> \n " ;
$html .= " <ul class='navbar-nav ml-auto'> \n " ;
2021-11-30 16:35:40 +01:00
//current user
2023-05-10 02:39:24 +02:00
if ( isset ( $_SESSION [ 'theme' ][ 'user_visible' ][ 'text' ]) && $_SESSION [ 'theme' ][ 'user_visible' ][ 'text' ] == 'true' ) {
2021-11-30 16:35:40 +01:00
$html .= " <li class='nav-item'> \n " ;
2024-08-10 02:14:52 +02:00
$html .= " <a class='header_user' href=' " . PROJECT_PATH . " /core/users/user_edit.php?id=user' title= \" " . $this -> text [ 'theme-label-user' ] . " \" ><i class=' " . ( ! empty ( $_SESSION [ 'theme' ][ 'body_header_icon_user' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'body_header_icon_user' ][ 'text' ] : 'fa-solid fa-user-circle' ) . " fa-lg fa-fw' style='margin-top: 6px; margin-right: 5px;'></i> " . escape ( $_SESSION [ 'username' ]) . " </a> " ;
2021-11-30 16:35:40 +01:00
$html .= " </li> \n " ;
}
2020-03-18 03:31:29 +01:00
//domain name/selector
2023-05-27 20:00:02 +02:00
if ( ! empty ( $_SESSION [ 'username' ]) && permission_exists ( 'domain_select' ) && count ( $_SESSION [ 'domains' ]) > 1 && $_SESSION [ 'theme' ][ 'domain_visible' ][ 'text' ] == 'true' ) {
2020-03-18 03:31:29 +01:00
$html .= " <li class='nav-item'> \n " ;
2024-08-10 02:14:52 +02:00
$html .= " <a class='header_domain' href='#' id='header_domain_selector_domain' title=' " . $this -> text [ 'theme-label-open_selector' ] . " '><i class=' " . ( ! empty ( $_SESSION [ 'theme' ][ 'body_header_icon_domain' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'body_header_icon_domain' ][ 'text' ] : 'fa-solid fa-earth-americas' ) . " fa-lg fa-fw' style='margin-top: 6px; margin-right: 5px;'></i> " . escape ( $_SESSION [ 'domain_name' ]) . " </a> " ;
2020-03-18 03:31:29 +01:00
$html .= " </li> \n " ;
}
//logout icon
2023-05-27 20:00:02 +02:00
if ( ! empty ( $_SESSION [ 'username' ]) && isset ( $_SESSION [ 'theme' ][ 'logout_icon_visible' ]) && $_SESSION [ 'theme' ][ 'logout_icon_visible' ][ 'text' ] == " true " ) {
2020-03-18 03:31:29 +01:00
$username_full = $_SESSION [ 'username' ] . (( count ( $_SESSION [ 'domains' ]) > 1 ) ? " @ " . $_SESSION [ " user_context " ] : null );
$html .= " <li class='nav-item'> \n " ;
2024-08-10 02:14:52 +02:00
$html .= " <a class='logout_icon' href='#' title= \" " . $this -> text [ 'theme-label-logout' ] . " \" onclick= \" modal_open('modal-logout','btn_logout'); \" ><span class='fa-solid fa-right-from-bracket'></span></a> " ;
2020-03-18 03:31:29 +01:00
$html .= " </li> \n " ;
unset ( $username_full );
}
$html .= " </ul> \n " ;
$html .= " </div> \n " ;
$html .= " </div> \n " ;
$html .= " </nav> \n " ;
2020-03-25 23:48:12 +01:00
//modal for logout icon (above)
2023-05-27 20:00:02 +02:00
if ( ! empty ( $_SESSION [ 'username' ]) && isset ( $_SESSION [ 'theme' ][ 'logout_icon_visible' ]) && $_SESSION [ 'theme' ][ 'logout_icon_visible' ][ 'text' ] == " true " ) {
2024-08-10 02:14:52 +02:00
$html .= modal :: create ([ 'id' => 'modal-logout' , 'type' => 'general' , 'message' => $this -> text [ 'theme-confirm-logout' ], 'actions' => button :: create ([ 'type' => 'button' , 'label' => $this -> text [ 'theme-label-logout' ], 'icon' => 'fa-solid fa-right-from-bracket' , 'id' => 'btn_logout' , 'style' => 'float: right; margin-left: 15px;' , 'collapse' => 'never' , 'link' => PROJECT_PATH . '/logout.php' , 'onclick' => " modal_close(); " ])]);
2020-03-25 23:48:12 +01:00
}
2020-03-18 03:31:29 +01:00
return $html ;
unset ( $html );
}
/**
* build the vertical side menu html
*/
public function menu_vertical ( $menu_array ) {
//menu brand image and/or text
2020-05-23 22:00:49 +02:00
$html .= " <div id='menu_side_control_container'> \n " ;
$html .= " <div class='menu_side_control_state' style='float: right; " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' ? 'display: none' : null ) . " '> \n " ;
2024-09-09 21:51:23 +02:00
if ( $_SESSION [ 'theme' ][ 'menu_brand_type' ][ 'text' ] != 'none' ) {
2024-09-09 22:11:32 +02:00
$html .= " <a class='menu_side_item_main menu_side_contract' onclick='menu_side_contract();' style='height: 60px; padding: 19px 16px 8px 16px !important; " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' ? " display: none; " : null ) . " '><i class='fa-solid fa-bars fa-fw'></i></a> " ;
2020-05-23 22:00:49 +02:00
}
$html .= " </div> \n " ;
2023-05-27 20:00:02 +02:00
$menu_brand_text = ! empty ( $_SESSION [ 'theme' ][ 'menu_brand_text' ][ 'text' ]) ? escape ( $_SESSION [ 'theme' ][ 'menu_brand_text' ][ 'text' ]) : " FusionPBX " ;
2024-09-09 20:29:49 +02:00
switch ( $_SESSION [ 'theme' ][ 'menu_brand_type' ][ 'text' ]) {
case 'none' :
2024-09-09 22:11:32 +02:00
$html .= " <a class='menu_side_item_main menu_side_contract' onclick='menu_side_contract();' style=' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' ? " display: none; " : null ) . " height: 60px; min-width: " . ( $_SESSION [ 'theme' ][ 'menu_side_width_contracted' ][ 'text' ] ? ? 60 ) . " px;' title= \" " . $this -> text [ 'theme-label-contract_menu' ] . " \" ><i class='fa-solid fa-bars fa-fw' style='z-index: 99800; padding-left: 1px; padding-top: 11px;'></i></a> " ;
$html .= " <a class='menu_side_item_main menu_side_expand' onclick='menu_side_expand();' style=' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] == 'expanded' || $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] == 'hidden' ? " display: none; " : null ) . " height: 60px;' title= \" " . $text [ 'theme-label-expand_menu' ] . " \" ><i class='fa-solid fa-bars fa-fw' style='z-index: 99800; padding-left: 1px; padding-top: 11px;'></i></a> " ;
2024-09-09 20:29:49 +02:00
break ;
case 'text' :
$html .= " <a class='menu_brand_text' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' ? " style='display: none;' " : null ) . " href=' " . PROJECT_PATH . " /'> " . escape ( $menu_brand_text ) . " </a> \n " ;
2024-09-09 22:11:32 +02:00
$html .= " <a class='menu_side_item_main menu_side_expand' style='height: 60px; padding-top: 19px; " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] == 'expanded' ? " display: none " : null ) . " ' onclick='menu_side_expand();' title= \" " . $this -> text [ 'theme-label-expand_menu' ] . " \" ><i class='fa-solid fa-bars fa-fw' style='z-index: 99800; padding-left: 1px;'></i></a> " ;
2024-09-09 20:29:49 +02:00
break ;
case 'image_text' :
$menu_brand_image_contracted = ! empty ( $_SESSION [ 'theme' ][ 'menu_side_brand_image_contracted' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'menu_side_brand_image_contracted' ][ 'text' ] : PROJECT_PATH . " /themes/default/images/logo_side_contracted.png " ;
$html .= " <a class='menu_brand_image' href=' " . PROJECT_PATH . " /'> " ;
$html .= " <img id='menu_brand_image_contracted' style=' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] == 'expanded' ? " display: none; " : null ) . " ' src=' " . escape ( $menu_brand_image_contracted ) . " ' title= \" " . escape ( $menu_brand_text ) . " \" > " ;
$html .= " <span id='menu_brand_image_expanded' class='menu_brand_text' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' ? " style='display: none;' " : null ) . " > " . escape ( $menu_brand_text ) . " </span> " ;
$html .= " </a> \n " ;
break ;
case 'image' :
default :
$menu_brand_image_contracted = ! empty ( $_SESSION [ 'theme' ][ 'menu_side_brand_image_contracted' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'menu_side_brand_image_contracted' ][ 'text' ] : PROJECT_PATH . " /themes/default/images/logo_side_contracted.png " ;
$menu_brand_image_expanded = ! empty ( $_SESSION [ 'theme' ][ 'menu_side_brand_image_expanded' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'menu_side_brand_image_expanded' ][ 'text' ] : PROJECT_PATH . " /themes/default/images/logo_side_expanded.png " ;
$html .= " <a class='menu_brand_image' href=' " . PROJECT_PATH . " /'> " ;
$html .= " <img id='menu_brand_image_contracted' style=' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] == 'expanded' ? " display: none; " : null ) . " ' src=' " . escape ( $menu_brand_image_contracted ) . " ' title= \" " . escape ( $menu_brand_text ) . " \" > " ;
$html .= " <img id='menu_brand_image_expanded' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' ? " style='display: none;' " : null ) . " src=' " . escape ( $menu_brand_image_expanded ) . " ' title= \" " . escape ( $menu_brand_text ) . " \" > " ;
$html .= " </a> \n " ;
break ;
2024-09-09 18:53:12 +02:00
}
2020-05-23 22:00:49 +02:00
$html .= " </div> \n " ;
2020-03-18 03:31:29 +01:00
//main menu items
2023-05-27 20:00:02 +02:00
if ( ! empty ( $menu_array )) {
2020-03-18 03:31:29 +01:00
foreach ( $menu_array as $menu_index_main => $menu_item_main ) {
2020-05-06 07:02:29 +02:00
$menu_target = ( $menu_item_main [ 'menu_item_category' ] == 'external' ) ? '_blank' : '' ;
2023-05-27 20:00:02 +02:00
$html .= " <a class='menu_side_item_main' " . ( ! empty ( $menu_item_main [ 'menu_item_link' ]) ? " href=' " . $menu_item_main [ 'menu_item_link' ] . " ' target=' " . $menu_target . " ' " : " onclick= \" menu_side_expand(); menu_side_item_toggle(' " . $menu_item_main [ 'menu_item_uuid' ] . " '); \" " ) . " title= \" " . $menu_item_main [ 'menu_language_title' ] . " \" > " ;
2020-05-25 19:53:44 +02:00
if ( is_array ( $menu_item_main [ 'menu_items' ]) && sizeof ( $menu_item_main [ 'menu_items' ]) != 0 && $_SESSION [ 'theme' ][ 'menu_side_item_main_sub_icons' ][ 'boolean' ] == 'true' ) {
2024-09-05 04:00:49 +02:00
$html .= " <div class='menu_side_item_main_sub_icons' style='float: right; margin-right: -1px; " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' ? " display: none; " : null ) . " '><i id='sub_arrow_ " . $menu_item_main [ 'menu_item_uuid' ] . " ' class='sub_arrows " . ( ! empty ( $_SESSION [ 'theme' ][ 'menu_side_item_main_sub_icon_expand' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'menu_side_item_main_sub_icon_expand' ][ 'text' ] : 'fa-solid fa-chevron-down' ) . " fa-xs'></i></div> \n " ;
2020-05-25 19:53:44 +02:00
}
2024-08-10 02:14:52 +02:00
if ( ! empty ( $menu_item_main [ 'menu_item_icon' ]) && substr ( $menu_item_main [ 'menu_item_icon' ], 0 , 3 ) == 'fa-' ) { // font awesome icon
$html .= " <i class='menu_side_item_icon " . $menu_item_main [ 'menu_item_icon' ] . " fa-fw' style='z-index: 99800; margin-right: 8px;'></i> " ;
2020-03-18 03:31:29 +01:00
}
2020-05-21 05:24:19 +02:00
$html .= " <span class='menu_side_item_title' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' ? " style='display: none;' " : null ) . " > " . $menu_item_main [ 'menu_language_title' ] . " </span> " ;
2020-03-18 03:31:29 +01:00
$html .= " </a> \n " ;
//sub menu items
if ( is_array ( $menu_item_main [ 'menu_items' ]) && sizeof ( $menu_item_main [ 'menu_items' ]) != 0 ) {
$html .= " <div id='sub_ " . $menu_item_main [ 'menu_item_uuid' ] . " ' class='menu_side_sub' style='display: none;'> \n " ;
foreach ( $menu_item_main [ 'menu_items' ] as $menu_index_sub => $menu_item_sub ) {
2024-09-10 01:02:45 +02:00
$menu_sub_icon = null ;
if ( $_SESSION [ 'theme' ][ 'menu_sub_icons' ][ 'boolean' ] != 'false' ) {
if ( ! empty ( $menu_item_sub [ 'menu_item_icon' ]) && substr ( $menu_item_sub [ 'menu_item_icon' ], 0 , 3 ) == 'fa-' ) { // font awesome icon
2024-09-10 02:47:42 +02:00
$menu_sub_icon = " <span class=' " . escape ( $menu_item_sub [ 'menu_item_icon' ]) . ( substr ( $menu_item_sub [ 'menu_item_icon' ], 0 , 3 ) == 'fa-' ? ' fa-fw' : null ) . " '></span> " ;
2024-09-10 01:02:45 +02:00
}
else {
$menu_sub_icon = null ;
}
}
2020-03-18 03:31:29 +01:00
$html .= " <a class='menu_side_item_sub' " . ( $menu_item_sub [ 'menu_item_category' ] == 'external' ? " target='_blank' " : null ) . " href=' " . $menu_item_sub [ 'menu_item_link' ] . " '> " ;
2020-05-21 05:24:19 +02:00
$html .= " <span class='menu_side_item_title' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' ? " style='display: none;' " : null ) . " > " . $menu_item_sub [ 'menu_language_title' ] . " </span> " ;
2024-09-10 01:02:45 +02:00
$html .= $menu_sub_icon . " </a> \n " ;
2020-03-18 03:31:29 +01:00
}
$html .= " </div> \n " ;
}
}
$html .= " <div style='height: 100px;'></div> \n " ;
}
$html .= " </div> \n " ;
2020-05-28 05:24:07 +02:00
if ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'expanded' && $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'hidden' ) {
$content_container_onclick = " onclick= \" clearTimeout(menu_side_contract_timer); if ( $ (window).width() >= 576) { menu_side_contract(); } \" " ;
}
2024-09-07 01:10:27 +02:00
$html .= " <div id='content_container' " . $content_container_onclick . " > \n " ;
2020-05-28 07:02:13 +02:00
$html .= " <div id='body_header'> \n " ;
2020-03-18 03:31:29 +01:00
//header: left
$html .= " <div class='float-left'> \n " ;
2024-09-09 21:22:44 +02:00
// $html .= button::create(['type'=>'button','id'=>'menu_side_state_hidden_button','title'=>$this->text['theme-label-expand_menu'],'icon'=>'bars','class'=>'default '.($_SESSION['theme']['menu_side_state']['text'] != 'hidden' ? 'hide-sm-up ' : null).'float-left','onclick'=>'menu_side_expand();']);
$html .= " <a id='menu_side_state_hidden_button' class=' " . ( $_SESSION [ 'theme' ][ 'menu_side_state' ][ 'text' ] != 'hidden' ? 'hide-sm-up ' : null ) . " ' href='show:menu' onclick= \" event.preventDefault(); menu_side_expand(); \" title= \" " . $this -> text [ 'theme-label-expand_menu' ] . " \" ><i class='fa-solid fa-bars fa-fw' style='margin: 7px 10px 5px 10px;'></i></a> " ;
2023-05-27 20:00:02 +02:00
$body_header_brand_text = ! empty ( $_SESSION [ 'theme' ][ 'body_header_brand_text' ][ 'text' ]) ? escape ( $_SESSION [ 'theme' ][ 'body_header_brand_text' ][ 'text' ]) : " FusionPBX " ;
2020-05-28 07:02:13 +02:00
if ( $_SESSION [ 'theme' ][ 'body_header_brand_type' ][ 'text' ] == 'image' || $_SESSION [ 'theme' ][ 'body_header_brand_type' ][ 'text' ] == 'image_text' ) {
2023-05-27 20:00:02 +02:00
$body_header_brand_image = ! empty ( $_SESSION [ 'theme' ][ 'body_header_brand_image' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'body_header_brand_image' ][ 'text' ] : PROJECT_PATH . " /themes/default/images/logo_side_expanded.png " ;
2020-05-28 07:02:13 +02:00
$html .= " <div id='body_header_brand_image'> " ;
$html .= " <a href=' " . PROJECT_PATH . " /'><img id='body_header_brand_image' src=' " . escape ( $body_header_brand_image ) . " ' title= \" " . escape ( $body_header_brand_text ) . " \" ></a> " ;
$html .= " </div> " ;
}
if ( $_SESSION [ 'theme' ][ 'body_header_brand_type' ][ 'text' ] == 'text' || $_SESSION [ 'theme' ][ 'body_header_brand_type' ][ 'text' ] == 'image_text' ) {
$html .= " <div id='body_header_brand_text'><a href=' " . PROJECT_PATH . " /'> " . $body_header_brand_text . " </a></div> " ;
2020-05-26 02:38:52 +02:00
}
2020-03-18 03:31:29 +01:00
$html .= " </div> \n " ;
//header: right
2020-05-26 02:38:52 +02:00
$html .= " <div class='float-right' style='white-space: nowrap;'> " ;
2020-03-18 03:31:29 +01:00
//current user
2024-09-28 01:14:42 +02:00
$user_graphic = " <i class=' " . ( ! empty ( $_SESSION [ 'theme' ][ 'body_header_icon_user' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'body_header_icon_user' ][ 'text' ] : 'fa-solid fa-user-circle' ) . " fa-lg fa-fw' style='margin-right: 5px;'></i> " ;
//determine usage of icon or image
if ( $_SESSION [ 'theme' ][ 'body_header_user_image' ][ 'boolean' ] == true && ! empty ( $_SESSION [ 'user' ][ 'contact_uuid' ]) && is_uuid ( $_SESSION [ 'user' ][ 'contact_uuid' ])) {
//load if not already in session
if ( empty ( $_SESSION [ 'user' ][ 'image' ])) {
$sql = " select attachment_filename, attachment_content from v_contact_attachments where contact_uuid = :contact_uuid and attachment_primary = 1 and attachment_filename is not null and attachment_content is not null " ;
$parameters [ 'contact_uuid' ] = $_SESSION [ 'user' ][ 'contact_uuid' ];
$contact_attachment = $this -> database -> select ( $sql , $parameters , 'row' );
if ( ! empty ( $contact_attachment ) && is_array ( $contact_attachment )) {
$contact_attachment_extension = pathinfo ( $contact_attachment [ 'attachment_filename' ], PATHINFO_EXTENSION );
if ( in_array ( $contact_attachment_extension ,[ 'jpg' , 'jpeg' , 'png' ])) {
$_SESSION [ 'user' ][ 'image' ][ 'filename' ] = $contact_attachment [ 'attachment_filename' ];
$_SESSION [ 'user' ][ 'image' ][ 'base64' ] = $contact_attachment [ 'attachment_content' ];
$_SESSION [ 'user' ][ 'image' ][ 'mime' ] = mime_content_type ( $contact_attachment [ 'attachment_filename' ]);
}
}
unset ( $sql , $parameters );
}
if ( ! empty ( $_SESSION [ 'user' ][ 'image' ])) {
$user_graphic_size = str_replace ([ 'px' , '%' ], '' , ( $_SESSION [ 'theme' ][ 'body_header_user_image_size' ][ 'numeric' ] ? ? 18 ));
$user_graphic = " <span style= \" display: inline-block; vertical-align: middle; width: " . $user_graphic_size . " px; height: " . $user_graphic_size . " px; border-radius: 50%; margin-right: 7px; margin-top: " . ( $user_graphic_size > 18 ? '-' . ( ceil (( $user_graphic_size - 18 ) / 2 ) - 4 ) : '-4' ) . " px; background-image: url('data: " . $_SESSION [ 'user' ][ 'image' ][ 'mime' ] . " ;base64, " . $_SESSION [ 'user' ][ 'image' ][ 'base64' ] . " '); background-repeat: no-repeat; background-size: cover; background-position: center; \" ></span> " ;
}
}
else {
$user_graphic_size = 18 ;
}
2020-05-26 02:38:52 +02:00
$html .= " <span style='display: inline-block; padding-right: 20px; font-size: 90%;'> \n " ;
2024-09-28 01:14:42 +02:00
$html .= " <a href=' " . PROJECT_PATH . " /core/users/user_edit.php?id=user' title= \" " . $this -> text [ 'theme-label-user' ] . " \" > " . ( $user_graphic ? ? null ) . $_SESSION [ 'username' ] . " </a> " ;
2020-03-18 03:31:29 +01:00
$html .= " </span> \n " ;
//domain name/selector (sm+)
2023-05-27 20:00:02 +02:00
if ( ! empty ( $_SESSION [ 'username' ]) && permission_exists ( 'domain_select' ) && count ( $_SESSION [ 'domains' ]) > 1 && $_SESSION [ 'theme' ][ 'domain_visible' ][ 'text' ] == 'true' ) {
2020-05-26 02:38:52 +02:00
$html .= " <span style='display: inline-block; padding-right: 10px; font-size: 90%;'> \n " ;
2024-09-28 01:14:42 +02:00
$html .= " <a href='#' id='header_domain_selector_domain' title=' " . $this -> text [ 'theme-label-open_selector' ] . " '><i class=' " . ( ! empty ( $_SESSION [ 'theme' ][ 'body_header_icon_domain' ][ 'text' ]) ? $_SESSION [ 'theme' ][ 'body_header_icon_domain' ][ 'text' ] : 'fa-solid fa-earth-americas' ) . " fa-fw' style='vertical-align: middle; font-size: " . ( $user_graphic_size - 1 ) . " px; margin-top: " . ( $user_graphic_size > 18 ? '-' . ( ceil (( $user_graphic_size - 18 ) / 2 ) - 4 ) : '-3' ) . " px; margin-right: 3px; line-height: 40%;'></i> " . escape ( $_SESSION [ 'domain_name' ]) . " </a> " ;
2020-03-18 03:31:29 +01:00
$html .= " </span> \n " ;
}
//logout icon
2023-05-27 20:00:02 +02:00
if ( ! empty ( $_SESSION [ 'username' ]) && $_SESSION [ 'theme' ][ 'logout_icon_visible' ][ 'text' ] == " true " ) {
2024-08-10 02:14:52 +02:00
$html .= " <a id='header_logout_icon' href='#' title= \" " . $this -> text [ 'theme-label-logout' ] . " \" onclick= \" modal_open('modal-logout','btn_logout'); \" ><span class='fa-solid fa-right-from-bracket'></span></a> " ;
2020-03-18 03:31:29 +01:00
}
2020-05-26 02:38:52 +02:00
$html .= " </div> " ;
2020-03-18 03:31:29 +01:00
$html .= " </div> \n " ;
2020-03-26 23:54:06 +01:00
//modal for logout icon (above)
2023-05-27 20:00:02 +02:00
if ( ! empty ( $_SESSION [ 'username' ]) && $_SESSION [ 'theme' ][ 'logout_icon_visible' ][ 'text' ] == " true " ) {
2024-08-10 02:14:52 +02:00
$html .= modal :: create ([ 'id' => 'modal-logout' , 'type' => 'general' , 'message' => $this -> text [ 'theme-confirm-logout' ], 'actions' => button :: create ([ 'type' => 'button' , 'label' => $this -> text [ 'theme-label-logout' ], 'icon' => 'fa-solid fa-right-from-bracket' , 'id' => 'btn_logout' , 'style' => 'float: right; margin-left: 15px;' , 'collapse' => 'never' , 'link' => PROJECT_PATH . '/logout.php' , 'onclick' => " modal_close(); " ])]);
2020-03-26 23:54:06 +01:00
}
2020-03-18 03:31:29 +01:00
return $html ;
unset ( $html );
}
2012-06-04 16:58:40 +02:00
}
2016-04-15 07:23:14 +02:00
}
2012-06-04 16:58:40 +02:00
2024-08-10 02:14:52 +02:00
?>