ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBackgroundTaskTableGUI.php
Go to the documentation of this file.
1<?php
4
5require_once("./Services/Table/classes/class.ilTable2GUI.php");
6require_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
7
14{
15
19 protected $setup;
20
21
27 public function __construct($setup)
28 {
29 global $lng;
30
31 parent::__construct(null, "");
32 $this->setTitle($lng->txt("background_tasks"));
33 $this->setLimit(9999);
34 $this->setup = $setup;
35
36 $this->addColumn($this->lng->txt("name"), "");
37 $this->addColumn($this->lng->txt("id"), "");
38 $this->addColumn($this->lng->txt("bt_available"), "");
39 $this->addColumn($this->lng->txt("running_tasks"), "");
40 $this->addColumn($this->lng->txt("waiting_tasks"), "");
41 $this->addColumn($this->lng->txt("actions"), "");
42
43 $this->setDefaultOrderField("name");
44 $this->setDefaultOrderDirection("asc");
45
46 $this->setEnableHeader(true);
47 $this->setFormAction("setup.php?cmd=gateway");
48 $this->setRowTemplate("tpl.bt_list_row.html", "setup");
49 $this->disable("footer");
50 $this->setEnableTitle(true);
51
52 $this->getClients();
53
54 // $this->addMultiCommand("changedefault", $lng->txt("set_default_client"));
55 }
56
57
61 public function getClients()
62 {
63 global $lng;
64
65 $clients = array();
66 $clientlist = new ilClientList($this->setup->db_connections);
67 $list = $clientlist->getClients();
68
69 foreach ($list as $key => $client) {
70 $client->provideGlobalDB();
71
72 $client_name = ($client->getName()) ? $client->getName() : "&lt;" . $lng->txt("no_client_name") . "&gt;";
73
74 if ($this->BTAvailable()) {
75 $running_tasks = $this->getRunningTasksForDB();
76 $waiting_tasks = $this->getWaitingTasksForDB();
77 $bt_available = true;
78 } else {
79 $running_tasks = "-";
80 $waiting_tasks = "-";
81 $bt_available = false;
82 }
83 // visible data part
84 $clients[] = array(
85 "name" => $client_name,
86 "desc" => $client->getDescription(),
87 "id" => $key,
88 "running_tasks" => $running_tasks,
89 "waiting_tasks" => $waiting_tasks,
90 "bt_available" => $bt_available
91
92 );
93 }
94
95 $this->setData($clients);
96 }
97
101 protected function fillRow($a_set)
102 {
103 global $lng;
104
105 $this->tpl->setVariable("NAME", $a_set["name"]);
106 $this->tpl->setVariable("DESC", $a_set["desc"]);
107 $this->tpl->setVariable("ID", $a_set["id"]);
108 $this->tpl->setVariable("RUNNING_TASKS", $a_set["running_tasks"]);
109 $this->tpl->setVariable("WAITING_TASKS", $a_set["waiting_tasks"]);
110 $this->tpl->setVariable("BT_AVAILABLE", $a_set["bt_available"] ? $this->lng->txt("yes") : $this->lng->txt("no"));
111
112 $adv = new ilAdvancedSelectionListGUI();
113 if ($a_set["bt_available"]) {
114 $adv->addItem($this->lng->txt("kill_waiting_tasks"), "", "setup.php?cmd=kill_waiting_tasks&client_id=" . $a_set["id"]);
115 }
116
117 $this->tpl->setVariable("ACTIONS", $adv->getHTML());
118 }
119
120 public function kill_waiting_tasks()
121 {
122 echo "hi";
123 exit;
124 }
125
126
127 private function getRunningTasksForDB()
128 {
129 return BucketContainer::where(["state" => State::RUNNING])->count();
130 }
131
132
133 private function getWaitingTasksForDB()
134 {
135 return BucketContainer::where(["state" => State::SCHEDULED])->count();
136 }
137
138
139 private function BTAvailable()
140 {
141 try {
142 BucketContainer::where("TRUE")->first();
143 return true;
144 } catch (Exception $e) {
145 return false;
146 }
147 }
148}
$client
Definition: resume.php:9
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
Class ilBackgroundTaskTableGUI.
__construct($setup)
ilBackgroundTaskTableGUI constructor.
client management
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
disable($a_module_name)
diesables particular modules of table
$key
Definition: croninfo.php:18
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41