--- /dev/null
+<?php
+
+// Dans un controller
+
+namespace App\Controller;
+
+use App\Controller\AppController;
+use Cake\Network\Http\Client;
+
+/**
+ * CakePHP UsersController
+ * @author mpastor
+ */
+class UsersController extends AppController {
+
+ public function initialize()
+ {
+ parent::initialize();
+ $this->loadComponent('ComptoirServer');
+ }
+
+ /**
+ * Get all users as Administration
+ */
+ public function getUsersByType() {
+ try {
+ $http = new Client();
+ $response = $http->get(COMPTOIR_SRV_API . "users/getUsersByType", $this->request->query, ['type' => 'json']);
+ $users = $response->body('json_decode');
+ } catch (Exception $exception) {
+ $this->log(var_export($exception, true), "debug");
+ }
+
+ $this->set('users', $users->users);
+ }
+
+ public function view($id=null) {
+ $this->ComptoirServer->get(COMPTOIR_SRV_API . "users/view/" . $id, 'user', 'user');
+ }
+
+ public function index() {
+ $this->ComptoirServer->get(COMPTOIR_SRV_API . "users/administrationUsers/", 'users', 'users');
+ }
+
+
+ public function providers() {
+
+
+ try {
+ $http = new Client();
+
+ $response = $http->get(COMPTOIR_SRV_API . "users/servicesproviderUsers", [], ['type' => 'json']);
+
+ $users = $response->body('json_decode');
+ } catch (Exception $exception) {
+ $this->log(var_export($exception, true), "debug");
+ }
+ $this->set("users", $users);
+ //$this->set('_serialize', ['relationshipsSoftwaresUser']);
+ }
+
+ /**
+ * Get a list of softwares create by a specific user
+ */
+ public function creatorOf() {
+
+
+ try {
+ $http = new Client();
+
+ $response = $http->get(COMPTOIR_SRV_API . "relationships-softwares-users/getcreatorOf", $this->request->query, ['type' => 'json']);
+
+ $users = $response->body('json_decode');
+ } catch (Exception $exception) {
+ $this->log(var_export($exception, true), "debug");
+ }
+ $this->set("users", $users);
+ //$this->set('_serialize', ['relationshipsSoftwaresUser']);
+ }
+
+ public function Backedsoftwares ( $id=null ){
+ $this->ComptoirServer->get(COMPTOIR_SRV_API . "users/backedSoftwares/" . $id, 'user', 'user');
+
+ }
+
+ /**
+ * Get the relationships between softwares and users using the query parameters specified in the query body.
+ *
+ */
+ public function getRelationshipsSoftwaresUsers() {
+ try {
+ $http = new Client();
+
+ $response = $http->get(COMPTOIR_SRV_API . "relationships-softwares-users/getRelationshipsByUserId", $this->request->query, ['type' => 'json']);
+
+ $relationshipsSoftwaresUser = $response->body('json_decode');
+ } catch (Exception $exception) {
+ $this->log(var_export($exception, true), "debug");
+ }
+
+ $this->set("relationshipsSoftwaresUser", $relationshipsSoftwaresUser->relationshipsSoftwaresUsers);
+ $this->set('_serialize', ['relationshipsSoftwaresUser']);
+ }
+
+
+ public function usedSoftwares ( $id = null ){
+ $this->ComptoirServer->get(COMPTOIR_SRV_API . "users/usedSoftwares/" . $id, 'user', 'user');
+
+ }
+
+ public function Createdsoftwares ( $id=null ){
+
+ $this->ComptoirServer->get(COMPTOIR_SRV_API . "users/createdSoftwares/" . $id, 'user', 'user');
+ }
+
+ public function contributionsSoftwares ( $id=null ){
+ $this->ComptoirServer->get(COMPTOIR_SRV_API . "users/contributionsSoftwares/" . $id, 'user', 'user');
+ }
+
+ public function providerforSoftwares ( $id=null ){
+ $this->ComptoirServer->get(COMPTOIR_SRV_API . "users/providerforSoftwares/" . $id, 'user', 'user');
+ }
+
+}