diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 0840c148ac9..a4fad4acf1c 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -132,6 +132,11 @@ $character_set_client="ISO-8859-1"; # Parameters not used yet +# dolibarr_smarty_libs_dir +# Examples: +# $dolibarr_smarty_libs_dir="/var/www/dolibarr/external-libs/smarty/libs/"; +# $dolibarr_smarty_compile="/var/www/dolibarr/documents/temp/smarty_templates"; +# $dolibarr_smarty_cache="/var/www/dolibarr/documents/temp/smarty_cache"; $dolibarr_smarty_libs_dir=""; $dolibarr_smarty_compile=""; $dolibarr_smarty_cache=""; diff --git a/htdocs/docsoc.php b/htdocs/docsoc.php index b1474d2cca4..bc07cc05ac7 100644 --- a/htdocs/docsoc.php +++ b/htdocs/docsoc.php @@ -183,8 +183,9 @@ if ($socid > 0) // Courriers // Les courriers sont des documents speciaux generes par des scripts + // situes dans scripts/courrier. // Voir Rodo - if ($conf->global->SOCIETE_NOLIST_COURRIER) + if ($conf->global->MAIN_MODULE_EDITEUR) { $filearray=array(); $errorlevel=error_reporting(); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 60ebeb50e25..d1b5df046b1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -492,6 +492,7 @@ if ($user->admin) $user->rights->user->self->password=1; } + /** * Overwrite configs global par configs perso * ------------------------------------------ @@ -534,22 +535,6 @@ if (isset($user->conf->MAIN_DISABLE_JAVASCRIPT) && $user->conf->MAIN_DISABLE_JAV $conf->use_javascript=! $user->conf->MAIN_DISABLE_JAVASCRIPT; } -// SMARTY -// Definit dans le fichier de conf -// $dolibarr_smarty_libs_dir="/home/www/dolitar/external-libs/smarty/libs/"; -// $dolibarr_smarty_compile="/home/www/dolitar/smarty_templates"; -// $dolibarr_smarty_cache="/home/www/dolitar/smarty_cache"; - -$smarty_libs = $dolibarr_smarty_libs_dir. "Smarty.class.php"; -if (file_exists ($smarty_libs)) -{ - require($smarty_libs); - $smarty = new Smarty(); - $smarty->compile_dir = $dolibarr_smarty_compile; - $smarty->cache_dir = $dolibarr_smarty_cache; - //$smarty->config_dir = '/web/www.domain.com/smarty/configs'; -} - // Defini gestionnaire de menu a utiliser if (! $user->societe_id) // Si utilisateur interne { @@ -564,6 +549,33 @@ else // Si utilisateur externe $conf->left_menu=$conf->global->MAIN_MENUFRONT_BARRELEFT; } + +if ($conf->left_menu != 'default.php') $conf->global->PRODUCT_CANVAS_ABILITY=0; +// Si besoin de smarty +if ($conf->global->PRODUCT_CANVAS_ABILITY) +{ + // SMARTY + // Definit dans le fichier de conf + // $dolibarr_smarty_libs_dir="/home/www/dolibarr/external-libs/smarty/libs/"; + // $dolibarr_smarty_compile="/home/www/dolibarr/documents/temp/smarty_templates"; + // $dolibarr_smarty_cache="/home/www/dolibarr/documents/temp/smarty_cache"; + + $smarty_libs = $dolibarr_smarty_libs_dir. "Smarty.class.php"; + if (file_exists ($smarty_libs)) + { + + require_once($smarty_libs); + $smarty = new Smarty(); + $smarty->compile_dir = $dolibarr_smarty_compile; + $smarty->cache_dir = $dolibarr_smarty_cache; + //$smarty->config_dir = '/web/www.domain.com/smarty/configs'; + } + else + { + dolibarr_print_error('',"Library Smarty ".$smarty_libs." not found. Check parameter dolibarr_smarty_libs_dir in conf file."); + } +} + // Si le login n'a pu etre recupere, on est identifie avec un compte qui n'existe pas. // Tentative de hacking ? if (! $user->login) accessforbidden(); diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 99e4b036439..5053d6a2240 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -175,6 +175,7 @@ if (! defined('NOREQUIREUSER')) /* * Chargement objet $conf + * After this, all parameters conf->global->CONSTANTS are loaded */ if (! defined('NOREQUIREDB')) { diff --git a/htdocs/product/canvas/product.livre.class.php b/htdocs/product/canvas/product.livre.class.php index 90e69b2caa3..803ab66d51d 100644 --- a/htdocs/product/canvas/product.livre.class.php +++ b/htdocs/product/canvas/product.livre.class.php @@ -382,7 +382,6 @@ class ProductLivre extends Product */ function assign_smarty_values(&$smarty, $action='') { - if ($action =='edit' or $action == 'create') { $this->GetAvailableFormat(); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index c7361ce195c..3c4ef44f1d4 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -407,168 +407,169 @@ $html = new Form($db); */ if ($_GET["action"] == 'create' && $user->rights->produit->creer) { - if ( !isset($product) ) - { - if ($_GET["canvas"] <> '' && file_exists('canvas/product.'.$_GET["canvas"].'.class.php') ) + if (! isset($product)) { - $class = 'Product'.ucfirst($_GET["canvas"]); - include_once('canvas/product.'.$_GET["canvas"].'.class.php'); - - $product = new $class($db,0,$user); + $filecanvas=DOL_DOCUMENT_ROOT.'/product/canvas/product.'.$_GET["canvas"].'.class.php'; + if ($_GET["canvas"] && file_exists($filecanvas) ) + { + $class = 'Product'.ucfirst($_GET["canvas"]); + include_once($filecanvas); + + $product = new $class($db,0,$user); + } + else + { + $product = new Product($db); + } } - else - { - $product = new Product($db); - } - } - $product->assign_smarty_values($smarty, 'create'); + $product->assign_smarty_values($smarty, 'create'); - if ($_error == 1) - { - $product = $e_product; - } - - llxHeader("","",$langs->trans("CardProduct".$product->type)); - - if ($mesg) print "$mesg\n"; - - if ($_GET["canvas"] == '') - { - print '
'; - } - else - { - //RODO - // On assigne les valeurs meme en creation car elles sont definies si - // on revient en erreur - // - $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/'; - $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); - $smarty->assign('tva_taux_value', $html->tva_taux_value); - $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle); - $smarty->display($_GET["canvas"].'-create.tpl'); - } } /** diff --git a/htdocs/product/pre.inc.php b/htdocs/product/pre.inc.php index 684f592d69b..fa712afdb39 100644 --- a/htdocs/product/pre.inc.php +++ b/htdocs/product/pre.inc.php @@ -38,89 +38,88 @@ $user->getrights('facture'); function llxHeader($head = "", $urlp = "", $title="") { - global $user, $conf, $langs; + global $user, $conf, $langs; - $user->getrights("produit"); - - top_menu($head, $title); - - $menu = new Menu(); - - if ($conf->produit->enabled) - { - $menu->add(DOL_URL_ROOT."/product/index.php?type=0", $langs->trans("Products")); - $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=0", $langs->trans("List")); - - if ($user->societe_id == 0 && $user->rights->produit->creer) - { - $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=0", $langs->trans("NewProduct")); - } - } - - // Produit specifique - $dir = DOL_DOCUMENT_ROOT . "/product/canvas/"; + $user->getrights("produit"); - if(is_dir($dir) && $conf->global->PRODUCT_CANVAS_ABILITY==='1' ) - { - if ($handle = opendir($dir)) + top_menu($head, $title); + + $menu = new Menu(); + + if ($conf->produit->enabled) { - while (($file = readdir($handle))!==false) - { - if (substr($file, strlen($file) -10) == '.class.php' && substr($file,0,8) == 'product.') + $menu->add(DOL_URL_ROOT."/product/index.php?type=0", $langs->trans("Products")); + $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=0", $langs->trans("List")); + + if ($user->societe_id == 0 && $user->rights->produit->creer) { - $parts = explode('.',$file); - $classname = 'Product'.ucfirst($parts[1]); - require_once($dir.$file); - $module = new $classname(); - - if ($module->active === '1' && $module->menu_add === 1) - { - $module->PersonnalizeMenu($menu); - $langs->load("products_".$module->canvas); - for ($j = 0 ; $j < sizeof($module->menus) ; $j++) - { - $menu->add_submenu($module->menus[$j][0], $langs->trans($module->menus[$j][1])); - } - } + $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=0", $langs->trans("NewProduct")); } - } - closedir($handle); } - } - $menu->add_submenu(DOL_URL_ROOT."/product/reassort.php?type=0", $langs->trans("Restock")); - - if ($conf->service->enabled) - { - $menu->add(DOL_URL_ROOT."/product/index.php?type=1", $langs->trans("Services")); - $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=1", $langs->trans("List")); - if ($user->societe_id == 0 && $user->rights->produit->creer) + // Produit specifique + $dir = DOL_DOCUMENT_ROOT . "/product/canvas/"; + if(is_dir($dir) && $conf->global->PRODUCT_CANVAS_ABILITY) { - $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=1", $langs->trans("NewService")); + if ($handle = opendir($dir)) + { + while (($file = readdir($handle))!==false) + { + if (substr($file, strlen($file) -10) == '.class.php' && substr($file,0,8) == 'product.') + { + $parts = explode('.',$file); + $classname = 'Product'.ucfirst($parts[1]); + require_once($dir.$file); + $module = new $classname(); + + if ($module->active === '1' && $module->menu_add === 1) + { + $module->PersonnalizeMenu($menu); + $langs->load("products_".$module->canvas); + for ($j = 0 ; $j < sizeof($module->menus) ; $j++) + { + $menu->add_submenu($module->menus[$j][0], $langs->trans($module->menus[$j][1])); + } + } + } + } + closedir($handle); + } } - } - - if ($conf->fournisseur->enabled) { - $langs->load("suppliers"); - $menu->add(DOL_URL_ROOT."/fourn/index.php", $langs->trans("Suppliers")); - } - - $menu->add(DOL_URL_ROOT."/product/stats/", $langs->trans("Statistics")); - if ($conf->propal->enabled) - { - $menu->add_submenu(DOL_URL_ROOT."/product/popuprop.php", $langs->trans("Popularity")); - } - - if ($conf->stock->enabled) - { - $menu->add(DOL_URL_ROOT."/product/stock/", $langs->trans("Stock")); - } - - if ($conf->categorie->enabled) - { - $menu->add(DOL_URL_ROOT."/categories/index.php?type=0", $langs->trans("Categories")); - } - - left_menu($menu->liste); + + $menu->add_submenu(DOL_URL_ROOT."/product/reassort.php?type=0", $langs->trans("Restock")); + + if ($conf->service->enabled) + { + $menu->add(DOL_URL_ROOT."/product/index.php?type=1", $langs->trans("Services")); + $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=1", $langs->trans("List")); + if ($user->societe_id == 0 && $user->rights->produit->creer) + { + $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=1", $langs->trans("NewService")); + } + } + + if ($conf->fournisseur->enabled) { + $langs->load("suppliers"); + $menu->add(DOL_URL_ROOT."/fourn/index.php", $langs->trans("Suppliers")); + } + + $menu->add(DOL_URL_ROOT."/product/stats/", $langs->trans("Statistics")); + if ($conf->propal->enabled) + { + $menu->add_submenu(DOL_URL_ROOT."/product/popuprop.php", $langs->trans("Popularity")); + } + + if ($conf->stock->enabled) + { + $menu->add(DOL_URL_ROOT."/product/stock/", $langs->trans("Stock")); + } + + if ($conf->categorie->enabled) + { + $menu->add(DOL_URL_ROOT."/categories/index.php?type=0", $langs->trans("Categories")); + } + + left_menu($menu->liste); } ?>