From a8f9a9d0c66c7678990f6f1864a1ee5bc751f9d9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Feb 2011 19:59:16 +0000 Subject: [PATCH] New: a specialized menu is now used when using smartphones --- ChangeLog | 1 + htdocs/admin/menus.php | 21 ++-- htdocs/core/class/conf.class.php | 26 ++++- htdocs/core/class/html.formadmin.class.php | 64 ++++++----- htdocs/core/class/smartphone.class.php | 61 +++-------- htdocs/core/tpl/passwordforgotten.tpl.php | 2 +- ...nu_iphone.sql => init_menu_smartphone.sql} | 0 .../{iphone.lib.php => smartphone.lib.php} | 32 +++--- ...ckoffice.php => smartphone_backoffice.php} | 12 +- ...toffice.php => smartphone_frontoffice.php} | 12 +- htdocs/index.php | 22 ++-- htdocs/install/mysql/data/llx_const.sql | 4 +- htdocs/lib/security.lib.php | 5 +- htdocs/main.inc.php | 103 +++++++++--------- htdocs/public/error-401.php | 14 +++ htdocs/public/error-404.php | 14 +++ .../smartphone/theme/default/default.css.php | 5 +- .../phones/smartphone/tpl/header.tpl.php | 12 +- .../theme/phones/smartphone/tpl/login.tpl.php | 55 +++++----- .../theme/phones/smartphone/tpl/menu.tpl.php | 33 ++++-- .../smartphone/tpl/passwordforgotten.tpl.php | 24 ++-- htdocs/user/passwordforgotten.php | 8 +- 22 files changed, 288 insertions(+), 242 deletions(-) rename htdocs/includes/menus/{init_menu_iphone.sql => init_menu_smartphone.sql} (100%) mode change 100644 => 100755 rename htdocs/includes/menus/smartphone/{iphone.lib.php => smartphone.lib.php} (90%) mode change 100644 => 100755 rename htdocs/includes/menus/smartphone/{iphone_backoffice.php => smartphone_backoffice.php} (72%) mode change 100644 => 100755 rename htdocs/includes/menus/smartphone/{iphone_frontoffice.php => smartphone_frontoffice.php} (73%) mode change 100644 => 100755 diff --git a/ChangeLog b/ChangeLog index 969b7ec5ccd..f40003bdb32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ $Id$ ***** ChangeLog for 3.1 compared to 3.0 ***** For users: +- New: A specialized menu is now used when using smartphones. - New: Can add information on current user on odt generation - New: Prefix on third party is not used by default. Hidden option SOCIETE_USEPREFIX can restore old feature. diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index bc7a429b165..30cc01bb356 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -164,18 +164,15 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') print ''; // Menu smartphone - if ($conf->global->MAIN_FEATURES_LEVEL >= 1) - { - $var=!$var; - print ''.$langs->trans("DefaultMenuSmartphoneManager").''; - print ''; - print $htmladmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'main_menu_smartphone', $dirsmartphone, empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"'); - print ''; - print ''; - print $htmladmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'main_menufront_smartphone', $dirsmartphone, empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"'); - print ''; - print ''; - } + $var=!$var; + print ''.$langs->trans("DefaultMenuSmartphoneManager").''; + print ''; + print $htmladmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'main_menu_smartphone', array($dirtop,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"'); + print ''; + print ''; + print $htmladmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'main_menufront_smartphone', array($dirtop,$dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"'); + print ''; + print ''; print ''; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index f7035f785ca..7ab11687460 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -31,7 +31,7 @@ /** * \class Conf - * \brief Classe de stockage de la config courante + * \brief Class to stock current configuration */ class Conf { @@ -207,8 +207,8 @@ class Conf // Clean some variables if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD="eldy_backoffice.php"; if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD="eldy_frontoffice.php"; - if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE="iphone_backoffice.php"; - if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE="iphone_frontoffice.php"; + if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE="smartphone_backoffice.php"; + if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE="smartphone_frontoffice.php"; // Variable globales LDAP if (empty($this->global->LDAP_FIELD_FULLNAME)) $this->global->LDAP_FIELD_FULLNAME=''; @@ -426,8 +426,26 @@ class Conf // For backward compatibility $this->produit=$this->product; - } + + // Define menu manager in setup + if (empty($user->societe_id)) // If internal user or not defined + { + $this->top_menu=(empty($this->global->MAIN_MENU_STANDARD_FORCED)?$this->global->MAIN_MENU_STANDARD:$this->global->MAIN_MENU_STANDARD_FORCED); + $this->smart_menu=(empty($this->global->MAIN_MENU_SMARTPHONE_FORCED)?$this->global->MAIN_MENU_SMARTPHONE:$this->global->MAIN_MENU_SMARTPHONE_FORCED); + // For backward compatibility + if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php'; + if ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php'; + } + else // If external user + { + $this->top_menu=(empty($this->global->MAIN_MENUFRONT_STANDARD_FORCED)?$this->global->MAIN_MENUFRONT_STANDARD:$this->global->MAIN_MENUFRONT_STANDARD_FORCED); + $this->smart_menu=(empty($this->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$this->global->MAIN_MENUFRONT_SMARTPHONE:$this->global->MAIN_MENUFRONT_SMARTPHONE_FORCED); + // For backward compatibility + if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_frontoffice.php'; + if ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_frontoffice.php'; + } + } } ?> diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 4d43cf32ccd..dd215a8f0cd 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -126,7 +126,7 @@ class FormAdmin * Return list of available menus (eldy_backoffice, ...) * @param selected Preselected menu value * @param htmlname Name of html select - * @param dirmenu Directory to scan + * @param dirmenu Directory to scan or array of directories to scan * @param moreattrib More attributes on html select tag */ function select_menu($selected='', $htmlname, $dirmenu, $moreattrib='') @@ -138,39 +138,44 @@ class FormAdmin $menuarray=array(); foreach ($conf->file->dol_document_root as $dirroot) { - $dir=$dirroot.$dirmenu; - if (is_dir($dir)) + if (is_array($dirmenu)) $dirmenus=$dirmenu; + else $dirmenus=array($dirmenu); + foreach($dirmenus as $dirtoscan) { - $handle=opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - if (preg_match('/lib\.php$/i',$file)) continue; // We exclude library files - $filelib=preg_replace('/\.php$/i','',$file); - $prefix=''; - if (preg_match('/^eldy|^iphone/i',$file)) $prefix='0'; // 0=Recommanded, 1=Experimental, 2=Other - else $prefix='2'; + $dir=$dirroot.$dirtoscan; + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + if (preg_match('/lib\.php$/i',$file)) continue; // We exclude library files + $filelib=preg_replace('/\.php$/i','',$file); + $prefix=''; + if (preg_match('/^eldy|^smartphone/i',$file)) $prefix='0'; // 0=Recommanded, 1=Experimental, 2=Other + else $prefix='2'; - if ($file == $selected) - { - $menuarray[$prefix.'_'.$file]=''; - } - else - { - $menuarray[$prefix.'_'.$file]=''; - } - } - } - closedir($handle); - } + if ($file == $selected) + { + $menuarray[$prefix.'_'.$file]=''; + } + else + { + $menuarray[$prefix.'_'.$file]=''; + } + } + } + closedir($handle); + } + } } } ksort($menuarray); - // Affichage liste deroulante des menus + // Output combo list of menus print ' diff --git a/htdocs/includes/menus/init_menu_iphone.sql b/htdocs/includes/menus/init_menu_smartphone.sql old mode 100644 new mode 100755 similarity index 100% rename from htdocs/includes/menus/init_menu_iphone.sql rename to htdocs/includes/menus/init_menu_smartphone.sql diff --git a/htdocs/includes/menus/smartphone/iphone.lib.php b/htdocs/includes/menus/smartphone/smartphone.lib.php old mode 100644 new mode 100755 similarity index 90% rename from htdocs/includes/menus/smartphone/iphone.lib.php rename to htdocs/includes/menus/smartphone/smartphone.lib.php index 1fb1688cbc1..d9a64f4bd65 --- a/htdocs/includes/menus/smartphone/iphone.lib.php +++ b/htdocs/includes/menus/smartphone/smartphone.lib.php @@ -19,30 +19,30 @@ */ /** - * \file htdocs/includes/menus/smartphone/iphone.lib.php - * \brief Library for file iphone menus + * \file htdocs/includes/menus/smartphone/smartphone.lib.php + * \brief Library for file smartphone menus * \version $Id$ */ /** - * Core function to output top menu iphone + * Core function to output top menu smartphone * * @param $db * @param $atarget * @param $type_user 0=Internal,1=External,2=All */ -function print_iphone_menu($db,$atarget,$type_user) +function print_smartphone_menu($db,$atarget,$type_user) { require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php"); global $user,$conf,$langs,$dolibarr_main_db_name; - + $submenus=''; - $menutop = new Menubase($db,'iphone','top'); - $menuleft = new Menubase($db,'iphone','left'); - $tabMenu = $menutop->menuTopCharger($type_user, '', 'iphone'); + $menutop = new Menubase($db,'smartphone','top'); + $menuleft = new Menubase($db,'smartphone','left'); + $tabMenu = $menutop->menuTopCharger($type_user, '', 'smartphone'); $numTabMenu = count($tabMenu); print_start_menu_array(); @@ -64,12 +64,12 @@ function print_iphone_menu($db,$atarget,$type_user) $title=$tabMenu[$i]['titre']; // To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($tabMenu[$i]['titre'],ENT_QUOTES,'UTF-8'),'',array('&'))); print_text_menu_entry($title); - + $newmenu = new Menu(); - $leftmenu = $menuleft->menuLeftCharger($newmenu,$tabMenu[$i]['mainmenu'],'',($user->societe_id?1:0),'iphone'); + $leftmenu = $menuleft->menuLeftCharger($newmenu,$tabMenu[$i]['mainmenu'],'',($user->societe_id?1:0),'smartphone'); $menus = $leftmenu->liste; //var_dump($menus); - + print ' + + - @@ -85,7 +89,8 @@ $smartphone->smartheader(); alert(''); - -smartfooter(); ?> \ No newline at end of file + \ No newline at end of file diff --git a/htdocs/theme/phones/smartphone/tpl/menu.tpl.php b/htdocs/theme/phones/smartphone/tpl/menu.tpl.php index 2d55bd8e412..1f96e88b8e1 100644 --- a/htdocs/theme/phones/smartphone/tpl/menu.tpl.php +++ b/htdocs/theme/phones/smartphone/tpl/menu.tpl.php @@ -17,25 +17,33 @@ * * $Id$ */ -$this->smartheader(); +require('header.tpl.php'); ?> +
- - -
-
- + global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; + print $appli; + ?>
-
+
+ showmenu(); ?> - +
- +
    @@ -44,9 +52,12 @@ $this->smartheader();
- +
-smartfooter(); ?> \ No newline at end of file +smartfooter(); +?> \ No newline at end of file diff --git a/htdocs/theme/phones/smartphone/tpl/passwordforgotten.tpl.php b/htdocs/theme/phones/smartphone/tpl/passwordforgotten.tpl.php index 17ceabdce2c..37c3957293f 100644 --- a/htdocs/theme/phones/smartphone/tpl/passwordforgotten.tpl.php +++ b/htdocs/theme/phones/smartphone/tpl/passwordforgotten.tpl.php @@ -17,7 +17,7 @@ * * $Id$ */ -$smartphone->smartheader(); +include('header.tpl.php'); ?> @@ -25,37 +25,39 @@ $smartphone->smartheader();
-

trans('Identification'); ?>

+
+ trans('Identification'); ?> +
- +
- +
- + - +
- + - +
- +
trans('SendNewPasswordDesc'); @@ -74,4 +76,6 @@ $smartphone->smartheader(); -smartfooter(); ?> \ No newline at end of file + \ No newline at end of file diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 6b65b1163cd..19d62a1141e 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -151,10 +151,10 @@ $title='Dolibarr '.DOL_VERSION; if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; // Select templates -if (class_exists('Smartphone')) +if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone)) { - // Template directory - $smartphone->getTemplateDir(); + include_once(DOL_DOCUMENT_ROOT.'/core/class/smartphone.class.php'); + $smartphone = new Smartphone($db,$conf->browser->phone); // This class is only to know template dir according to phone type $smartphone->title = $title; $template_dir = $smartphone->template_dir; } @@ -215,7 +215,7 @@ if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $rowspan++; if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY) && ! $disabled) { global $db; - + $res=dol_include_once('/multicompany/class/actions_multicompany.class.php'); if ($res) {