Skip to content

Commit 4e5468e

Browse files
committed
Migrate to Namespace
1 parent 6168afa commit 4e5468e

44 files changed

Lines changed: 1792 additions & 1691 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ajax/addOptions.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30+
use Glpi\Exception\Http\BadRequestHttpException;
31+
use GlpiPlugin\Tasklists\TaskType;
32+
3033
header("Content-Type: text/html; charset=UTF-8");
3134
Html::header_nocache();
3235

@@ -39,9 +42,7 @@
3942
}
4043

4144
if (!isset($_REQUEST['action'])) {
42-
Toolbox::logError("Missing action parameter");
43-
http_response_code(400);
44-
return;
45+
throw new BadRequestHttpException("Missing action parameter");
4546
}
4647
$action = $_REQUEST['action'];
4748

@@ -80,7 +81,7 @@
8081
if ($_REQUEST['action'] == 'addUsers') {
8182

8283
header("Content-Type: application/json; charset=UTF-8", true);
83-
$users = PluginTasklistsTaskType::findUsers($_REQUEST['context']);
84+
$users = TaskType::findUsers($_REQUEST['context']);
8485

8586
if (!isset($_SESSION["usersKanban"][Session::getLoginUserID()])) {
8687
$_SESSION["usersKanban"][Session::getLoginUserID()] = json_encode([-1]);

ajax/contextForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30-
include("../../../inc/includes.php");
30+
use GlpiPlugin\Tasklists\TaskState;
3131

3232
Session::checkLoginUser();
3333
Session::checkRight('plugin_tasklists_config', UPDATE);
@@ -44,7 +44,7 @@
4444

4545
'withtemplate' => 0
4646
];
47-
$task = new PluginTasklistsTaskState();
47+
$task = new TaskState();
4848
$task->showForm(0, $options);
4949

5050
}

ajax/dropdownState.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30+
use GlpiPlugin\Tasklists\Task;
3031

3132
header("Content-Type: text/html; charset=UTF-8");
3233
Html::header_nocache();
@@ -36,6 +37,6 @@
3637

3738
if (isset($_POST["plugin_tasklists_tasktypes_id"])) {
3839

39-
PluginTasklistsTask::displayState($_POST['plugin_tasklists_tasktypes_id']);
40+
Task::displayState($_POST['plugin_tasklists_tasktypes_id']);
4041

4142
}

ajax/dropdownTypeTasks.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30+
use GlpiPlugin\Tasklists\Task;
31+
3032
if (strpos($_SERVER['PHP_SELF'], "dropdownTypeTasks.php")) {
3133
header("Content-Type: text/html; charset=UTF-8");
3234
Html::header_nocache();
@@ -63,7 +65,7 @@
6365

6466

6567
Dropdown::show(
66-
'PluginTasklistsTask',
68+
Task::class,
6769
[
6870
'name' => $_POST['myname'],
6971
'used' => $used,

ajax/getTaskComment.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30+
use GlpiPlugin\Tasklists\Task_Comment;
31+
3032
header("Content-Type: text/html; charset=UTF-8");
3133
Html::header_nocache();
3234

@@ -53,4 +55,4 @@
5355
$answer = $_POST['answer'];
5456
}
5557

56-
echo PluginTasklistsTask_Comment::getCommentForm($plugin_tasklists_tasks_id, $lang, $edit, $answer);
58+
echo Task_Comment::getCommentForm($plugin_tasklists_tasks_id, $lang, $edit, $answer);

ajax/getUserPicture.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
*/
3535

3636
use Glpi\Exception\Http\BadRequestHttpException;
37-
3837
use function Safe\json_encode;
3938

4039
header("Content-Type: application/json; charset=UTF-8");

ajax/kanban.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
use Glpi\Exception\Http\HttpException;
4040
use Glpi\Features\KanbanInterface;
4141
use Glpi\Features\TeamworkInterface;
42+
use GlpiPlugin\Tasklists\Item_Kanban;
4243

4344
use function Safe\json_encode;
4445
use function Safe\preg_split;
@@ -181,7 +182,7 @@
181182
$can_move = $kanban->canOrderKanbanCard($_POST['kanban']['items_id']);
182183
}
183184
if ($can_move) {
184-
Item_Kanban::moveCard(
185+
\Item_Kanban::moveCard(
185186
$_POST['kanban']['itemtype'],
186187
$_POST['kanban']['items_id'],
187188
$_POST['card'],
@@ -191,24 +192,24 @@
191192
}
192193
} elseif (($_POST['action'] ?? null) === 'show_column') {
193194
$checkParams(['column', 'kanban']);
194-
Item_Kanban::showColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column']);
195+
\Item_Kanban::showColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column']);
195196
} elseif (($_POST['action'] ?? null) === 'hide_column') {
196197
$checkParams(['column', 'kanban']);
197-
Item_Kanban::hideColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column']);
198+
\Item_Kanban::hideColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column']);
198199
} elseif (($_POST['action'] ?? null) === 'collapse_column') {
199200
$checkParams(['column', 'kanban']);
200-
Item_Kanban::collapseColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column']);
201+
\Item_Kanban::collapseColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column']);
201202
} elseif (($_POST['action'] ?? null) === 'expand_column') {
202203
$checkParams(['column', 'kanban']);
203-
Item_Kanban::expandColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column']);
204+
\Item_Kanban::expandColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column']);
204205
} elseif (($_POST['action'] ?? null) === 'move_column') {
205206
$checkParams(['column', 'kanban', 'position']);
206-
Item_Kanban::moveColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column'], $_POST['position']);
207+
\Item_Kanban::moveColumn($_POST['kanban']['itemtype'], $_POST['kanban']['items_id'], $_POST['column'], $_POST['position']);
207208
} elseif ($_REQUEST['action'] === 'refresh') {
208209
$checkParams(['column_field']);
209210
// Get all columns to refresh the kanban
210211
header("Content-Type: application/json; charset=UTF-8", true);
211-
$force_columns = Item_Kanban::getAllShownColumns($itemtype, $_REQUEST['items_id']);
212+
$force_columns = \Item_Kanban::getAllShownColumns($itemtype, $_REQUEST['items_id']);
212213
$columns = $itemtype::getKanbanColumns($_REQUEST['items_id'], $_REQUEST['column_field'], $force_columns, true);
213214
echo json_encode($columns, JSON_FORCE_OBJECT);
214215
} elseif ($_REQUEST['action'] === 'get_switcher_dropdown') {
@@ -247,25 +248,25 @@
247248
if (!isset($_POST['state'])) {
248249
// Do nothing with the state unless it isn't saved yet. Could be that no columns are shown or an error occurred.
249250
// If the state is supposed to be cleared, it should come through as a clear_column_state request.
250-
if (Item_Kanban::hasStateForItem($_POST['itemtype'], $_POST['items_id'])) {
251+
if (\Item_Kanban::hasStateForItem($_POST['itemtype'], $_POST['items_id'])) {
251252
return;
252253
}
253-
Item_Kanban::saveStateForItem($_POST['itemtype'], $_POST['items_id'], []);
254+
\Item_Kanban::saveStateForItem($_POST['itemtype'], $_POST['items_id'], []);
254255
return;
255256
}
256257
$checkParams(['items_id', 'state']);
257-
Item_Kanban::saveStateForItem($_POST['itemtype'], $_POST['items_id'], $_POST['state']);
258+
\Item_Kanban::saveStateForItem($_POST['itemtype'], $_POST['items_id'], $_POST['state']);
258259
} elseif ($_REQUEST['action'] === 'load_column_state') {
259260
$checkParams(['items_id', 'last_load']);
260261
header("Content-Type: application/json; charset=UTF-8", true);
261262
$response = [
262-
'state' => Item_Kanban::loadStateForItem($_REQUEST['itemtype'], $_REQUEST['items_id'], $_REQUEST['last_load']),
263+
'state' => \Item_Kanban::loadStateForItem($_REQUEST['itemtype'], $_REQUEST['items_id'], $_REQUEST['last_load']),
263264
'timestamp' => $_SESSION['glpi_currenttime'],
264265
];
265266
echo json_encode($response, JSON_FORCE_OBJECT);
266267
} elseif ($_REQUEST['action'] === 'clear_column_state') {
267268
$checkParams(['items_id']);
268-
$result = Item_Kanban::clearStateForItem($_REQUEST['itemtype'], $_REQUEST['items_id']);
269+
$result = \Item_Kanban::clearStateForItem($_REQUEST['itemtype'], $_REQUEST['items_id']);
269270
if (!$result) {
270271
throw new HttpException(500);
271272
}

ajax/seetask.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30+
use GlpiPlugin\Tasklists\Task;
3031

3132
Session::checkLoginUser();
3233
Session::checkRight('plugin_tasklists', UPDATE);
@@ -44,10 +45,10 @@
4445
'withtemplate' => 0
4546
];
4647
echo "<div class='center'>";
47-
echo "<a href='" . PluginTasklistsTask::getFormURL(true) . "?id=" . $_GET['id'] . "'>" . __("View this item in his context") . "</a>";
48+
echo "<a href='" . Task::getFormURL(true) . "?id=" . $_GET['id'] . "'>" . __("View this item in his context") . "</a>";
4849
echo "</div>";
4950
echo "<hr>";
50-
$task = new PluginTasklistsTask();
51+
$task = new Task();
5152
$task->showForm($_GET['id'],$options);
5253
} else if (isset($_GET['plugin_tasklists_tasktypes_id'])
5354
&& isset($_GET['plugin_tasklists_taskstates_id'])) {
@@ -57,7 +58,7 @@
5758
'plugin_tasklists_taskstates_id' => $_GET['plugin_tasklists_taskstates_id'],
5859
'withtemplate' => 0
5960
];
60-
$task = new PluginTasklistsTask();
61+
$task = new Task();
6162
if ($id = $task->hasTemplate($options)) {
6263
$options['withtemplate'] = 2;
6364
$task->showForm($id, $options);
@@ -66,7 +67,7 @@
6667
}
6768
} else if (isset($_GET['clone_id'])) {
6869
$id = $_GET['clone_id'];
69-
$task = new PluginTasklistsTask();
70+
$task = new Task();
7071
if ($task->getFromDB($id)) {
7172
$options = [
7273
'from_edit_ajax' => true,
@@ -80,12 +81,12 @@
8081
'visibility' => $task->fields['visibility'],
8182
'withtemplate' => 0
8283
];
83-
$taskcloned = new PluginTasklistsTask();
84+
$taskcloned = new Task();
8485
$taskcloned->showForm(0, $options);
8586
}
8687
} else if (isset($_GET['task_id'])) {
8788
$id = $_GET['task_id'];
88-
$task = new PluginTasklistsTask();
89+
$task = new Task();
8990
if ($task->getFromDB($id)) {
9091
$options = [
9192
'from_edit_ajax' => true,

ajax/updatetask.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,21 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30+
use GlpiPlugin\Tasklists\Task;
3031

3132
Session::checkLoginUser();
3233
Session::checkRight('plugin_tasklists', UPDATE);
3334

3435
if (isset($_POST['data_id'])
3536
&& isset($_POST['percent_done'])) {
36-
$task = new PluginTasklistsTask();
37+
$task = new Task();
3738
$input['percent_done'] = $_POST['percent_done'];
3839
$input['id'] = $_POST['data_id'];
3940
$task->update($input);
4041

4142
} else if (isset($_POST['data_id'])
4243
&& isset($_POST['updatepriority'])) {
43-
$task = new PluginTasklistsTask();
44+
$task = new Task();
4445
if ($task->getFromDB($_POST['data_id'])) {
4546
if ($task->fields["priority"] < 5) {
4647
$input['priority'] = $task->fields["priority"] + 1;
@@ -50,7 +51,7 @@
5051
}
5152
} else if (isset($_POST['data_id'])
5253
&& isset($_POST['archivetask'])) {
53-
$task = new PluginTasklistsTask();
54+
$task = new Task();
5455
$input['is_archived'] = 1;
5556
$input['id'] = $_POST['data_id'];
5657
$task->update($input);
@@ -59,13 +60,13 @@
5960
&& isset($_POST['state_id'])
6061
&& isset($_POST['context_id'])) {
6162

62-
$task = new PluginTasklistsTask();
63+
$task = new Task();
6364
$dbu = new DbUtils();
6465
$cond = ["plugin_tasklists_taskstates_id" => $_POST['state_id'],
6566
"plugin_tasklists_tasktypes_id" => $_POST['context_id'],
6667
"is_deleted" => 0,
6768
"is_archived" => 0];
68-
$tasks = $dbu->getAllDataFromTable($dbu->getTableForItemType('PluginTasklistsTasks'),
69+
$tasks = $dbu->getAllDataFromTable($dbu->getTableForItemType(Task::class),
6970
$cond);
7071
foreach ($tasks as $key => $row) {
7172
if ($task->getFromDB($row['id'])) {

front/comment.form.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30+
use GlpiPlugin\Tasklists\Menu;
31+
use GlpiPlugin\Tasklists\Task;
3032

3133
if (!isset($_GET["id"])) {
3234
$_GET["id"] = "";
@@ -35,9 +37,9 @@
3537
$_GET["withtemplate"] = "";
3638
}
3739

38-
Html::header(PluginTasklistsTask::getTypeName(2), '', "helpdesk", "plugintasklistsmenu");
40+
Html::header(Task::getTypeName(2), '', "helpdesk", Menu::class);
3941

40-
$task = new PluginTasklistsTask();
42+
$task = new Task();
4143
$task->checkGlobal(READ);
4244
$task->getFromDB($_GET['id']);
4345
$note = new Notepad();

0 commit comments

Comments
 (0)