From ffd7071448ccf323ac099f6fa1d6b905512e9a6b Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 11 May 2021 19:34:27 +0000 Subject: [PATCH] wip #4464 @1 --- .../DAO/class.common.dao.utilisateur.php | 2 + .../Metier/class.common.utilisateur.php | 1 + inc/commons/class.common.core.php | 2 +- inc/ws/Util/_common.php | 1 + inc/ws/Util/class.ws.ws3api.php | 45 +++++++++++++++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 inc/ws/Util/class.ws.ws3api.php diff --git a/inc/commons/DAO/class.common.dao.utilisateur.php b/inc/commons/DAO/class.common.dao.utilisateur.php index f10ff50e7..e690b849a 100644 --- a/inc/commons/DAO/class.common.dao.utilisateur.php +++ b/inc/commons/DAO/class.common.dao.utilisateur.php @@ -29,6 +29,7 @@ class commonDAOUtilisateur extends commonDAO $utilisateur->prenom = $r->prenom; $utilisateur->email = $r->email; $utilisateur->password = $r->password; + $utilisateur->api_token = $r->api_token; $utilisateur->ws_password = $r->ws_password; $utilisateur->adresse = $r->adresse; $utilisateur->code_postal = $r->code_postal; @@ -92,6 +93,7 @@ class commonDAOUtilisateur extends commonDAO $utilisateur->prenom = ''; $utilisateur->email = ''; $utilisateur->password = crypt::createPassword(); + $utilisateur->api_token= CubeIT_Crypt::generateRandomString(60); $utilisateur->adresse = ''; $utilisateur->code_postal = ''; $utilisateur->ville = ''; diff --git a/inc/commons/Metier/class.common.utilisateur.php b/inc/commons/Metier/class.common.utilisateur.php index 4e8ebf6d8..0414b8359 100644 --- a/inc/commons/Metier/class.common.utilisateur.php +++ b/inc/commons/Metier/class.common.utilisateur.php @@ -7,6 +7,7 @@ class commonUtilisateur extends cubeMetier { protected $email; protected $login; protected $password; + protected $api_token; protected $nom; protected $prenom; protected $adresse; diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index 31bf0feb1..85ffd59ef 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -534,7 +534,7 @@ class commonCore extends cubeCore } - $this->views->createView('e2_u', 'SELECT id AS utilisateur_id, enabled, email, password, e1_ws_password AS ws_password, firstname AS prenom, lastname AS nom, phone AS telephone,e1_mobile AS mobile,e1_fax as fax, locale AS lang, + $this->views->createView('e2_u', 'SELECT id AS utilisateur_id, enabled, email, password, api_token, e1_ws_password AS ws_password, firstname AS prenom, lastname AS nom, phone AS telephone,e1_mobile AS mobile,e1_fax as fax, locale AS lang, e1_ws_settings AS ws_settings, e1_settings AS settings, e1_ws_rights AS ws_rights, e1_ws_domains AS ws_domains, e1_ws_count AS ws_count, e1_login AS login,e1_grade AS grade,e1_resetpassword AS reset_password, JSON_UNQUOTE(address->"$.address") AS adresse, JSON_UNQUOTE(address->"$.postcode") AS code_postal, diff --git a/inc/ws/Util/_common.php b/inc/ws/Util/_common.php index 7104abd20..adc7eaf2e 100644 --- a/inc/ws/Util/_common.php +++ b/inc/ws/Util/_common.php @@ -11,5 +11,6 @@ $__autoload['wsExporter'] = __DIR__. '/class.ws.exporter.php'; $__autoload['wsPDFConvert'] = __DIR__. '/class.ws.pdf.convert.php'; $__autoload['wsUtil'] = __DIR__. '/class.ws.util.php'; $__autoload['wsArticles'] = __DIR__. '/class.ws.articles.php'; +$__autoload['ws3API'] = __DIR__. '/class.ws.ws3api.php'; $__autoload['wsHTML5'] = __DIR__. '/html5/class.ws.html5.php'; diff --git a/inc/ws/Util/class.ws.ws3api.php b/inc/ws/Util/class.ws.ws3api.php new file mode 100644 index 000000000..2ddaedd9f --- /dev/null +++ b/inc/ws/Util/class.ws.ws3api.php @@ -0,0 +1,45 @@ +restPost('fluidbook-theme', ['api_token' => $core->user->api_token, 'theme' => $this->_themeData($theme)]); + } + + public function updateTheme($theme) + { + global $core; + $this->restPut('fluidbook-theme/' . $theme->theme_id, ['api_token' => $core->user->api_token, 'theme' => $this->_themeData($theme)]); + } + + /** + * @param wsTheme $theme + */ + protected function _themeData($theme) + { + $data = []; + $data['theme_id'] = $theme->theme_id; + $data['proprietaire'] = $theme->proprietaire; + $data['nom'] = $theme->nom; + $data['parametres'] = $theme->parametres->toArray(); + + return $data; + } + +} \ No newline at end of file -- 2.39.5