diff --git a/FEATURES/65027 b/FEATURES/65027 new file mode 100644 index 0000000000000000000000000000000000000000..ede189b1bc8015f2b4e5455ac3aec6b55502df43 --- /dev/null +++ b/FEATURES/65027 @@ -0,0 +1,10 @@ + '65027' => + ['Label' => $this->_('[explo] [contractuel] connecteur Skilleos'), + 'Desc' => '', + 'Image' => '', + 'Video' => '', + 'Category' => '', + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => '', + 'Test' => '', + 'Date' => '2017-09-26'], \ No newline at end of file diff --git a/VERSIONS_WIP/65027 b/VERSIONS_WIP/65027 new file mode 100644 index 0000000000000000000000000000000000000000..7af85a929b15dc987a64e5efaa8a074466a73ab5 --- /dev/null +++ b/VERSIONS_WIP/65027 @@ -0,0 +1 @@ + - ticket #65027 : [explo] [contractuel] connecteur Skilleos \ No newline at end of file diff --git a/library/Class/WebService/SimpleWebClient.php b/library/Class/WebService/SimpleWebClient.php index 1e74842440cd7602778c2e32ba9e4d34f6539d86..6dc885fd0c71d382fcd6243564adcf7c3ae15622 100644 --- a/library/Class/WebService/SimpleWebClient.php +++ b/library/Class/WebService/SimpleWebClient.php @@ -27,9 +27,13 @@ class Class_WebService_SimpleWebClient { return Zend_Registry::get('httpClient'); } - public function open_url($url) { + + public function open_url($url,$headers = []) { + $httpClient = $this->getHttpClient(); $httpClient->resetParameters(); + if (count($headers)>0) + $httpClient->setHeaders($headers); $httpClient->setMethod(Zend_Http_Client::GET); $httpClient->setUri($url); $response = $httpClient->request(); diff --git a/library/digital_resources/Skilleos/Batch.php b/library/digital_resources/Skilleos/Batch.php new file mode 100644 index 0000000000000000000000000000000000000000..b9083a7c52c5284929f5724473b5feafed177c1c --- /dev/null +++ b/library/digital_resources/Skilleos/Batch.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Skilleos_Batch extends Class_DigitalResource_Batch { + +} +?> \ No newline at end of file diff --git a/library/digital_resources/Skilleos/Config.php b/library/digital_resources/Skilleos/Config.php new file mode 100644 index 0000000000000000000000000000000000000000..f9a5e50729de0134f8d3a527e0a8c3fe8a6c50c7 --- /dev/null +++ b/library/digital_resources/Skilleos/Config.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright (c) 2012-2016, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class Skilleos_Config extends Class_DigitalResource_Config { + + public function getConfig() { + return [ + 'DocTypeLabel' => $this->_('Cours en ligne Skilleos'), + 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à Skilleos'), + 'MenuLabel' => $this->_('Lien vers Skilleos'), + 'Introduction' => $this->_('Première plateforme de cours vidéo en ligne pour vos loisirs et votre vie professionnelle'), + 'NotAllowedMessage' => $this->_('Votre abonnement ne permet pas l\`accès à cette ressource.'), + + 'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/Skilleos', + 'Url' => 'http://www.skilleos.com/', + 'Icon' => 'http://bokeh-library-portal.org/userfiles/media/ressources_numeriques/skilleos.png', + + 'MailUrl' => 'https://skilleos.zendesk.com/hc/fr/requests/new', + + 'AdminVars' => [ + 'BIB_ID' => Class_AdminVar_Meta::newDefault($this->_('Identifiant fournit par Skilleos'))->bePrivate(), + 'CLIENT_ID' => Class_AdminVar_Meta::newDefault($this->_('Client_id fournit par Skilleos'))->bePrivate(), + 'CLIENT_SECRET' => Class_AdminVar_Meta::newDefault($this->_('client_secret fournit par Skilleos'))->bePrivate(), + ], + + 'SsoAction' => true, + 'Batch' => 'Skilleos_Batch', + 'Service' => 'Skilleos_Service', + 'ModuleMenu' => 'Skilleos_ModuleMenu', + ]; + } + + +/* public function getSsoUrl($user, $album = null) { + $link = new Skilleos_Link($user->getMail()); + return $link->url($album); + } +*/ + + + public function isEnabled() { + return 0 < $this->getAdminVar('BIB_ID'); + } +} diff --git a/library/digital_resources/Skilleos/Link.php b/library/digital_resources/Skilleos/Link.php new file mode 100644 index 0000000000000000000000000000000000000000..efa2b2cd3106245e9619e150314759a2480f2ec3 --- /dev/null +++ b/library/digital_resources/Skilleos/Link.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Skilleos_Link extends Skilleos_LinkAbstract { + const ROOT_URL = 'http://skilleos.com/sigb/sso/'; + + protected $_mail; + protected $_base_url; + + + public function __construct($mail) { + $this->_mail = ($mail) ? $mail : Class_Profil::getPortail()->getMailSiteOrPortail(); + } + + + public function url($album = null) { + $url = static::ROOT_URL + . $this->baseUrl() + . '&AccessHash=' . $this->accessHash(); + + if (!$album) + return $url; + + return $url . '&ReturnUrl=' . $this->_getReturnURL($album); + } + + + protected function accessHash() { + return sha1($this->baseUrl() . static::SHA1_KEY); + } + + + protected function baseUrl() { + if (null === $this->_base_url) + $this->_base_url = static::BASE_URL + . 'id_resource=' . $this->cryptedMail() + . '&id=' . Skilleos_Config::getInstance()->getAdminVar('ID') + ; + + return $this->_base_url; + } + + + protected function cryptedMail() { + return bin2hex(openssl_encrypt($this->_mail, 'aes-128-cbc', static::AES_KEY, true, static::AES_KEY)); + } +} +?> \ No newline at end of file diff --git a/library/digital_resources/Skilleos/ModuleMenu.php b/library/digital_resources/Skilleos/ModuleMenu.php new file mode 100644 index 0000000000000000000000000000000000000000..af78fdbaffb2a00742ac0031e959a9f198d5b6cf --- /dev/null +++ b/library/digital_resources/Skilleos/ModuleMenu.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Skilleos_ModuleMenu extends Class_DigitalResource_ModuleMenu {} +?> \ No newline at end of file diff --git a/library/digital_resources/Skilleos/Service.php b/library/digital_resources/Skilleos/Service.php new file mode 100644 index 0000000000000000000000000000000000000000..dcdf818c05c3e2ac856859db2527e4eab9aae47d --- /dev/null +++ b/library/digital_resources/Skilleos/Service.php @@ -0,0 +1,71 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Skilleos_Service extends Class_DigitalResource_Service { + protected $_parser, + $_albums = []; + protected static $REST_URL = 'http://moncompte.skilleos.com/rest/api/trainings'; + /* Fonction appelée à la fin du moissonnage pour supprimer les albums obsolètes. + La méthode $this->_getHarvestedIds(); vous permet de récupérer les identifiants des albums moissonnés. */ + protected function _deleteNonHarvested() { + return $this; + } + + + protected function getToken() { + return json_decode($this->httpGet('http://moncompte.skilleos.com/oauth/v2/token?grant_type=client_credentials&client_id='. Skilleos_Config::getInstance()->getAdminVar('CLIENT_ID')."&client_secret=".Skilleos_Config::getInstance()->getAdminVar('CLIENT_SECRET')))->access_token; + } + + + /* Fonction appelée par la mécanique de moissonnage. + C'est ici que le parser doit créer les albums */ + protected function loadPage($page_number = 1) { + $token = $this->getToken(); + $client = $this->getHttpClient(); + + $json = json_decode($client->open_url(static::$REST_URL, + [ + "User-Agent" => "Mozilla/5.0 Gecko/2010 Firefox/5", + 'Authorization' => 'Bearer '.$token])); + + foreach ($json as $result) { +// var_dump($result->lessons); +// exit; + + $this->_albums[] = new Skilleos_Service_Parser($result,$this); + + } +// $this->_parser->parseJson($json); + + + return $this; + } + + public function getPageCount() { + return $this->_page_count; + } + + public function getRessourcesNumeriques() { + return $this->_albums; + } +} +?> \ No newline at end of file diff --git a/library/digital_resources/Skilleos/Service/Parser.php b/library/digital_resources/Skilleos/Service/Parser.php new file mode 100644 index 0000000000000000000000000000000000000000..86ad63fec152e10aca1ed07b72a2920f22a6db97 --- /dev/null +++ b/library/digital_resources/Skilleos/Service/Parser.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Skilleos_Service_Parser extends Class_WebService_BibNumerique_RessourceNumerique { + public function __construct($json) { + $this->setId($json->id) + ->setTitle($json->name) + ->setExternalUri() + ->setTypeDocId(Skilleos_Config::getInstance()->getDocType()); + + $this->_lessons = []; + foreach ($json->lessons as $lesson) { + $current=new Class_AlbumRessource(); + $current->setTitre($lesson->name) + ->set + $this->_lessons[]=$current; + } + $this->setRessources($this->_lessons); + + } +} +?> \ No newline at end of file diff --git a/library/digital_resources/Skilleos/controllers/IndexController.php b/library/digital_resources/Skilleos/controllers/IndexController.php new file mode 100644 index 0000000000000000000000000000000000000000..98da9b30077a8dcd39f6d858d6704cb98e31be25 --- /dev/null +++ b/library/digital_resources/Skilleos/controllers/IndexController.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Skilleos_Plugin_IndexController extends Class_DigitalResource_Controller { + public function function_name() { + + } +} +?> \ No newline at end of file diff --git a/library/digital_resources/Skilleos/views/scripts/index/index.phtml b/library/digital_resources/Skilleos/views/scripts/index/index.phtml new file mode 100644 index 0000000000000000000000000000000000000000..84b24a2342e14a518bec06a2c64f3d28354143b6 --- /dev/null +++ b/library/digital_resources/Skilleos/views/scripts/index/index.phtml @@ -0,0 +1,3 @@ +<?php +echo $this->tag('p', + $this->_('Nombre d\'albums présents : %s',$this->records_count)); ?>