From b356c34dc47d1ba00bb25e8f0e865d727f7f0eb5 Mon Sep 17 00:00:00 2001 From: De Coninck Laurent Date: Sun, 12 Feb 2017 17:22:06 +0100 Subject: [PATCH 1/9] [mail; password; forgotten][#6334] - Fix mail url Fix the mail url on password generation --- htdocs/user/class/user.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index cd0000c1e60..79e17fd3f81 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1653,12 +1653,12 @@ class User extends CommonObject // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current if (! $changelater) { - $url = $urlwithroot.'/'; + $url = $dolibarr_main_url_root.'/'; $mesg.= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived").".\n"; $mesg.= $outputlangs->transnoentitiesnoconv("NewKeyIs")." :\n\n"; @@ -1674,7 +1674,7 @@ class User extends CommonObject } else { - $url = $urlwithroot.'/user/passwordforgotten.php?action=validatenewpassword&username='.$this->login."&passwordhash=".dol_hash($password); + $url = $dolibarr_main_url_root.'/user/passwordforgotten.php?action=validatenewpassword&username='.$this->login."&passwordhash=".dol_hash($password); $mesg.= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived")."\n"; $mesg.= $outputlangs->transnoentitiesnoconv("NewKeyWillBe")." :\n\n"; From 294517a8e0b1bd525d5d49e2fd99f84ae8a8254c Mon Sep 17 00:00:00 2001 From: De Coninck Laurent Date: Mon, 13 Feb 2017 16:49:10 +0100 Subject: [PATCH 2/9] use already existing variable --- htdocs/user/class/user.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 79e17fd3f81..ab76948fea4 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1652,13 +1652,12 @@ class User extends CommonObject $subject = $outputlangs->transnoentitiesnoconv("SubjectNewPassword", $appli); // Define $urlwithroot - //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); - //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file if (! $changelater) { - $url = $dolibarr_main_url_root.'/'; + $url = $urlwithroot.'/'; $mesg.= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived").".\n"; $mesg.= $outputlangs->transnoentitiesnoconv("NewKeyIs")." :\n\n"; @@ -1674,7 +1673,7 @@ class User extends CommonObject } else { - $url = $dolibarr_main_url_root.'/user/passwordforgotten.php?action=validatenewpassword&username='.$this->login."&passwordhash=".dol_hash($password); + $url = $urlwithroot.'/user/passwordforgotten.php?action=validatenewpassword&username='.$this->login."&passwordhash=".dol_hash($password); $mesg.= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived")."\n"; $mesg.= $outputlangs->transnoentitiesnoconv("NewKeyWillBe")." :\n\n"; From e903bf2b5c8fecd35478cd4ca323710f7d03985a Mon Sep 17 00:00:00 2001 From: fmarcet Date: Tue, 14 Feb 2017 18:55:39 +0100 Subject: [PATCH 3/9] Fix: Bad code makes don't work for external modules numeration model --- htdocs/comm/propal/class/propal.class.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d94932d10c8..68966bae711 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1138,12 +1138,6 @@ class Propal extends CommonObject $clonedObj->id=0; $clonedObj->statut=self::STATUS_DRAFT; - if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) - { - $this->error='ErrorSetupNotComplete'; - return -1; - } - // Clear fields $clonedObj->user_author = $user->id; $clonedObj->user_valid = ''; @@ -1152,12 +1146,6 @@ class Propal extends CommonObject $clonedObj->fin_validite = $clonedObj->date + ($clonedObj->duree_validite * 24 * 3600); if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $clonedObj->ref_client = ''; - // Set ref - require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php'; - $obj = $conf->global->PROPALE_ADDON; - $modPropale = new $obj; - $clonedObj->ref = $modPropale->getNextValue($objsoc,$clonedObj); - // Create clone $result=$clonedObj->create($user); From 89e6d86bf7d9073e6a63234561f5edba3a92553d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 15 Feb 2017 09:08:27 +0100 Subject: [PATCH 4/9] FIX #6411 --- htdocs/core/boxes/box_services_contracts.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 9f71a98e77f..752509a0616 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -70,15 +70,12 @@ class box_services_contracts extends ModeleBoxes $sql.= " cd.rowid as cdid, cd.tms as datem, cd.statut, cd.label, cd.description, cd.product_type as type,"; $sql.= " p.rowid as product_id, p.ref as product_ref"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; - $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= "INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= ")"; $sql.= " WHERE c.entity = ".$conf->entity; - $sql.= " AND s.rowid = c.fk_soc"; - $sql.= " AND c.rowid = cd.fk_contrat"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= $db->order("c.tms","DESC"); $sql.= $db->plimit($max, 0); From c175dfe68bdfa20c12bea5aac5b1046ce7f20208 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Wed, 15 Feb 2017 09:47:18 +0100 Subject: [PATCH 5/9] Fix: Bad code makes don't work for external modules numeration model --- htdocs/comm/propal/class/propal.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 68966bae711..f272120477f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1136,6 +1136,7 @@ class Propal extends CommonObject } $clonedObj->id=0; + $clonedObj->ref=''; $clonedObj->statut=self::STATUS_DRAFT; // Clear fields From 0a9ffa58c1d749cea2bf8214972fbd21a3964c25 Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 20 Feb 2017 09:00:39 +0100 Subject: [PATCH 6/9] FIX : event status is not modified when assign an user --- htdocs/comm/action/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index cd1c9ecfd1b..a6878473fea 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -853,6 +853,9 @@ if ($id > 0) $result3=$object->fetch_contact(); $result4=$object->fetch_userassigned(); $result5=$object->fetch_optionals($id,$extralabels); + + $percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):(in_array(GETPOST('complete'),array(-1,100))?GETPOST('complete'):GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + if($listUserAssignedUpdated || $donotclearsession) { @@ -1030,7 +1033,7 @@ if ($id > 0) // Status print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - $percent=GETPOST("percentage")?GETPOST("percentage"):$object->percentage; + $percent = GETPOST("percentage") ? GETPOST("percentage"): $object->percentage; $formactions->form_select_status_action('formaction',$percent,1); print ''; From 089aa1df330925bea40c15075cdc2ac282a472bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2017 23:22:47 +0100 Subject: [PATCH 7/9] FIX If bank module on, field must be required to register payment of expense report. --- htdocs/expensereport/payment/payment.php | 38 +++++++++++------------- htdocs/main.inc.php | 2 ++ htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index e361a9954c0..c957b171e79 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("bills"); +$langs->load("banks"); $chid=GETPOST("id"); $action=GETPOST('action'); @@ -62,22 +63,22 @@ if ($action == 'add_payment') $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - if (! $_POST["fk_typepayment"] > 0) + if (! ($_POST["fk_typepayment"] > 0)) { - $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")), null, 'errors'); $error++; } if ($datepaid == '') { - $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")); + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")), null, 'errors'); $error++; } - if (! empty($conf->banque->enabled) && ! $accountid > 0) + if (! empty($conf->banque->enabled) && ! ($accountid > 0)) { - $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit")); + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToDebit")), null, 'errors'); $error++; } - + if (! $error) { $paymentid = 0; @@ -163,7 +164,6 @@ $form=new Form($db); // Form to create expense report payment if (GETPOST("action") == 'create') { - $expensereport = new ExpenseReport($db); $expensereport->fetch($chid); @@ -171,11 +171,6 @@ if (GETPOST("action") == 'create') print load_fiche_titre($langs->trans("DoPayment")); - if ($mesg) - { - print "
$mesg
"; - } - print '
'; print ''; print ''; @@ -222,12 +217,15 @@ if (GETPOST("action") == 'create') print "\n"; print ''; - print ''; - print ''.$langs->trans('AccountToDebit').''; - print ''; - $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$expensereport->accountid, "accountid", 0, '',1); // Show open bank account list - print ''; - + if (! empty($conf->banque->enabled)) + { + print ''; + print ''.$langs->trans('AccountToDebit').''; + print ''; + $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$expensereport->accountid, "accountid", 0, '',1); // Show open bank account list + print ''; + } + // Number print ''.$langs->trans('Numero'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; @@ -243,9 +241,7 @@ if (GETPOST("action") == 'create') dol_fiche_end(); - /* - * Autres charges impayees - */ + // List of expenses ereport not already paid completely $num = 1; $i = 0; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5105a8eef32..40d1326c45e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1700,8 +1700,10 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra else $appli.=" ".DOL_VERSION; print '
'; if ($doliurl) print ''; + else print ''; print $appli; if ($doliurl) print ''; + else print ''; print '
'."\n"; // Link to bugtrack diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 72d63b55ff6..76cbad28f00 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1475,7 +1475,7 @@ font.vsmenudisabled { font-size:px; font-family: ; white-space: nowrap; } font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; } -a.help:link, a.help:visited, a.help:hover, a.help:active { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #666666; text-decoration: none; } +a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #666666; text-decoration: none; } .vmenu div.blockvmenufirst, .vmenu div.blockvmenulogo, .vmenu div.blockvmenusearchphone, .vmenu div.blockvmenubookmarks { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ad9bda1b4dd..32c0604386c 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1512,7 +1512,7 @@ font.vsmenudisabled { font-size:px; font-family: ; white-space: nowrap; } font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; } -a.help:link, a.help:visited, a.help:hover, a.help:active { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #666666; text-decoration: none; } +a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #666666; text-decoration: none; } div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks From 32678015c98b49dc190e4af09ca86346439397ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2017 23:52:13 +0100 Subject: [PATCH 8/9] FIX protection against infinite loop on hierarchy --- htdocs/core/lib/treeview.lib.php | 9 ++++++--- htdocs/user/class/user.class.php | 28 ++++++++++++++++++++-------- htdocs/user/hierarchy.php | 10 +++++++++- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index 6fc0c9f013f..db0fcd07fae 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -97,7 +97,7 @@ function tree_showpad(&$fulltree,$key,$silent=0) // ------------------------------- Used by menu editor, category view, ... ----------------- /** - * Recursive function to output menu tree.
  • ...
+ * Recursive function to output a tree.
  • ...
* It is also used for the tree of categories. * Note: To have this function working, check you have loaded the js and css for treeview. * $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', @@ -106,7 +106,7 @@ function tree_showpad(&$fulltree,$key,$silent=0) * TODO Replace with jstree plugin instead of treeview plugin. * * @param array $tab Array of all elements - * @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>) + * @param array $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>) * @param int $rang Level of element * @param string $iddivjstree Id to use for parent ul element * @param int $donoresetalreadyloaded Do not reset global array $donoresetalreadyloaded used to avoid to go down on an aleady processed record @@ -139,7 +139,10 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal print '
    '; } - if ($rang > 50) return; // Protect against infinite loop. Max 50 depth + if ($rang > 50) + { + return; // Protect against infinite loop. Max 50 depth + } //ballayage du tableau $sizeoftab=count($tab); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ab76948fea4..c4b4ac48250 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2544,7 +2544,12 @@ class User extends CommonObject dol_syslog(get_class($this)."::get_full_tree call to build_path_from_id_user", LOG_DEBUG); foreach($this->users as $key => $val) { - $this->build_path_from_id_user($key,0); // Process a branch from the root user key (this user has no parent) + $result = $this->build_path_from_id_user($key,0); // Process a branch from the root user key (this user has no parent) + if ($result < 0) + { + $this->error='ErrorLoopInHierarchy'; + return -1; + } } // Exclude leaf including $deleteafterid from tree @@ -2601,10 +2606,10 @@ class User extends CommonObject * Function called by get_full_tree(). * * @param int $id_user id_user entry to update - * @param int $protection Deep counter to avoid infinite loop - * @return void + * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound) + * @return int < 0 if KO (infinit loop), >= 0 if OK */ - function build_path_from_id_user($id_user,$protection=1000) + function build_path_from_id_user($id_user,$protection=0) { dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG); @@ -2612,7 +2617,7 @@ class User extends CommonObject { // Already defined dol_syslog(get_class($this)."::build_path_from_id_user fullpath and fullname already defined", LOG_WARNING); - return; + return 0; } // Define fullpath and fullname @@ -2620,9 +2625,16 @@ class User extends CommonObject $this->users[$id_user]['fullname'] = $this->users[$id_user]['lastname']; $i=0; $cursor_user=$id_user; - while ((empty($protection) || $i < $protection) && ! empty($this->parentof[$cursor_user])) + $useridfound=array($id_user); + while (! empty($this->parentof[$cursor_user])) { - $this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath']; + if (in_array($this->parentof[$cursor_user], $useridfound)) + { + dol_syslog("The hierarchy of user has a recursive loop", LOG_WARNING); + return -1; // Should not happen. Protection against looping hierarchy + } + $useridfound[]=$this->parentof[$cursor_user]; + $this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath']; $this->users[$id_user]['fullname'] = $this->users[$this->parentof[$cursor_user]]['lastname'].' >> '.$this->users[$id_user]['fullname']; $i++; $cursor_user=$this->parentof[$cursor_user]; } @@ -2630,7 +2642,7 @@ class User extends CommonObject // We count number of _ to have level $this->users[$id_user]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->users[$id_user]['fullpath'])); - return; + return 1; } /** diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 66d725b3204..11f115278ee 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -71,9 +71,15 @@ print load_fiche_titre($langs->trans("ListOfUsers"). ' ('.$langs->trans("Hierarc // Load hierarchy of users $user_arbo = $userstatic->get_full_tree(0, ($search_statut != '' && $search_statut >= 0) ? "statut = ".$search_statut : ''); +if (! is_array($user_arbo) && $user_arbo < 0) +{ + setEventMessages($userstatic->error, $userstatic->errors, 'warnings'); +} +else +{ // Define fulltree array $fulltree=$user_arbo; - +//var_dump($fulltree); // Define data (format for treeview) $data=array(); $data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>''); @@ -131,6 +137,7 @@ foreach($fulltree as $key => $val) ); } +//var_dump($data); print ''."\n"; @@ -185,6 +192,7 @@ else print ""; print "\n"; +} // /*print '