From e87fb1c0dc80aedd63ef6565d31a8d0eee7ffaec Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 7 Jan 2022 12:19:03 +0100 Subject: [PATCH 1/3] add column into table inst --- htdocs/install/mysql/tables/llx_projet_task_time.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_projet_task_time.sql b/htdocs/install/mysql/tables/llx_projet_task_time.sql index 786d8907588..63eadb1177f 100644 --- a/htdocs/install/mysql/tables/llx_projet_task_time.sql +++ b/htdocs/install/mysql/tables/llx_projet_task_time.sql @@ -24,6 +24,7 @@ create table llx_projet_task_time task_datehour datetime, -- day + hour task_date_withhour integer DEFAULT 0, -- 0 by default, 1 if date was entered with start hour task_duration double, + fk_product integer NULL, fk_user integer, thm double(24,8), invoice_id integer DEFAULT NULL, -- If we need to invoice each line of timespent, we can save invoice id here From f5788bef669dfc72407e7237e6bc6927268071b3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 7 Jan 2022 12:20:27 +0100 Subject: [PATCH 2/3] OK BDD --- .../install/mysql/migration/15.0.0-16.0.0.sql | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 htdocs/install/mysql/migration/15.0.0-16.0.0.sql diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql new file mode 100644 index 00000000000..64df9ca79cb --- /dev/null +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -0,0 +1,34 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 14.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table; +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex; +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. +-- To rebuild sequence for postgresql after insert by forcing id autoincrement fields: +-- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); + + +-- Missing in v14 or lower +ALTER TABLE llx_projet_task_time ADD COLUMN fk_product integer NULL; From aa2b244bf399d6a56f1bff4c03772224e888b39e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 19 Jan 2022 13:31:51 +0100 Subject: [PATCH 3/3] fix wordpress indent --- .../OAuth/OAuth2/Service/WordPress.php | 153 ++++++++++-------- 1 file changed, 83 insertions(+), 70 deletions(-) diff --git a/htdocs/includes/OAuth/OAuth2/Service/WordPress.php b/htdocs/includes/OAuth/OAuth2/Service/WordPress.php index c59e90c605f..79a13d00e2d 100755 --- a/htdocs/includes/OAuth/OAuth2/Service/WordPress.php +++ b/htdocs/includes/OAuth/OAuth2/Service/WordPress.php @@ -11,87 +11,100 @@ use OAuth\Common\Http\Exception\TokenResponseException; use OAuth\OAuth2\Service\Exception\InvalidAccessTypeException; use OAuth\Common\Http\Uri\Uri; +/** + * Class For WordPress OAuth + */ class WordPress extends AbstractService { - protected $accessType = 'online'; + /** + * @var string + */ + protected $accessType = 'online'; - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true); + /** + * Construct + * + * @param CredentialsInterface $credentials credentials + * @param ClientInterface $httpClient httpClient + * @param TokenStorageInterface $storage storage + * @param $scopes scope + * @param UriInterface|null $baseApiUri baseApiUri + * @throws Exception\InvalidScopeException + */ + public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null) + { + parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true); - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://addresse_de_votre_site_wordpress'); - } - } -/* - // LDR CHANGE Add approval_prompt to force the prompt if value is set to 'force' so it force return of a "refresh token" in addition to "standard token" - public $approvalPrompt='auto'; - public function setApprouvalPrompt($prompt) - { - if (!in_array($prompt, array('auto', 'force'), true)) { - // @todo Maybe could we rename this exception - throw new InvalidAccessTypeException('Invalid approuvalPrompt, expected either auto or force.'); - } - $this->approvalPrompt = $prompt; - }*/ - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri(sprintf('%s/oauth/authorize', $this->baseApiUri)); - } + if (null === $baseApiUri) { + $this->baseApiUri = new Uri('https://addresse_de_votre_site_wordpress'); + } + } + /* + // LDR CHANGE Add approval_prompt to force the prompt if value is set to 'force' so it force return of a "refresh token" in addition to "standard token" + public $approvalPrompt='auto'; + public function setApprouvalPrompt($prompt) + { + if (!in_array($prompt, array('auto', 'force'), true)) { + // @todo Maybe could we rename this exception + throw new InvalidAccessTypeException('Invalid approuvalPrompt, expected either auto or force.'); + } + $this->approvalPrompt = $prompt; + }*/ - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri(sprintf('%s/oauth/token', $this->baseApiUri)); - } + /** + * @return Uri + */ + public function getAuthorizationEndpoint() + { + return new Uri(sprintf('%s/oauth/authorize', $this->baseApiUri)); + } - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - global $conf; - return empty($conf->global->OAUTH_WORDPRESS_AUTHORIZATION_METHOD_QUERY_STRING) ? static::AUTHORIZATION_METHOD_HEADER_BEARER : static::AUTHORIZATION_METHOD_QUERY_STRING; - } + /** + * @return Uri + */ + public function getAccessTokenEndpoint() + { + return new Uri(sprintf('%s/oauth/token', $this->baseApiUri)); + } - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); + /** + * @return int + */ + protected function getAuthorizationMethod() + { + global $conf; + return empty($conf->global->OAUTH_WORDPRESS_AUTHORIZATION_METHOD_QUERY_STRING) ? static::AUTHORIZATION_METHOD_HEADER_BEARER : static::AUTHORIZATION_METHOD_QUERY_STRING; + } - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response: "'.(isset($responseBody)?$responseBody:'NULL').'"'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '" : "'.$data['error_description'].'"'); - } + /** + * @param $responseBody responseBody + * @return StdOAuth2Token + * @throws TokenResponseException + */ + protected function parseAccessTokenResponse($responseBody) + { + $data = json_decode($responseBody, true); - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); + if (null === $data || !is_array($data)) { + throw new TokenResponseException('Unable to parse response: "'.(isset($responseBody)?$responseBody:'NULL').'"'); + } elseif (isset($data['error'])) { + throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '" : "'.$data['error_description'].'"'); + } - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } + $token = new StdOAuth2Token(); + $token->setAccessToken($data['access_token']); + $token->setLifetime($data['expires_in']); - unset($data['access_token']); - unset($data['expires_in']); + if (isset($data['refresh_token'])) { + $token->setRefreshToken($data['refresh_token']); + unset($data['refresh_token']); + } - $token->setExtraParams($data); + unset($data['access_token']); + unset($data['expires_in']); - return $token; - } + $token->setExtraParams($data); + + return $token; + } }