This commit is contained in:
Frédéric FRANCE 2019-02-26 21:13:07 +01:00
parent 675a17a74c
commit e6c3eb0ba1
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
44 changed files with 268 additions and 262 deletions

View File

@ -94,7 +94,7 @@ class DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
private function _cleanObjectDatas($object)
protected function _cleanObjectDatas($object)
{
// Remove $db object property for object
@ -222,7 +222,7 @@ class DolibarrApi
* @return bool
* @throws RestException
*/
private static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
{
// Features/modules to check
@ -248,7 +248,7 @@ class DolibarrApi
* @param string $sqlfilters sqlfilter string
* @return boolean True if valid, False if not valid
*/
private function _checkFilters($sqlfilters)
protected function _checkFilters($sqlfilters)
{
//$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
//$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters);
@ -278,7 +278,7 @@ class DolibarrApi
* @param array $matches Array of found string by regex search
* @return string Forged criteria. Example: "t.field like 'abc%'"
*/
private static function _forge_criteria_callback($matches)
protected static function _forge_criteria_callback($matches)
{
// phpcs:enable
global $db;

View File

@ -370,6 +370,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
// We need constructor into function unActivateModule into admin.lib.php
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Enables a module.
* Inserts all informations into database
@ -384,6 +385,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
*/
protected function _init($array_sql, $options = '')
{
// phpcs:enable
global $conf;
$err=0;
@ -476,6 +478,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Disable function. Deletes the module constants and boxes from the database.
*
@ -486,6 +489,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
*/
protected function _remove($array_sql, $options = '')
{
// phpcs:enable
$err=0;
$this->db->begin();
@ -1044,7 +1048,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
* @param string $reldir Relative directory where to scan files
* @return int <=0 if KO, >0 if OK
*/
protected function _load_tables($reldir)
private function _load_tables($reldir)
{
// phpcs:enable
global $conf;
@ -1052,7 +1056,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$error=0;
$dirfound=0;
if (empty($reldir)) { return 1;
if (empty($reldir)) {
return 1;
}
include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';

View File

@ -25,7 +25,7 @@
require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php';
/**
* Class to manage cheque receipts numbering rules Mint
* Class to manage cheque receipts numbering rules Mint
*/
class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
{
@ -145,7 +145,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*

View File

@ -133,7 +133,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*

View File

@ -382,7 +382,7 @@ class modAdherent extends DolibarrModules
global $conf,$langs;
// Permissions
$this->remove($options);
$this->removeFromChild(array(), $options);
//ODT template
/*
@ -408,6 +408,6 @@ class modAdherent extends DolibarrModules
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','member',".$conf->entity.")"
);
return $this->_init($sql, $options);
return $this->initFromChild($sql, $options);
}
}

View File

@ -204,18 +204,20 @@ class modAgenda extends DolibarrModules
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
$this->menu[$r]=array('fk_menu'=>0,
'type'=>'top',
'titre'=>'TMenuAgenda',
'mainmenu'=>'agenda',
'url'=>'/comm/action/index.php',
'langs'=>'agenda',
'position'=>86,
'perms'=>'$user->rights->agenda->myactions->read',
'enabled'=>'$conf->agenda->enabled',
'target'=>'',
'user'=>2);
$r++;
$this->menu[$r]=array(
'fk_menu'=>0,
'type'=>'top',
'titre'=>'TMenuAgenda',
'mainmenu'=>'agenda',
'url'=>'/comm/action/index.php',
'langs'=>'agenda',
'position'=>86,
'perms'=>'$user->rights->agenda->myactions->read',
'enabled'=>'$conf->agenda->enabled',
'target'=>'',
'user'=>2,
);
$r++;
$this->menu[$r]=array('fk_menu'=>'r=0',
'type'=>'left',

View File

@ -224,14 +224,14 @@ class modApi extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
{
$sql = array();
public function init($options = '')
{
$sql = array();
$result=$this->_load_tables('/api/sql/');
$result = $this->_load_tables('/api/sql/');
return $this->_init($sql, $options);
}
return $this->initFromChild($sql, $options);
}
/**
* Function called when module is disabled.
@ -241,7 +241,7 @@ class modApi extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options = '')
public function remove($options = '')
{
// Remove old constants with entity fields different of 0
$sql = array(
@ -249,6 +249,6 @@ class modApi extends DolibarrModules
"DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('API_PRODUCTION_MODE', 1)
);
return $this->_remove($sql, $options);
return $this->removeFromChild($sql, $options);
}
}

View File

@ -325,10 +325,10 @@ class modAsset extends DolibarrModules
global $conf;
// Permissions
$this->remove($options);
$this->removeFromChild(array(), $options);
$sql = array();
return $this->_init($sql, $options);
return $this->initFromChild($sql, $options);
}
}

View File

@ -210,7 +210,7 @@ class modBanque extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf;

View File

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

View File

@ -145,9 +145,8 @@ class modBlockedLog extends DolibarrModules
*
* @return boolean True if already used, otherwise False
*/
function alreadyUsed()
public function alreadyUsed()
{
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$b=new BlockedLog($this->db);
return $b->alreadyUsed(1);
@ -162,7 +161,7 @@ class modBlockedLog extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf, $user;
@ -205,7 +204,7 @@ class modBlockedLog extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options = '')
public function remove($options = '')
{
global $conf, $user;
@ -233,7 +232,7 @@ class modBlockedLog extends DolibarrModules
if ($b->alreadyUsed(1))
{
$res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error
$res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error
}
else
{

View File

@ -121,24 +121,24 @@ class modCashDesk extends DolibarrModules
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
}
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
{
$sql = array();
public function init($options = '')
{
$sql = array();
// Remove permissions and default values
$this->remove($options);
// Remove permissions and default values
$this->remove($options);
return $this->_init($sql, $options);
}
return $this->_init($sql, $options);
}
}

View File

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

View File

@ -269,7 +269,7 @@ class modCommande extends DolibarrModules
* @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf,$langs;
@ -299,6 +299,6 @@ class modCommande extends DolibarrModules
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")"
);
return $this->_init($sql, $options);
return $this->_init($sql, $options);
}
}

View File

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

View File

@ -212,7 +212,7 @@ class modContrat extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf;

View File

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

View File

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

View File

@ -151,7 +151,7 @@ class modDon extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf;

View File

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

View File

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

View File

@ -86,7 +86,7 @@ class modExternalRss extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf;
@ -126,7 +126,7 @@ class modExternalRss extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options = '')
public function remove($options = '')
{
$sql = array();

View File

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

View File

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

View File

@ -131,7 +131,7 @@ class modHRM extends DolibarrModules
* @param string $options Enabling module ('', 'noboxes')
* @return int if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
// Permissions
$this->remove($options);

View File

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

View File

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

View File

@ -130,7 +130,7 @@ class modOauth extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf;

View File

@ -310,7 +310,7 @@ class modProjet extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf,$langs;

View File

@ -265,7 +265,7 @@ class modPropale extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf,$langs;

View File

@ -130,7 +130,7 @@ class modReceiptPrinter extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf;
// Clean before activation

View File

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

View File

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

View File

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

View File

@ -185,7 +185,7 @@ class modTax extends DolibarrModules
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
public function init($options = '')
{
global $conf;

View File

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

View File

@ -137,9 +137,9 @@ class modWorkflow extends DolibarrModules
* It also creates data directories
*
* @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
$this->remove($options);

View File

@ -47,7 +47,7 @@ class PrintingDriver
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
$this->db = $db;
}
@ -59,7 +59,7 @@ class PrintingDriver
* @param integer $maxfilenamelength Max length of value to show
* @return array List of drivers
*/
static function listDrivers($db, $maxfilenamelength = 0)
public static function listDrivers($db, $maxfilenamelength = 0)
{
global $conf;
@ -80,7 +80,7 @@ class PrintingDriver
*
* @return string Return translation of key PrintingModuleDescXXX where XXX is module name, or $this->desc if not exists
*/
function getDesc()
public function getDesc()
{
global $langs;
$langs->load("printing");

View File

@ -70,7 +70,7 @@ class printing_printgcp extends PrintingDriver
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
global $conf, $langs, $dolibarr_main_url_root;
@ -89,47 +89,47 @@ class printing_printgcp extends PrintingDriver
);
} else {
$this->google_id = $conf->global->OAUTH_GOOGLE_ID;
$this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET;
// Token storage
$storage = new DoliStorage($this->db, $this->conf);
//$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE);
// Setup the credentials for the requests
$this->google_id = $conf->global->OAUTH_GOOGLE_ID;
$this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET;
// Token storage
$storage = new DoliStorage($this->db, $this->conf);
//$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE);
// Setup the credentials for the requests
$credentials = new Credentials(
$this->google_id,
$this->google_secret,
$urlwithroot.'/core/modules/oauth/google_oauthcallback.php'
);
$access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken');
$serviceFactory = new \OAuth\ServiceFactory();
$apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array());
$token_ok=true;
try {
$token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
$token_ok = false;
}
//var_dump($this->errors);exit;
$this->google_id,
$this->google_secret,
$urlwithroot.'/core/modules/oauth/google_oauthcallback.php'
);
$access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken');
$serviceFactory = new \OAuth\ServiceFactory();
$apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array());
$token_ok=true;
try {
$token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
$token_ok = false;
}
//var_dump($this->errors);exit;
$expire = false;
// Is token expired or will token expire in the next 30 seconds
if ($token_ok) {
$expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30));
}
$expire = false;
// Is token expired or will token expire in the next 30 seconds
if ($token_ok) {
$expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30));
}
// Token expired so we refresh it
if ($token_ok && $expire) {
try {
// il faut sauvegarder le refresh token car google ne le donne qu'une seule fois
$refreshtoken = $token->getRefreshToken();
$token = $apiService->refreshAccessToken($token);
$token->setRefreshToken($refreshtoken);
$storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
// Token expired so we refresh it
if ($token_ok && $expire) {
try {
// il faut sauvegarder le refresh token car google ne le donne qu'une seule fois
$refreshtoken = $token->getRefreshToken();
$token = $apiService->refreshAccessToken($token);
$token->setRefreshToken($refreshtoken);
$storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
if ($this->google_id != '' && $this->google_secret != '') {
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info');
$this->conf[] = array(

View File

@ -62,7 +62,7 @@ class printing_printipp extends PrintingDriver
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
global $conf;
@ -152,7 +152,7 @@ class printing_printipp extends PrintingDriver
*
* @return int 0 if OK, >0 if KO
*/
function listAvailablePrinters()
public function listAvailablePrinters()
{
global $conf, $langs;
$error = 0;

View File

@ -62,7 +62,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
*
* @return string Text with description
*/
function info()
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
@ -74,7 +74,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
*
* @return string Example
*/
function getExample()
public function getExample()
{
return $this->prefix."0501-0001";
}
@ -86,7 +86,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
*
* @return boolean false si conflit, true si ok
*/
function canBeActivated()
public function canBeActivated()
{
global $conf,$langs,$db;
@ -124,7 +124,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
* @param Propal $propal Object commercial proposal
* @return string Next value
*/
function getNextValue($objsoc, $propal)
public function getNextValue($objsoc, $propal)
{
global $db,$conf;
@ -165,7 +165,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
* @param Object $objforref Object for number to search
* @return string Next free value
*/
function getNumRef($objsoc, $objforref)
public function getNumRef($objsoc, $objforref)
{
return $this->getNextValue($objsoc, $objforref);
}

View File

@ -44,10 +44,10 @@ class SupplierInvoices extends DolibarrApi
/**
* Constructor
*/
function __construct()
public function __construct()
{
global $db, $conf;
$this->db = $db;
global $db, $conf;
$this->db = $db;
$this->invoice = new FactureFournisseur($this->db);
}
@ -61,23 +61,23 @@ class SupplierInvoices extends DolibarrApi
*
* @throws RestException
*/
function get($id)
public function get($id)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Supplier invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice);
$this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice);
}
/**
@ -94,9 +94,9 @@ class SupplierInvoices extends DolibarrApi
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of invoice objects
*
* @throws RestException
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '')
{
global $db, $conf;
@ -120,7 +120,7 @@ class SupplierInvoices extends DolibarrApi
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Filter by status
// Filter by status
if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)";
if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)";
if ($status == 'paid') $sql.= " AND t.fk_statut IN (2)";
@ -137,7 +137,7 @@ class SupplierInvoices extends DolibarrApi
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
@ -182,7 +182,7 @@ class SupplierInvoices extends DolibarrApi
* @param array $request_data Request datas
* @return int ID of supplier invoice
*/
function post($request_data = null)
public function post($request_data = null)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401, "Insuffisant rights");
@ -218,7 +218,7 @@ class SupplierInvoices extends DolibarrApi
* @param array $request_data Datas
* @return int
*/
function put($id, $request_data = null)
public function put($id, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401);
@ -229,9 +229,9 @@ class SupplierInvoices extends DolibarrApi
throw new RestException(404, 'Supplier invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
if ($field == 'id') continue;
@ -250,7 +250,7 @@ class SupplierInvoices extends DolibarrApi
* @param int $id Supplier invoice ID
* @return type
*/
function delete($id)
public function delete($id)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) {
throw new RestException(401);
@ -260,9 +260,9 @@ class SupplierInvoices extends DolibarrApi
throw new RestException(404, 'Supplier invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( $this->invoice->delete(DolibarrApiAccess::$user) < 0)
{
@ -296,34 +296,34 @@ class SupplierInvoices extends DolibarrApi
* "notrigger": 0
* }
*/
function validate($id, $idwarehouse = 0, $notrigger = 0)
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger);
if ($result == 0) {
throw new RestException(304, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error);
}
$result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger);
if ($result == 0) {
throw new RestException(304, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Invoice validated (Ref='.$this->invoice->ref.')'
)
);
return array(
'success' => array(
'code' => 200,
'message' => 'Invoice validated (Ref='.$this->invoice->ref.')'
)
);
}
/**
@ -332,7 +332,7 @@ class SupplierInvoices extends DolibarrApi
* @param Object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object)
private function _cleanObjectDatas($object)
{
$object = parent::_cleanObjectDatas($object);
@ -354,7 +354,7 @@ class SupplierInvoices extends DolibarrApi
*
* @throws RestException
*/
function _validate($data)
private function _validate($data)
{
$invoice = array();
foreach (SupplierInvoices::$FIELDS as $field) {

View File

@ -44,7 +44,7 @@ class SupplierOrders extends DolibarrApi
/**
* Constructor
*/
function __construct()
public function __construct()
{
global $db, $conf;
$this->db = $db;
@ -61,7 +61,7 @@ class SupplierOrders extends DolibarrApi
*
* @throws RestException
*/
function get($id)
public function get($id)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) {
throw new RestException(401);
@ -96,7 +96,7 @@ class SupplierOrders extends DolibarrApi
*
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '')
{
global $db, $conf;
@ -187,7 +187,7 @@ class SupplierOrders extends DolibarrApi
* @param array $request_data Request datas
* @return int ID of supplier order
*/
function post($request_data = null)
public function post($request_data = null)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
throw new RestException(401, "Insuffisant rights");
@ -223,7 +223,7 @@ class SupplierOrders extends DolibarrApi
* @param array $request_data Datas
* @return int
*/
function put($id, $request_data = null)
public function put($id, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
throw new RestException(401);
@ -255,7 +255,7 @@ class SupplierOrders extends DolibarrApi
* @param int $id Supplier order ID
* @return type
*/
function delete($id)
public function delete($id)
{
if (! DolibarrApiAccess::$user->rights->fournisseur->commande->supprimer) {
throw new RestException(401);
@ -300,7 +300,7 @@ class SupplierOrders extends DolibarrApi
* "notrigger": 0
* }
*/
function validate($id, $idwarehouse = 0, $notrigger = 0)
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
throw new RestException(401);
@ -336,7 +336,7 @@ class SupplierOrders extends DolibarrApi
* @param Object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object)
private function _cleanObjectDatas($object)
{
$object = parent::_cleanObjectDatas($object);
@ -358,7 +358,7 @@ class SupplierOrders extends DolibarrApi
*
* @throws RestException
*/
function _validate($data)
private function _validate($data)
{
$order = array();
foreach (SupplierOrders::$FIELDS as $field) {

View File

@ -48,7 +48,7 @@ class PaiementFourn extends Paiement
public $picto = 'payment';
var $statut; //Status of payment. 0 = unvalidated; 1 = validated
public $statut; //Status of payment. 0 = unvalidated; 1 = validated
// fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...)
// fk_paiement dans llx_paiement_facture est le rowid du paiement
@ -69,7 +69,7 @@ class PaiementFourn extends Paiement
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
$this->db = $db;
}
@ -82,7 +82,7 @@ class PaiementFourn extends Paiement
* @param int $fk_bank Id of bank line associated to payment
* @return int <0 if KO, -2 if not found, >0 if OK
*/
function fetch($id, $ref = '', $fk_bank = '')
public function fetch($id, $ref = '', $fk_bank = '')
{
$error=0;
@ -146,7 +146,7 @@ class PaiementFourn extends Paiement
* @param Societe $thirdparty Thirdparty
* @return int id of created payment, < 0 if error
*/
function create($user, $closepaidinvoices = 0, $thirdparty = null)
public function create($user, $closepaidinvoices = 0, $thirdparty = null)
{
global $langs,$conf;
@ -319,7 +319,7 @@ class PaiementFourn extends Paiement
* @param int $notrigger No trigger
* @return int <0 si ko, >0 si ok
*/
function delete($notrigger = 0)
public function delete($notrigger = 0)
{
global $conf, $user, $langs;
@ -421,7 +421,7 @@ class PaiementFourn extends Paiement
* @param int $id Id du paiement dont il faut afficher les infos
* @return void
*/
function info($id)
public function info($id)
{
$sql = 'SELECT c.rowid, datec, fk_user_author as fk_user_creat, tms';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as c';
@ -465,7 +465,7 @@ class PaiementFourn extends Paiement
* @param string $filter SQL filter
* @return array Array of supplier invoice id
*/
function getBillsArray($filter = '')
public function getBillsArray($filter = '')
{
$sql = 'SELECT fk_facturefourn';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'facture_fourn as f';
@ -503,12 +503,12 @@ class PaiementFourn extends Paiement
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle
*/
function getLibStatut($mode = 0)
public function getLibStatut($mode = 0)
{
return $this->LibStatut($this->statut, $mode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@ -516,7 +516,7 @@ class PaiementFourn extends Paiement
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
*/
function LibStatut($status, $mode = 0)
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs;
@ -570,7 +570,7 @@ class PaiementFourn extends Paiement
* @param int $notooltip 1=Disable tooltip
* @return string Chaine avec URL
*/
function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0)
public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0)
{
global $langs;
@ -606,7 +606,7 @@ class PaiementFourn extends Paiement
* @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines
* @return void
*/
function initAsSpecimen($option = '')
public function initAsSpecimen($option = '')
{
global $user,$langs,$conf;
@ -631,7 +631,7 @@ class PaiementFourn extends Paiement
* @param string $mode 'next' for next value or 'last' for last value
* @return string free ref or last ref
*/
function getNextNumRef($soc, $mode = 'next')
public function getNextNumRef($soc, $mode = 'next')
{
global $conf, $db, $langs;
$langs->load("bills");
@ -755,7 +755,7 @@ class PaiementFourn extends Paiement
*
* @return string 'dolibarr' if standard comportment or paid in dolibarr currency, 'customer' if payment received from multicurrency inputs
*/
function getWay()
public function getWay()
{
global $conf;
@ -776,14 +776,14 @@ class PaiementFourn extends Paiement
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the third party of object, from id into this->thirdparty
*
* @param int $force_thirdparty_id Force thirdparty id
* @return int <0 if KO, >0 if OK
*/
function fetch_thirdparty($force_thirdparty_id = 0)
public function fetch_thirdparty($force_thirdparty_id = 0)
{
// phpcs:enable
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';