diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php
index e101fb89602..89d170feb60 100644
--- a/htdocs/api/class/api.class.php
+++ b/htdocs/api/class/api.class.php
@@ -173,7 +173,7 @@ class DolibarrApi
unset($object->name_bis);
unset($object->newref);
- if ($object->table_element != 'ticket') {
+ if (!isset($object->table_element) || $object->table_element != 'ticket') {
unset($object->comments);
}
diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php
index 25765e7f7e5..17d8916b9aa 100644
--- a/htdocs/api/class/api_login.class.php
+++ b/htdocs/api/class/api_login.class.php
@@ -48,8 +48,8 @@ class Login
* @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access)
* @return array Response status and user token
*
- * @throws RestException 403
- * @throws RestException 500
+ * @throws RestException 403 Access denied
+ * @throws RestException 500 System error
*
* @url GET /
* @url POST /
diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php
index 48da6483152..9c936c1d943 100644
--- a/htdocs/compta/bank/various_payment/list.php
+++ b/htdocs/compta/bank/various_payment/list.php
@@ -466,14 +466,18 @@ if ($result)
// Project
if ($arrayfields['project']['checked']) {
- $proj->fetch($obj->fk_project);
- print '
'.$proj->getNomUrl(1).' | ';
+ print '';
+ if ($obj->fk_project > 0) {
+ $proj->fetch($obj->fk_project);
+ print $proj->getNomUrl(1);
+ }
+ print ' | ';
if (!$i) $totalarray['nbfield']++;
}
// Bank account
if ($arrayfields['bank']['checked']) {
- print '';
+ print ' | ';
if ($obj->bid > 0)
{
$accountstatic->id = $obj->bid;
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index d273dd7cdf7..72a8ec2974d 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -614,14 +614,14 @@ while ($i < min($num, $limit))
$socstatic->logo = $obj->logo;
$socstatic->country_id = $obj->country_id;
$socstatic->country_code = '';
- $socstatic->country_label = '';*/
+ $socstatic->country = '';*/
if ($obj->country_id > 0) {
if (!isset($cacheCountryIDCode[$obj->country_id]['code'])) {
$tmparray = getCountry($obj->country_id, 'all');
$cacheCountryIDCode[$obj->country_id] = array('code'=> empty($tmparray['code']) ? '' : $tmparray['code'], 'label' => empty($tmparray['label']) ? '' : $tmparray['label']);
}
$socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code'];
- $socstatic->country_label = $cacheCountryIDCode[$obj->country_id]['label'];
+ $socstatic->country = $cacheCountryIDCode[$obj->country_id]['label'];
}
@@ -695,7 +695,7 @@ while ($i < min($num, $limit))
if (!empty($arrayfields['country.code_iso']['checked']))
{
print ' | ';
- print $socstatic->country_label;
+ print $socstatic->country;
print ' | ';
if (!$i) $totalarray['nbfield']++;
}
diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php
index 6ffce6d781b..5b6130d8eb2 100644
--- a/htdocs/core/boxes/box_funnel_of_prospection.php
+++ b/htdocs/core/boxes/box_funnel_of_prospection.php
@@ -61,9 +61,9 @@ class box_funnel_of_prospection extends ModeleBoxes
$this->db = $db;
- $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1); // Not enabled by default, still need some work
+ $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1 ? 1 : 0); // Not enabled by default, still need some work
- $this->hidden = !($user->rights->projet->lire);
+ $this->hidden = empty($user->rights->projet->lire);
}
/**
diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php
index 1e32a28f25c..9faf45932e2 100644
--- a/htdocs/core/boxes/modules_boxes.php
+++ b/htdocs/core/boxes/modules_boxes.php
@@ -56,7 +56,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
/**
* @var boolean Condition to have widget visible (in most cases, permissions)
*/
- public $hidden = 0;
+ public $hidden = false;
/**
* @var int Box definition database ID
diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php
index 6f60f6cdca6..f9f1c3b99ef 100644
--- a/htdocs/core/class/notify.class.php
+++ b/htdocs/core/class/notify.class.php
@@ -112,6 +112,7 @@ class Notify
$listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0);
+ $texte = '';
$nb = -1;
if (is_array($listofnotiftodo)) {
$nb = count($listofnotiftodo);
@@ -170,6 +171,8 @@ class Notify
if (is_object($object)) {
$valueforthreshold = $object->total_ht;
}
+
+ $sqlnotifcode = '';
if ($notifcode) {
if (is_numeric($notifcode)) {
$sqlnotifcode = " AND n.fk_action = ".$notifcode; // Old usage
diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php
index 93eaeb6d4f2..07b67e30062 100644
--- a/htdocs/core/class/utils.class.php
+++ b/htdocs/core/class/utils.class.php
@@ -168,7 +168,7 @@ class Utils
$this->output = $langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
if ($count > $countdeleted) $this->output .= '
'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
} else {
- $this->output = $langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)' : '');
+ $this->output = $langs->trans("PurgeNothingToDelete").(in_array('tempfilesold', $choicesarray) ? ' (older than 24h for temp files)' : '');
}
// Recreate temp dir that are not automatically recreated by core code for performance purpose, we need them
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index dd80c660e71..884d8eac496 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -4461,7 +4461,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
$savlimit = $limit;
$savtotalnboflines = $totalnboflines;
- $totalnboflines = abs($totalnboflines);
+ $totalnboflines = abs((int) $totalnboflines);
if ($picto == 'setup') $picto = 'title_setup.png';
if (($conf->browser->name == 'ie') && $picto == 'generic') $picto = 'title.gif';
diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php
index e68ecb8bc1d..d50fec76353 100644
--- a/htdocs/user/class/api_users.class.php
+++ b/htdocs/user/class/api_users.class.php
@@ -142,11 +142,11 @@ class Users extends DolibarrApi
* Get properties of an user object
*
* @param int $id ID of user
- * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose)
- * @return array|mixed data without useless information
+ * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose)
+ * @return array|mixed data without useless information
*
- * @throws RestException 401 Insufficient rights
- * @throws RestException 404 User or group not found
+ * @throws RestException 401 Insufficient rights
+ * @throws RestException 404 User or group not found
*/
public function get($id, $includepermissions = 0)
{
@@ -177,13 +177,13 @@ class Users extends DolibarrApi
* Get properties of an user object by login
*
* @param string $login Login of user
- * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose)
- * @return array|mixed data without useless information
+ * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose)
+ * @return array|mixed Data without useless information
*
* @url GET login/{login}
*
- * @throws RestException 401 Insufficient rights
- * @throws RestException 404 User or group not found
+ * @throws RestException 401 Insufficient rights
+ * @throws RestException 404 User or group not found
*/
public function getByLogin($login, $includepermissions = 0)
{
@@ -211,8 +211,8 @@ class Users extends DolibarrApi
* Get properties of an user object by Email
*
* @param string $email Email of user
- * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose)
- * @return array|mixed data without useless information
+ * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose)
+ * @return array|mixed Data without useless information
*
* @url GET email/{email}
*
@@ -314,11 +314,13 @@ class Users extends DolibarrApi
/**
* Update account
*
- * @param int $id Id of account to update
- * @param array $request_data Datas
- * @return array
+ * @param int $id Id of account to update
+ * @param array $request_data Datas
+ * @return array|mixed Record after update
*
- * @throws RestException
+ * @throws RestException 401 Not allowed
+ * @throws RestException 404 Not found
+ * @throws RestException 500 System error
*/
public function put($id, $request_data = null)
{
diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php
index 7864c93243f..140351e7d21 100644
--- a/htdocs/webservices/server_actioncomm.php
+++ b/htdocs/webservices/server_actioncomm.php
@@ -122,7 +122,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array();
}
-if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -315,7 +315,7 @@ function getActionComm($authentication, $id)
//Get extrafield values
$actioncomm->fetch_optionals();
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -454,7 +454,7 @@ function createActionComm($authentication, $actioncomm)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -551,7 +551,7 @@ function updateActionComm($authentication, $actioncomm)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php
index 9abc7b6088f..6fc521a43c7 100644
--- a/htdocs/webservices/server_contact.php
+++ b/htdocs/webservices/server_contact.php
@@ -127,7 +127,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array();
}
-if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -319,7 +319,7 @@ function getContact($authentication, $id, $ref_ext)
//Get extrafield values
$contact->fetch_optionals();
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -424,7 +424,7 @@ function createContact($authentication, $contact)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -671,7 +671,7 @@ function updateContact($authentication, $contact)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php
index 62e8dc99d72..30c105d7192 100644
--- a/htdocs/webservices/server_order.php
+++ b/htdocs/webservices/server_order.php
@@ -120,7 +120,7 @@ $extrafield_line_array = null;
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_line_array = array();
}
-if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -224,7 +224,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array();
}
-if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -705,7 +705,7 @@ function createOrder($authentication, $order)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -743,7 +743,7 @@ function createOrder($authentication, $order)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -948,7 +948,7 @@ function updateOrder($authentication, $order)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php
index f723dcfd054..f285d245030 100644
--- a/htdocs/webservices/server_productorservice.php
+++ b/htdocs/webservices/server_productorservice.php
@@ -142,7 +142,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array();
}
-if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -436,7 +436,7 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = ''
//Get extrafield values
$product->fetch_optionals();
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -563,7 +563,7 @@ function createProductOrService($authentication, $product)
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -719,7 +719,7 @@ function updateProductOrService($authentication, $product)
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -1090,7 +1090,7 @@ function getProductsForCategory($authentication, $id, $lang = '')
//Get extrafield values
$tmpproduct->fetch_optionals();
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
diff --git a/htdocs/webservices/server_project.php b/htdocs/webservices/server_project.php
index 9d4c93c9ce9..0817332c09f 100644
--- a/htdocs/webservices/server_project.php
+++ b/htdocs/webservices/server_project.php
@@ -169,7 +169,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array();
}
-if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -277,7 +277,7 @@ function createProject($authentication, $project)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -386,7 +386,7 @@ function getProject($authentication, $id = '', $ref = '')
$extrafields->fetch_name_optionals_label($elementtype, true);
//Get extrafield values
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
$project->fetch_optionals();
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php
index 3a1e911f510..5bde94cc0d5 100644
--- a/htdocs/webservices/server_thirdparty.php
+++ b/htdocs/webservices/server_thirdparty.php
@@ -130,7 +130,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array();
}
-if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -365,7 +365,7 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
//Get extrafield values
$thirdparty->fetch_optionals();
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -481,7 +481,7 @@ function createThirdParty($authentication, $thirdparty)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -615,7 +615,7 @@ function updateThirdParty($authentication, $thirdparty)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -723,7 +723,7 @@ function getListOfThirdParties($authentication, $filterthirdparty)
$extrafieldsOptions = array();
$obj = $db->fetch_object($resql);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php
index 6f7ed5c10aa..25cb2324412 100644
--- a/htdocs/webservices/server_user.php
+++ b/htdocs/webservices/server_user.php
@@ -193,7 +193,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array();
}
-if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
@@ -599,7 +599,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
- if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
+ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php
index 2bce51e2a05..6222f7fcaf7 100644
--- a/test/phpunit/RestAPIUserTest.php
+++ b/test/phpunit/RestAPIUserTest.php
@@ -164,22 +164,22 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase
print __METHOD__." Request GET url=".$url."\n";
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
- //print __METHOD__." Result for unexisting user: ".var_export($result, true)."\n";
+ //print __METHOD__." result for get on unexisting user: ".var_export($result, true)."\n";
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
$this->assertEquals($result['curl_error_no'], '');
$object=json_decode($result['content'], true);
- $this->assertNotNull($object, "Parsing of json result must no be null");
- $this->assertEquals(404, $object['error']['code']);
+ $this->assertNotNull($object, "Parsing of json result must not be null");
+ $this->assertEquals(404, $object['error']['code'], 'Error code is not 404');
$url = $this->api_url.'/users/1?api_key='.$this->api_key;
print __METHOD__." Request GET url=".$url."\n";
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
- //print __METHOD__." Result for existing user user: ".var_export($result, true)."\n";
+ print __METHOD__." result for get on an existing user: ".var_export($result, true)."\n";
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
$this->assertEquals($result['curl_error_no'], '');
$object=json_decode($result['content'], true);
- $this->assertNotNull($object, "Parsing of json result must no be null");
+ $this->assertNotNull($object, "Parsing of json result must not be null");
$this->assertEquals(1, $object['statut']);
}
@@ -190,7 +190,6 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase
*/
public function testRestCreateUser()
{
-
// attemp to create without mandatory fields :
$url = $this->api_url.'/users?api_key='.$this->api_key;
$addheaders=array('Content-Type: application/json');
@@ -222,7 +221,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase
$body = json_encode($bodyobj);
print __METHOD__." Request POST url=".$url."\n";
$result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
- print __METHOD__." Result code for creating user ".var_export($result, true)."\n";
+ print __METHOD__." rclsesult code for creating user ".var_export($result, true)."\n";
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
$this->assertEquals($result['curl_error_no'], '');
$resid=json_decode($result['content'], true);