diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index b9cefe45306..e42c2e9a83b 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -30,16 +30,19 @@ if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) { - $ret = $object->fetch($id, $ref); - if ($ret > 0) - { - $object->fetch_thirdparty(); - $id = $object->id; - } - else - { - if (empty($object->error) && ! count($object->errors)) setEventMessages('Fetch on object return an error without filling $object->error nor $object->errors', null, 'errors'); - else setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } + if (($id > 0 && is_numeric($id)) || ! empty($ref)) // To discard case when id is list of ids like '1,2,3...' + { + $ret = $object->fetch($id, $ref); + if ($ret > 0) + { + $object->fetch_thirdparty(); + $id = $object->id; + } + else + { + if (empty($object->error) && ! count($object->errors)) setEventMessages('Fetch on object return an error without filling $object->error nor $object->errors', null, 'errors'); + else setEventMessages($object->error, $object->errors, 'errors'); + $action=''; + } + } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ea71f3e1100..6d0aa119316 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6568,7 +6568,7 @@ function dol_getmypid() /** * Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields) * - * @param string|string[] $fields String or array of strings, filled with the name of all fields in the SQL query we must check (combined with a OR) + * @param string|string[] $fields String or array of strings, filled with the name of all fields in the SQL query we must check (combined with a OR). Example: array("p.field1","p.field2") * @param string $value The value to look for. * If param $mode is 0, can contains several keywords separated with a space or | * like "keyword1 keyword2" = We want record field like keyword1 AND field like keyword2 diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 14f3c7e37d4..2a77de4f552 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -754,8 +754,8 @@ class Task extends CommonObject } if ($socid) $sql.= " AND p.fk_soc = ".$socid; if ($projectid) $sql.= " AND p.rowid in (".$projectid.")"; - if ($filteronproj) $sql.= " AND (p.ref LIKE '%".$this->db->escape($filteronproj)."%' OR p.title LIKE '%".$this->db->escape($filteronproj)."%')"; - if ($filteronprojstatus > -1) $sql.= " AND p.fk_statut = ".$filteronprojstatus; + if ($filteronproj) $sql.= natural_search(array("p.ref", "p.title"), $filteronproj); + if ($filteronprojstatus > -1) $sql.= " AND p.fk_statut IN (".$filteronprojstatus.")"; if ($morewherefilter) $sql.=$morewherefilter; $sql.= " ORDER BY p.ref, t.rang, t.dateo"; diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 77e4709f4b9..c3552d714f2 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -80,12 +80,12 @@ if (! empty($conf->use_javascript_ajax)) ); } -$title=$langs->trans("Project").' - '.$langs->trans("Gantt").' - '.$object->ref.' '.$object->name; -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Gantt"); +$title=$langs->trans("Project").' - '.$langs->trans("Gantt").($object->ref?' - '.$object->ref.' '.$object->name:''); +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=($object->ref?$object->ref.' '.$object->name.' - ':'').$langs->trans("Gantt"); $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("",$title,$help_url,'',0,0,$arrayofjs,$arrayofcss); -if ($id > 0 || ! empty($ref)) +if (($id > 0 && is_numeric($id)) || ! empty($ref)) { // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); @@ -93,7 +93,6 @@ if ($id > 0 || ! empty($ref)) //$userDelete = $object->restrictedProjectArea($user,'delete'); //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $tab='gantt'; $head=project_prepare_head($object); @@ -195,7 +194,7 @@ if ($id > 0 || ! empty($ref)) * Buttons actions */ -if ($id > 0) +if ($id > 0 && is_numeric($id)) { print '
'; @@ -229,7 +228,7 @@ else // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user // can have a parent that is not affected to him). -$tasksarray=$task->getTasksArray(0, 0, $object->id, $socid, 0); +$tasksarray=$task->getTasksArray(0, 0, ($object->id ? $object->id : $id), $socid, 0); // We load also tasks limited to a particular user //$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$object->id,0) : ''); //var_dump($tasksarray);