parent
78f7c571c0
commit
cf9b8ba0e7
@ -0,0 +1,11 @@ |
||||
name: API Pléiade GLPI |
||||
type: module |
||||
description: 'API For gets tickets of GLPI instance' |
||||
package: Pleiade |
||||
core: 8.x |
||||
core_version_requirement: ^8 || ^9 |
||||
|
||||
# Information |
||||
version: '1.0.x-dev' |
||||
project: 'api_glpi_pleiade' |
||||
datestamp: 1624364473 |
@ -0,0 +1,12 @@ |
||||
api_glpi_pleiade_js: |
||||
version: 1.x |
||||
js: |
||||
js/api_glpi_pleiade.js: {} |
||||
dependencies: |
||||
- core/drupal |
||||
- core/once |
||||
api_glpi_pleiade_css: |
||||
version: 1.x |
||||
css: |
||||
theme: |
||||
css/api_glpi_pleiade.css: {} |
@ -0,0 +1,6 @@ |
||||
api_glpi_pleiade.admin: |
||||
title: 'API Pléiade - GLPI module settings' |
||||
description: 'Page de configuration du module GLPI Pléiade' |
||||
parent: pleiade.group.admin |
||||
route_name: api_glpi_pleiade.settings |
||||
weight: 2 |
@ -0,0 +1,32 @@ |
||||
<?php |
||||
|
||||
|
||||
/** |
||||
* quick check modules orders of execution (default all zero) |
||||
* As e must be sure this one fires after our main lemon modules |
||||
* see https://davidjguru.github.io/blog/drupal-tips-altering-order-of-execution-in-resources |
||||
*/ |
||||
|
||||
|
||||
/** |
||||
* @param $variables |
||||
*/ |
||||
function api_glpi_pleiade_preprocess_page(&$variables){ |
||||
|
||||
$config = \Drupal::config('api_glpi_pleiade.settings'); |
||||
$glpi_url = $config->get('glpi_url'); |
||||
$app_token = $config->get('app_token'); |
||||
$bot_id = $config->get('endpoint_ticket'); |
||||
|
||||
|
||||
//Add the JS library |
||||
$variables['#attached']['library'][] = 'api_glpi_pleiade/api_glpi_pleiade_js'; |
||||
//Add the CSS library |
||||
$variables['#attached']['library'][] = 'api_glpi_pleiade/api_glpi_pleiade_css'; |
||||
|
||||
$variables['#attached']['drupalSettings']['api_glpi_pleiade']['glpi_url'] = $glpi_url; |
||||
$variables['#attached']['drupalSettings']['api_glpi_pleiade']['app_token'] = $app_token; |
||||
$variables['#attached']['drupalSettings']['api_glpi_pleiade']['endpoint_ticket'] = $endpoint_ticket; |
||||
|
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
api_glpi_pleiade.settings: |
||||
path: '/admin/config/api_glpi_pleiade/settings' |
||||
defaults: |
||||
_form: '\Drupal\api_glpi_pleiade\Form\GlpiFields' |
||||
_title: 'GLPI Pléiade Settings' |
||||
requirements: |
||||
_permission: 'administer site configuration' |
||||
|
||||
api_glpi_pleiade.glpi_list_tickets: |
||||
path: '/v1/api_glpi_pleiade/glpi_list_tickets' |
||||
defaults: |
||||
_controller: '\Drupal\api_glpi_pleiade\Controller\GlpiController::glpi_list_tickets' |
||||
_title: 'Tickets Query' |
||||
_format: json |
||||
requirements: |
||||
_access: 'TRUE' |
@ -0,0 +1,26 @@ |
||||
<?php |
||||
|
||||
namespace Drupal\api_glpi_pleiade\Controller; |
||||
|
||||
use Drupal\Core\Controller\ControllerBase; |
||||
|
||||
use Drupal\Component\Serialization\JSON; |
||||
use Symfony\Component\HttpFoundation\RedirectResponse; |
||||
use Symfony\Component\HttpFoundation\JsonResponse; |
||||
use Symfony\Component\HttpFoundation\Request; |
||||
use Drupal\user\Entity\UserInterface; |
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface; |
||||
|
||||
|
||||
class GlpiController extends ControllerBase { |
||||
|
||||
public function __construct() { |
||||
$moduleHandler = \Drupal::service('module_handler'); |
||||
if ($moduleHandler->moduleExists('api_glpi_pleiade')) { |
||||
$this->settings_glpi = \Drupal::config('api_glpi_pleiade.settings'); |
||||
} |
||||
} |
||||
public function glpi_list_tickets(Request $request){ |
||||
|
||||
} |
||||
} |
@ -0,0 +1,72 @@ |
||||
<?php |
||||
|
||||
namespace Drupal\api_glpi_pleiade\Form; |
||||
|
||||
use Drupal\Core\Form\ConfigFormBase; |
||||
use Drupal\Core\Form\FormStateInterface; |
||||
|
||||
/** |
||||
* Configure API Pléiade Pastell fields settings. |
||||
*/ |
||||
class GlpiFields extends ConfigFormBase { |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getFormId() { |
||||
return 'api_glpi_pleiade_config_form'; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function getEditableConfigNames() { |
||||
return [ |
||||
'api_glpi_pleiade.settings' |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function buildForm(array $form, FormStateInterface $form_state) { |
||||
$config = $this->config('api_glpi_pleiade.settings'); |
||||
|
||||
$form['glpi_url'] = [ |
||||
'#type' => 'textfield', |
||||
'#title' => $this->t('Url de l\'instance GLPI'), |
||||
'#default_value' => $config->get('glpi_url'), |
||||
|
||||
]; |
||||
$form['app_token'] = [ |
||||
'#type' => 'textfield', |
||||
'#title' => $this->t('Token Api ( Configuration -> Générale -> API -> client API )'), |
||||
'#default_value' => $config->get('app_token'), |
||||
]; |
||||
|
||||
$form['endpoint_ticket'] = [ |
||||
'#type' => 'textfield', |
||||
'#title' => $this->t('Endpoint Url For tickets'), |
||||
'#default_value' => $config->get('endpoint_ticket'), |
||||
]; |
||||
|
||||
|
||||
return parent::buildForm($form, $form_state); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function submitForm(array &$form, FormStateInterface $form_state) { |
||||
// Retrieve the configuration. |
||||
$config = $this->config('api_glpi_pleiade.settings'); |
||||
$config->set('glpi_url', $form_state->getValue('glpi_url')); |
||||
$config->set('app_token', $form_state->getValue('app_token')); |
||||
$config->set('endpoint_ticket', $form_state->getValue('endpoint_ticket')); |
||||
|
||||
$config->save(); |
||||
|
||||
parent::submitForm($form, $form_state); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,12 @@ |
||||
name: API Pléiade Moodle Infos |
||||
type: module |
||||
description: 'API To get entities of Moodle for Pléiade' |
||||
# package: Pleiade User Infos |
||||
package: Pleiade |
||||
core: 8.x |
||||
core_version_requirement: ^8 || ^9 |
||||
|
||||
# Information |
||||
version: '1.0.x-dev' |
||||
project: 'api_moodle_pleiade' |
||||
datestamp: 1624364473 |
@ -0,0 +1,12 @@ |
||||
api_moodle_pleiade_js: |
||||
version: 1.x |
||||
js: |
||||
js/api_moodle_pleiade.js: {} |
||||
dependencies: |
||||
- core/drupal |
||||
- core/once |
||||
api_moodle_pleiade_css: |
||||
version: 1.x |
||||
css: |
||||
theme: |
||||
css/api_moodle_pleiade.css: {} |
@ -0,0 +1,6 @@ |
||||
api_moodle_pleiade.admin: |
||||
title: 'API Pléiade - Moodle module settings' |
||||
description: 'Page de configuration du odule Moodle Pléiade' |
||||
parent: pleiade.group.admin |
||||
route_name: api_moodle_pleiade.settings |
||||
weight: 12 |
@ -0,0 +1,38 @@ |
||||
<?php |
||||
|
||||
|
||||
/** |
||||
* quick check modules orders of execution (default all zero) |
||||
* As e must be sure this one fires after our main lemon modules |
||||
* see https://davidjguru.github.io/blog/drupal-tips-altering-order-of-execution-in-resources |
||||
*/ |
||||
|
||||
|
||||
/** |
||||
* @param $variables |
||||
*/ |
||||
function api_moodle_pleiade_preprocess_page(&$variables){ |
||||
|
||||
$config = \Drupal::config('api_moodle_pleiade.settings'); |
||||
$moodle_url = $config->get('moodle_url'); |
||||
$username_moodle = $config->get('username_moodle'); |
||||
$password_moodle = $config->get('password_moodle'); |
||||
$function_moodle = $config->get('function_moodle'); |
||||
$services_moodle = $config->get('services_moodle'); |
||||
|
||||
|
||||
//Add the JS library |
||||
$variables['#attached']['library'][] = 'api_moodle_pleiade/api_moodle_pleiade_js'; |
||||
//Add the CSS library |
||||
$variables['#attached']['library'][] = 'api_moodle_pleiade/api_moodle_pleiade_css'; |
||||
|
||||
$variables['#attached']['drupalSettings']['api_moodle_pleiade']['moodle_url'] = $moodle_url; |
||||
$variables['#attached']['drupalSettings']['api_moodle_pleiade'] = [ |
||||
'moodle_url' => $moodle_url, |
||||
'username_moodle' => $username_moodle, |
||||
'password_moodle' => $password_moodle, |
||||
'function_moodle' => $function_moodle, |
||||
'services_moodle' => $services_moodle, |
||||
]; |
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
api_moodle_pleiade.settings: |
||||
path: '/admin/config/api_moodle_pleiade/settings' |
||||
defaults: |
||||
_form: '\Drupal\api_moodle_pleiade\Form\MoodleFields' |
||||
_title: 'moodle Pléiade Settings' |
||||
requirements: |
||||
_permission: 'administer site configuration' |
||||
|
||||
api_moodle_pleiade.moodle_entities: |
||||
path: '/v1/api_moodle_pleiade/moodle_entities' |
||||
defaults: |
||||
_controller: '\Drupal\api_moodle_pleiade\Controller\MoodleController::moodle_entities' |
||||
_title: 'moodle Query' |
||||
_format: json |
||||
requirements: |
||||
_access: 'TRUE' |
@ -0,0 +1,19 @@ |
||||
.btn-e-coll{ |
||||
background-color: #1f3889!important; |
||||
|
||||
} |
||||
.card-img-top { |
||||
width: 300px!important; |
||||
max-width: 300px!important; |
||||
height: 200px; |
||||
object-fit: cover; |
||||
} |
||||
#moodle_courses .card{ |
||||
box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important; |
||||
margin-bottom: 1rem!important; |
||||
} |
||||
|
||||
#moodle_courses p{ |
||||
margin: 0 0 0 0!important; |
||||
|
||||
} |
@ -0,0 +1,107 @@ |
||||
(function (Drupal, once, drupalSettings) { |
||||
"use strict"; |
||||
Drupal.behaviors.APIMoodleBehavior = { |
||||
attach: function (context, settings) { |
||||
|
||||
if (drupalSettings.path.isFront) { |
||||
once("APIMoodleBehavior", "body", context).forEach(function () { |
||||
|
||||
var xhr = new XMLHttpRequest(); |
||||
xhr.open("GET", Drupal.url("v1/api_moodle_pleiade/moodle_entities")); |
||||
xhr.responseType = "json"; |
||||
xhr.onload = function () { |
||||
if (xhr.status === 200) { |
||||
|
||||
var donnees = (xhr.response); |
||||
const div = document.querySelector('#moodle_courses');
|
||||
var blocMoodle = "" |
||||
if(donnees && div) |
||||
{
|
||||
|
||||
blocMoodle += '<div class="col-lg-12">\ |
||||
<div class="shadow-lg">\ |
||||
<div class="card mb-2">\ |
||||
<div class="card-header rounded-top bg-white border-bottom rounded-top">\ |
||||
<h4 class="card-title text-dark py-2">Cours E-Learning d\'E-collectivités</h4></div>\ |
||||
<div class="d-flex justify-content-evenly mx-2">\ |
||||
' |
||||
var count_entities = donnees.length - 1 |
||||
var usedNumbers = [1]; |
||||
for (var i = 0; i < 3; i++) { |
||||
var number = Math.floor(Math.random() * count_entities + 1); |
||||
if (usedNumbers.includes(number)) { |
||||
// Number is already used, decrement the loop index to try again
|
||||
i--; |
||||
}
|
||||
else
|
||||
{ |
||||
usedNumbers.push(number); |
||||
|
||||
if(donnees[number].overviewfiles[0]) |
||||
{ |
||||
if(donnees[number].overviewfiles[0].fileurl) |
||||
{ |
||||
var imageurl = donnees[number].overviewfiles[0].fileurl |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
var imageurl = "https://ecollectivites.fr/sites/default/files/inline-images/logo-ecollectivites.jpg" |
||||
} |
||||
if(donnees[number].categoryname) |
||||
{ |
||||
var categoryCourse = donnees[number].categoryname |
||||
} |
||||
else |
||||
{ |
||||
var categoryCourse= "" |
||||
} |
||||
|
||||
|
||||
if(number !== 0){ |
||||
blocMoodle +=
|
||||
'<a href="https://preprod.ecollectivites.fr/moodle/course/view.php?id='+ donnees[number].id +'">\ |
||||
<div class="mt-3 d-flex justify-content-center">\ |
||||
<div class="card">\ |
||||
<img src="'+ imageurl +'" class="card-img-top" alt="Course Image">\ |
||||
<div class="card-body d-flex flex-column">\ |
||||
<h5 class="card-title d-flex justify-content-center">'+ categoryCourse +'</h5>\ |
||||
<p class="d-flex align-items-center justify-content-center btn mt-auto btn-e-coll text-white w-100">Voir ce cours</p>\ |
||||
</div>\ |
||||
</div>\ |
||||
</div>\ |
||||
</a>'; |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
||||
blocMoodle += "</div></div></div></div>"; |
||||
} |
||||
else // if no notification
|
||||
{ |
||||
|
||||
} |
||||
document.getElementById("moodle_courses").innerHTML = |
||||
blocMoodle; |
||||
} |
||||
}; |
||||
xhr.onerror = function () { |
||||
console.log("Error making AJAX call"); |
||||
}; |
||||
xhr.onabort = function () { |
||||
console.log("AJAX call aborted"); |
||||
}; |
||||
xhr.ontimeout = function () { |
||||
console.log("AJAX call timed out"); |
||||
}; |
||||
xhr.onloadend = function () { |
||||
|
||||
}; |
||||
|
||||
xhr.send(); |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
})(Drupal, once, drupalSettings); |
@ -0,0 +1,102 @@ |
||||
<?php |
||||
|
||||
namespace Drupal\api_moodle_pleiade\Controller; |
||||
|
||||
use Drupal\Core\Controller\ControllerBase; |
||||
use Symfony\Component\HttpFoundation\JsonResponse; |
||||
use Symfony\Component\HttpFoundation\Request; |
||||
use Drupal\user\Entity\UserInterface; |
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface; |
||||
|
||||
|
||||
class MoodleController extends ControllerBase { |
||||
|
||||
public function __construct() { |
||||
$moduleHandler = \Drupal::service('module_handler'); |
||||
if ($moduleHandler->moduleExists('api_moodle_pleiade')) { |
||||
$this->settings_moodle = \Drupal::config('api_moodle_pleiade.settings'); |
||||
} |
||||
} |
||||
public function moodle_entities(Request $request) { |
||||
$this->client = \Drupal::httpClient(); |
||||
$moodle_url = $this->settings_moodle->get('moodle_url'); |
||||
$username_moodle = $this->settings_moodle->get('username_moodle'); |
||||
$password_moodle = $this->settings_moodle->get('password_moodle'); |
||||
$function_moodle = $this->settings_moodle->get('function_moodle'); |
||||
$services_moodle = $this->settings_moodle->get('services_moodle'); |
||||
|
||||
$moodleUrl = $moodle_url.'/login/token.php?username='.$username_moodle.'&password='.$password_moodle.'&service='.$services_moodle; |
||||
|
||||
// Set parameters for retrieving all courses |
||||
$requestParams = [ |
||||
'headers' => [], |
||||
]; |
||||
|
||||
// Make the request |
||||
$clientRequest = $this->client->request('POST', $moodleUrl, $requestParams); |
||||
$json_string = $clientRequest->getBody()->getContents(); |
||||
$data = json_decode($json_string, true); |
||||
$token = $data['token']; |
||||
|
||||
$this->client = \Drupal::httpClient(); |
||||
|
||||
if ($token !== null) { |
||||
// Return the response in JSON format |
||||
$moodleUrl1 = $moodle_url.'/webservice/rest/server.php?wstoken='.$token.'&wsfunction='.$function_moodle.'&moodlewsrestformat=json'; |
||||
|
||||
// Set parameters for retrieving all courses |
||||
$requestParams1 = [ |
||||
'headers' => [], |
||||
]; |
||||
|
||||
// Make the request |
||||
$clientRequest1 = $this->client->request('POST', $moodleUrl1, $requestParams1); |
||||
|
||||
$response = $clientRequest1->getBody()->getContents(); |
||||
$array_courses = json_decode($response)->courses; |
||||
|
||||
foreach($array_courses as $courses){ |
||||
$fileurl = $courses->overviewfiles[0]->fileurl; |
||||
|
||||
if($fileurl){ |
||||
$requestParams4 = [ |
||||
'headers' => [ |
||||
"Content-Type" => "image/jpeg" |
||||
], |
||||
]; |
||||
$clientRequest4 = $this->client->request('GET', $fileurl.'?token=146b998e4049174242a38f4b9a71b271', $requestParams4); |
||||
$base = $clientRequest4->getBody()->getContents(); |
||||
$base64 = base64_encode($base); |
||||
$mime = "image/jpeg"; |
||||
$img = ('data:' . $mime . ';base64,' . $base64); |
||||
|
||||
$courses->overviewfiles[0]->fileurl = $img; |
||||
} |
||||
} |
||||
|
||||
// $moodleUrl4 = 'https://preprod.ecollectivites.fr/moodle/webservice/pluginfile.php/26/course/overviewfiles/zimbra-logo-611x378.jpg?token=146b998e4049174242a38f4b9a71b271'; |
||||
// // Make the request |
||||
// $clientRequest4 = $this->client->request('GET', $moodleUrl4, $requestParams4); |
||||
// $base = $clientRequest4->getBody()->getContents(); |
||||
// $base64 = base64_encode($base); |
||||
// $mime = "image/jpeg"; |
||||
// $img = ('data:' . $mime . ';base64,' . $base64); |
||||
|
||||
if ($response !== null) |
||||
{ |
||||
// Return the response in JSON format |
||||
return new JsonResponse(json_encode($array_courses), 200, [], true); |
||||
} |
||||
else |
||||
{ |
||||
// Handle the case where the response is null |
||||
return new JsonResponse(['error' => 'Response is null'], 400); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
// Handle the case where the response is null |
||||
return new JsonResponse(['error' => 'Response is null'], 400); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,84 @@ |
||||
<?php |
||||
|
||||
namespace Drupal\api_moodle_pleiade\Form; |
||||
|
||||
use Drupal\Core\Form\ConfigFormBase; |
||||
use Drupal\Core\Form\FormStateInterface; |
||||
|
||||
/** |
||||
* Configure API Pléiade Pastell fields settings. |
||||
*/ |
||||
class MoodleFields extends ConfigFormBase { |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getFormId() { |
||||
return 'api_moodle_pleiade_config_form'; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function getEditableConfigNames() { |
||||
return [ |
||||
'api_moodle_pleiade.settings' |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function buildForm(array $form, FormStateInterface $form_state) { |
||||
$config = $this->config('api_moodle_pleiade.settings'); |
||||
|
||||
$form['moodle_url'] = [ |
||||
'#type' => 'textfield', |
||||
'#title' => $this->t('Url Moodle'), |
||||
'#default_value' => $config->get('moodle_url'), |
||||
]; |
||||
$form['username_moodle'] = [ |
||||
'#type' => 'textfield', |
||||
'#title' => $this->t('Moodle Username'), |
||||
'#default_value' => $config->get('username_moodle'), |
||||
]; |
||||
|
||||
$form['password_moodle'] = [ |
||||
'#type' => 'password', |
||||
'#title' => $this->t('Moodle Password'), |
||||
'#default_value' => $config->get('password_moodle'), |
||||
]; |
||||
|
||||
$form['function_moodle'] = [ |
||||
'#type' => 'textfield', |
||||
'#title' => $this->t('Moodle Function'), |
||||
'#default_value' => $config->get('function_moodle'), |
||||
]; |
||||
|
||||
$form['services_moodle'] = [ |
||||
'#type' => 'textfield', |
||||
'#title' => $this->t('Moodle Services'), |
||||
'#default_value' => $config->get('services_moodle'), |
||||
]; |
||||
return parent::buildForm($form, $form_state); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function submitForm(array &$form, FormStateInterface $form_state) { |
||||
// Retrieve the configuration. |
||||
$config = $this->config('api_moodle_pleiade.settings'); |
||||
$config->set('moodle_url', $form_state->getValue('moodle_url')); |
||||
$config->set('username_moodle', $form_state->getValue('username_moodle')); |
||||
$config->set('password_moodle', $form_state->getValue('password_moodle')); |
||||
$config->set('function_moodle', $form_state->getValue('function_moodle')); |
||||
$config->set('services_moodle', $form_state->getValue('services_moodle')); |
||||
|
||||
|
||||
$config->save(); |
||||
|
||||
parent::submitForm($form, $form_state); |
||||
} |
||||
|
||||
} |
@ -1,163 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace Drupal\api_parapheur_pleiade; |
||||
|
||||
use Drupal\Component\Serialization\Json; |
||||
use GuzzleHttp\Exception\RequestException; |
||||
use Drupal\cas\Service\CasProxyHelper; |
||||
|
||||
/** |
||||
* Basic manager of module. |
||||
*/ |
||||
class IParapheurDataApiManager { |
||||
|
||||
/** |
||||
* Drupal's settings manager. |
||||
*/ |
||||
protected $settings; |
||||
|
||||
public $client; |
||||
/** |
||||
* Constructor. |
||||
*/ |
||||
public function __construct() { |
||||
if (!isset($_COOKIE['lemonldap'])) { |
||||
$msg = 'Pas authentifié dans le SSO Lemon'; |
||||
\Drupal::logger('api_parapheur_pleiade')->error($msg); |
||||
return; |
||||
} |
||||
$this->client = \Drupal::httpClient(); |
||||
// get our custom module settings |
||||
$this->settings = \Drupal::config('api_parapheur_pleiade.settings'); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Do CURL request with authorization. |
||||
* |
||||
* @param string $endpoint |
||||
* A request action of api. |
||||
* @param string $method |
||||
* A method of curl request. |
||||
* @param Array $inputs |
||||
* A data of curl request. |
||||
* |
||||
* @return array |
||||
* An associate array with respond data. |
||||
*/ |
||||
private function executeCurl($endpoint, $method, $inputs, $api) { |
||||
if (!isset($_COOKIE['lemonldap'])) { |
||||
$msg = 'Pas authentifié dans le SSO '; |
||||
\Drupal::logger('api_parapheur_pleiade')->error($msg); |
||||
return NULL; |
||||
} |
||||
if( $this->settings->get('field_parapheur_auth_method') == 'cas' || $this->settings->get('field_parapheur_auth_method') == 'oidc'){ |
||||
$PARAPHEUR_AP_URL = $api . '?auth=cas'; |
||||
} |
||||
else |
||||
{ |
||||
$PARAPHEUR_AP_URL = $api; |
||||
} |
||||
|
||||
// ProxyTicket |
||||
|
||||
// TEST |
||||
// $PT_request_url = 'https://iparapheurdev.ecollectivites.fr/iparapheur/proxy/alfresco/parapheur/bureaux?auth=cas'; |
||||
|
||||
// On utilise le sergvice du module CAS Drupal\cas\Service\CasProxyHelper; |
||||
$proxy_ticket = \Drupal::service('cas.proxy_helper')->getProxyTicket($PT_request_url); |
||||
// $PARAPHEUR_AP_URL = $PT_request_url . '&ticket=' . $proxy_ticket; |
||||
|
||||
// $PARAPHEUR_AP_URL = 'https://iparapheurdev.ecollectivites.fr/iparapheur/proxy/alfresco/parapheur/bureaux?auth=cas&ticket='.$proxy_ticket; |
||||
// $PARAPHEUR_AP_URL = ' https://iparapheurdev.ecollectivites.fr/'; |
||||
|
||||
$options = [ |
||||
'headers' => [ |
||||
'Content-Type' => 'application/json', |
||||
'Cookie'=> 'llnglanguage=fr; lemonldap=' . $_COOKIE['lemonldap'] |
||||
], |
||||
]; |
||||
$method = 'POST'; |
||||
|
||||
if (!empty($inputs)) { |
||||
|
||||
if($method == 'GET'){ |
||||
$PARAPHEUR_AP_URL.= '?' . self::arrayKeyfirst($inputs) . '=' . array_shift($inputs); |
||||
foreach($inputs as $param => $value){ |
||||
$PARAPHEUR_AP_URL.= '&' . $param . '=' . $value; |
||||
} |
||||
}else{ |
||||
//POST request send data in array index form_params. |
||||
$options['body'] = $inputs; |
||||
} |
||||
} |
||||
|
||||
try { |
||||
$clientRequest = $this->client->request($method, 'https://idtest.ecollectivites.fr/remote.php/dav/files/pleiade1%40formation/', $options); |
||||
|
||||
$body = $clientRequest->getBody()->getContents(); |
||||
|
||||
} catch (RequestException $e) { |
||||
\Drupal::logger('api_parapheur_pleiade')->error('Curl error: @error', ['@error' => $e->getMessage()]); |
||||
} |
||||
|
||||
var_dump($body); |
||||
return Json::decode($body); |
||||
} |
||||
|
||||
/** |
||||
* Get Request of API. |
||||
* |
||||
* @param string $endpoint |
||||
* A request action. |
||||
* @param string $input |
||||
* A data of curl request. |
||||
* |
||||
* @return array |
||||
* A respond data. |
||||
*/ |
||||
public function curlGet($endpoint, $inputs, $api) { |
||||
return $this->executeCurl($endpoint, "GET", $inputs, $api); |
||||
} |
||||
|
||||
/** |
||||
* Post Request of API. |
||||
* |
||||
* @param string $endpoint |
||||
* A request action. |
||||
* @param string $inputs |
||||
* A data of curl request. |
||||
* |
||||
* @return array |
||||
* A respond data. |
||||
*/ |
||||
public function curlPost($endpoint, $inputs, $api) { |
||||
return $this->executeCurl($endpoint, "POST", $inputs, $api); |
||||
} |
||||
|
||||
public function searchMyDesktop() { |
||||
$endpoints = $this->settings->get('field_parapheur_bureaux_url'); // Endpoint myapplications de Lemon qui renvoie toutes nos apps |
||||
// \Drupal::logger('api_parapheur_documents')->info('function searchMyApps triggered !'); |
||||
return $this->curlGet($endpoints, [], $this->settings->get('field_parapheur_url') . $this->settings->get('field_parapheur_bureaux_url')); |
||||
} |
||||
|
||||
/** |
||||
* Function to return first element of the array, compatability with PHP 5, note that array_key_first is only available for PHP > 7.3. |
||||
* |
||||
* @param array $array |
||||
* Associative array. |
||||
* |
||||
* @return string |
||||
* The first key data. |
||||
*/ |
||||
public static function arrayKeyfirst($array){ |
||||
if (!function_exists('array_key_first')) { |
||||
foreach($array as $key => $unused) { |
||||
return $key; |
||||
} |
||||
return NULL; |
||||
}else{ |
||||
return array_key_first($array); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,143 @@ |
||||
|
||||
.slick-dots, .slick-next, .slick-prev { |
||||
position: absolute; |
||||
display: block; |
||||
padding: 0 |
||||
} |
||||
|
||||
.slick-dots li button:before, .slick-next:before, .slick-prev:before { |
||||
font-family: slick; |
||||
-webkit-font-smoothing: antialiased; |
||||
-moz-osx-font-smoothing: grayscale |
||||
} |
||||
|
||||
|
||||
.slick-next, .slick-prev { |
||||
font-size: 0; |
||||
line-height: 0; |
||||
top: 50%; |
||||
width: 20px; |
||||
height: 20px; |
||||
margin-top: -10px\9; |
||||
-webkit-transform: translate(0, -50%); |
||||
-ms-transform: translate(0, -50%); |
||||
transform: translate(0, -50%); |
||||
cursor: pointer; |
||||
color: transparent; |
||||
border: none; |
||||
outline: 0; |
||||
background: 0 0 |
||||
} |
||||
|
||||
.slick-next:focus, .slick-next:hover, .slick-prev:focus, .slick-prev:hover { |
||||
color: transparent; |
||||
outline: 0; |
||||
background: 0 0 |
||||
} |
||||
|
||||
.slick-next:focus:before, .slick-next:hover:before, .slick-prev:focus:before, .slick-prev:hover:before { |
||||
opacity: 1 |
||||
} |
||||
|
||||
.slick-next.slick-disabled:before, .slick-prev.slick-disabled:before { |
||||
opacity: .25 |
||||
} |
||||
|
||||
.slick-next:before, .slick-prev:before { |
||||
font-size: 20px; |
||||
line-height: 1; |
||||
opacity: .75; |
||||
color: #fff |
||||
} |
||||
|
||||
.slick-prev { |
||||
left: -25px |
||||
} |
||||
|
||||
[dir=rtl] .slick-prev { |
||||
right: -25px; |
||||
left: auto |
||||
} |
||||
|
||||
.slick-prev:before { |
||||
content: '←' |
||||
} |
||||
|
||||
.slick-next:before, [dir=rtl] .slick-prev:before { |
||||
content: '→' |
||||
} |
||||
|
||||
.slick-next { |
||||
right: -25px |
||||
} |
||||
|
||||
[dir=rtl] .slick-next { |
||||
right: auto; |
||||
left: -25px |
||||
} |
||||
|
||||
[dir=rtl] .slick-next:before { |
||||
content: '←' |
||||
} |
||||
|
||||
.slick-slider { |
||||
margin-bottom: 30px |
||||
} |
||||
|
||||
.slick-dots { |
||||
bottom: -45px; |
||||
width: 100%; |
||||
list-style: none; |
||||
text-align: center |
||||
} |
||||
|
||||
.slick-dots li { |
||||
position: relative; |
||||
display: inline-block; |
||||
width: 20px; |
||||
height: 20px; |
||||
margin: 0 5px; |
||||
padding: 0; |
||||
cursor: pointer |
||||
} |
||||
|
||||
.slick-dots li button { |
||||
font-size: 0; |
||||
line-height: 0; |
||||
display: block; |
||||
width: 20px; |
||||
height: 20px; |
||||
padding: 5px; |
||||
cursor: pointer; |
||||
color: transparent; |
||||
border: 0; |
||||
outline: 0; |
||||
background: 0 0 |
||||
} |
||||
|
||||
.slick-dots li button:focus, .slick-dots li button:hover { |
||||
outline: 0 |
||||
} |
||||
|
||||
.slick-dots li button:focus:before, .slick-dots li button:hover:before { |
||||
opacity: 1 |
||||
} |
||||
|
||||
.slick-dots li button:before { |
||||
font-size: 6px; |
||||
line-height: 20px; |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
width: 20px; |
||||
height: 20px; |
||||
content: '•'; |
||||
text-align: center; |
||||
opacity: .25; |
||||
color: #000 |
||||
} |
||||
|
||||
.slick-dots li.slick-active button:before { |
||||
opacity: .75; |
||||
color: #000 |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue