Skip to content

Commit

Permalink
fix: marketplace compatibility + bump version (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
flegastelois authored Jan 14, 2021
1 parent 3cedab1 commit d59094e
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 58 deletions.
2 changes: 1 addition & 1 deletion ajax/surveytranslation.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}

global $CFG_GLPI;
$redirection = $CFG_GLPI["root_doc"]."/plugins/satisfaction/front/survey.form.php?id=";
$redirection = Plugin::getWebDir('satisfaction')."/front/survey.form.php?id=";

$translation = new PluginSatisfactionSurveyTranslation();

Expand Down
22 changes: 11 additions & 11 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
function plugin_satisfaction_install() {
global $DB;

include_once(GLPI_ROOT . "/plugins/satisfaction/inc/profile.class.php");
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/notificationtargetticket.class.php");
include_once(Plugin::getPhpDir('satisfaction')."/inc/profile.class.php");
include_once(Plugin::getPhpDir('satisfaction')."/inc/notificationtargetticket.class.php");

if (!$DB->tableExists("glpi_plugin_satisfaction_surveys")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/empty-1.5.0.sql");
$DB->runFile(Plugin::getPhpDir('satisfaction')."/install/sql/empty-1.5.0.sql");

} else {
if (!$DB->fieldExists("glpi_plugin_satisfaction_surveyquestions", "type")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.1.0.sql");
$DB->runFile(Plugin::getPhpDir('satisfaction')."/install/sql/update-1.1.0.sql");
}
//version 1.2.1
if (!$DB->fieldExists("glpi_plugin_satisfaction_surveyquestions", "default_value")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.2.2.sql");
$DB->runFile(Plugin::getPhpDir('satisfaction')."/install/sql/update-1.2.2.sql");
}
//version 1.4.1
if (!$DB->tableExists("glpi_plugin_satisfaction_surveytranslations")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.4.1.sql");
$DB->runFile(Plugin::getPhpDir('satisfaction')."/install/sql/update-1.4.1.sql");
}

//version 1.4.3
if (!$DB->tableExists("glpi_plugin_satisfaction_surveyreminders")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.4.3.sql");
$DB->runFile(Plugin::getPhpDir('satisfaction')."/install/sql/update-1.4.3.sql");
}

//version 1.4.5
if (!$DB->fieldExists("glpi_plugin_satisfaction_surveys", "reminders_days")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.4.5.sql");
$DB->runFile(Plugin::getPhpDir('satisfaction')."/install/sql/update-1.4.5.sql");
}
}

Expand All @@ -50,9 +50,9 @@ function plugin_satisfaction_install() {
function plugin_satisfaction_uninstall() {
global $DB;

include_once(GLPI_ROOT . "/plugins/satisfaction/inc/profile.class.php");
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/menu.class.php");
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/notificationtargetticket.class.php");
include_once(Plugin::getPhpDir('satisfaction')."/inc/profile.class.php");
include_once(Plugin::getPhpDir('satisfaction')."/inc/menu.class.php");
include_once(Plugin::getPhpDir('satisfaction')."/inc/notificationtargetticket.class.php");

$tables = [
"glpi_plugin_satisfaction_surveys",
Expand Down
5 changes: 3 additions & 2 deletions inc/menu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ static function getMenuContent() {
$menu = [];

if (Session::haveRight('plugin_satisfaction', READ)) {
$web_dir = '/' . Plugin::getWebDir('satisfaction', false);
$menu['title'] = self::getMenuName();
$menu['page'] = "/plugins/satisfaction/front/survey.php";
$menu['page'] = "/plugins/satisfaction/front/survey.php";
$menu['page'] = $web_dir."/front/survey.php";
$menu['page'] = $web_dir."/front/survey.php";
$menu['links']['search'] = PluginSatisfactionSurvey::getSearchURL(false);
if (PluginSatisfactionSurvey::canCreate()) {
$menu['links']['add'] = PluginSatisfactionSurvey::getFormURL(false);
Expand Down
2 changes: 1 addition & 1 deletion inc/surveyquestion.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function showForm($ID, $options = []) {
Dropdown::showNumber('number', ['max' => 10,
'min' => 2,
'value' => $surveyquestion->fields['number'],
'on_change' => "plugin_satisfaction_load_defaultvalue(\"" . $CFG_GLPI['root_doc'] . "\", this.value);"]);
'on_change' => "plugin_satisfaction_load_defaultvalue(\"" . Plugin::getWebDir('satisfaction') . "\", this.value);"]);
echo "</td>";

if (!empty($surveyquestion->fields['number'])) {
Expand Down
2 changes: 1 addition & 1 deletion inc/surveyreminder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static function showSurvey(PluginSatisfactionSurvey $survey, $preview = false) {
self::PREDEFINED_REMINDER_OPTION_NAME => 1
];
Ajax::updateItemJsCode("viewreminder$sID$rand_survey",
$CFG_GLPI["root_doc"] . "/plugins/satisfaction/ajax/viewsubitem_reminder.php", $params);
Plugin::getWebDir('satisfaction') . "/ajax/viewsubitem_reminder.php", $params);
echo "};";

echo "</script>\n";
Expand Down
6 changes: 3 additions & 3 deletions inc/surveytranslation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static function showTranslations(PluginSatisfactionSurvey $item) {

$rand = mt_rand();
$canedit = $item->can($item->getID(), UPDATE);
$target = $CFG_GLPI["root_doc"]."/plugins/satisfaction/ajax/surveytranslation.form.php";
$target = Plugin::getWebDir('satisfaction')."/ajax/surveytranslation.form.php";

if ($canedit) {
echo "<div id='viewtranslation" . $item->getType().$item->getID() . "$rand'></div>\n";
Expand Down Expand Up @@ -209,7 +209,7 @@ static function showTranslations(PluginSatisfactionSurvey $item) {
'action' => 'GET'
];
Ajax::updateItemJsCode("viewtranslation" . $item->getType().$item->getID() . "$rand",
$CFG_GLPI["root_doc"]."/plugins/satisfaction/ajax/surveytranslation.form.php",
Plugin::getWebDir('satisfaction')."/ajax/surveytranslation.form.php",
$params);
echo "};";
echo "</script>\n";
Expand Down Expand Up @@ -358,7 +358,7 @@ function getQuestionDropdown($surveyId){
function getFormHeader($translationID, $surveyID){

global $CFG_GLPI;
$target = $CFG_GLPI["root_doc"]."/plugins/satisfaction/ajax/surveytranslation.form.php";
$target = Plugin::getWebDir('satisfaction')."/ajax/surveytranslation.form.php";

$result = "<form name='form' method='post' action='$target' enctype='multipart/form-data'>";
$result.= "<input type='hidden' name='survey_id' value='$surveyID'>";
Expand Down
2 changes: 1 addition & 1 deletion satisfaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function plugin_satisfaction_load_defaultvalue(root_doc, default_value){
}

$.ajax({
url: root_doc+'/plugins/satisfaction/ajax/satisfaction.php',
url: root_doc+'/ajax/satisfaction.php',
type: 'POST',
data: '&action_default_value&default_value='+ default_value + '&value=' + value,
dataType: 'html',
Expand Down
7 changes: 6 additions & 1 deletion satisfaction.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@
<author>Infotel</author>
</authors>
<versions>
<version>
<num>1.5.1</num>
<compatibility>~9.5.0</compatibility>
<download_url>https://github.com/pluginsGLPI/satisfaction/releases/download/1.5.1/glpi-satisfaction-1.5.1.tar.gz</download_url>
</version>
<version>
<num>1.5.0</num>
<compatibility>9.5</compatibility>
<compatibility>~9.5.0</compatibility>
</version>
<version>
<num>1.4.4</num>
Expand Down
55 changes: 18 additions & 37 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
* Init the hooks of the plugins -Needed
*/

define('PLUGIN_SATISFACTION_VERSION', '1.5.0');
define ("PLUGIN_SATISFACTION_VERSION", "1.5.1");

// Minimal GLPI version, inclusive
define('PLUGIN_SATISFACTION_MIN_GLPI', '9.5');
// Maximum GLPI version, exclusive
define('PLUGIN_SATISFACTION_MAX_GLPI', '9.6');

function plugin_init_satisfaction() {
global $PLUGIN_HOOKS;
Expand Down Expand Up @@ -61,41 +66,17 @@ function plugin_version_satisfaction() {

$author = "<a href='www.teclib.com'>TECLIB'</a>";
$author.= ", <a href='http://blogglpi.infotel.com/'>Infotel</a>";
return ['name' => __("More satisfaction", 'satisfaction'),
'version' => PLUGIN_SATISFACTION_VERSION,
'author' => $author,
'license' => 'GPLv2+',
'homepage' => 'https://github.com/pluginsGLPI/satisfaction',
'requirements' => [
'glpi' => [
'min' => '9.5',
'dev' => false
]
]
return [
'name' => __("More satisfaction", 'satisfaction'),
'version' => PLUGIN_SATISFACTION_VERSION,
'author' => $author,
'license' => 'GPLv2+',
'homepage' => 'https://github.com/pluginsGLPI/satisfaction',
'requirements' => [
'glpi' => [
'min' => PLUGIN_SATISFACTION_MIN_GLPI,
'max' => PLUGIN_SATISFACTION_MAX_GLPI,
]
]
];
}

/**
* Optional : check prerequisites before install : may print errors or add to message after redirect
*
* @return bool
*/
function plugin_satisfaction_check_prerequisites() {
if (version_compare(GLPI_VERSION, '9.5', 'lt')
|| version_compare(GLPI_VERSION, '9.6', 'ge')) {
if (method_exists('Plugin', 'messageIncompatible')) {
echo Plugin::messageIncompatible('core', '9.5');
}
return false;
}
return true;
}

/**
* Uninstall process for plugin : need to return true if succeeded : may display messages or add to message after redirect
*
* @return bool
*/
function plugin_satisfaction_check_config() {
return true;
}

0 comments on commit d59094e

Please sign in to comment.