From 1756862a65727407975d95ca134e5f71984984d8 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 6 Sep 2015 07:56:43 +0200 Subject: [PATCH 1/7] Typo --- htdocs/contact/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index a45437b3a39..9778d0c8a71 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -646,7 +646,7 @@ else print ': '; if ($object->birthday_alert) { - print ''; + print ''; } else { From e88d7076a63405f0d70d59f9c54eb65ad54f7a71 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 6 Sep 2015 07:58:49 +0200 Subject: [PATCH 2/7] Fix Problem with checked input when you edit a survey --- htdocs/opensurvey/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index d93c37cbfb9..87373c571f8 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -248,7 +248,7 @@ if (!$object->fk_user_creat) { print ''.$langs->trans('ToReceiveEMailForEachVote').''; if ($action == 'edit') { - print 'mailsonde?' checked':'').'">'; + print 'mailsonde?'checked="checked"':'').'">'; } else { print yn($object->mailsonde); @@ -266,7 +266,7 @@ print ''; print ''.$langs->trans('CanComment').''; if ($action == 'edit') { - print 'allow_comments?' checked':'').'">'; + print 'allow_comments?'checked="checked"':'').'">'; } else print yn($object->allow_comments); print ''; @@ -275,7 +275,7 @@ print ''; print ''.$langs->trans('CanSeeOthersVote').''; if ($action == 'edit') { - print 'allow_spy?' checked':'').'">'; + print 'allow_spy?'checked="checked"':'').'">'; } else print yn($object->allow_spy); print ''; From 9cd5e7cafae8249a8a30097b0ac639d16ec51e99 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 14:22:03 +0200 Subject: [PATCH 3/7] Fix some errors into code generator. --- dev/skeletons/build_class_from_table.php | 10 +++++----- dev/skeletons/skeleton_class.class.php | 5 ----- dev/skeletons/skeleton_page.php | 10 +++++----- htdocs/core/class/commonobject.class.php | 10 +++++----- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index 43f29a17ad3..6dac857ac11 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -69,8 +69,9 @@ if ($db->type != 'mysql' && $db->type != 'mysqli') } // Show parameters -print 'Tablename='.$argv[1]."\n"; -print "Current dir is ".getcwd()."\n"; +print 'Tablename: '.$argv[1]."\n"; +print "Current dir: ".getcwd()."\n"; +print "Database name: ".$db->database_name."\n"; // Define array with list of properties @@ -304,10 +305,9 @@ foreach($property as $key => $prop) } else { - $varprop.=' \'.(! isset($this->'.$prop['field'].')?\'NULL\':"\'".'; + $varprop.='\'.(! isset($this->'.$prop['field'].')?\'NULL\':"\'".'; $varprop.="\$this->".$prop['field'].""; - $varprop.='.\').'; - + $varprop.='"\'")'; } if ($i < (count($property)-$no_output_field)) $varprop.=".','"; diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 854e4a4fb47..2f8c78556e1 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -38,11 +38,6 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; */ class Skeleton_Class extends CommonObject { - /** - * @var DoliDb Database handler - */ - protected $db; - /** * @var string Error code (or message) * @deprecated diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php index 7665ce9986a..a74088b3702 100644 --- a/dev/skeletons/skeleton_page.php +++ b/dev/skeletons/skeleton_page.php @@ -43,7 +43,7 @@ if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@includ if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only if (! $res) die("Include of main fails"); // Change this following line to use the correct relative path from htdocs -include_once(DOL_DOCUMENT_ROOT.'/core/class/formcompany.class.php'); +include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); dol_include_once('/module/class/skeleton_class.class.php'); // Load traductions files requiredby by page @@ -62,7 +62,7 @@ if ($user->societe_id > 0) //accessforbidden(); } -if (empty($action) && empty($id) && empty($ref)) $action='create'; +if (empty($action) && empty($id) && empty($ref)) $action='list'; // Load object if id or ref is provided as parameter $object=new Skeleton_Class($db); @@ -225,7 +225,7 @@ jQuery(document).ready(function() { // Part to show a list -if ($action == 'list' || empty($id)) +if ($action == 'list' || (empty($id) && $action != 'create')) { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -243,7 +243,7 @@ if ($action == 'list' || empty($id)) $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; - $sql.= " ORDER BY field1 ASC"; + $sql.=$db->order($sortfield, $sortorder); print '
'; @@ -329,7 +329,7 @@ if ($action == 'list' || empty($id)) // Part to create if ($action == 'create') { - print_fiche_titre($langs->trans("NewResidence")); + print_fiche_titre($langs->trans("NewSkeleton")); print ''; print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a4136d880f0..65ece020ac8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -53,6 +53,11 @@ abstract class CommonObject */ public $error; + /** + * @var string[] Array of error strings + */ + public $errors=array(); + /** * @var string Key value used to track if data is coming from import wizard */ @@ -82,11 +87,6 @@ abstract class CommonObject // Following vars are used by some objects only. We keep this property here in CommonObject to be able to provide common method using them. - /** - * @var string[] Array of error strings - */ - public $errors=array(); - /** * @var string[] Can be used to pass information when only object is provided to method */ From c9264fa1bc0f438a755ca8e95495b0c2c47ce586 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 20:17:05 +0200 Subject: [PATCH 4/7] Fix memcached effect was lost because init was done each time. --- htdocs/core/class/translate.class.php | 3 +- htdocs/core/lib/memory.lib.php | 54 +++++++++++++++++++-------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 100af13af5d..5d06586fb16 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -234,7 +234,8 @@ class Translate if ($usecachekey) { //dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey); - + //global $aaa; $aaa+=1; + //print $aaa." ".$usecachekey."\n"; require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php'; $tmparray=dol_getcache($usecachekey); if (is_array($tmparray) && count($tmparray)) diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index b68016c3a46..7df56b6283c 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -47,10 +47,16 @@ function dol_setcache($memoryid,$data) // Using a memcached server if (! empty($conf->memcached->enabled) && class_exists('Memcached')) { - $memoryid=session_name().'_'.$memoryid; - $m=new Memcached(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcached(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); //print "Add memoryid=".$memoryid; $m->add($memoryid,$data); // This fails if key already exists @@ -66,10 +72,16 @@ function dol_setcache($memoryid,$data) } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) { - $memoryid=session_name().'_'.$memoryid; - $m=new Memcache(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcache(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); $result=$m->add($memoryid,$data); // This fails if key already exists if ($result) @@ -103,10 +115,16 @@ function dol_getcache($memoryid) // Using a memcached server if (! empty($conf->memcached->enabled) && class_exists('Memcached')) { + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcached(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + $memoryid=session_name().'_'.$memoryid; - $m=new Memcached(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); //$m->setOption(Memcached::OPT_COMPRESSION, false); //print "Get memoryid=".$memoryid; $data=$m->get($memoryid); @@ -124,10 +142,16 @@ function dol_getcache($memoryid) } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) { - $memoryid=session_name().'_'.$memoryid; - $m=new Memcache(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcache(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); $data=$m->get($memoryid); //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n
"; From 9667b6a7c6e637c670bf215f623b79822b0242d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 20:22:44 +0200 Subject: [PATCH 5/7] Solve conflict of var name --- htdocs/core/lib/memory.lib.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 7df56b6283c..e8a9ac382a0 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -47,20 +47,20 @@ function dol_setcache($memoryid,$data) // Using a memcached server if (! empty($conf->memcached->enabled) && class_exists('Memcached')) { - global $m; - if (empty($m) || ! is_object($m)) + global $dolmemcache; + if (empty($dolmemcache) || ! is_object($dolmemcache)) { - $m=new Memcached(); + $dolmemcache=new Memcached(); $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); if (! $result) return -1; } $memoryid=session_name().'_'.$memoryid; - //$m->setOption(Memcached::OPT_COMPRESSION, false); + //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); //print "Add memoryid=".$memoryid; - $m->add($memoryid,$data); // This fails if key already exists - $rescode=$m->getResultCode(); + $dolmemcache->add($memoryid,$data); // This fails if key already exists + $rescode=$dolmemcache->getResultCode(); if ($rescode == 0) { return count($data); @@ -72,18 +72,18 @@ function dol_setcache($memoryid,$data) } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) { - global $m; - if (empty($m) || ! is_object($m)) + global $dolmemcache; + if (empty($dolmemcache) || ! is_object($dolmemcache)) { - $m=new Memcache(); + $dolmemcache=new Memcache(); $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); if (! $result) return -1; } $memoryid=session_name().'_'.$memoryid; - //$m->setOption(Memcached::OPT_COMPRESSION, false); - $result=$m->add($memoryid,$data); // This fails if key already exists + //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); + $result=$dolmemcache->add($memoryid,$data); // This fails if key already exists if ($result) { return count($data); From 5529ef7a50bf16b455336aee0bede0a06d7efa6b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 20:53:16 +0200 Subject: [PATCH 6/7] Better doc --- dev/skeletons/modMyModule.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 7eebdee8bcd..8c55edc3d1a 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -193,7 +193,7 @@ class modMyModule extends DolibarrModules // Add here entries to declare new menus // // Example to declare a new Top Menu entry and its Left menu entry: - // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu + // $this->menu[$r]=array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode // 'type'=>'top', // This is a Top menu entry // 'titre'=>'MyModule top menu', // 'mainmenu'=>'mymodule', @@ -208,7 +208,7 @@ class modMyModule extends DolibarrModules // $r++; // // Example to declare a Left Menu entry into an existing Top menu entry: - // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode // 'type'=>'left', // This is a Left menu entry // 'titre'=>'MyModule left menu', // 'mainmenu'=>'xxx', From 82ad81fc032075e798285a98ab56834f3366d9a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 20:56:28 +0200 Subject: [PATCH 7/7] Fix picto --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 62170e7d277..f5dc621aaf3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2766,7 +2766,7 @@ function print_fiche_titre($title, $mesg='', $picto='title_generic.png', $pictoi * @param int $id To force an id on html objects * @return string */ -function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id=0) +function load_fiche_titre($titre, $mesg='', $picto='title_generic.png', $pictoisfullpath=0, $id=0) { global $conf;