From 2e838983cace66ed75ad7f0ebded1bab57f83fd1 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 29 Jul 2016 12:05:05 +0200 Subject: [PATCH] Restructuring of sidebox menus in mail --- mail/inc/class.mail_hooks.inc.php | 136 ++++++++++++++---------------- 1 file changed, 61 insertions(+), 75 deletions(-) diff --git a/mail/inc/class.mail_hooks.inc.php b/mail/inc/class.mail_hooks.inc.php index 80f3da1861..88860f6f89 100644 --- a/mail/inc/class.mail_hooks.inc.php +++ b/mail/inc/class.mail_hooks.inc.php @@ -388,90 +388,76 @@ class mail_hooks { unset($hook_data); // not used, but required by function signature - //error_log(__METHOD__); // always show the side bar unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); $appname = 'mail'; - $menu_title = $GLOBALS['egw_info']['apps'][$appname]['title'] . ' '. lang('Menu'); -/* - $file = array(); - $profileID = 0; - if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) - $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; - try - { - $mail_bo = Mail::getInstance(true,$profileID); - $profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID; - } catch (Exception $e) { - //error_log(__METHOD__."()" . $e->getMessage()); - $profileID = Mail\Account::get_default_acc_id(); - } - $preferences =& $mail_bo->mailPreferences; - $serverCounter = $sieveEnabledServerCounter = 0; - // account select box - $selectedID = $profileID; - $allAccountData = Mail\Account::search($only_current_user=true, $just_name=false, $order_by=null); - if ($allAccountData) { - $rememberFirst=$selectedFound=null; - foreach ($allAccountData as $tmpkey => $icServers) + // Mail sidebox menus + $menus = array( + array( + 'title' => $GLOBALS['egw_info']['apps'][$appname]['title'], + 'enable' => true, + 'items' => array( + array( + 'no_lang' => true, + 'text'=>'', + 'link'=>false, + 'icon' => false + ), + array( + 'no_lang' => true, + 'text'=>'', + 'link'=>false, + 'icon' => false + ) + ) + ), + array ( + 'title' => lang('Mail Menu'), + 'enable' => true, + 'items' => array ( + 'menuOpened' => false, + array ( + 'text' => 'import message', + 'link' => "javascript:egw_openWindowCentered2('". + Egw::link('/index.php', array('menuaction' => 'mail.mail_ui.importMessage') ,false). + "','importMessageDialog',600,100,'no','$appname');" + ), + array ( + 'enable' => self::access('createaccount'), + 'text'=>'create new account', + 'link'=> "javascript:egw_openWindowCentered2('" . + Egw::link('/index.php', array('menuaction' => 'mail.mail_wizard.add'), ''). + "','_blank',640,480,'yes')", + ), + ) + ), + array ( + 'title' => lang('Admin'), + 'enable' => $GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile(), + 'items' => array ( + 'Site Configuration' => Egw::link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname), + ) + ) + ); + + // Menu generator + foreach ($menus as &$menu) + { + foreach ($menu['items'] as &$item) { - if (is_null($rememberFirst)) $rememberFirst = $tmpkey; - if ($tmpkey == $selectedID) $selectedFound=true; - //error_log(__METHOD__.__LINE__.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); - $host = $icServers->acc_sieve_host; - if (empty($host)) continue; - if ($icServers->acc_sieve_enabled && $icServers->acc_sieve_port) $sieveEnabledServerCounter++; - $serverCounter++; - //error_log(__METHOD__.__LINE__.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id])); + if (array_key_exists('enable', $item) && !$item['enable']) { + unset($item); + } + } + if (!(array_key_exists('enable', $menu) && !$menu['enable'])) + { + display_sidebox($appname,$menu['title'],$menu['items']); } } -*/ - $file=array(); - // Destination div for folder tree - $file[] = array( - 'no_lang' => true, - 'text'=>'', - 'link'=>false, - 'icon' => false - ); - $file[] = array( - 'no_lang' => true, - 'text'=>'', - 'link'=>false, - 'icon' => false - ); - $linkData = array( - 'menuaction' => 'mail.mail_ui.importMessage', - ); - - $file += array( - 'import message' => "javascript:egw_openWindowCentered2('".Egw::link('/index.php', $linkData,false)."','importMessageDialog',600,100,'no','$appname');", - ); - - - // create account wizard - if (self::access('createaccount')) - { - $file += array( - 'create new account' => "javascript:egw_openWindowCentered2('" . - Egw::link('/index.php', array('menuaction' => 'mail.mail_wizard.add'), ''). - "','_blank',640,480,'yes')", - ); - } - // display them all - display_sidebox($appname,$menu_title,$file); - - if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile()) - { - $file = Array( - 'Site Configuration' => Egw::link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname), - ); - display_sidebox($appname,lang('Admin'),$file); - } + // add pgp encryption menu at the end Api\Hooks::pgp_encryption_menu('mail'); - } /**