Clean duplicated vars

This commit is contained in:
Laurent Destailleur 2017-06-01 18:18:57 +02:00
parent 76e1438fe6
commit dd2d9f533a

View File

@ -20,7 +20,7 @@
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
/** /**
* API class for projects * API class for projects
* *
@ -83,8 +83,8 @@ class Projects extends DolibarrApi
return $this->_cleanObjectDatas($this->project); return $this->_cleanObjectDatas($this->project);
} }
/** /**
* List projects * List projects
* *
@ -102,7 +102,7 @@ class Projects extends DolibarrApi
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
@ -126,7 +126,7 @@ class Projects extends DolibarrApi
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
if (! DolibarrApi::_checkFilters($sqlfilters)) if (! DolibarrApi::_checkFilters($sqlfilters))
{ {
@ -135,7 +135,7 @@ class Projects extends DolibarrApi
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0)
@ -227,7 +227,7 @@ class Projects extends DolibarrApi
} }
$this->project->getLinesArray(DolibarrApiAccess::$user); $this->project->getLinesArray(DolibarrApiAccess::$user);
$result = array(); $result = array();
foreach ($this->project->lines as $line) // $line is a task foreach ($this->project->lines as $line) // $line is a task
{ {
if ($includetimespent == 1) if ($includetimespent == 1)
{ {
@ -243,7 +243,7 @@ class Projects extends DolibarrApi
return $result; return $result;
} }
/** /**
* Get roles a user is assigned to a project with * Get roles a user is assigned to a project with
* *
@ -256,20 +256,20 @@ class Projects extends DolibarrApi
*/ */
function getRoles($id, $userid=0) { function getRoles($id, $userid=0) {
global $db; global $db;
if(! DolibarrApiAccess::$user->rights->projet->lire) { if(! DolibarrApiAccess::$user->rights->projet->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->project->fetch($id); $result = $this->project->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Project not found'); throw new RestException(404, 'Project not found');
} }
if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$taskstatic=new Task($this->db); $taskstatic=new Task($this->db);
$userp = DolibarrApiAccess::$user; $userp = DolibarrApiAccess::$user;
@ -285,8 +285,8 @@ class Projects extends DolibarrApi
} }
return $result; return $result;
} }
/** /**
* Add a task to given project * Add a task to given project
* *
@ -347,7 +347,7 @@ class Projects extends DolibarrApi
return false; return false;
} }
*/ */
/** /**
* Update a task to given project * Update a task to given project
* *
@ -405,9 +405,9 @@ class Projects extends DolibarrApi
} }
return false; return false;
}*/ }*/
/** /**
* Update project general fields (won't touch lines of project) * Update project general fields (won't touch lines of project)
* *
@ -482,7 +482,7 @@ class Projects extends DolibarrApi
* Validate a project. * Validate a project.
* You can test this API with the following input message * You can test this API with the following input message
* { "notrigger": 0 } * { "notrigger": 0 }
* *
* @param int $id Project ID * @param int $id Project ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* *
@ -526,7 +526,7 @@ class Projects extends DolibarrApi
); );
} }
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
@ -534,9 +534,12 @@ class Projects extends DolibarrApi
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
*/ */
function _cleanObjectDatas($object) { function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
unset($object->titre);
unset($object->datec);
unset($object->datem);
unset($object->barcode_type); unset($object->barcode_type);
unset($object->barcode_type_code); unset($object->barcode_type_code);
unset($object->barcode_type_label); unset($object->barcode_type_label);
@ -558,21 +561,21 @@ class Projects extends DolibarrApi
unset($object->country); unset($object->country);
unset($object->country_id); unset($object->country_id);
unset($object->country_code); unset($object->country_code);
unset($object->weekWorkLoad); unset($object->weekWorkLoad);
unset($object->weekWorkLoad); unset($object->weekWorkLoad);
//unset($object->lines); // for task we use timespent_lines, but for project we use lines //unset($object->lines); // for task we use timespent_lines, but for project we use lines
unset($object->total_ht); unset($object->total_ht);
unset($object->total_tva); unset($object->total_tva);
unset($object->total_localtax1); unset($object->total_localtax1);
unset($object->total_localtax2); unset($object->total_localtax2);
unset($object->total_ttc); unset($object->total_ttc);
return $object; return $object;
} }
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* *
@ -591,8 +594,8 @@ class Projects extends DolibarrApi
} }
return $object; return $object;
} }
// TODO // TODO
// getSummaryOfTimeSpent // getSummaryOfTimeSpent
} }