Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into 13.0

This commit is contained in:
Laurent Destailleur 2020-12-21 18:21:36 +01:00
commit e2c192813e
11 changed files with 565 additions and 475 deletions

View File

@ -15,6 +15,9 @@ function faaa()
return 'faaa'; return 'faaa';
} }
/**
* Class Aaa
*/
class Aaa class Aaa
{ {
const AAA='aaa'; const AAA='aaa';

View File

@ -12,6 +12,9 @@ function fbbb()
return 'fbbb'; return 'fbbb';
} }
/**
* Class Bbb
*/
class Bbb class Bbb
{ {
const BBB='bbb'; const BBB='bbb';

View File

@ -75,10 +75,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_input_method as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_input_method as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -112,70 +110,68 @@ class Setup extends DolibarrApi
return $list; return $list;
} }
/** /**
* Get the list of ordering origins. * Get the list of ordering origins.
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Number of items per page * @param int $limit Number of items per page
* @param int $page Page number {@min 0} * @param int $page Page number {@min 0}
* @param int $active Payment type is active or not {@min 0} {@max 1} * @param int $active Payment type is active or not {@min 0} {@max 1}
* @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')"
* *
* @url GET dictionary/ordering_origins * @url GET dictionary/ordering_origins
* *
* @return array [List of ordering reasons] * @return array [List of ordering reasons]
* *
* @throws RestException 400 * @throws RestException 400
*/ */
public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
if (!DolibarrApiAccess::$user->rights->commande->lire) { if (!DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT rowid, code, label, module"; $sql = "SELECT rowid, code, label, module";
$sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters)) throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
{ }
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
} $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; }
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) { if ($page < 0) {
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset); $sql .= $this->db->plimit($limit, $offset);
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) { for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result); $list[] = $this->db->fetch_object($result);
} }
} else { } else {
throw new RestException(400, $this->db->lasterror()); throw new RestException(400, $this->db->lasterror());
} }
return $list; return $list;
} }
/** /**
* Get the list of payments types. * Get the list of payments types.
@ -206,10 +202,8 @@ class Setup extends DolibarrApi
$sql .= " WHERE t.entity IN (".getEntity('c_paiement').")"; $sql .= " WHERE t.entity IN (".getEntity('c_paiement').")";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -272,10 +266,8 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_departements as t"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_departements as t";
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -374,10 +366,8 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -551,10 +541,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -659,10 +647,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -720,13 +706,15 @@ class Setup extends DolibarrApi
$sql = "SELECT id, code, type, libelle as label, module"; $sql = "SELECT id, code, type, libelle as label, module";
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; if ($type) {
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
}
if ($module) {
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -784,12 +772,12 @@ class Setup extends DolibarrApi
$sql = "SELECT id, code, label, accountancy_code, active, module, position"; $sql = "SELECT id, code, label, accountancy_code, active, module, position";
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; if ($module) {
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -848,13 +836,15 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid, code, element as type, libelle as label, source, module, position"; $sql = "SELECT rowid, code, element as type, libelle as label, source, module, position";
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
if ($type) $sql .= " AND type LIKE '%".$this->db->escape($type)."%'"; if ($type) {
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; $sql .= " AND type LIKE '%".$this->db->escape($type)."%'";
}
if ($module) {
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -911,12 +901,12 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid, code, label, module"; $sql = "SELECT rowid, code, label, module";
$sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; if ($module) {
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -970,7 +960,9 @@ class Setup extends DolibarrApi
{ {
$list = array(); $list = array();
$sql = "SELECT t.code_iso, t.label, t.unicode"; $sql = "SELECT t.code_iso, t.label, t.unicode";
if (!empty($multicurrency)) $sql .= " , cr.date_sync, cr.rate "; if (!empty($multicurrency)) {
$sql .= " , cr.date_sync, cr.rate ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."c_currencies as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_currencies as t";
if (!empty($multicurrency)) { if (!empty($multicurrency)) {
$sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso"; $sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso";
@ -985,10 +977,8 @@ class Setup extends DolibarrApi
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1043,18 +1033,22 @@ class Setup extends DolibarrApi
throw new RestException(401, 'Only an admin user can get list of extrafields'); throw new RestException(401, 'Only an admin user can get list of extrafields');
} }
if ($type == 'thirdparty') $type = 'societe'; if ($type == 'thirdparty') {
if ($type == 'contact') $type = 'socpeople'; $type = 'societe';
}
if ($type == 'contact') {
$type = 'socpeople';
}
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed"; $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed";
$sql .= " FROM ".MAIN_DB_PREFIX."extrafields as t"; $sql .= " FROM ".MAIN_DB_PREFIX."extrafields as t";
$sql .= " WHERE t.entity IN (".getEntity('extrafields').")"; $sql .= " WHERE t.entity IN (".getEntity('extrafields').")";
if (!empty($type)) $sql .= " AND t.elementtype = '".$this->db->escape($type)."'"; if (!empty($type)) {
$sql .= " AND t.elementtype = '".$this->db->escape($type)."'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1064,12 +1058,9 @@ class Setup extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ if ($this->db->num_rows($resql)) {
if ($this->db->num_rows($resql)) while ($tab = $this->db->fetch_object($resql)) {
{
while ($tab = $this->db->fetch_object($resql))
{
// New usage // New usage
$list[$tab->elementtype][$tab->name]['type'] = $tab->type; $list[$tab->elementtype][$tab->name]['type'] = $tab->type;
$list[$tab->elementtype][$tab->name]['label'] = $tab->label; $list[$tab->elementtype][$tab->name]['label'] = $tab->label;
@ -1090,8 +1081,7 @@ class Setup extends DolibarrApi
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
} }
if (!count($list)) if (!count($list)) {
{
throw new RestException(404, 'No extrafield found'); throw new RestException(404, 'No extrafield found');
} }
@ -1123,13 +1113,15 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
$sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
if ($zipcode) $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'"; if ($zipcode) {
if ($town) $sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'"; $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'";
}
if ($town) {
$sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'";
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1192,10 +1184,8 @@ class Setup extends DolibarrApi
$sql .= " WHERE t.entity IN (".getEntity('c_payment_term').")"; $sql .= " WHERE t.entity IN (".getEntity('c_payment_term').")";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1252,10 +1242,8 @@ class Setup extends DolibarrApi
$sql .= " WHERE t.entity IN (".getEntity('c_shipment_mode').")"; $sql .= " WHERE t.entity IN (".getEntity('c_shipment_mode').")";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1313,10 +1301,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1380,10 +1366,8 @@ class Setup extends DolibarrApi
$sql .= " WHERE t.entity IN (".getEntity('c_socialnetworks').")"; $sql .= " WHERE t.entity IN (".getEntity('c_socialnetworks').")";
$sql .= " AND t.active = ".$active; $sql .= " AND t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1440,10 +1424,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1500,10 +1482,8 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t";
$sql .= " WHERE t.active = ".$active; $sql .= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1562,10 +1542,8 @@ class Setup extends DolibarrApi
// if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; // if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
// if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; // if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -1604,13 +1582,13 @@ class Setup extends DolibarrApi
* *
* @url GET /company * @url GET /company
* *
* @return array|mixed Data without useless information * @return array|mixed Mysoc object
* *
* @throws RestException 403 Forbidden * @throws RestException 403 Forbidden
*/ */
public function getCompany() public function getCompany()
{ {
global $mysoc; global $conf, $mysoc;
if (!DolibarrApiAccess::$user->admin if (!DolibarrApiAccess::$user->admin
&& (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) { && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) {
@ -1710,8 +1688,7 @@ class Setup extends DolibarrApi
global $langs, $conf; global $langs, $conf;
if (!DolibarrApiAccess::$user->admin if (!DolibarrApiAccess::$user->admin
&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) && (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) {
{
throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK'); throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK');
} }
@ -1731,10 +1708,16 @@ class Setup extends DolibarrApi
$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
// Remote file to compare to // Remote file to compare to
$xmlremote = ($target == 'default' ? '' : $target); $xmlremote = ($target == 'default' ? '' : $target);
if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL; if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) {
$xmlremote = $conf->global->MAIN_FILECHECK_URL;
}
$param = 'MAIN_FILECHECK_URL_'.DOL_VERSION; $param = 'MAIN_FILECHECK_URL_'.DOL_VERSION;
if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param; if (empty($xmlremote) && !empty($conf->global->$param)) {
if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; $xmlremote = $conf->global->$param;
}
if (empty($xmlremote)) {
$xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
}
if ($target == 'local') { if ($target == 'local') {
if (dol_is_file($xmlfile)) { if (dol_is_file($xmlfile)) {
@ -1756,8 +1739,7 @@ class Setup extends DolibarrApi
} }
} }
if ($xml) if ($xml) {
{
$checksumconcat = array(); $checksumconcat = array();
$file_list = array(); $file_list = array();
$out = ''; $out = '';
@ -1776,14 +1758,15 @@ class Setup extends DolibarrApi
$out .= '</tr>'."\n"; $out .= '</tr>'."\n";
$i = 0; $i = 0;
foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement foreach ($xml->dolibarr_constants[0]->constant as $constant) { // $constant is a simpleXMLElement
{
$constname = $constant['name']; $constname = $constant['name'];
$constvalue = (string) $constant; $constvalue = (string) $constant;
$constvalue = (empty($constvalue) ? '0' : $constvalue); $constvalue = (empty($constvalue) ? '0' : $constvalue);
// Value found // Value found
$value = ''; $value = '';
if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; if ($constname && $conf->global->$constname != '') {
$value = $conf->global->$constname;
}
$valueforchecksum = (empty($value) ? '0' : $value); $valueforchecksum = (empty($value) ? '0' : $value);
$checksumconcat[] = $valueforchecksum; $checksumconcat[] = $valueforchecksum;
@ -1797,8 +1780,7 @@ class Setup extends DolibarrApi
$out .= "</tr>\n"; $out .= "</tr>\n";
} }
if ($i == 0) if ($i == 0) {
{
$out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; $out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
} }
$out .= '</table>'; $out .= '</table>';
@ -1808,9 +1790,7 @@ class Setup extends DolibarrApi
} }
// Scan htdocs // Scan htdocs
if (is_object($xml->dolibarr_htdocs_dir[0])) if (is_object($xml->dolibarr_htdocs_dir[0])) {
{
//var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit;
$includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']);
// Defined qualified files (must be same than into generate_filelist_xml.php) // Defined qualified files (must be same than into generate_filelist_xml.php)
@ -1821,11 +1801,9 @@ class Setup extends DolibarrApi
// Fill file_list with files in signature, new files, modified files // Fill file_list with files in signature, new files, modified files
$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list
// Complete with list of new files // Complete with list of new files
foreach ($scanfiles as $keyfile => $valfile) foreach ($scanfiles as $keyfile => $valfile) {
{
$tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']);
if (!in_array($tmprelativefilename, $file_list['insignature'])) if (!in_array($tmprelativefilename, $file_list['insignature'])) {
{
$md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file
$file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile);
} }
@ -1842,11 +1820,9 @@ class Setup extends DolibarrApi
$out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>'; $out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>';
$out .= '</tr>'."\n"; $out .= '</tr>'."\n";
$tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); $tmpfilelist = dol_sort_array($file_list['missing'], 'filename');
if (is_array($tmpfilelist) && count($tmpfilelist)) if (is_array($tmpfilelist) && count($tmpfilelist)) {
{
$i = 0; $i = 0;
foreach ($tmpfilelist as $file) foreach ($tmpfilelist as $file) {
{
$i++; $i++;
$out .= '<tr class="oddeven">'; $out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n"; $out .= '<td>'.$i.'</td>'."\n";
@ -1877,11 +1853,9 @@ class Setup extends DolibarrApi
$out .= '<td class="right">'.$langs->trans("DateModification").'</td>'; $out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
$out .= '</tr>'."\n"; $out .= '</tr>'."\n";
$tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename');
if (is_array($tmpfilelist2) && count($tmpfilelist2)) if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
{
$i = 0; $i = 0;
foreach ($tmpfilelist2 as $file) foreach ($tmpfilelist2 as $file) {
{
$i++; $i++;
$out .= '<tr class="oddeven">'; $out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n"; $out .= '<td>'.$i.'</td>'."\n";
@ -1925,11 +1899,9 @@ class Setup extends DolibarrApi
$out .= '<td class="right">'.$langs->trans("DateModification").'</td>'; $out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
$out .= '</tr>'."\n"; $out .= '</tr>'."\n";
$tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename');
if (is_array($tmpfilelist3) && count($tmpfilelist3)) if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
{
$i = 0; $i = 0;
foreach ($tmpfilelist3 as $file) foreach ($tmpfilelist3 as $file) {
{
$i++; $i++;
$out .= '<tr class="oddeven">'; $out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n"; $out .= '<td>'.$i.'</td>'."\n";
@ -1958,8 +1930,7 @@ class Setup extends DolibarrApi
// Show warning // Show warning
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) {
{
//setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); //setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
} else { } else {
//setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); //setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings');
@ -1970,17 +1941,13 @@ class Setup extends DolibarrApi
// Scan scripts // Scan scripts
asort($checksumconcat); // Sort list of checksum asort($checksumconcat); // Sort list of checksum
//var_dump($checksumconcat);
$checksumget = md5(join(',', $checksumconcat)); $checksumget = md5(join(',', $checksumconcat));
$checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum);
$outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown"));
if ($checksumget == $checksumtoget) { if ($checksumget == $checksumtoget) {
if (count($file_list['added'])) if (count($file_list['added'])) {
{
$resultcode = 'warning'; $resultcode = 'warning';
$resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; $resultcomment = 'FileIntegrityIsOkButFilesWereAdded';
//$outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>'; //$outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>';
@ -2019,8 +1986,7 @@ class Setup extends DolibarrApi
global $conf; global $conf;
if (!DolibarrApiAccess::$user->admin if (!DolibarrApiAccess::$user->admin
&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES)) && (empty($conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES)) {
{
throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_GET_MODULES'); throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_GET_MODULES');
} }

View File

@ -891,7 +891,6 @@ class DolGraph
$color1 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]); $color1 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
$color2 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]); $color2 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
$this->stringtoshow .= ', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 . '", "#' . $color2 . '"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' . "\n"; $this->stringtoshow .= ', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 . '", "#' . $color2 . '"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' . "\n";
//$this->stringtoshow.=', shadowSize: 20'."\n"; TODO Uncommet this
$this->stringtoshow .= '});' . "\n"; $this->stringtoshow .= '});' . "\n";
$this->stringtoshow .= '}' . "\n"; $this->stringtoshow .= '}' . "\n";
} }

View File

@ -113,25 +113,38 @@ class Notify
$listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0);
$nb = -1; $nb = -1;
if (is_array($listofnotiftodo)) $nb = count($listofnotiftodo); if (is_array($listofnotiftodo)) {
if ($nb < 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); $nb = count($listofnotiftodo);
if ($nb == 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent"); }
if ($nb == 1) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent"); if ($nb < 0) {
if ($nb >= 2) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb); $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend");
} elseif ($nb == 0) {
$texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent");
} elseif ($nb == 1) {
$texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent");
} elseif ($nb >= 2) {
$texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb);
}
if (is_array($listofnotiftodo)) if (is_array($listofnotiftodo)) {
{
$i = 0; $i = 0;
foreach ($listofnotiftodo as $key => $val) foreach ($listofnotiftodo as $key => $val) {
{ if ($i) {
if ($i) $texte .= ', '; $texte .= ', ';
else $texte .= ' ('; } else {
if ($val['isemailvalid']) $texte .= $val['email']; $texte .= ' (';
else $texte .= $val['emaildesc']; }
if ($val['isemailvalid']) {
$texte .= $val['email'];
} else {
$texte .= $val['emaildesc'];
}
$i++; $i++;
} }
if ($i) $texte .= ')'; if ($i) {
} $texte .= ')';
}
}
return $texte; return $texte;
} }
@ -154,12 +167,19 @@ class Notify
$resarray = array(); $resarray = array();
$valueforthreshold = 0; $valueforthreshold = 0;
if (is_object($object)) $valueforthreshold = $object->total_ht; if (is_object($object)) {
$valueforthreshold = $object->total_ht;
}
if ($notifcode) {
if (is_numeric($notifcode)) {
$sqlnotifcode = " AND n.fk_action = ".$notifcode; // Old usage
} else {
$sqlnotifcode = " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
}
}
if (!$error) if (!$error) {
{ if ($socid >= 0 && in_array('thirdparty', $scope)) {
if ($socid >= 0 && in_array('thirdparty', $scope))
{
$sql = "SELECT a.code, c.email, c.rowid"; $sql = "SELECT a.code, c.email, c.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; $sql .= " ".MAIN_DB_PREFIX."socpeople as c,";
@ -168,29 +188,26 @@ class Notify
$sql .= " WHERE n.fk_contact = c.rowid"; $sql .= " WHERE n.fk_contact = c.rowid";
$sql .= " AND a.rowid = n.fk_action"; $sql .= " AND a.rowid = n.fk_action";
$sql .= " AND n.fk_soc = s.rowid"; $sql .= " AND n.fk_soc = s.rowid";
if ($notifcode) $sql .= $sqlnotifcode;
{
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage
else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
}
$sql .= " AND s.entity IN (".getEntity('societe').")"; $sql .= " AND s.entity IN (".getEntity('societe').")";
if ($socid > 0) $sql .= " AND s.rowid = ".$socid; if ($socid > 0) {
$sql .= " AND s.rowid = ".$socid;
}
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) if ($obj) {
{
$newval2 = trim($obj->email); $newval2 = trim($obj->email);
$isvalid = isValidEmail($newval2); $isvalid = isValidEmail($newval2);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid); if (empty($resarray[$newval2])) {
$resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
}
} }
$i++; $i++;
} }
@ -201,39 +218,34 @@ class Notify
} }
} }
if (!$error) if (!$error) {
{ if ($userid >= 0 && in_array('user', $scope)) {
if ($userid >= 0 && in_array('user', $scope))
{
$sql = "SELECT a.code, c.email, c.rowid"; $sql = "SELECT a.code, c.email, c.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql .= " ".MAIN_DB_PREFIX."user as c,"; $sql .= " ".MAIN_DB_PREFIX."user as c,";
$sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a"; $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql .= " WHERE n.fk_user = c.rowid"; $sql .= " WHERE n.fk_user = c.rowid";
$sql .= " AND a.rowid = n.fk_action"; $sql .= " AND a.rowid = n.fk_action";
if ($notifcode) $sql .= $sqlnotifcode;
{
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage
else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
}
$sql .= " AND c.entity IN (".getEntity('user').")"; $sql .= " AND c.entity IN (".getEntity('user').")";
if ($userid > 0) $sql .= " AND c.rowid = ".$userid; if ($userid > 0) {
$sql .= " AND c.rowid = ".$userid;
}
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) if ($obj) {
{
$newval2 = trim($obj->email); $newval2 = trim($obj->email);
$isvalid = isValidEmail($newval2); $isvalid = isValidEmail($newval2);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid); if (empty($resarray[$newval2])) {
$resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
}
} }
$i++; $i++;
} }
@ -244,48 +256,55 @@ class Notify
} }
} }
if (!$error) if (!$error) {
{ if (in_array('global', $scope)) {
if (in_array('global', $scope))
{
// List of notifications enabled for fixed email // List of notifications enabled for fixed email
foreach ($conf->global as $key => $val) foreach ($conf->global as $key => $val) {
{ if ($notifcode) {
if ($notifcode) if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
{ continue;
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; }
} else { } else {
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
continue;
}
} }
$threshold = (float) $reg[1]; $threshold = (float) $reg[1];
if ($valueforthreshold < $threshold) continue; if ($valueforthreshold < $threshold) {
continue;
}
$tmpemail = explode(',', $val); $tmpemail = explode(',', $val);
foreach ($tmpemail as $key2 => $val2) foreach ($tmpemail as $key2 => $val2) {
{
$newval2 = trim($val2); $newval2 = trim($val2);
if ($newval2 == '__SUPERVISOREMAIL__') if ($newval2 == '__SUPERVISOREMAIL__') {
{ if ($user->fk_user > 0) {
if ($user->fk_user > 0)
{
$tmpuser = new User($this->db); $tmpuser = new User($this->db);
$tmpuser->fetch($user->fk_user); $tmpuser->fetch($user->fk_user);
if ($tmpuser->email) $newval2 = trim($tmpuser->email); if ($tmpuser->email) {
else $newval2 = ''; $newval2 = trim($tmpuser->email);
} else $newval2 = ''; } else {
$newval2 = '';
}
} else {
$newval2 = '';
}
} }
if ($newval2) if ($newval2) {
{
$isvalid = isValidEmail($newval2, 0); $isvalid = isValidEmail($newval2, 0);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid); if (empty($resarray[$newval2])) {
$resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
}
} }
} }
} }
} }
} }
if ($error) return -1; if ($error) {
return -1;
}
//var_dump($resarray); //var_dump($resarray);
return $resarray; return $resarray;
@ -309,11 +328,12 @@ class Notify
global $dolibarr_main_url_root; global $dolibarr_main_url_root;
global $action; global $action;
if (!in_array($notifcode, $this->arrayofnotifsupported)) return 0; if (!in_array($notifcode, $this->arrayofnotifsupported)) {
return 0;
}
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (!is_object($hookmanager)) if (!is_object($hookmanager)) {
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db); $hookmanager = new HookManager($this->db);
} }
@ -330,7 +350,9 @@ class Notify
// Define some vars // Define some vars
$application = 'Dolibarr'; $application = 'Dolibarr';
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$application = $conf->global->MAIN_APPLICATION_TITLE;
}
$replyto = $conf->notification->email_from; $replyto = $conf->notification->email_from;
$object_type = ''; $object_type = '';
$link = ''; $link = '';
@ -343,8 +365,7 @@ class Notify
$sql = ''; $sql = '';
// Check notification per third party // Check notification per third party
if (!empty($object->socid) && $object->socid > 0) if (!empty($object->socid) && $object->socid > 0) {
{
$sql .= "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,"; $sql .= "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
$sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type"; $sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c,"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c,";
@ -354,8 +375,11 @@ class Notify
$sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action"; $sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
$sql .= " AND n.fk_soc = s.rowid"; $sql .= " AND n.fk_soc = s.rowid";
$sql .= " AND c.statut = 1"; $sql .= " AND c.statut = 1";
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage if (is_numeric($notifcode)) {
else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage $sql .= " AND n.fk_action = ".$notifcode; // Old usage
} else {
$sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
}
$sql .= " AND s.rowid = ".$object->socid; $sql .= " AND s.rowid = ".$object->socid;
$sql .= "\nUNION\n"; $sql .= "\nUNION\n";
@ -369,41 +393,42 @@ class Notify
$sql .= " ".MAIN_DB_PREFIX."notify_def as n"; $sql .= " ".MAIN_DB_PREFIX."notify_def as n";
$sql .= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action"; $sql .= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action";
$sql .= " AND c.statut = 1"; $sql .= " AND c.statut = 1";
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage if (is_numeric($notifcode)) {
else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage $sql .= " AND n.fk_action = ".$notifcode; // Old usage
} else {
$sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
}
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$projtitle = ''; $projtitle = '';
if (!empty($object->fk_project)) if (!empty($object->fk_project)) {
{
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$proj = new Project($this->db); $proj = new Project($this->db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$projtitle = '('.$proj->title.')'; $projtitle = '('.$proj->title.')';
} }
if ($num > 0) if ($num > 0) {
{
$i = 0; $i = 0;
while ($i < $num && !$error) // For each notification couple defined (third party/actioncode) while ($i < $num && !$error) { // For each notification couple defined (third party/actioncode)
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$sendto = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; $sendto = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">";
$notifcodedefid = $obj->adid; $notifcodedefid = $obj->adid;
$trackid = ''; $trackid = '';
if ($obj->type_target == 'tocontactid') $trackid = 'con'.$obj->id; if ($obj->type_target == 'tocontactid') {
if ($obj->type_target == 'touserid') $trackid = 'use'.$obj->id; $trackid = 'con'.$obj->id;
}
if ($obj->type_target == 'touserid') {
$trackid = 'use'.$obj->id;
}
if (dol_strlen($obj->email)) if (dol_strlen($obj->email)) {
{
// Set output language // Set output language
$outputlangs = $langs; $outputlangs = $langs;
if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
{
$outputlangs = new Translate('', $conf); $outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($obj->default_lang); $outputlangs->setDefaultLang($obj->default_lang);
$outputlangs->loadLangs(array("main", "other")); $outputlangs->loadLangs(array("main", "other"));
@ -511,8 +536,7 @@ class Notify
} }
$ref = dol_sanitizeFileName($newref); $ref = dol_sanitizeFileName($newref);
$pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; $pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
if (!dol_is_file($pdf_path)) if (!dol_is_file($pdf_path)) {
{
// We can't add PDF as it is not generated yet. // We can't add PDF as it is not generated yet.
$filepdf = ''; $filepdf = '';
} else { } else {
@ -525,13 +549,18 @@ class Notify
$message .= $mesg; $message .= $mesg;
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
if (!isset($action)) $action = ''; if (!isset($action)) {
$action = '';
}
$reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) if (empty($reshook)) {
{ if (!empty($hookmanager->resArray['subject'])) {
if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; $subject .= $hookmanager->resArray['subject'];
if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; }
if (!empty($hookmanager->resArray['message'])) {
$message .= $hookmanager->resArray['message'];
}
} }
$mailfile = new CMailFile( $mailfile = new CMailFile(
@ -553,17 +582,15 @@ class Notify
'notification' 'notification'
); );
if ($mailfile->sendfile()) if ($mailfile->sendfile()) {
{
if ($obj->type_target == 'touserid') { if ($obj->type_target == 'touserid') {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
} else { } else {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
} }
if (!$this->db->query($sql)) if (!$this->db->query($sql)) {
{
dol_print_error($this->db); dol_print_error($this->db);
} }
} else { } else {
@ -579,23 +606,22 @@ class Notify
dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty($object->socid) ? '' : $object->socid)); dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty($object->socid) ? '' : $object->socid));
} }
} else { } else {
$error++; $error++;
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR); dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR);
return -1; return -1;
} }
// Check notification using fixed email // Check notification using fixed email
if (!$error) if (!$error) {
{ foreach ($conf->global as $key => $val) {
foreach ($conf->global as $key => $val)
{
$reg = array(); $reg = array();
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
continue;
}
$threshold = (float) $reg[1]; $threshold = (float) $reg[1];
if (!empty($object->total_ht) && $object->total_ht <= $threshold) if (!empty($object->total_ht) && $object->total_ht <= $threshold) {
{
dol_syslog("A notification is requested for notifcode = ".$notifcode." but amount = ".$object->total_ht." so lower than threshold = ".$threshold.". We discard this notification"); dol_syslog("A notification is requested for notifcode = ".$notifcode." but amount = ".$object->total_ht." so lower than threshold = ".$threshold.". We discard this notification");
continue; continue;
} }
@ -604,7 +630,9 @@ class Notify
$sendto = $conf->global->$param; $sendto = $conf->global->$param;
$notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid'); $notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
if ($notifcodedefid <= 0) dol_print_error($this->db, 'Failed to get id from code'); if ($notifcodedefid <= 0) {
dol_print_error($this->db, 'Failed to get id from code');
}
$trackid = ''; $trackid = '';
$object_type = ''; $object_type = '';
@ -721,8 +749,7 @@ class Notify
} }
$ref = dol_sanitizeFileName($newref); $ref = dol_sanitizeFileName($newref);
$pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; $pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
if (!dol_is_file($pdf_path)) if (!dol_is_file($pdf_path)) {
{
// We can't add PDF as it is not generated yet. // We can't add PDF as it is not generated yet.
$filepdf = ''; $filepdf = '';
} else { } else {
@ -736,14 +763,14 @@ class Notify
$message = nl2br($message); $message = nl2br($message);
// Replace keyword __SUPERVISOREMAIL__ // Replace keyword __SUPERVISOREMAIL__
if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) {
{
$newval = ''; $newval = '';
if ($user->fk_user > 0) if ($user->fk_user > 0) {
{
$supervisoruser = new User($this->db); $supervisoruser = new User($this->db);
$supervisoruser->fetch($user->fk_user); $supervisoruser->fetch($user->fk_user);
if ($supervisoruser->email) $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>'); if ($supervisoruser->email) {
$newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
}
} }
dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval); dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
$sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto); $sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
@ -752,14 +779,16 @@ class Notify
$sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string
} }
if ($sendto) if ($sendto) {
{
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
$reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) if (empty($reshook)) {
{ if (!empty($hookmanager->resArray['subject'])) {
if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; $subject .= $hookmanager->resArray['subject'];
if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; }
if (!empty($hookmanager->resArray['message'])) {
$message .= $hookmanager->resArray['message'];
}
} }
$mailfile = new CMailFile( $mailfile = new CMailFile(
$subject, $subject,
@ -780,12 +809,10 @@ class Notify
'notification' 'notification'
); );
if ($mailfile->sendfile()) if ($mailfile->sendfile()) {
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')";
if (!$this->db->query($sql)) if (!$this->db->query($sql)) {
{
dol_print_error($this->db); dol_print_error($this->db);
} }
} else { } else {
@ -796,7 +823,10 @@ class Notify
} }
} }
if (!$error) return $num; if (!$error) {
else return -1 * $error; return $num;
} else {
return -1 * $error;
}
} }
} }

View File

@ -44,21 +44,45 @@ dolibarr_install_syslog("- fileconf: entering fileconf.php page");
// install.forced.php into directory htdocs/install (This is the case with some wizard // install.forced.php into directory htdocs/install (This is the case with some wizard
// installer like DoliWamp, DoliMamp or DoliBuntu). // installer like DoliWamp, DoliMamp or DoliBuntu).
// We first init "forced values" to nothing. // We first init "forced values" to nothing.
if (!isset($force_install_noedit)) $force_install_noedit = ''; // 1=To block vars specific to distrib, 2 to block all technical parameters if (!isset($force_install_noedit)) {
if (!isset($force_install_type)) $force_install_type = ''; $force_install_noedit = ''; // 1=To block vars specific to distrib, 2 to block all technical parameters
if (!isset($force_install_dbserver)) $force_install_dbserver = ''; }
if (!isset($force_install_port)) $force_install_port = ''; if (!isset($force_install_type)) {
if (!isset($force_install_database)) $force_install_database = ''; $force_install_type = '';
if (!isset($force_install_prefix)) $force_install_prefix = ''; }
if (!isset($force_install_createdatabase)) $force_install_createdatabase = ''; if (!isset($force_install_dbserver)) {
if (!isset($force_install_databaselogin)) $force_install_databaselogin = ''; $force_install_dbserver = '';
if (!isset($force_install_databasepass)) $force_install_databasepass = ''; }
if (!isset($force_install_databaserootlogin)) $force_install_databaserootlogin = ''; if (!isset($force_install_port)) {
if (!isset($force_install_databaserootpass)) $force_install_databaserootpass = ''; $force_install_port = '';
}
if (!isset($force_install_database)) {
$force_install_database = '';
}
if (!isset($force_install_prefix)) {
$force_install_prefix = '';
}
if (!isset($force_install_createdatabase)) {
$force_install_createdatabase = '';
}
if (!isset($force_install_databaselogin)) {
$force_install_databaselogin = '';
}
if (!isset($force_install_databasepass)) {
$force_install_databasepass = '';
}
if (!isset($force_install_databaserootlogin)) {
$force_install_databaserootlogin = '';
}
if (!isset($force_install_databaserootpass)) {
$force_install_databaserootpass = '';
}
// Now we load forced values from install.forced.php file. // Now we load forced values from install.forced.php file.
$useforcedwizard = false; $useforcedwizard = false;
$forcedfile = "./install.forced.php"; $forcedfile = "./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; // Must be after inc.php if ($conffile == "/etc/dolibarr/conf.php") {
$forcedfile = "/etc/dolibarr/install.forced.php"; // Must be after inc.php
}
if (@file_exists($forcedfile)) { if (@file_exists($forcedfile)) {
$useforcedwizard = true; $useforcedwizard = true;
include_once $forcedfile; include_once $forcedfile;
@ -75,8 +99,7 @@ session_start(); // To be able to keep info into session (used for not losing pa
pHeader($langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY) ? '' : $force_dolibarr_js_JQUERY.'/'), 'main-inside-bis'); pHeader($langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY) ? '' : $force_dolibarr_js_JQUERY.'/'), 'main-inside-bis');
// Test if we can run a first install process // Test if we can run a first install process
if (!is_writable($conffile)) if (!is_writable($conffile)) {
{
print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING); dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING);
dolibarr_install_syslog("- fileconf: end"); dolibarr_install_syslog("- fileconf: end");
@ -84,29 +107,30 @@ if (!is_writable($conffile))
exit; exit;
} }
if (!empty($force_install_message)) if (!empty($force_install_message)) {
{
print '<div><br>'.$langs->trans($force_install_message).'</div>'; print '<div><br>'.$langs->trans($force_install_message).'</div>';
/*print '<script type="text/javascript">'; /*print '<script type="text/javascript">';
print ' jQuery(document).ready(function() { print ' jQuery(document).ready(function() {
jQuery("#linktoshowtechnicalparam").click(function() { jQuery("#linktoshowtechnicalparam").click(function() {
jQuery(".hidewhenedit").hide(); jQuery(".hidewhenedit").hide();
jQuery(".hidewhennoedit").show(); jQuery(".hidewhennoedit").show();
});'; });';
if ($force_install_noedit) print 'jQuery(".hidewhennoedit").hide();'; if ($force_install_noedit) print 'jQuery(".hidewhennoedit").hide();';
print '});'; print '});';
print '</script>'; print '</script>';
print '<br><a href="#" id="linktoshowtechnicalparam" class="hidewhenedit">'.$langs->trans("ShowEditTechnicalParameters").'</a><br>'; print '<br><a href="#" id="linktoshowtechnicalparam" class="hidewhenedit">'.$langs->trans("ShowEditTechnicalParameters").'</a><br>';
*/ */
} }
?> ?>
<div> <div>
<table class="nobordernopadding<?php if ($force_install_noedit) print ' hidewhennoedit'; ?>"> <table class="nobordernopadding<?php if ($force_install_noedit) {
print ' hidewhennoedit';
} ?>">
<tr> <tr>
<td colspan="3" class="label"> <td colspan="3" class="label">
@ -116,7 +140,7 @@ if (!empty($force_install_message))
<!-- Documents root $dolibarr_main_document_root --> <!-- Documents root $dolibarr_main_document_root -->
<tr> <tr>
<td class="label"><label for="main_dir"><b><?php print $langs->trans("WebPagesDirectory"); ?></b></label></td> <td class="label"><label for="main_dir"><b><?php print $langs->trans("WebPagesDirectory"); ?></b></label></td>
<?php <?php
if (empty($dolibarr_main_url_root)) { if (empty($dolibarr_main_url_root)) {
$dolibarr_main_document_root = detect_dolibarr_main_document_root(); $dolibarr_main_document_root = detect_dolibarr_main_document_root();
@ -124,10 +148,10 @@ if (empty($dolibarr_main_url_root)) {
?> ?>
<td class="label"> <td class="label">
<input type="text" <input type="text"
class="minwidth300" class="minwidth300"
id="main_dir" id="main_dir"
name="main_dir" name="main_dir"
value="<?php print $dolibarr_main_document_root ?>" value="<?php print $dolibarr_main_document_root ?>"
<?php <?php
if (!empty($force_install_noedit)) { if (!empty($force_install_noedit)) {
print ' disabled'; print ' disabled';
@ -157,10 +181,10 @@ if (!empty($force_install_noedit)) {
?> ?>
<td class="label"> <td class="label">
<input type="text" <input type="text"
class="minwidth300" class="minwidth300"
id="main_data_dir" id="main_data_dir"
name="main_data_dir" name="main_data_dir"
value="<?php print $dolibarr_main_data_root ?>" value="<?php print $dolibarr_main_data_root ?>"
<?php if (!empty($force_install_noedit)) { <?php if (!empty($force_install_noedit)) {
print ' disabled'; print ' disabled';
} ?> } ?>
@ -185,14 +209,14 @@ if (!empty($force_install_noedit)) {
} }
?> ?>
<tr> <tr>
<td class="label"><label for="main_url"><b><?php echo $langs->trans("URLRoot"); ?></b></label> <td class="label"><label for="main_url"><b><?php echo $langs->trans("URLRoot"); ?></b></label>
</td> </td>
<td class="label"> <td class="label">
<input type="text" <input type="text"
class="minwidth300" class="minwidth300"
id="main_url" id="main_url"
name="main_url" name="main_url"
value="<?php print $dolibarr_main_url_root; ?> " value="<?php print $dolibarr_main_url_root; ?> "
<?php if (!empty($force_install_noedit)) { <?php if (!empty($force_install_noedit)) {
print ' disabled'; print ' disabled';
} }
@ -212,13 +236,17 @@ if (!empty($force_install_noedit)) {
if (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if the installation process is "https://" if (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if the installation process is "https://"
?> ?>
<tr> <tr>
<td class="label"><label for="main_force_https"><?php echo $langs->trans("ForceHttps"); ?></label></td> <td class="label"><label for="main_force_https"><?php echo $langs->trans("ForceHttps"); ?></label></td>
<td class="label"> <td class="label">
<input type="checkbox" <input type="checkbox"
id="main_force_https" id="main_force_https"
name="main_force_https" name="main_force_https"
<?php if (!empty($force_install_mainforcehttps)) { print ' checked'; } ?> <?php if (!empty($force_install_mainforcehttps)) {
<?php if ($force_install_noedit == 2 && $force_install_mainforcehttps !== null) { print ' disabled'; } ?> print ' checked';
} ?>
<?php if ($force_install_noedit == 2 && $force_install_mainforcehttps !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?> <td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?>
@ -238,13 +266,15 @@ if (!empty($force_install_noedit)) {
</tr> </tr>
<tr> <tr>
<td class="label"><label for="db_name"><b><?php echo $langs->trans("DatabaseName"); ?></b></label></td> <td class="label"><label for="db_name"><b><?php echo $langs->trans("DatabaseName"); ?></b></label></td>
<td class="label"> <td class="label">
<input type="text" <input type="text"
id="db_name" id="db_name"
name="db_name" name="db_name"
value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>" value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
<?php if ($force_install_noedit == 2 && $force_install_database !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_database !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td> <td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
@ -252,8 +282,7 @@ if (!empty($force_install_noedit)) {
<?php <?php
if (!isset($dolibarr_main_db_host)) if (!isset($dolibarr_main_db_host)) {
{
$dolibarr_main_db_host = "localhost"; $dolibarr_main_db_host = "localhost";
} }
?> ?>
@ -273,55 +302,86 @@ if (!empty($force_install_noedit)) {
// Scan les drivers // Scan les drivers
$dir = DOL_DOCUMENT_ROOT.'/core/db'; $dir = DOL_DOCUMENT_ROOT.'/core/db';
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i', $file, $reg)) {
{
if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i', $file, $reg))
{
$type = $reg[1]; $type = $reg[1];
if ($type === 'DoliDB') continue; // Skip abstract class if ($type === 'DoliDB') {
continue; // Skip abstract class
}
$class = 'DoliDB'.ucfirst($type); $class = 'DoliDB'.ucfirst($type);
include_once $dir."/".$file; include_once $dir."/".$file;
if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported) if ($type == 'sqlite') {
if ($type == 'sqlite3') continue; // We hide sqlite3 because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported) continue; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
}
if ($type == 'sqlite3') {
continue; // We hide sqlite3 because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
}
// Version min of database // Version min of database
$versionbasemin = explode('.', $class::VERSIONMIN); $versionbasemin = explode('.', $class::VERSIONMIN);
$note = '('.$class::LABEL.' >= '.$class::VERSIONMIN.')'; $note = '('.$class::LABEL.' >= '.$class::VERSIONMIN.')';
// Switch to mysql if mysqli is not present // Switch to mysql if mysqli is not present
if ($defaultype == 'mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql'; if ($defaultype == 'mysqli' && !function_exists('mysqli_connect')) {
$defaultype = 'mysql';
}
// Show line into list // Show line into list
if ($type == 'mysql') { $testfunction = 'mysql_connect'; $testclass = ''; } if ($type == 'mysql') {
if ($type == 'mysqli') { $testfunction = 'mysqli_connect'; $testclass = ''; } $testfunction = 'mysql_connect'; $testclass = '';
if ($type == 'pgsql') { $testfunction = 'pg_connect'; $testclass = ''; } }
if ($type == 'mssql') { $testfunction = 'mssql_connect'; $testclass = ''; } if ($type == 'mysqli') {
if ($type == 'sqlite') { $testfunction = ''; $testclass = 'PDO'; } $testfunction = 'mysqli_connect'; $testclass = '';
if ($type == 'sqlite3') { $testfunction = ''; $testclass = 'SQLite3'; } }
if ($type == 'pgsql') {
$testfunction = 'pg_connect'; $testclass = '';
}
if ($type == 'mssql') {
$testfunction = 'mssql_connect'; $testclass = '';
}
if ($type == 'sqlite') {
$testfunction = ''; $testclass = 'PDO';
}
if ($type == 'sqlite3') {
$testfunction = ''; $testclass = 'SQLite3';
}
$option .= '<option value="'.$type.'"'.($defaultype == $type ? ' selected' : ''); $option .= '<option value="'.$type.'"'.($defaultype == $type ? ' selected' : '');
if ($testfunction && !function_exists($testfunction)) $option .= ' disabled'; if ($testfunction && !function_exists($testfunction)) {
if ($testclass && !class_exists($testclass)) $option .= ' disabled'; $option .= ' disabled';
}
if ($testclass && !class_exists($testclass)) {
$option .= ' disabled';
}
$option .= '>'; $option .= '>';
$option .= $type.'&nbsp; &nbsp;'; $option .= $type.'&nbsp; &nbsp;';
if ($note) $option .= ' '.$note; if ($note) {
$option .= ' '.$note;
}
// Deprecated and experimental // Deprecated and experimental
if ($type == 'mysql') $option .= ' '.$langs->trans("Deprecated"); if ($type == 'mysql') {
elseif ($type == 'mssql') $option .= ' '.$langs->trans("VersionExperimental"); $option .= ' '.$langs->trans("Deprecated");
elseif ($type == 'sqlite') $option .= ' '.$langs->trans("VersionExperimental"); } elseif ($type == 'mssql') {
elseif ($type == 'sqlite3') $option .= ' '.$langs->trans("VersionExperimental"); $option .= ' '.$langs->trans("VersionExperimental");
// No available } elseif ($type == 'sqlite') {
elseif (!function_exists($testfunction)) $option .= ' - '.$langs->trans("FunctionNotAvailableInThisPHP"); $option .= ' '.$langs->trans("VersionExperimental");
} elseif ($type == 'sqlite3') {
$option .= ' '.$langs->trans("VersionExperimental");
} elseif (!function_exists($testfunction)) {
// No available
$option .= ' - '.$langs->trans("FunctionNotAvailableInThisPHP");
}
$option .= '</option>'; $option .= '</option>';
} }
} }
} }
?> ?>
<select id="db_type" <select id="db_type"
name="db_type" name="db_type"
<?php if ($force_install_noedit == 2 && $force_install_type !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_type !== null) {
print ' disabled';
} ?>
> >
<?php print $option; ?> <?php print $option; ?>
</select> </select>
@ -335,10 +395,12 @@ if (!empty($force_install_noedit)) {
<td class="label"><label for="db_host"><b><?php echo $langs->trans("DatabaseServer"); ?></b></label></td> <td class="label"><label for="db_host"><b><?php echo $langs->trans("DatabaseServer"); ?></b></label></td>
<td class="label"> <td class="label">
<input type="text" <input type="text"
id="db_host" id="db_host"
name="db_host" name="db_host"
value="<?php print (!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>" value="<?php print (!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
<?php if ($force_install_noedit == 2 && $force_install_dbserver !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_dbserver !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?> <td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?>
@ -347,13 +409,15 @@ if (!empty($force_install_noedit)) {
</tr> </tr>
<tr class="hidesqlite"> <tr class="hidesqlite">
<td class="label"><label for="db_port"><?php echo $langs->trans("Port"); ?></label></td> <td class="label"><label for="db_port"><?php echo $langs->trans("Port"); ?></label></td>
<td class="label"> <td class="label">
<input type="text" <input type="text"
name="db_port" name="db_port"
id="db_port" id="db_port"
value="<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>" value="<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
<?php if ($force_install_noedit == 2 && $force_install_port !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_port !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?> <td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?>
@ -362,26 +426,32 @@ if (!empty($force_install_noedit)) {
</tr> </tr>
<tr class="hidesqlite"> <tr class="hidesqlite">
<td class="label"><label for="db_prefix"><?php echo $langs->trans("DatabasePrefix"); ?></label></td> <td class="label"><label for="db_prefix"><?php echo $langs->trans("DatabasePrefix"); ?></label></td>
<td class="label"> <td class="label">
<input type="text" <input type="text"
id="db_prefix" id="db_prefix"
name="db_prefix" name="db_prefix"
value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>" value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
<?php if ($force_install_noedit == 2 && $force_install_prefix !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_prefix !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("DatabasePrefixDescription"); ?></td> <td class="comment"><?php echo $langs->trans("DatabasePrefixDescription"); ?></td>
</tr> </tr>
<tr class="hidesqlite"> <tr class="hidesqlite">
<td class="label"><label for="db_create_database"><?php echo $langs->trans("CreateDatabase"); ?></label></td> <td class="label"><label for="db_create_database"><?php echo $langs->trans("CreateDatabase"); ?></label></td>
<td class="label"> <td class="label">
<input type="checkbox" <input type="checkbox"
id="db_create_database" id="db_create_database"
name="db_create_database" name="db_create_database"
<?php if ($force_install_createdatabase) { print ' checked'; } ?> <?php if ($force_install_createdatabase) {
<?php if ($force_install_noedit == 2 && $force_install_createdatabase !== null) { print ' disabled'; } ?> print ' checked';
} ?>
<?php if ($force_install_noedit == 2 && $force_install_createdatabase !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("CheckToCreateDatabase"); ?> <td class="comment"><?php echo $langs->trans("CheckToCreateDatabase"); ?>
@ -392,10 +462,12 @@ if (!empty($force_install_noedit)) {
<td class="label"><label for="db_user"><b><?php echo $langs->trans("Login"); ?></b></label></td> <td class="label"><label for="db_user"><b><?php echo $langs->trans("Login"); ?></b></label></td>
<td class="label"> <td class="label">
<input type="text" <input type="text"
id="db_user" id="db_user"
name="db_user" name="db_user"
value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>" value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
<?php if ($force_install_noedit == 2 && $force_install_databaselogin !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_databaselogin !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td> <td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td>
@ -405,9 +477,9 @@ if (!empty($force_install_noedit)) {
<td class="label"><label for="db_pass"><b><?php echo $langs->trans("Password"); ?></b></label></td> <td class="label"><label for="db_pass"><b><?php echo $langs->trans("Password"); ?></b></label></td>
<td class="label"> <td class="label">
<input type="password" <input type="password"
id="db_pass" autocomplete="off" id="db_pass" autocomplete="off"
name="db_pass" name="db_pass"
value="<?php value="<?php
// If $force_install_databasepass is on, we don't want to set password, we just show '***'. Real value will be extracted from the forced install file at step1. // If $force_install_databasepass is on, we don't want to set password, we just show '***'. Real value will be extracted from the forced install file at step1.
$autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*')); $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
if (!empty($dolibarr_main_prod)) { if (!empty($dolibarr_main_prod)) {
@ -415,7 +487,9 @@ if (!empty($force_install_noedit)) {
} }
print dol_escape_htmltag($autofill); print dol_escape_htmltag($autofill);
?>" ?>"
<?php if ($force_install_noedit == 2 && $force_install_databasepass !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_databasepass !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td> <td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td>
@ -425,10 +499,14 @@ if (!empty($force_install_noedit)) {
<td class="label"><label for="db_create_user"><?php echo $langs->trans("CreateUser"); ?></label></td> <td class="label"><label for="db_create_user"><?php echo $langs->trans("CreateUser"); ?></label></td>
<td class="label"> <td class="label">
<input type="checkbox" <input type="checkbox"
id="db_create_user" id="db_create_user"
name="db_create_user" name="db_create_user"
<?php if (!empty($force_install_createuser)) { print ' checked'; } ?> <?php if (!empty($force_install_createuser)) {
<?php if ($force_install_noedit == 2 && $force_install_createuser !== null) { print ' disabled'; } ?> print ' checked';
} ?>
<?php if ($force_install_noedit == 2 && $force_install_createuser !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?> <td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?>
@ -451,11 +529,13 @@ if (!empty($force_install_noedit)) {
<td class="label"><label for="db_user_root"><b><?php echo $langs->trans("Login"); ?></b></label></td> <td class="label"><label for="db_user_root"><b><?php echo $langs->trans("Login"); ?></b></label></td>
<td class="label"> <td class="label">
<input type="text" <input type="text"
id="db_user_root" id="db_user_root"
name="db_user_root" name="db_user_root"
class="needroot" class="needroot"
value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : @$db_user_root; ?>" value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : @$db_user_root; ?>"
<?php if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) { print ' disabled'; } ?> <?php if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?> <td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
@ -473,25 +553,29 @@ if (!empty($force_install_noedit)) {
<td class="label"><label for="db_pass_root"><b><?php echo $langs->trans("Password"); ?></b></label></td> <td class="label"><label for="db_pass_root"><b><?php echo $langs->trans("Password"); ?></b></label></td>
<td class="label"> <td class="label">
<input type="password" <input type="password"
autocomplete="off" autocomplete="off"
id="db_pass_root" id="db_pass_root"
name="db_pass_root" name="db_pass_root"
class="needroot" class="needroot"
value="<?php value="<?php
// If $force_install_databaserootpass is on, we don't want to set password here, we just show '***'. Real value will be extracted from the forced install file at step1. // If $force_install_databaserootpass is on, we don't want to set password here, we just show '***'. Real value will be extracted from the forced install file at step1.
$autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : @$db_pass_root); $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : @$db_pass_root);
if (!empty($dolibarr_main_prod)) { if (!empty($dolibarr_main_prod)) {
$autofill = ''; $autofill = '';
} }
// Do not autofill password if instance is a production instance // Do not autofill password if instance is a production instance
if (!empty($_SERVER["SERVER_NAME"]) && !in_array($_SERVER["SERVER_NAME"], if (!empty($_SERVER["SERVER_NAME"]) && !in_array(
array('127.0.0.1', 'localhost', 'localhostgit')) $_SERVER["SERVER_NAME"],
array('127.0.0.1', 'localhost', 'localhostgit')
)
) { ) {
$autofill = ''; $autofill = '';
} // Do not autofill password for remote access } // Do not autofill password for remote access
print dol_escape_htmltag($autofill); print dol_escape_htmltag($autofill);
?>" ?>"
<?php if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) { print ' disabled'; /* May be removed by javascript*/ } ?> <?php if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
print ' disabled'; /* May be removed by javascript*/
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?> <td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>
@ -535,7 +619,7 @@ jQuery(document).ready(function() {
jQuery(".hideroot").show(); jQuery(".hideroot").show();
<?php <?php
if ($force_install_noedit == 0) { ?> if ($force_install_noedit == 0) { ?>
jQuery(".needroot").removeAttr('disabled'); jQuery(".needroot").removeAttr('disabled');
<?php } ?> <?php } ?>
} }
else else

View File

@ -1514,6 +1514,7 @@ class Products extends DolibarrApi
foreach ($combinations as $key => $combination) { foreach ($combinations as $key => $combination) {
$prodc2vp = new ProductCombination2ValuePair($this->db); $prodc2vp = new ProductCombination2ValuePair($this->db);
$combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id);
$combinations[$key] = $this->_cleanObjectDatas($combinations[$key]);
} }
return $combinations; return $combinations;
@ -1547,6 +1548,7 @@ class Products extends DolibarrApi
foreach ($combinations as $key => $combination) { foreach ($combinations as $key => $combination) {
$prodc2vp = new ProductCombination2ValuePair($this->db); $prodc2vp = new ProductCombination2ValuePair($this->db);
$combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id);
$combinations[$key] = $this->_cleanObjectDatas($combinations[$key]);
} }
return $combinations; return $combinations;
@ -1754,7 +1756,7 @@ class Products extends DolibarrApi
unset($object->libelle); unset($object->libelle);
unset($object->product_id_already_linked); unset($object->product_id_already_linked);
unset($object->reputations); unset($object->reputations);
unset($object->db);
unset($object->name); unset($object->name);
unset($object->firstname); unset($object->firstname);
unset($object->lastname); unset($object->lastname);

View File

@ -981,6 +981,10 @@ class MouvementStock extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$origin = new User($this->db); $origin = new User($this->db);
break; break;
case 'reception':
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
$origin = new Reception($this->db);
break;
default: default:
if ($origintype) if ($origintype)

View File

@ -20,7 +20,6 @@
use Luracast\Restler\RestException; use Luracast\Restler\RestException;
/** /**
* API class for thirdparties * API class for thirdparties
* *
@ -69,7 +68,7 @@ class Thirdparties extends DolibarrApi
* Return an array with thirdparty informations * Return an array with thirdparty informations
* *
* @param int $id Id of third party to load * @param int $id Id of third party to load
* @return Object Cleaned Societe object * @return array|mixed Cleaned Societe object
* *
* @throws RestException * @throws RestException
*/ */
@ -84,7 +83,7 @@ class Thirdparties extends DolibarrApi
* Return an array with thirdparty informations * Return an array with thirdparty informations
* *
* @param string $email Email of third party to load * @param string $email Email of third party to load
* @return Object Cleaned Societe object * @return array|mixed Cleaned Societe object
* *
* @url GET email/{email} * @url GET email/{email}
* *
@ -101,7 +100,7 @@ class Thirdparties extends DolibarrApi
* Return an array with thirdparty informations * Return an array with thirdparty informations
* *
* @param string $barcode Barcode of third party to load * @param string $barcode Barcode of third party to load
* @return Object Cleaned Societe object * @return array|mixed Cleaned Societe object
* *
* @url GET barcode/{barcode} * @url GET barcode/{barcode}
* *
@ -247,7 +246,7 @@ class Thirdparties extends DolibarrApi
* *
* @param int $id Id of thirdparty to update * @param int $id Id of thirdparty to update
* @param array $request_data Datas * @param array $request_data Datas
* @return Object|boolean * @return array|mixed|boolean
*/ */
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
@ -1190,7 +1189,7 @@ class Thirdparties extends DolibarrApi
* @param int $id ID of thirdparty * @param int $id ID of thirdparty
* @param array $request_data Request data * @param array $request_data Request data
* *
* @return object BankAccount of thirdparty * @return array|mixed BankAccount of thirdparty
* *
* @url POST {id}/bankaccounts * @url POST {id}/bankaccounts
*/ */
@ -1233,7 +1232,7 @@ class Thirdparties extends DolibarrApi
* @param int $bankaccount_id ID of CompanyBankAccount * @param int $bankaccount_id ID of CompanyBankAccount
* @param array $request_data Request data * @param array $request_data Request data
* *
* @return object BankAccount of thirdparty * @return array|mixed BankAccount of thirdparty
* *
* @url PUT {id}/bankaccounts/{bankaccount_id} * @url PUT {id}/bankaccounts/{bankaccount_id}
*/ */
@ -1389,7 +1388,7 @@ class Thirdparties extends DolibarrApi
* @param int $id ID of thirdparty * @param int $id ID of thirdparty
* @param string $site Site key * @param string $site Site key
* *
* @return SocieteAccount[] * @return array|mixed
* @throws RestException 401 Unauthorized: User does not have permission to read thirdparties * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties
* @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty
* *
@ -1461,7 +1460,7 @@ class Thirdparties extends DolibarrApi
* @param int $id ID of thirdparty * @param int $id ID of thirdparty
* @param array $request_data Request data * @param array $request_data Request data
* *
* @return SocieteAccount * @return array|mixed
* *
* @throws RestException 401 Unauthorized: User does not have permission to read thirdparties * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties
* @throws RestException 409 Conflict: A SocieteAccount entity (gateway) already exists for this company and site. * @throws RestException 409 Conflict: A SocieteAccount entity (gateway) already exists for this company and site.
@ -1519,7 +1518,7 @@ class Thirdparties extends DolibarrApi
* @param string $site Site key * @param string $site Site key
* @param array $request_data Request data * @param array $request_data Request data
* *
* @return SocieteAccount * @return array|mixed
* *
* @throws RestException 401 Unauthorized: User does not have permission to read thirdparties * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties
* @throws RestException 422 Unprocessable Entity: You must pass the site attribute in your request data ! * @throws RestException 422 Unprocessable Entity: You must pass the site attribute in your request data !
@ -1599,7 +1598,7 @@ class Thirdparties extends DolibarrApi
* @param string $site Site key * @param string $site Site key
* @param array $request_data Request data * @param array $request_data Request data
* *
* @return SocieteAccount * @return array|mixed
* *
* @throws RestException 401 Unauthorized: User does not have permission to read thirdparties * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties
* @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty
@ -1733,7 +1732,7 @@ class Thirdparties extends DolibarrApi
* Clean sensible object datas * Clean sensible object datas
* *
* @param Object $object Object to clean * @param Object $object Object to clean
* @return Object Object with cleaned properties * @return array|mixed Object with cleaned properties
*/ */
protected function _cleanObjectDatas($object) protected function _cleanObjectDatas($object)
{ {
@ -1806,7 +1805,7 @@ class Thirdparties extends DolibarrApi
* @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records)
* @param string $email Email of third party (Warning, this can return several records) * @param string $email Email of third party (Warning, this can return several records)
* @param string $ref_alias Name_alias of third party (Warning, this can return several records) * @param string $ref_alias Name_alias of third party (Warning, this can return several records)
* @return Object cleaned Societe object * @return array|mixed cleaned Societe object
* *
* @throws RestException * @throws RestException
*/ */

View File

@ -227,7 +227,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
$db->commit(); $db->commit();
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
} elseif ($valueid > 0) { } elseif ($action === 'update' && $valueid > 0) {
if ($prodcomb->fetch($valueid) < 0) { if ($prodcomb->fetch($valueid) < 0) {
dol_print_error($db, $langs->trans('ErrorRecordNotFound')); dol_print_error($db, $langs->trans('ErrorRecordNotFound'));
exit(); exit();

View File

@ -29,7 +29,7 @@ $action = GETPOST('action', 'alpha');
* Actions * Actions
*/ */
if ($action == 'create') { if ($action == 'add') {
if (empty($ref) || empty($label)) { if (empty($ref) || empty($label)) {
setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors');
} else { } else {