Skip to content

Commit d59094e

Browse files
authored
fix: marketplace compatibility + bump version (#25)
1 parent 3cedab1 commit d59094e

File tree

9 files changed

+45
-58
lines changed

9 files changed

+45
-58
lines changed

ajax/surveytranslation.form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838

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

4242
$translation = new PluginSatisfactionSurveyTranslation();
4343

hook.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@
66
function plugin_satisfaction_install() {
77
global $DB;
88

9-
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/profile.class.php");
10-
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/notificationtargetticket.class.php");
9+
include_once(Plugin::getPhpDir('satisfaction')."/inc/profile.class.php");
10+
include_once(Plugin::getPhpDir('satisfaction')."/inc/notificationtargetticket.class.php");
1111

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

1515
} else {
1616
if (!$DB->fieldExists("glpi_plugin_satisfaction_surveyquestions", "type")) {
17-
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.1.0.sql");
17+
$DB->runFile(Plugin::getPhpDir('satisfaction')."/install/sql/update-1.1.0.sql");
1818
}
1919
//version 1.2.1
2020
if (!$DB->fieldExists("glpi_plugin_satisfaction_surveyquestions", "default_value")) {
21-
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.2.2.sql");
21+
$DB->runFile(Plugin::getPhpDir('satisfaction')."/install/sql/update-1.2.2.sql");
2222
}
2323
//version 1.4.1
2424
if (!$DB->tableExists("glpi_plugin_satisfaction_surveytranslations")) {
25-
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.4.1.sql");
25+
$DB->runFile(Plugin::getPhpDir('satisfaction')."/install/sql/update-1.4.1.sql");
2626
}
2727

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

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

@@ -50,9 +50,9 @@ function plugin_satisfaction_install() {
5050
function plugin_satisfaction_uninstall() {
5151
global $DB;
5252

53-
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/profile.class.php");
54-
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/menu.class.php");
55-
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/notificationtargetticket.class.php");
53+
include_once(Plugin::getPhpDir('satisfaction')."/inc/profile.class.php");
54+
include_once(Plugin::getPhpDir('satisfaction')."/inc/menu.class.php");
55+
include_once(Plugin::getPhpDir('satisfaction')."/inc/notificationtargetticket.class.php");
5656

5757
$tables = [
5858
"glpi_plugin_satisfaction_surveys",

inc/menu.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ static function getMenuContent() {
2222
$menu = [];
2323

2424
if (Session::haveRight('plugin_satisfaction', READ)) {
25+
$web_dir = '/' . Plugin::getWebDir('satisfaction', false);
2526
$menu['title'] = self::getMenuName();
26-
$menu['page'] = "/plugins/satisfaction/front/survey.php";
27-
$menu['page'] = "/plugins/satisfaction/front/survey.php";
27+
$menu['page'] = $web_dir."/front/survey.php";
28+
$menu['page'] = $web_dir."/front/survey.php";
2829
$menu['links']['search'] = PluginSatisfactionSurvey::getSearchURL(false);
2930
if (PluginSatisfactionSurvey::canCreate()) {
3031
$menu['links']['add'] = PluginSatisfactionSurvey::getFormURL(false);

inc/surveyquestion.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function showForm($ID, $options = []) {
234234
Dropdown::showNumber('number', ['max' => 10,
235235
'min' => 2,
236236
'value' => $surveyquestion->fields['number'],
237-
'on_change' => "plugin_satisfaction_load_defaultvalue(\"" . $CFG_GLPI['root_doc'] . "\", this.value);"]);
237+
'on_change' => "plugin_satisfaction_load_defaultvalue(\"" . Plugin::getWebDir('satisfaction') . "\", this.value);"]);
238238
echo "</td>";
239239

240240
if (!empty($surveyquestion->fields['number'])) {

inc/surveyreminder.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static function showSurvey(PluginSatisfactionSurvey $survey, $preview = false) {
133133
self::PREDEFINED_REMINDER_OPTION_NAME => 1
134134
];
135135
Ajax::updateItemJsCode("viewreminder$sID$rand_survey",
136-
$CFG_GLPI["root_doc"] . "/plugins/satisfaction/ajax/viewsubitem_reminder.php", $params);
136+
Plugin::getWebDir('satisfaction') . "/ajax/viewsubitem_reminder.php", $params);
137137
echo "};";
138138

139139
echo "</script>\n";

inc/surveytranslation.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static function showTranslations(PluginSatisfactionSurvey $item) {
131131

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

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

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

363363
$result = "<form name='form' method='post' action='$target' enctype='multipart/form-data'>";
364364
$result.= "<input type='hidden' name='survey_id' value='$surveyID'>";

satisfaction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function plugin_satisfaction_load_defaultvalue(root_doc, default_value){
1111
}
1212

1313
$.ajax({
14-
url: root_doc+'/plugins/satisfaction/ajax/satisfaction.php',
14+
url: root_doc+'/ajax/satisfaction.php',
1515
type: 'POST',
1616
data: '&action_default_value&default_value='+ default_value + '&value=' + value,
1717
dataType: 'html',

satisfaction.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,14 @@
8888
<author>Infotel</author>
8989
</authors>
9090
<versions>
91+
<version>
92+
<num>1.5.1</num>
93+
<compatibility>~9.5.0</compatibility>
94+
<download_url>https://github.com/pluginsGLPI/satisfaction/releases/download/1.5.1/glpi-satisfaction-1.5.1.tar.gz</download_url>
95+
</version>
9196
<version>
9297
<num>1.5.0</num>
93-
<compatibility>9.5</compatibility>
98+
<compatibility>~9.5.0</compatibility>
9499
</version>
95100
<version>
96101
<num>1.4.4</num>

setup.php

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
* Init the hooks of the plugins -Needed
55
*/
66

7-
define('PLUGIN_SATISFACTION_VERSION', '1.5.0');
7+
define ("PLUGIN_SATISFACTION_VERSION", "1.5.1");
8+
9+
// Minimal GLPI version, inclusive
10+
define('PLUGIN_SATISFACTION_MIN_GLPI', '9.5');
11+
// Maximum GLPI version, exclusive
12+
define('PLUGIN_SATISFACTION_MAX_GLPI', '9.6');
813

914
function plugin_init_satisfaction() {
1015
global $PLUGIN_HOOKS;
@@ -61,41 +66,17 @@ function plugin_version_satisfaction() {
6166

6267
$author = "<a href='www.teclib.com'>TECLIB'</a>";
6368
$author.= ", <a href='http://blogglpi.infotel.com/'>Infotel</a>";
64-
return ['name' => __("More satisfaction", 'satisfaction'),
65-
'version' => PLUGIN_SATISFACTION_VERSION,
66-
'author' => $author,
67-
'license' => 'GPLv2+',
68-
'homepage' => 'https://github.com/pluginsGLPI/satisfaction',
69-
'requirements' => [
70-
'glpi' => [
71-
'min' => '9.5',
72-
'dev' => false
73-
]
74-
]
69+
return [
70+
'name' => __("More satisfaction", 'satisfaction'),
71+
'version' => PLUGIN_SATISFACTION_VERSION,
72+
'author' => $author,
73+
'license' => 'GPLv2+',
74+
'homepage' => 'https://github.com/pluginsGLPI/satisfaction',
75+
'requirements' => [
76+
'glpi' => [
77+
'min' => PLUGIN_SATISFACTION_MIN_GLPI,
78+
'max' => PLUGIN_SATISFACTION_MAX_GLPI,
79+
]
80+
]
7581
];
7682
}
77-
78-
/**
79-
* Optional : check prerequisites before install : may print errors or add to message after redirect
80-
*
81-
* @return bool
82-
*/
83-
function plugin_satisfaction_check_prerequisites() {
84-
if (version_compare(GLPI_VERSION, '9.5', 'lt')
85-
|| version_compare(GLPI_VERSION, '9.6', 'ge')) {
86-
if (method_exists('Plugin', 'messageIncompatible')) {
87-
echo Plugin::messageIncompatible('core', '9.5');
88-
}
89-
return false;
90-
}
91-
return true;
92-
}
93-
94-
/**
95-
* Uninstall process for plugin : need to return true if succeeded : may display messages or add to message after redirect
96-
*
97-
* @return bool
98-
*/
99-
function plugin_satisfaction_check_config() {
100-
return true;
101-
}

0 commit comments

Comments
 (0)