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