Skip to content

Commit

Permalink
Merge pull request #14 from ticgal/develop
Browse files Browse the repository at this point in the history
Merge develop into main
  • Loading branch information
inesmv authored Feb 1, 2022
2 parents b2504b5 + 2dd972e commit e856b55
Show file tree
Hide file tree
Showing 25 changed files with 504 additions and 247 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# One-Time Secret GLPI Plugin CHANGELOG
## 1.1.1
### Features

### Bugfixes
- Copyright year replaced

## 1.1.0
### Features
- Added French and Arabic translations
### Bugfixes
- Fixed errors at secrets with special characters

## 1.0.1
### Feaures
### Features
- Open link in new window or tab
### Bugfixes
- Tweak Localazy integration to drop deprecated translations
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

Byemail
Copyright (C) 2021 TICgal / GLPIPlugins
Copyright (C) 2021-2022 TICgal / GLPIPlugins

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
Expand Down
6 changes: 3 additions & 3 deletions front/config.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
OneTimeSecret plugin for GLPI
Copyright (C) 2021 by the TICgal Team.
Copyright (C) 2021-2022 by the TICgal Team.
https://www.tic.gal
-------------------------------------------------------------------------
LICENSE
Expand All @@ -20,11 +20,11 @@
--------------------------------------------------------------------------
@package OneTimeSecret
@author the TICgal team
@copyright Copyright (c) 2021 TICgal team
@copyright Copyright (c) 2021-2022 TICgal team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://www.tic.gal
@since 2021
@since 2021-2022
----------------------------------------------------------------------
*/
include('../../../inc/includes.php');
Expand Down
6 changes: 3 additions & 3 deletions front/link.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
OneTimeSecret plugin for GLPI
Copyright (C) 2021 by the TICgal Team.
Copyright (C) 2021-2022 by the TICgal Team.
https://www.tic.gal
-------------------------------------------------------------------------
LICENSE
Expand All @@ -20,11 +20,11 @@
--------------------------------------------------------------------------
@package OneTimeSecret
@author the TICgal team
@copyright Copyright (c) 2021 TICgal team
@copyright Copyright (c) 2021-2022 TICgal team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://www.tic.gal
@since 2021
@since 2021-2022
----------------------------------------------------------------------
*/

Expand Down
6 changes: 3 additions & 3 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
OneTimeSecret plugin for GLPI
Copyright (C) 2021 by the TICgal Team.
Copyright (C) 2021-2022 by the TICgal Team.
https://www.tic.gal
-------------------------------------------------------------------------
LICENSE
Expand All @@ -20,11 +20,11 @@
--------------------------------------------------------------------------
@package OneTimeSecret
@author the TICgal team
@copyright Copyright (c) 2021 TICgal team
@copyright Copyright (c) 2021-2022 TICgal team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://www.tic.gal
@since 2021
@since 2021-2022
----------------------------------------------------------------------
*/
function plugin_onetimesecret_install() {
Expand Down
6 changes: 3 additions & 3 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
OneTimeSecret plugin for GLPI
Copyright (C) 2021 by the TICgal Team.
Copyright (C) 2021-2022 by the TICgal Team.
https://www.tic.gal
-------------------------------------------------------------------------
LICENSE
Expand All @@ -20,11 +20,11 @@
--------------------------------------------------------------------------
@package OneTimeSecret
@author the TICgal team
@copyright Copyright (c) 2021 TICgal team
@copyright Copyright (c) 2021-2022 TICgal team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://www.tic.gal
@since 2021
@since 2021-2022
----------------------------------------------------------------------
*/
if(!defined('GLPI_ROOT')) {
Expand Down
6 changes: 3 additions & 3 deletions inc/link.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
OneTimeSecret plugin for GLPI
Copyright (C) 2021 by the TICgal Team.
Copyright (C) 2021-2022 by the TICgal Team.
https://www.tic.gal
-------------------------------------------------------------------------
LICENSE
Expand All @@ -20,11 +20,11 @@
--------------------------------------------------------------------------
@package OneTimeSecret
@author the TICgal team
@copyright Copyright (c) 2021 TICgal team
@copyright Copyright (c) 2021-2022 TICgal team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://www.tic.gal
@since 2021
@since 2021-2022
----------------------------------------------------------------------
*/

Expand Down
6 changes: 3 additions & 3 deletions inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
OneTimeSecret plugin for GLPI
Copyright (C) 2021 by the TICgal Team.
Copyright (C) 2021-2022 by the TICgal Team.
https://www.tic.gal/
-------------------------------------------------------------------------
LICENSE
Expand All @@ -20,11 +20,11 @@
--------------------------------------------------------------------------
@package OneTimeSecret
@author the TICgal team
@copyright Copyright (c) 2021 TICgal team
@copyright Copyright (c) 2021-2022 TICgal team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://www.tic.gal/
@since 2021
@since 2021-2022
----------------------------------------------------------------------
*/

Expand Down
90 changes: 51 additions & 39 deletions inc/secret.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
OneTimeSecret plugin for GLPI
Copyright (C) 2021 by the TICgal Team.
Copyright (C) 2021-2022 by the TICgal Team.
https://www.tic.gal
-------------------------------------------------------------------------
LICENSE
Expand All @@ -20,11 +20,11 @@
--------------------------------------------------------------------------
@package OneTimeSecret
@author the TICgal team
@copyright Copyright (c) 2021 TICgal team
@copyright Copyright (c) 2021-2022 TICgal team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://www.tic.gal
@since 2021
@since 2021-2022
----------------------------------------------------------------------
*/

Expand All @@ -40,7 +40,7 @@ static function authentication(){
$config->getFromDB(1);

$curl = curl_init();
$server = "https://".$config->fields["email"] . ":" . Toolbox::sodiumDecrypt($config->fields["apikey"])."onetimesecret.com/api";
$server = "https://".$config->fields["email"] . ":" . Toolbox::sodiumDecrypt($config->fields["apikey"]).$config->fields["server"]."/api";

curl_setopt($curl, CURLOPT_URL, $server);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Expand Down Expand Up @@ -71,13 +71,14 @@ static function createSecret($params=[]) {

$curl = curl_init();

$post_fields = 'secret='.$params["password"].'&ttl='.self::hoursToSeconds($params["lifetime"]);
$post_fields = ['secret'=>$params["password"],
'ttl'=>self::hoursToSeconds($params["lifetime"])];
if($params["passphrase"]!=""){
$post_fields .= '&passphrase='.$params["passphrase"];
$post_fields ["passphrase"]= $params["passphrase"];
}

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://onetimesecret.com/api/v1/share',
CURLOPT_URL => 'https://'.$config->fields['server'].'/api/v1/share',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
Expand All @@ -90,20 +91,19 @@ static function createSecret($params=[]) {


CURLOPT_HTTPHEADER => array(
"Authorization: Basic " . base64_encode($config->fields["email"] . ":" . Toolbox::sodiumDecrypt($config->fields["apikey"])),
'Content-Type: application/x-www-form-urlencoded'
"Authorization: Basic " . base64_encode($config->fields["email"] . ":" . Toolbox::sodiumDecrypt($config->fields["apikey"]))
),
));

$response = curl_exec($curl);

curl_close($curl);

$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

$data = json_decode($response,true);

return "https://onetimesecret.com/secret/".$data["secret_key"];
return "https://".$config->fields["server"]."/secret/".$data["secret_key"];
}

static function hoursToSeconds($hours){
Expand All @@ -115,29 +115,7 @@ static function hoursToSeconds($hours){
static function addFollowup($params,$text='') {
global $DB, $CFG_GLPI;

//Switch to the desired language
$bak_language = $_SESSION["glpilanguage"];$bak_dropdowntranslations = (isset($_SESSION['glpi_dropdowntranslations']) ? $_SESSION['glpi_dropdowntranslations'] : null);

$query = [
'FROM'=>Ticket_User::getTable(),
'WHERE'=> [
'tickets_id' => $params["tickets_id"],
'type' => 1
]
];

foreach ($DB->request($query) as $ticket_user) {
$user = new User();
$user->getFromDB($ticket_user["users_id"]);
$lang = $user->fields["language"];
if($lang==null){
$lang=$CFG_GLPI["language"];
}
}

$_SESSION['glpi_dropdowntranslations'] = DropdownTranslation::getAvailableTranslations($lang);
Session::loadLanguage($lang);
$_SESSION["glpilanguage"] = $lang;

$query = [
'FROM'=>Ticket::getTable(),
Expand All @@ -162,13 +140,47 @@ static function addFollowup($params,$text='') {
$content .= "<li>".sprintf(__('This secret link will expire %1$s hours after its generation.','onetimesecret'),$params["lifetime"])."</li></ul>";
$content .= "<br>". __("Regards,",'onetimesecret');


$input = [
'items_id'=>$params["tickets_id"],
'itemtype'=>Ticket::getType(),
'content'=>$content,
'users_id'=> Session::getLoginUserID()
//Switch to the desired language
$bak_language = $_SESSION["glpilanguage"];$bak_dropdowntranslations = (isset($_SESSION['glpi_dropdowntranslations']) ? $_SESSION['glpi_dropdowntranslations'] : null);

$query = [
'FROM'=>Ticket_User::getTable(),
'WHERE'=> [
'tickets_id' => $params["tickets_id"],
'type' => 1
]
];
$input=[];
foreach ($DB->request($query) as $ticket_user) {
$user = new User();
$user->getFromDB($ticket_user["users_id"]);
$lang = $user->fields["language"];
if($lang==null){
$lang=$CFG_GLPI["language"];
}

if(Session::getLoginUserID()==$ticket_user["users_id"]){
$input = [
'items_id'=>$params["tickets_id"],
'itemtype'=>Ticket::getType(),
'content'=>$content,
'_status'=>Ticket::ASSIGNED,
'users_id'=> Session::getLoginUserID()
];
}else{
$input = [
'items_id'=>$params["tickets_id"],
'itemtype'=>Ticket::getType(),
'content'=>$content,
'users_id'=> Session::getLoginUserID()
];
}
}

$_SESSION['glpi_dropdowntranslations'] = DropdownTranslation::getAvailableTranslations($lang);
Session::loadLanguage($lang);
$_SESSION["glpilanguage"] = $lang;

$input=Toolbox::sanitize($input);
$fup->add($input);

Expand Down
Binary file added locales/ar_SA.mo
Binary file not shown.
Loading

0 comments on commit e856b55

Please sign in to comment.