From f33289ed6a486671d7e7cd777b3f04634a430123 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Aug 2017 19:15:06 +0200 Subject: [PATCH] Better examples --- htdocs/core/modules/DolibarrModules.class.php | 9 ++++++- .../core/modules/modMyModule.class.php | 25 +++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 7ef1143b9f8..c1c42d2fb40 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1486,7 +1486,14 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ")"; dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); - $this->db->query($sql); + $resql = $this->db->query($sql); + if (! $resql) + { + $err++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + break; + } } $i++; } diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 00199f1d3a4..6892bcab104 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -125,13 +125,22 @@ class modMyModule extends DolibarrModules 1=>array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) ); + + if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) + { + $conf->mymodule=new stdClass(); + $conf->mymodule->enabled=0; + } + + // Array to add new pages in new tabs - // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 - // 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname - // Can also be: $this->tabs = array('data'=>'...', 'entity'=>0); + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // - // where objecttype can be + // Where objecttype can be // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) // 'contact' to add a tab in contact view // 'contract' to add a tab in contract view @@ -151,13 +160,7 @@ class modMyModule extends DolibarrModules // 'stock' to add a tab in stock view // 'thirdparty' to add a tab in third party view // 'user' to add a tab in user view - $this->tabs = array(); - if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) - { - $conf->mymodule=new stdClass(); - $conf->mymodule->enabled=0; - } // Dictionaries $this->dictionaries=array();