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

This commit is contained in:
Laurent Destailleur 2020-11-12 13:02:24 +01:00
commit e5b615f484
6 changed files with 110 additions and 43 deletions

View File

@ -4,7 +4,7 @@
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -41,7 +41,7 @@ $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); $socid = GETPOST('socid', 'int') ? ((int) GETPOST('socid', 'int')) : ((int) GETPOST('id', 'int'));
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');

View File

@ -2404,6 +2404,7 @@ class Adherent extends CommonObject
global $conf, $langs; global $conf, $langs;
$info = array(); $info = array();
$socialnetworks = getArrayOfSocialNetworks();
$keymodified = false; $keymodified = false;
// Object classes // Object classes
@ -2418,8 +2419,13 @@ class Adherent extends CommonObject
} }
// Possible LDAP KEY (constname => varname) // Possible LDAP KEY (constname => varname)
$ldapkey = array('LDAP_MEMBER_FIELD_FULLNAME' => 'fullname', 'LDAP_MEMBER_FIELD_NAME' => 'lastname', 'LDAP_MEMBER_FIELD_LOGIN' => 'login', 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' => 'login', $ldapkey = array(
'LDAP_MEMBER_FIELD_MAIL' => 'email'); 'LDAP_MEMBER_FIELD_FULLNAME' => 'fullname',
'LDAP_MEMBER_FIELD_NAME' => 'lastname',
'LDAP_MEMBER_FIELD_LOGIN' => 'login',
'LDAP_MEMBER_FIELD_LOGIN_SAMBA' => 'login',
'LDAP_MEMBER_FIELD_MAIL' => 'email'
);
// Member // Member
foreach ($ldapkey as $constname => $varname) { foreach ($ldapkey as $constname => $varname) {
@ -2439,10 +2445,11 @@ class Adherent extends CommonObject
if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
if ($this->skype && !empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; foreach ($socialnetworks as $key => $value) {
if ($this->twitter && !empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter; if ($this->socialnetworks[$value['label']] && !empty($conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])})) {
if ($this->facebook && !empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; $info[$conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])}] = $this->socialnetworks[$value['label']];
if ($this->linkedin && !empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin; }
}
if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
@ -2455,8 +2462,12 @@ class Adherent extends CommonObject
// When password is modified // When password is modified
if (!empty($this->pass)) { if (!empty($this->pass)) {
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte
}
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption)
}
} // Set LDAP password if possible } // Set LDAP password if possible
elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password
if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {

View File

@ -43,16 +43,36 @@ class CActionComm
*/ */
public $id; public $id;
/**
* @var string code
*/
public $code; public $code;
/**
* @var string type
*/
public $type; public $type;
public $libelle; // deprecated
/**
* @var string label
* @deprecated
* @see $label
*/
public $libelle;
/** /**
* @var string Type of agenda event label * @var string Type of agenda event label
*/ */
public $label; public $label;
/**
* @var int active
*/
public $active; public $active;
/**
* @var string color hex
*/
public $color; public $color;
/** /**
@ -60,6 +80,9 @@ class CActionComm
*/ */
public $picto; public $picto;
/**
* @var array array of type_actions
*/
public $type_actions = array(); public $type_actions = array();
@ -76,14 +99,14 @@ class CActionComm
/** /**
* Load action type from database * Load action type from database
* *
* @param int $id id or code of action type to read * @param int|string $id id or code of action type to read
* @return int 1=ok, 0=not found, -1=error * @return int 1=ok, 0=not found, -1=error
*/ */
public function fetch($id) public function fetch($id)
{ {
$sql = "SELECT id, code, type, libelle as label, color, active, picto"; $sql = "SELECT id, code, type, libelle as label, color, active, picto";
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
if (is_numeric($id)) $sql .= " WHERE id=".$id; if (is_numeric($id)) $sql .= " WHERE id=".(int) $id;
else $sql .= " WHERE code='".$this->db->escape($id)."'"; else $sql .= " WHERE code='".$this->db->escape($id)."'";
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@ -138,7 +161,9 @@ class CActionComm
$sql = "SELECT id, code, libelle as label, module, type, color, picto"; $sql = "SELECT id, code, libelle as label, module, type, color, picto";
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
$sql .= " WHERE 1=1"; $sql .= " WHERE 1=1";
if ($active != '') $sql .= " AND active=".$active; if ($active != '') {
$sql .= " AND active=".(int) $active;
}
if (!empty($excludetype)) $sql .= " AND type <> '".$this->db->escape($excludetype)."'"; if (!empty($excludetype)) $sql .= " AND type <> '".$this->db->escape($excludetype)."'";
if ($morefilter) $sql .= " AND ".$morefilter; if ($morefilter) $sql .= " AND ".$morefilter;
$sql .= " ORDER BY module, position, type"; $sql .= " ORDER BY module, position, type";

View File

@ -215,6 +215,8 @@ if ($nbofentries > 0)
print '</table></td>'; print '</table></td>';
print '</tr>'; print '</tr>';
} }
print "</table>";
print '<input type="submit" value="'.$langs->trans("Save").'"></form>';
//Printer3 //Printer3
print '<table class="liste nohover" width="100%">'; print '<table class="liste nohover" width="100%">';

View File

@ -65,6 +65,8 @@ if (GETPOST('action', 'alpha') == 'set')
} elseif (GETPOST('action', 'alpha') == 'setmethod') } elseif (GETPOST('action', 'alpha') == 'setmethod')
{ {
dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity);
// TakePOS connector require ReceiptPrinter module
if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && !$conf->receiptprinter->enabled) activateModule("modReceiptPrinter");
} }
@ -109,27 +111,25 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser")
print "</td></tr>\n"; print "</td></tr>\n";
// Receipt printer module // Receipt printer module
if ($conf->global->MAIN_FEATURES_LEVEL >= 1) { print '<tr class="oddeven"><td>';
print '<tr class="oddeven"><td>'; print $langs->trans('DolibarrReceiptPrinter');
print $langs->trans('DolibarrReceiptPrinter'); print '<td>';
print '<td>'; print $langs->trans('ReceiptPrinterMethodDescription');
print $langs->trans('ReceiptPrinterMethodDescription'); print '<br>';
print '<br>'; print '<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php">'.$langs->trans("Setup").'</a>';
print '<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php">'.$langs->trans("Setup").'</a>'; print '</td><td class="right">';
print '</td><td class="right">'; if ($conf->receiptprinter->enabled) {
if ($conf->receiptprinter->enabled) { if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") {
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { print img_picto($langs->trans("Activated"), 'switch_on');
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmethod&token='.newToken().'&value=receiptprinter">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
}
} else { } else {
print '<span class="opacitymedium">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmethod&token='.newToken().'&value=receiptprinter">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print $langs->trans("ModuleReceiptPrinterMustBeEnabled");
print '</span>';
} }
print "</td></tr>\n"; } else {
print '<span class="opacitymedium">';
print $langs->trans("ModuleReceiptPrinterMustBeEnabled");
print '</span>';
} }
print "</td></tr>\n";
// TakePOS Connector // TakePOS Connector
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';

View File

@ -96,6 +96,30 @@ class User extends CommonObject
*/ */
public $socialnetworks; public $socialnetworks;
/**
* @var string skype account
* @deprecated
*/
public $skype;
/**
* @var string twitter account
* @deprecated
*/
public $twitter;
/**
* @var string facebook account
* @deprecated
*/
public $facebook;
/**
* @var string linkedin account
* @deprecated
*/
public $linkedin;
/** /**
* @var string job position * @var string job position
*/ */
@ -1643,7 +1667,7 @@ class User extends CommonObject
$this->datestartvalidity = empty($this->datestartvalidity) ? '' : $this->datestartvalidity; $this->datestartvalidity = empty($this->datestartvalidity) ? '' : $this->datestartvalidity;
$this->dateendvalidity = empty($this->dateendvalidity) ? '' : $this->dateendvalidity; $this->dateendvalidity = empty($this->dateendvalidity) ? '' : $this->dateendvalidity;
$this->birth = trim($this->birth); $this->birth = trim($this->birth);
$this->fk_warehouse = trim(empty($this->fk_warehouse) ? '' : $this->fk_warehouse); $this->fk_warehouse = (int) $this->fk_warehouse;
// Check parameters // Check parameters
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) { if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
@ -1714,7 +1738,7 @@ class User extends CommonObject
$sql .= ", entity = '".$this->db->escape($this->entity)."'"; $sql .= ", entity = '".$this->db->escape($this->entity)."'";
$sql .= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null'); $sql .= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null');
$sql .= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null'); $sql .= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null');
$sql .= ", fk_warehouse = ".($this->fk_warehouse ? "'".$this->db->escape($this->fk_warehouse)."'" : "null"); $sql .= ", fk_warehouse = ".($this->fk_warehouse > 0 ? $this->fk_warehouse : "null");
$sql .= ", lang = ".($this->lang ? "'".$this->db->escape($this->lang)."'" : "null"); $sql .= ", lang = ".($this->lang ? "'".$this->db->escape($this->lang)."'" : "null");
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
@ -2653,6 +2677,9 @@ class User extends CommonObject
global $conf, $langs; global $conf, $langs;
$info = array(); $info = array();
$socialnetworks = getArrayOfSocialNetworks();
$keymodified = false; $keymodified = false;
// Object classes // Object classes
@ -2672,10 +2699,6 @@ class User extends CommonObject
'LDAP_FIELD_FAX' => 'office_fax', 'LDAP_FIELD_FAX' => 'office_fax',
'LDAP_FIELD_MAIL' => 'email', 'LDAP_FIELD_MAIL' => 'email',
'LDAP_FIELD_SID' => 'ldap_sid', 'LDAP_FIELD_SID' => 'ldap_sid',
'LDAP_FIELD_SKYPE' => 'skype',
'LDAP_FIELD_TWITTER' => 'twitter',
'LDAP_FIELD_FACEBOOK' => 'facebook',
'LDAP_FIELD_LINKEDIN' => 'linkedin'
); );
// Champs // Champs
@ -2691,6 +2714,11 @@ class User extends CommonObject
} }
} }
} }
foreach ($socialnetworks as $key => $value) {
if ($this->socialnetworks[$value['label']] && !empty($conf->global->{'LDAP_FIELD_'.strtoupper($value['label'])})) {
$info[$conf->global->{'LDAP_FIELD_'.strtoupper($value['label'])}] = $this->socialnetworks[$value['label']];
}
}
if ($this->address && !empty($conf->global->LDAP_FIELD_ADDRESS)) { if ($this->address && !empty($conf->global->LDAP_FIELD_ADDRESS)) {
$info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address; $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
} }
@ -2959,6 +2987,8 @@ class User extends CommonObject
// TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?) // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?)
global $user, $conf; global $user, $conf;
$socialnetworks = getArrayOfSocialNetworks();
$this->firstname = $ldapuser->{$conf->global->LDAP_FIELD_FIRSTNAME}; $this->firstname = $ldapuser->{$conf->global->LDAP_FIELD_FIRSTNAME};
$this->lastname = $ldapuser->{$conf->global->LDAP_FIELD_NAME}; $this->lastname = $ldapuser->{$conf->global->LDAP_FIELD_NAME};
$this->login = $ldapuser->{$conf->global->LDAP_FIELD_LOGIN}; $this->login = $ldapuser->{$conf->global->LDAP_FIELD_LOGIN};
@ -2969,10 +2999,9 @@ class User extends CommonObject
$this->user_mobile = $ldapuser->{$conf->global->LDAP_FIELD_MOBILE}; $this->user_mobile = $ldapuser->{$conf->global->LDAP_FIELD_MOBILE};
$this->office_fax = $ldapuser->{$conf->global->LDAP_FIELD_FAX}; $this->office_fax = $ldapuser->{$conf->global->LDAP_FIELD_FAX};
$this->email = $ldapuser->{$conf->global->LDAP_FIELD_MAIL}; $this->email = $ldapuser->{$conf->global->LDAP_FIELD_MAIL};
$this->skype = $ldapuser->{$conf->global->LDAP_FIELD_SKYPE}; foreach ($socialnetworks as $key => $value) {
$this->twitter = $ldapuser->{$conf->global->LDAP_FIELD_TWITTER}; $this->socialnetworks[$value['label']] = $ldapuser{$conf->global->{'LDAP_FIELD_'.strtoupper($value['label'])}};
$this->facebook = $ldapuser->{$conf->global->LDAP_FIELD_FACEBOOK}; }
$this->linkedin = $ldapuser->{$conf->global->LDAP_FIELD_LINKEDIN};
$this->ldap_sid = $ldapuser->{$conf->global->LDAP_FIELD_SID}; $this->ldap_sid = $ldapuser->{$conf->global->LDAP_FIELD_SID};
$this->job = $ldapuser->{$conf->global->LDAP_FIELD_TITLE}; $this->job = $ldapuser->{$conf->global->LDAP_FIELD_TITLE};