diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index a0e74c5cdd5..e05931f437d 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -39,6 +39,9 @@ class FormProjets */ public $error = ''; + public $errors = array(); + + public $nboftasks; @@ -622,6 +625,8 @@ class FormProjets if ($resql) { $num = $this->db->num_rows($resql); $i = 0; + $sellist = ''; + if ($num > 0) { $sellist = ''; $sellist .= ''.$placeholder.''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 81f830d6456..54cb2a1e57f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1423,13 +1423,17 @@ function dol_string_nounprintableascii($str, $removetabcrlf = 1) /** * Returns text escaped for inclusion into javascript code * - * @param string $stringtoescape String to escape - * @param int $mode 0=Escape also ' and " into ', 1=Escape ' but not " for usage into 'string', 2=Escape " but not ' for usage into "string", 3=Escape ' and " with \ - * @param int $noescapebackslashn 0=Escape also \n. 1=Do not escape \n. - * @return string Escaped string. Both ' and " are escaped into ' if they are escaped. + * @param string $stringtoescape String to escape + * @param int $mode 0=Escape also ' and " into ', 1=Escape ' but not " for usage into 'string', 2=Escape " but not ' for usage into "string", 3=Escape ' and " with \ + * @param int $noescapebackslashn 0=Escape also \n. 1=Do not escape \n. + * @return string Escaped string. Both ' and " are escaped into ' if they are escaped. */ function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0) { + if (is_null($stringtoescape)) { + return ''; + } + // escape quotes and backslashes, newlines, etc. $substitjs = array("'"=>"\\'", "\r"=>'\\r'); //$substitjs['']='<\/'; // We removed this. Should be useless. @@ -11891,8 +11895,8 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n 'contact_id'=>$obj->fk_contact, 'socpeopleassigned' => $contactaction->socpeopleassigned, - 'lastname'=>$obj->lastname, - 'firstname'=>$obj->firstname, + 'lastname' => (empty($obj->lastname) ? '' : $obj->lastname), + 'firstname' => (empty($obj->firstname) ? '' : $obj->firstname), 'fk_element'=>$obj->fk_element, 'elementtype'=>$obj->elementtype, // Type of event diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 5f521fd63de..dfb114576a3 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -344,7 +344,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', } else { $objectid = $object; // $objectid can be X or 'X,Y,Z' } - $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input + if ($objectid) { + $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input + } //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); //print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index c8d2d8d5a4f..1028706ed6b 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -156,7 +156,7 @@ class modTicket extends DolibarrModules 'tabfieldvalue' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public,fk_parent", "code,label,pos,use_default"), 'tabfieldinsert' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public,fk_parent", "code,label,pos,use_default"), 'tabrowid' => array("rowid", "rowid", "rowid", "rowid"), - 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled && !empty($conf->global->TICKET_ENABLE_RESOLUTION)), + 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled && getDolGlobalString('TICKET_ENABLE_RESOLUTION')), 'tabhelp' => array( array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 936633508fa..501cdcc5f4b 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1299,7 +1299,7 @@ if ($action == 'create' && $user->rights->projet->creer) { // Budget print ''.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).''; } print ''; @@ -1443,9 +1443,11 @@ if ($action == 'create' && $user->rights->projet->creer) { '; } + /* * Actions Buttons */ + print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index 024dce3abc9..7103916cdb4 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -136,7 +136,7 @@ print ''; // Budget print ''.$langs->trans("Budget").''; -if (strcmp($object->budget_amount, '')) { +if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); } print ''; diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index f6827fc19b3..2174a02c347 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -387,7 +387,7 @@ if ($id > 0 || !empty($ref)) { // Budget print ''.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, '', $langs, 0, 0, 0, $conf->currency).''; } print ''; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 7bad7fd493d..8f548685631 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -291,14 +291,14 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity percent print ''.$langs->trans("OpportunityProbability").''; - if (strcmp($object->opp_percent, '')) { + if (!is_null($object->opp_percent) && strcmp($object->opp_percent, '')) { print price($object->opp_percent, '', $langs, 1, 0).' %'; } print ''; // Opportunity Amount print ''.$langs->trans("OpportunityAmount").''; - if (strcmp($object->opp_amount, '')) { + if (!is_null($object->opp_amount) && strcmp($object->opp_amount, '')) { print ''.price($object->opp_amount, '', $langs, 1, 0, 0, $conf->currency).''; if (strcmp($object->opp_percent, '')) { print ' '.$langs->trans("Weighted").': '.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; @@ -309,7 +309,7 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Budget print ''.$langs->trans("Budget").''; -if (strcmp($object->budget_amount, '')) { +if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency).''; } print ''; @@ -657,7 +657,6 @@ if (!empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) { } - $parameters = array('listofreferent'=>$listofreferent); $resHook = $hookmanager->executeHooks('completeListOfReferent', $parameters, $object, $action); @@ -693,7 +692,7 @@ if (!$showdatefilter) { print ''; print 'id.'" method="POST">'; print ''; - print ''; + print ''; print ''; print ''; print $form->selectDate($dates, 'dates', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); @@ -730,7 +729,7 @@ $tooltiponprofitplus = $tooltiponprofitminus = ''; foreach ($listofreferent as $key => $value) { $name = $langs->trans($value['name']); $qualified = $value['test']; - $margin = $value['margin']; + $margin = empty($value['margin']) ? 0 : $value['margin']; if ($qualified && isset($margin)) { // If this element must be included into profit calculation ($margin is 'minus' or 'add') if ($margin == 'add') { $tooltiponprofitplus .= ' > '.$name." (+)\n"; @@ -777,8 +776,8 @@ foreach ($listofreferent as $key => $value) { $tablename = $value['table']; $datefieldname = $value['datefieldname']; $qualified = $value['test']; - $margin = $value['margin']; - $project_field = $value['project_field']; + $margin = empty($value['margin']) ? 0 : $value['margin']; + $project_field = empty($value['project_field']) ? '' : $value['project_field']; if ($qualified && isset($margin)) { // If this element must be included into profit calculation ($margin is 'minus' or 'add') $element = new $classname($db); @@ -990,11 +989,11 @@ foreach ($listofreferent as $key => $value) { $tablename = $value['table']; $datefieldname = $value['datefieldname']; $qualified = $value['test']; - $langtoload = $value['lang']; - $urlnew = $value['urlnew']; - $buttonnew = $value['buttonnew']; - $testnew = $value['testnew']; - $project_field = $value['project_field']; + $langtoload = empty($value['lang']) ? '' : $value['lang']; + $urlnew = empty($value['urlnew']) ? '' : $value['urlnew']; + $buttonnew = empty($value['buttonnew']) ? '' : $value['buttonnew']; + $testnew = empty($value['testnew']) ? '' : $value['testnew']; + $project_field = empty($value['project_field']) ? '' : $value['project_field']; $exclude_select_element = array('payment_various'); if (!empty($value['exclude_select_element'])) { diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index f2889d7c469..dea34c4badc 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -181,7 +181,7 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) { // Budget print ''.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); } print ''; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 3322b63b171..d3097631a6f 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -616,7 +616,7 @@ if ($id > 0 || !empty($ref)) { // Budget print ''.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency).''; } print ''; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index fccf9d2ffe1..dfa26202a2d 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -632,7 +632,7 @@ if ($id > 0 || !empty($ref)) { // Budget print ''.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).''; } print ''; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 94ed0edaffd..139a1711658 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1004,7 +1004,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Budget print ''.$langs->trans("Budget").''; - if (strcmp($projectstatic->budget_amount, '')) { + if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount, '')) { print ''.price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency).''; } print ''; @@ -2616,7 +2616,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!count($tasks)) { $totalnboffields = 1; foreach ($arrayfields as $value) { - if ($value['checked']) { + if (!empty($value['checked'])) { $totalnboffields++; } } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index d4e0148f662..05c724b718e 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -294,7 +294,7 @@ class Ticket extends CommonObject 'email_msgid' => array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'help'=>'EmailMsgIDDesc'), 'email_date' => array('type'=>'datetime', 'label'=>'EmailDate', 'visible'=>-2, 'enabled'=>1, 'position'=>541), 'progress' => array('type'=>'integer', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>"", 'isameasure'=>2, 'csslist'=>'width50'), - 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>'$conf->global->TICKET_ENABLE_RESOLUTION', 'position'=>550, 'notnull'=>1), + 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>'getDolGlobalString("TICKET_ENABLE_RESOLUTION")', 'position'=>550, 'notnull'=>1), 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'SolvedClosed', 9 => 'Deleted')), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), );