Commit last modules changes

e_collectivites-version
Romain_L 2 years ago
parent 78f7c571c0
commit cf9b8ba0e7
  1. 11
      api_glpi_pleiade/api_glpi_pleiade.info.yml
  2. 12
      api_glpi_pleiade/api_glpi_pleiade.libraries.yml
  3. 6
      api_glpi_pleiade/api_glpi_pleiade.links.menu.yml
  4. 32
      api_glpi_pleiade/api_glpi_pleiade.module
  5. 16
      api_glpi_pleiade/api_glpi_pleiade.routing.yml
  6. 0
      api_glpi_pleiade/css/api_glpi_pleiade.css
  7. 0
      api_glpi_pleiade/js/api_glpi_pleiade.js
  8. 26
      api_glpi_pleiade/src/Controller/GlpiController.php
  9. 72
      api_glpi_pleiade/src/Form/GlpiFields.php
  10. 7
      api_lemon_pleiade/css/api_lemon_pleiade.css
  11. 1
      api_lemon_pleiade/js/api_lemon_pleiade_desktop_blocks.js
  12. 12
      api_moodle_pleiade/api_moodle_pleiade.info.yml
  13. 12
      api_moodle_pleiade/api_moodle_pleiade.libraries.yml
  14. 6
      api_moodle_pleiade/api_moodle_pleiade.links.menu.yml
  15. 38
      api_moodle_pleiade/api_moodle_pleiade.module
  16. 16
      api_moodle_pleiade/api_moodle_pleiade.routing.yml
  17. 19
      api_moodle_pleiade/css/api_moodle_pleiade.css
  18. 107
      api_moodle_pleiade/js/api_moodle_pleiade.js
  19. 102
      api_moodle_pleiade/src/Controller/MoodleController.php
  20. 84
      api_moodle_pleiade/src/Form/MoodleFields.php
  21. 11
      api_parapheur_pleiade/src/Controller/PleiadeAjaxParapheurController.php
  22. 163
      api_parapheur_pleiade/src/IParapheurDataApiManager.php
  23. 4
      api_pastell_pleiade/api_pastell_pleiade.info.yml
  24. 1
      api_pastell_pleiade/api_pastell_pleiade.libraries.yml
  25. 14
      api_pastell_pleiade/js/api_pastell_entites.js
  26. 3
      api_user_pleiade/api_user_pleiade.info.yml
  27. 2
      api_user_pleiade/api_user_pleiade.libraries.yml
  28. 6
      api_user_pleiade/api_user_pleiade.module
  29. 69
      api_user_pleiade/css/api_user_pleiade.css
  30. 143
      api_user_pleiade/css/lib/slick.css
  31. 91
      api_user_pleiade/js/api_user_pleiade.js
  32. 1940
      api_user_pleiade/js/lib/slick.js
  33. 11
      api_user_pleiade/src/Controller/PleiadeUserController.php
  34. 26
      api_user_pleiade/src/Form/PleiadeUserFieldsConfig.php
  35. 4
      api_zimbra_pleiade/api_zimbra_pleiade.info.yml
  36. 59
      module_api_pleiade/src/ApiPleiadeManager.php

@ -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);
}
}

@ -1,5 +1,5 @@
#menuTestLemon2 .sidebar-link {
padding: 2px 0 0 8px;
#menuTestLemon2 .sidebar-link, #menuPastell .sidebar-link {
padding: 2px 0 0 14px!important;
display: flex;
white-space: nowrap;
align-items: center;
@ -23,3 +23,6 @@
align-items: center;
white-space: nowrap;
}
.accordion-body {
padding: 0rem 0rem 0rem 0!important;
}

@ -46,6 +46,7 @@
}
// ajout du html dans la div du bloc lemon du thème au lieu du spinner
document.getElementById("lemon_block_id").innerHTML = blocLemon;
}
};
xhr.onerror = function () {

@ -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);
}
}

@ -3,22 +3,21 @@
namespace Drupal\api_parapheur_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\api_parapheur_pleiade\IParapheurDataApiManager;
use Drupal\module_api_pleiade\ApiPleiadeManager;
class PleiadeAjaxParapheurController extends ControllerBase {
public function parapheur_entities_query(Request $request){
$return = []; //our variable to fill with data returned by Parapheur
$parapheurdataApi = new IParapheurDataApiManager();
$parapheurdataApi = new ApiPleiadeManager();
$return = $parapheurdataApi->searchMyDesktop();
return new JsonResponse(json_encode($return), 200, [], true);
if($return){
return new JsonResponse(json_encode($return), 200, [], true);
}
}
}

@ -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);
}
}
}

@ -7,10 +7,6 @@ package: Pleiade
core: 8.x
core_version_requirement: ^8 || ^9
dependencies:
- api_lemon_pleiade
- module_api_pleiade
# Information
version: '1.0.x-dev'
project: 'api_pastell_pleiade'

@ -4,6 +4,7 @@ api_pastell_pleiade_js:
js/api_pastell_entites.js: {}
js/libs/moment.js: {}
js/api_pastell_documents.js: {}
# js/api_pastell_menu.js: {}
js/libs/jquery.dataTables.min.js: {}
js/libs/dataTables.bootstrap5.min.js: {}

@ -9,13 +9,13 @@
function () {
// le nom du groupe LDAP pour pastell doit etre renseigné dans l'admin
// check si existe + si dans le Drupal tempstore stocké par le module Lemon Pléiade
var pastellLDAPGroup = drupalSettings.api_pastell_pleiade.field_pastell_ldap_group;
var userGroupsTempstore = drupalSettings.api_lemon_pleiade.user_groups;
// console.log('Pastell ldap group from Pastell Pléiade setting: ' + pastellLDAPGroup);
// console.log('Drupal tempstore groups from Lemon Pléiade module: ' + userGroupsTempstore);
// var pastellLDAPGroup = drupalSettings.api_pastell_pleiade.field_pastell_ldap_group;
// var userGroupsTempstore = drupalSettings.api_lemon_pleiade.user_groups;
// // console.log('Pastell ldap group from Pastell Pléiade setting: ' + pastellLDAPGroup);
// // console.log('Drupal tempstore groups from Lemon Pléiade module: ' + userGroupsTempstore);
// Call only if pastell group set and in private tempstore user_groups
if (pastellLDAPGroup && userGroupsTempstore.includes(pastellLDAPGroup)) {
// // Call only if pastell group set and in private tempstore user_groups
// if (pastellLDAPGroup && userGroupsTempstore.includes(pastellLDAPGroup)) {
// prepare menu
var linkEntitie = document.getElementById("collectiviteChoice");
// make ajax call
@ -121,7 +121,7 @@
};
xhr.send();
} // end if pastell group & in tempstore
// } // end if pastell group & in tempstore
}); // end once
} // fin only on frontpage
},

@ -6,9 +6,6 @@ package: Pleiade
core: 8.x
core_version_requirement: ^8 || ^9
dependencies:
- module_api_pleiade
# Information
version: '1.0.x-dev'
project: 'api_user_pleiade'

@ -3,6 +3,7 @@ api_user_pleiade_js:
js:
js/api_user_pleiade.js: {}
js/lib/steptip.js: {}
js/lib/slick.js: {}
dependencies:
- core/drupal
- core/once
@ -11,3 +12,4 @@ api_user_pleiade_css:
css:
theme:
css/api_user_pleiade.css: {}
css/lib/slick.css: {}

@ -15,6 +15,9 @@ function api_user_pleiade_preprocess_page(&$variables){
$config = \Drupal::config('api_user_pleiade.settings');
$have_chatbot = $config->get('have_chatbot');
$apiKey = $config->get('apiKey');
$bot_id = $config->get('bot_id');
//Add the JS library
$variables['#attached']['library'][] = 'api_user_pleiade/api_user_pleiade_js';
@ -22,5 +25,8 @@ function api_user_pleiade_preprocess_page(&$variables){
$variables['#attached']['library'][] = 'api_user_pleiade/api_user_pleiade_css';
$variables['#attached']['drupalSettings']['api_user_pleiade']['have_chatbot'] = $have_chatbot;
$variables['#attached']['drupalSettings']['api_user_pleiade']['apiKey'] = $apiKey;
$variables['#attached']['drupalSettings']['api_user_pleiade']['bot_id'] = $bot_id;
}

@ -1,10 +1,18 @@
.alert_popup svg:hover {
/* .alert_popup svg:hover {
transform: scale(1.3);
/* (150% zoom - Note: if the zoom is too large, it will go outside of the viewport) */
}
.alert_popup svg {
} */
/* .alert_popup svg {
transition: transform .2s;
} */
.notification_scale{
animation: pulse 1s infinite ease-in-out alternate;
}
@keyframes pulse {
from { transform: scale(0.2); }
to { transform: scale(1.9); }
}
#notification_alert .feather {
@ -485,3 +493,56 @@ tr.introjs-showElement>th {
z-index: 1;
opacity: 0
}
#sntch_button{
right: 20px!important;
bottom: 20px!important;
padding: 25px!important;
animation: bounce 2s infinite ease-in-out;
-webkit-animation: bounce 2s infinite ease-in-out;
-moz-animation: bounce 2s infinite ease-in-out;
-o-animation: bounce 2s infinite ease-in-out;
animation-iteration-count: 5;
}
@-webkit-keyframes bounce {
0%, 20%, 50%, 80%, 100% {-webkit-transform: translateY(0);}
40% {-webkit-transform: translateY(-20px);}
60% {-webkit-transform: translateY(-15px);}
}
@-moz-keyframes bounce {
0%, 20%, 50%, 80%, 100% {-moz-transform: translateY(0);}
40% {-moz-transform: translateY(-20px);}
60% {-moz-transform: translateY(-15px);}
}
@-o-keyframes bounce {
0%, 20%, 50%, 80%, 100% {-o-transform: translateY(0);}
40% {-o-transform: translateY(-20px);}
60% {-o-transform: translateY(-15px);}
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
40% {transform: translateY(-20px);}
60% {transform: translateY(-15px);}
}
.btn-accessibility_a-plus {
font-size: 22px;
vertical-align: baseline!important;
}
.btn-accessibility_a-less {
vertical-align: baseline!important;
}
body[data-theme=dark] .btn-accessibility{
color: #FFF!important;
}
.btn-accessibility {
background: none!important;
color: #1f3889!important;
border: none!important;
padding: 0!important;
}

@ -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
}

@ -3,10 +3,72 @@
Drupal.behaviors.APIzimbraUserInfoBehavior = {
attach: function (context, settings) {
// Load on front page only,
// ajout diminution and augmentation de la taille de la police
if (drupalSettings.path.isFront) {
once("APIzimbraUserInfoBehavior", "body", context).forEach(function () {
// requete
// Augmenter la taille des polices
var increaseBtn = document.getElementById("increase-btn");
var decreaseBtn = document.getElementById("decrease-btn");
function toggleAccordion() {
const extendedMenu = localStorage.getItem('extended_menu');
if (extendedMenu !== null) {
const input = document.querySelector('input[name="extended_menu"]');
input.setAttribute('checked', 'checked');
console.log('ok');
const accordionCollapses = document.querySelectorAll('.accordion-collapse');
for (let i = 0; i < accordionCollapses.length; i++) {
accordionCollapses[i].classList.toggle('show');
}
}
}
function handleCheckboxChange() {
const checkbox = document.querySelector('input[name="extended_menu"]');
const accordionCollapses = document.querySelectorAll('.accordion-collapse');
if (checkbox.checked) {
localStorage.setItem('extended_menu', true);
for (let i = 0; i < accordionCollapses.length; i++) {
accordionCollapses[i].classList.add('show');
}
} else {
localStorage.removeItem('extended_menu');
for (let i = 0; i < accordionCollapses.length; i++) {
accordionCollapses[i].classList.remove('show');
}
}
}
window.addEventListener('load', toggleAccordion);
const checkbox = document.querySelector('input[name="extended_menu"]');
checkbox.addEventListener('change', handleCheckboxChange);
// Add event listeners to the buttons
increaseBtn.addEventListener("click", function() {
var el = document.body;
var style = window.getComputedStyle(el, null).getPropertyValue('font-size');
var style_up = window.getComputedStyle(increaseBtn, null).getPropertyValue('font-size');
var fontSize = parseFloat(style);
var fontSizeUp = parseFloat(style_up);
console.log(style_up)
el.style.fontSize = (fontSize + 3) + 'px';
increaseBtn.style.fontSize = (fontSizeUp + 3) + 'px';
decreaseBtn.style.fontSize = (fontSize + 3) + 'px';
});
decreaseBtn.addEventListener("click", function() {
var el = document.body;
var style = window.getComputedStyle(el, null).getPropertyValue('font-size');
var style_down = window.getComputedStyle(decreaseBtn, null).getPropertyValue('font-size');
var style_up = window.getComputedStyle(increaseBtn, null).getPropertyValue('font-size');
var fontSize = parseFloat(style);
var fontSizeDown = parseFloat(style_down);
var fontSizeUp = parseFloat(style_up);
console.log(fontSize)
el.style.fontSize = (fontSize - 3) + 'px';
decreaseBtn.style.fontSize = (fontSizeDown - 3) + 'px';
increaseBtn.style.fontSize = (fontSizeUp - 3) + 'px';
});
var xhr = new XMLHttpRequest();
xhr.open("GET", Drupal.url("v1/api_user_pleiade/user_infos_query"));
xhr.responseType = "json";
@ -21,6 +83,7 @@
var oneHourAgo = now + (60 * 60);
// get notification_alert div
const div = document.querySelector('#notification_alert');
const div_chatbot = document.querySelector('.page-wrapper');
//console.log(oneHourAgo);
if(donnees && div){
@ -32,6 +95,7 @@
const div_alert = document.querySelector('.alert_popup'); // add svg with red point
if(div_alert)
{
div_alert.classList.add("notification_scale");
div_alert.innerHTML += '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="25" height="25" viewBox="0 0 24 24" fill="none"stroke="currentColor" stroke-width="2" xml:space="preserve" style="cursor: pointer;"><defs></defs><g transform="matrix(1 0 0 1 12 12)" ><g style=""><g transform="matrix(1 0 0 1 0 -2.5)" ><path style="stroke: #1f3889; stroke-width: 2; stroke-dasharray: none; stroke-linecap: round; stroke-dashoffset: 0; stroke-linejoin: round; stroke-miterlimit: 4; fill: none; fill-rule: nonzero; opacity: 1;" transform=" translate(-12, -9.5)" d="M 18 8 A 6 6 0 0 0 6 8 c 0 7 -3 9 -3 9 h 18 s -3 -2 -3 -9" stroke-linecap="round" /></g><g transform="matrix(1 0 0 1 0 9.5)" ><path style="stroke: #1f3889; stroke-width: 2; stroke-dasharray: none; stroke-linecap: round; stroke-dashoffset: 0; stroke-linejoin: round; stroke-miterlimit: 4; fill: none; fill-rule: nonzero; opacity: 1;" transform=" translate(-12, -21.5)" d="M 13.73 21 a 2 2 0 0 1 -3.46 0" stroke-linecap="round" /></g></g></g><g transform="matrix(0.07 0 0 0.07 19.5 3.33)" ><circle style="stroke: rgb(255,0,0); stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(255,0,0); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" cx="0" cy="0" r="40" /></g></svg>';
}
for (var i = 0; i < donnees.length; i++) {
@ -80,11 +144,7 @@
</div>\
<div class="dropdown-divider"></a>';
}
else if( donnees[i].hasOwnProperty("want_chatbot") ) { // if notification is iparapheur
document.body.innerHTML += '<script src="https://account.snatchbot.me/script.js"></script><script>window.sntchChat.Init(321742)</script>';
}
}
}
else // if no notification
@ -111,8 +171,22 @@
xhr.send();
}); // fin once function
//ajout guide interactif
// // Get the checkbox element and the collapse element
// function toggleAccordion() {
// const extendedMenu = localStorage.getItem('extended_menu');
// if (extendedMenu !== null) {
// const input = document.querySelector('input[name="extended_menu"]');
// input.setAttribute('checked', 'checked');
// console.log('ok');
// const accordionCollapses = document.querySelectorAll('.accordion-collapse');
// for (let i = 0; i < accordionCollapses.length; i++) {
// accordionCollapses[i].classList.toggle('show');
// }
// }
// }
// window.addEventListener('load', toggleAccordion);
//ajout guide interactif
document.getElementById("interactive_guid").addEventListener("click", function(){
introJs().setOptions({
showProgress: true,
@ -124,11 +198,14 @@
intro: "En cliquant sur les menus, vous pouvez ici accéder à vos différents applicatifs."
}, {
element: document.querySelector('#lemon_block_id'),
intro: "Vous pouvez également accéder aux applicatifs en cliquand sur les différents blocs.",
intro: "Vous pouvez également accéder aux applicatifs en cliquant sur les différents blocs.",
position: 'right'
}, {
element: document.querySelector('#collectiviteChoice'),
intro: "Si vous appartenez à plusieurs entitées, vous pouvez choisir celle que vous souhaitez ici. "
}, {
element: document.querySelector('.box-accessibility'),
intro: "Si vous avez des problèmes de vue, Vous pouvez augmenter la police ou la diminuer ici. "
}, {
element: document.querySelector('.alert_popup'),
intro: "Si vous avez des notifications, elles apparaîtront ici. "

File diff suppressed because it is too large Load Diff

@ -20,8 +20,6 @@ class PleiadeUserController extends ControllerBase {
$this->settings_user = \Drupal::config('api_user_pleiade.settings');
}
}
public function user_list_query(Request $request){
@ -76,18 +74,17 @@ class PleiadeUserController extends ControllerBase {
public function user_infos_query(Request $request){
$users_infos = [];
$userdataApi = new ApiPleiadeManager();
$return = $_COOKIE['nbOfMails'];
$return_tasks = json_decode($userdataApi->searchIfUserHaveSoonTasks(), true);
$return_iparapheur = json_decode($userdataApi->searchIfUserHaveParapheurDocs(), true);
$want_Chatbot = $this->settings_user->get('have_chatbot');
// Load the user storage service.
if($want_Chatbot){
$have_chatbot = $this->settings_user->get('have_chatbot');
if($have_chatbot){
$users_infos[] = array(
"want_chatbot" => true
"have_chatbot" => true
);
}

@ -37,7 +37,28 @@ class PleiadeUserFieldsConfig extends ConfigFormBase {
'#title' => $this->t('Assistant Virtuel ?'),
'#default_value' => $config->get('have_chatbot'),
];
];
$form['apiKey'] = [
'#type' => 'textfield',
'#title' => $this->t('Clé Api SnatchBot ( Si activé )'),
'#default_value' => $config->get('apiKey'),
];
$form['apiKey']['#states'] = [
'visible' => [
':input[name="have_chatbot"]' => ['checked' => TRUE],
],
];
$form['bot_id'] = [
'#type' => 'textfield',
'#title' => $this->t('ID bot SnatchBot ( Si activé )'),
'#default_value' => $config->get('bot_id'),
];
$form['bot_id']['#states'] = [
'visible' => [
':input[name="have_chatbot"]' => ['checked' => TRUE],
],
];
return parent::buildForm($form, $form_state);
}
@ -49,6 +70,9 @@ class PleiadeUserFieldsConfig extends ConfigFormBase {
// Retrieve the configuration.
$config = $this->config('api_user_pleiade.settings');
$config->set('have_chatbot', $form_state->getValue('have_chatbot'));
$config->set('apiKey', $form_state->getValue('apiKey'));
$config->set('bot_id', $form_state->getValue('bot_id'));
$config->save();
parent::submitForm($form, $form_state);

@ -7,10 +7,6 @@ package: Pleiade
core: 8.x
core_version_requirement: ^8 || ^9
dependencies:
- api_lemon_pleiade
- module_api_pleiade
# Information
version: '1.0.x-dev'
project: 'api_zimbra_pleiade'

@ -216,9 +216,62 @@ class ApiPleiadeManager {
////////////////////////////////////////////////////////
elseif($application =='parapheur')
elseif($application == 'parapheur')
{
if( $this->settings_parapheur->get('field_parapheur_auth_method') == 'cas' || $this->settings_parapheur->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 service 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']
],
];
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, $PARAPHEUR_AP_URL , $options);
$body = $clientRequest->getBody()->getContents();
} catch (RequestException $e) {
\Drupal::logger('api_parapheur_pleiade')->error('Curl error: @error', ['@error' => $e->getMessage()]);
}
return Json::encode('A configurer');
// return Json::decode($body);
// }
}
}
/**
@ -362,9 +415,9 @@ class ApiPleiadeManager {
public function searchMyDesktop() {
$endpoints = $this->settings_parapheur->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_parapheur->get('field_parapheur_url') . $this->settings_parapheur->get('field_parapheur_bureaux_url'), 'parapheur');
return $this->curlGet([], [], $this->settings_parapheur->get('field_parapheur_url') . $this->settings_parapheur->get('field_parapheur_bureaux_url'), 'parapheur');
}
/**

Loading…
Cancel
Save