Merge branch 'develop' of github.com:Dolibarr/dolibarr into dev_add_tag_on_massaction

This commit is contained in:
Florian HENRY 2020-12-24 15:00:15 +01:00
commit 1b6a4fc4ae
26 changed files with 157 additions and 82 deletions

View File

@ -292,6 +292,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/product %_datadir/dolibarr/htdocs/product
%_datadir/dolibarr/htdocs/projet %_datadir/dolibarr/htdocs/projet
%_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/public
%_datadir/dolibarr/htdocs/recruitment
%_datadir/dolibarr/htdocs/reception %_datadir/dolibarr/htdocs/reception
%_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/resource
%_datadir/dolibarr/htdocs/salaries %_datadir/dolibarr/htdocs/salaries

View File

@ -209,6 +209,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/product %_datadir/dolibarr/htdocs/product
%_datadir/dolibarr/htdocs/projet %_datadir/dolibarr/htdocs/projet
%_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/public
%_datadir/dolibarr/htdocs/recruitment
%_datadir/dolibarr/htdocs/reception %_datadir/dolibarr/htdocs/reception
%_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/resource
%_datadir/dolibarr/htdocs/salaries %_datadir/dolibarr/htdocs/salaries

View File

@ -220,6 +220,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/product %_datadir/dolibarr/htdocs/product
%_datadir/dolibarr/htdocs/projet %_datadir/dolibarr/htdocs/projet
%_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/public
%_datadir/dolibarr/htdocs/recruitment
%_datadir/dolibarr/htdocs/reception %_datadir/dolibarr/htdocs/reception
%_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/resource
%_datadir/dolibarr/htdocs/salaries %_datadir/dolibarr/htdocs/salaries

View File

@ -123,7 +123,7 @@ print '</td></tr>';
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("MailingDelay").'</td><td>'; print $langs->trans("MailingDelay").'</td><td>';
print '<input size="32" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">'; print '<input class="width75" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
print '</td></tr>'; print '</td></tr>';

View File

@ -173,7 +173,7 @@ class DolibarrApi
unset($object->name_bis); unset($object->name_bis);
unset($object->newref); unset($object->newref);
if ($object->table_element != 'ticket') { if (!isset($object->table_element) || $object->table_element != 'ticket') {
unset($object->comments); unset($object->comments);
} }

View File

@ -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) * @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 * @return array Response status and user token
* *
* @throws RestException 403 * @throws RestException 403 Access denied
* @throws RestException 500 * @throws RestException 500 System error
* *
* @url GET / * @url GET /
* @url POST / * @url POST /

View File

@ -331,11 +331,10 @@ if (empty($reshook))
} }
} }
if (!empty($conf->global->MAILING_DELAY)) if (!empty($conf->global->MAILING_DELAY)) {
{ dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY); usleep((float) $conf->global->MAILING_DELAY * 1000000);
sleep($conf->global->MAILING_DELAY); }
}
//test if CHECK READ change statut prospect contact //test if CHECK READ change statut prospect contact
} else { } else {

View File

@ -463,24 +463,51 @@ if ($object->fetch($id) >= 0)
$sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text"; $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE mc.fk_mailing=".$object->id; $sql .= " WHERE mc.fk_mailing=".$object->id;
if ($search_lastname) $sql .= natural_search("mc.lastname", $search_lastname); $asearchcriteriahasbeenset = 0;
if ($search_firstname) $sql .= natural_search("mc.firstname", $search_firstname); if ($search_lastname) {
if ($search_email) $sql .= natural_search("mc.email", $search_email); $sql .= natural_search("mc.lastname", $search_lastname);
if ($search_other) $sql .= natural_search("mc.other", $search_other); $asearchcriteriahasbeenset++;
if ($search_dest_status != '' && $search_dest_status >= -1) $sql .= " AND mc.statut=".$db->escape($search_dest_status)." "; }
if ($search_firstname) {
$sql .= natural_search("mc.firstname", $search_firstname);
$asearchcriteriahasbeenset++;
}
if ($search_email) {
$sql .= natural_search("mc.email", $search_email);
$asearchcriteriahasbeenset++;
}
if ($search_other) {
$sql .= natural_search("mc.other", $search_other);
$asearchcriteriahasbeenset++;
}
if ($search_dest_status != '' && $search_dest_status >= -1) {
$sql .= " AND mc.statut=".$db->escape($search_dest_status)." ";
$asearchcriteriahasbeenset++;
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{ $page = 0;
$page = 0; $offset = 0;
$offset = 0; }
}
// Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
if (empty($asearchcriteriahasbeenset)) {
if ($nbtotalofrecords != $object->email) {
dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
//print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
$resultrefresh = $object->refreshNbOfTargets();
if ($resultrefresh < 0) {
dol_print_error($db, $object->error, $object->errors);
}
}
}
} }
//$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets

View File

@ -510,6 +510,8 @@ class Mailing extends CommonObject
dol_syslog("Mailing::delete_targets", LOG_DEBUG); dol_syslog("Mailing::delete_targets", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$this->refreshNbOfTargets();
return 1; return 1;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
@ -577,6 +579,38 @@ class Mailing extends CommonObject
return 0; return 0;
} }
/**
* Refresh denormalized value ->nbemail into emailing record
* Note: There is also the method update_nb into modules_mailings that is used for this.
*
* @return int <0 if KO, >0 if OK
*/
public function refreshNbOfTargets()
{
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " WHERE fk_mailing = ".$this->id;
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj) {
$nbforupdate = $obj->nb;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
$sql .= ' WHERE rowid = '.$this->id;
$resqlupdate = $this->db->query($sql);
if (! $resqlupdate) {
$this->error = $this->db->lasterror();
return -1;
}
}
} else {
$this->error = $this->db->lasterror();
return -1;
}
return 1;
}
/** /**
* Return a link to the object card (with optionally the picto) * Return a link to the object card (with optionally the picto)

View File

@ -466,14 +466,18 @@ if ($result)
// Project // Project
if ($arrayfields['project']['checked']) { if ($arrayfields['project']['checked']) {
$proj->fetch($obj->fk_project); print '<td class="nowraponall">';
print '<td class="nowraponall">'.$proj->getNomUrl(1).'</td>'; if ($obj->fk_project > 0) {
$proj->fetch($obj->fk_project);
print $proj->getNomUrl(1);
}
print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Bank account // Bank account
if ($arrayfields['bank']['checked']) { if ($arrayfields['bank']['checked']) {
print '<td>'; print '<td class="nowraponall">';
if ($obj->bid > 0) if ($obj->bid > 0)
{ {
$accountstatic->id = $obj->bid; $accountstatic->id = $obj->bid;

View File

@ -614,14 +614,14 @@ while ($i < min($num, $limit))
$socstatic->logo = $obj->logo; $socstatic->logo = $obj->logo;
$socstatic->country_id = $obj->country_id; $socstatic->country_id = $obj->country_id;
$socstatic->country_code = ''; $socstatic->country_code = '';
$socstatic->country_label = '';*/ $socstatic->country = '';*/
if ($obj->country_id > 0) { if ($obj->country_id > 0) {
if (!isset($cacheCountryIDCode[$obj->country_id]['code'])) { if (!isset($cacheCountryIDCode[$obj->country_id]['code'])) {
$tmparray = getCountry($obj->country_id, 'all'); $tmparray = getCountry($obj->country_id, 'all');
$cacheCountryIDCode[$obj->country_id] = array('code'=> empty($tmparray['code']) ? '' : $tmparray['code'], 'label' => empty($tmparray['label']) ? '' : $tmparray['label']); $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_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'])) if (!empty($arrayfields['country.code_iso']['checked']))
{ {
print '<td class="center">'; print '<td class="center">';
print $socstatic->country_label; print $socstatic->country;
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }

View File

@ -61,9 +61,9 @@ class box_funnel_of_prospection extends ModeleBoxes
$this->db = $db; $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);
} }
/** /**

View File

@ -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) * @var boolean Condition to have widget visible (in most cases, permissions)
*/ */
public $hidden = 0; public $hidden = false;
/** /**
* @var int Box definition database ID * @var int Box definition database ID

View File

@ -112,6 +112,7 @@ class Notify
$listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0);
$texte = '';
$nb = -1; $nb = -1;
if (is_array($listofnotiftodo)) { if (is_array($listofnotiftodo)) {
$nb = count($listofnotiftodo); $nb = count($listofnotiftodo);
@ -170,6 +171,8 @@ class Notify
if (is_object($object)) { if (is_object($object)) {
$valueforthreshold = $object->total_ht; $valueforthreshold = $object->total_ht;
} }
$sqlnotifcode = '';
if ($notifcode) { if ($notifcode) {
if (is_numeric($notifcode)) { if (is_numeric($notifcode)) {
$sqlnotifcode = " AND n.fk_action = ".$notifcode; // Old usage $sqlnotifcode = " AND n.fk_action = ".$notifcode; // Old usage

View File

@ -168,7 +168,7 @@ class Utils
$this->output = $langs->trans("PurgeNDirectoriesDeleted", $countdeleted); $this->output = $langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
if ($count > $countdeleted) $this->output .= '<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted)); if ($count > $countdeleted) $this->output .= '<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
} else { } 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 // Recreate temp dir that are not automatically recreated by core code for performance purpose, we need them

View File

@ -4461,7 +4461,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
$savlimit = $limit; $savlimit = $limit;
$savtotalnboflines = $totalnboflines; $savtotalnboflines = $totalnboflines;
$totalnboflines = abs($totalnboflines); $totalnboflines = abs((int) $totalnboflines);
if ($picto == 'setup') $picto = 'title_setup.png'; if ($picto == 'setup') $picto = 'title_setup.png';
if (($conf->browser->name == 'ie') && $picto == 'generic') $picto = 'title.gif'; if (($conf->browser->name == 'ie') && $picto == 'generic') $picto = 'title.gif';

View File

@ -142,11 +142,11 @@ class Users extends DolibarrApi
* Get properties of an user object * Get properties of an user object
* *
* @param int $id ID of user * @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) * @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 * @return array|mixed data without useless information
* *
* @throws RestException 401 Insufficient rights * @throws RestException 401 Insufficient rights
* @throws RestException 404 User or group not found * @throws RestException 404 User or group not found
*/ */
public function get($id, $includepermissions = 0) public function get($id, $includepermissions = 0)
{ {
@ -177,13 +177,13 @@ class Users extends DolibarrApi
* Get properties of an user object by login * Get properties of an user object by login
* *
* @param string $login Login of user * @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) * @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 * @return array|mixed Data without useless information
* *
* @url GET login/{login} * @url GET login/{login}
* *
* @throws RestException 401 Insufficient rights * @throws RestException 401 Insufficient rights
* @throws RestException 404 User or group not found * @throws RestException 404 User or group not found
*/ */
public function getByLogin($login, $includepermissions = 0) public function getByLogin($login, $includepermissions = 0)
{ {
@ -211,8 +211,8 @@ class Users extends DolibarrApi
* Get properties of an user object by Email * Get properties of an user object by Email
* *
* @param string $email Email of user * @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) * @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 * @return array|mixed Data without useless information
* *
* @url GET email/{email} * @url GET email/{email}
* *
@ -314,11 +314,13 @@ class Users extends DolibarrApi
/** /**
* Update account * Update account
* *
* @param int $id Id of account to update * @param int $id Id of account to update
* @param array $request_data Datas * @param array $request_data Datas
* @return array * @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) public function put($id, $request_data = null)
{ {

View File

@ -122,7 +122,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) { if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -315,7 +315,7 @@ function getActionComm($authentication, $id)
//Get extrafield values //Get extrafield values
$actioncomm->fetch_optionals(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -454,7 +454,7 @@ function createActionComm($authentication, $actioncomm)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -551,7 +551,7 @@ function updateActionComm($authentication, $actioncomm)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {

View File

@ -127,7 +127,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) { if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -319,7 +319,7 @@ function getContact($authentication, $id, $ref_ext)
//Get extrafield values //Get extrafield values
$contact->fetch_optionals(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -424,7 +424,7 @@ function createContact($authentication, $contact)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -671,7 +671,7 @@ function updateContact($authentication, $contact)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {

View File

@ -120,7 +120,7 @@ $extrafield_line_array = null;
if (is_array($extrafields) && count($extrafields) > 0) { if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_line_array = array(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -224,7 +224,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) { if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -705,7 +705,7 @@ function createOrder($authentication, $order)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -743,7 +743,7 @@ function createOrder($authentication, $order)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -948,7 +948,7 @@ function updateOrder($authentication, $order)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {

View File

@ -142,7 +142,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) { if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -436,7 +436,7 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = ''
//Get extrafield values //Get extrafield values
$product->fetch_optionals(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -563,7 +563,7 @@ function createProductOrService($authentication, $product)
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -719,7 +719,7 @@ function updateProductOrService($authentication, $product)
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -1090,7 +1090,7 @@ function getProductsForCategory($authentication, $id, $lang = '')
//Get extrafield values //Get extrafield values
$tmpproduct->fetch_optionals(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {

View File

@ -169,7 +169,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) { if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -277,7 +277,7 @@ function createProject($authentication, $project)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -386,7 +386,7 @@ function getProject($authentication, $id = '', $ref = '')
$extrafields->fetch_name_optionals_label($elementtype, true); $extrafields->fetch_name_optionals_label($elementtype, true);
//Get extrafield values //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(); $project->fetch_optionals();
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)

View File

@ -130,7 +130,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) { if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -365,7 +365,7 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
//Get extrafield values //Get extrafield values
$thirdparty->fetch_optionals(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -481,7 +481,7 @@ function createThirdParty($authentication, $thirdparty)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -615,7 +615,7 @@ function updateThirdParty($authentication, $thirdparty)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -723,7 +723,7 @@ function getListOfThirdParties($authentication, $filterthirdparty)
$extrafieldsOptions = array(); $extrafieldsOptions = array();
$obj = $db->fetch_object($resql); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {

View File

@ -193,7 +193,7 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) { if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array(); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {
@ -599,7 +599,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true); $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) foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{ {

View File

@ -74,6 +74,10 @@ if (empty($conf->global->MAILING_LIMIT_SENDBYCLI))
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
if (!empty($conf->global->MAILING_DELAY)) {
print 'A delay of '.((float) $conf->global->MAILING_DELAY * 1000000).' millisecond has been set between each email'."\n";
}
if ($conf->global->MAILING_LIMIT_SENDBYCLI == '-1') {} if ($conf->global->MAILING_LIMIT_SENDBYCLI == '-1') {}
$user = new User($db); $user = new User($db);
@ -332,7 +336,7 @@ if ($resql) {
} }
if (!empty($conf->global->MAILING_DELAY)) { if (!empty($conf->global->MAILING_DELAY)) {
sleep($conf->global->MAILING_DELAY); usleep((float) $conf->global->MAILING_DELAY * 1000000);
} }
} }
} else { } else {

View File

@ -164,22 +164,22 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase
print __METHOD__." Request GET url=".$url."\n"; print __METHOD__." Request GET url=".$url."\n";
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); $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"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
$this->assertEquals($result['curl_error_no'], ''); $this->assertEquals($result['curl_error_no'], '');
$object=json_decode($result['content'], true); $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(404, $object['error']['code']); $this->assertEquals(404, $object['error']['code'], 'Error code is not 404');
$url = $this->api_url.'/users/1?api_key='.$this->api_key; $url = $this->api_url.'/users/1?api_key='.$this->api_key;
print __METHOD__." Request GET url=".$url."\n"; print __METHOD__." Request GET url=".$url."\n";
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); $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"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
$this->assertEquals($result['curl_error_no'], ''); $this->assertEquals($result['curl_error_no'], '');
$object=json_decode($result['content'], true); $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']); $this->assertEquals(1, $object['statut']);
} }
@ -190,7 +190,6 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase
*/ */
public function testRestCreateUser() public function testRestCreateUser()
{ {
// attemp to create without mandatory fields : // attemp to create without mandatory fields :
$url = $this->api_url.'/users?api_key='.$this->api_key; $url = $this->api_url.'/users?api_key='.$this->api_key;
$addheaders=array('Content-Type: application/json'); $addheaders=array('Content-Type: application/json');
@ -222,7 +221,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase
$body = json_encode($bodyobj); $body = json_encode($bodyobj);
print __METHOD__." Request POST url=".$url."\n"; print __METHOD__." Request POST url=".$url."\n";
$result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); $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"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
$this->assertEquals($result['curl_error_no'], ''); $this->assertEquals($result['curl_error_no'], '');
$resid=json_decode($result['content'], true); $resid=json_decode($result['content'], true);