This commit is contained in:
Frédéric FRANCE 2019-02-26 00:34:43 +01:00
parent 06db81f3c3
commit 675a17a74c
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
6 changed files with 89 additions and 73 deletions

View File

@ -382,7 +382,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
* *
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
private function _init($array_sql, $options = '') protected function _init($array_sql, $options = '')
{ {
global $conf; global $conf;
$err=0; $err=0;
@ -484,7 +484,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
* *
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
private function _remove($array_sql, $options = '') protected function _remove($array_sql, $options = '')
{ {
$err=0; $err=0;
@ -658,11 +658,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
$content = dolMd2Html( $content = dolMd2Html(
$content, 'parsedown', $content,
'parsedown',
array( array(
'doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1), 'doc/' => dol_buildpath(strtolower($this->name).'/doc/', 1),
'img/'=>dol_buildpath(strtolower($this->name).'/img/', 1), 'img/' => dol_buildpath(strtolower($this->name).'/img/', 1),
'images/'=>dol_buildpath(strtolower($this->name).'/imgages/', 1), 'images/' => dol_buildpath(strtolower($this->name).'/imgages/', 1),
) )
); );
} }
@ -671,8 +672,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$content = nl2br($content); $content = nl2br($content);
} }
} }
else // Mostly for internal modules else
{ {
// Mostly for internal modules
if (! empty($this->descriptionlong)) { if (! empty($this->descriptionlong)) {
if (is_array($this->langfiles)) { if (is_array($this->langfiles)) {
foreach($this->langfiles as $val) foreach($this->langfiles as $val)
@ -805,14 +807,20 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$ret=''; $ret='';
$newversion=preg_replace('/_deprecated/', '', $this->version); $newversion=preg_replace('/_deprecated/', '', $this->version);
if ($newversion == 'experimental') { $ret=($translated?$langs->transnoentitiesnoconv("VersionExperimental"):$newversion); if ($newversion == 'experimental') {
} elseif ($newversion == 'development') { $ret=($translated?$langs->transnoentitiesnoconv("VersionDevelopment"):$newversion); $ret=($translated?$langs->transnoentitiesnoconv("VersionExperimental"):$newversion);
} elseif ($newversion == 'dolibarr') { $ret=DOL_VERSION; } elseif ($newversion == 'development') {
} elseif ($newversion) { $ret=$newversion; $ret=($translated?$langs->transnoentitiesnoconv("VersionDevelopment"):$newversion);
} else { $ret=($translated?$langs->transnoentitiesnoconv("VersionUnknown"):'unknown'); } elseif ($newversion == 'dolibarr') {
$ret=DOL_VERSION;
} elseif ($newversion) {
$ret=$newversion;
} else {
$ret=($translated?$langs->transnoentitiesnoconv("VersionUnknown"):'unknown');
} }
if (preg_match('/_deprecated/', $this->version)) { $ret.=($translated?' ('.$langs->transnoentitiesnoconv("Deprecated").')':$this->version); if (preg_match('/_deprecated/', $this->version)) {
$ret.=($translated?' ('.$langs->transnoentitiesnoconv("Deprecated").')':$this->version);
} }
return $ret; return $ret;
} }
@ -825,13 +833,17 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
*/ */
public function isCoreOrExternalModule() public function isCoreOrExternalModule()
{ {
if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { return 'core'; if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') {
return 'core';
} }
if (! empty($this->version) && ! in_array($this->version, array('experimental','development'))) { return 'external'; if (! empty($this->version) && ! in_array($this->version, array('experimental','development'))) {
return 'external';
} }
if (! empty($this->editor_name) || ! empty($this->editor_url)) { return 'external'; if (! empty($this->editor_name) || ! empty($this->editor_url)) {
return 'external';
} }
if ($this->numero >= 100000) { return 'external'; if ($this->numero >= 100000) {
return 'external';
} }
return 'unknown'; return 'unknown';
} }
@ -911,11 +923,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) { $err++; if (! $resql) {
} else $err++;
{ } else {
$obj=$this->db->fetch_object($resql); $obj=$this->db->fetch_object($resql);
if ($obj) { return $this->db->jdate($obj->tms); if ($obj) {
return $this->db->jdate($obj->tms);
} }
} }
@ -938,15 +951,16 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) { $err++; if (! $resql) {
} else $err++;
{ } else {
$obj=$this->db->fetch_object($resql); $obj=$this->db->fetch_object($resql);
$tmp=array(); $tmp=array();
if ($obj->note) { if ($obj->note) {
$tmp=json_decode($obj->note, true); $tmp=json_decode($obj->note, true);
} }
if ($obj) { return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); if ($obj) {
return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms));
} }
} }
@ -974,7 +988,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG); dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) { $err++; if (! $resql) {
$err++;
} }
$note=json_encode(array('authorid'=>(is_object($user)?$user->id:0), 'ip'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']))); $note=json_encode(array('authorid'=>(is_object($user)?$user->id:0), 'ip'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])));
@ -1029,7 +1044,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
* @param string $reldir Relative directory where to scan files * @param string $reldir Relative directory where to scan files
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
*/ */
private function _load_tables($reldir) protected function _load_tables($reldir)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;

View File

@ -89,7 +89,7 @@ class modNotification extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
function init($options = '') public function init($options = '')
{ {
// Permissions // Permissions
$this->remove($options); $this->remove($options);

View File

@ -124,40 +124,41 @@ class modPrelevement extends DolibarrModules
$this->rights[$r][4] = 'bons'; $this->rights[$r][4] = 'bons';
$this->rights[$r][5] = 'credit'; $this->rights[$r][5] = 'credit';
/* $this->rights[2][0] = 154; /*
$this->rights[2][0] = 154;
$this->rights[2][1] = 'Setup withdraw account'; $this->rights[2][1] = 'Setup withdraw account';
$this->rights[2][2] = 'w'; $this->rights[2][2] = 'w';
$this->rights[2][3] = 0; $this->rights[2][3] = 0;
$this->rights[2][4] = 'bons'; $this->rights[2][4] = 'bons';
$this->rights[2][5] = 'configurer'; $this->rights[2][5] = 'configurer';
*/ */
// Menus // Menus
//------- //-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
} }
/** /**
* Function called when module is enabled. * Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories * It also creates data directories
* *
* @param string $options Options when enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function init($options = '') public function init($options = '')
{ {
global $conf; global $conf;
// Permissions // Permissions
$this->remove($options); $this->remove($options);
$sql = array( $sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")",
); );
return $this->_init($sql, $options); return $this->_init($sql, $options);
} }
} }

View File

@ -521,7 +521,7 @@ class modProduct extends DolibarrModules
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));
if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
$this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array(
'sp.price'=>"PriceQtyMinHT*", 'sp.price'=>"PriceQtyMinHT*",
'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
'sp.remise_percent'=>'DiscountQtyMin' 'sp.remise_percent'=>'DiscountQtyMin'
@ -625,20 +625,20 @@ $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array
} }
/** /**
* Function called when module is enabled. * Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories * It also creates data directories
* *
* @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
function init($options = '') public function init($options = '')
{ {
$this->remove($options); $this->remove($options);
$sql = array(); $sql = array();
return $this->_init($sql, $options); return $this->_init($sql, $options);
} }
} }

View File

@ -159,12 +159,12 @@ class modSalaries extends DolibarrModules
/** /**
* Function called when module is enabled. * Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories * It also creates data directories
* *
* @param string $options Options when enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function init($options = '') public function init($options = '')
{ {

View File

@ -360,7 +360,7 @@ class modMyModule extends DolibarrModules
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories * It also creates data directories
* *
* @param string $options Options when enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function init($options = '') public function init($options = '')