Skip to content

Commit 43cabd9

Browse files
committed
Refactor 'Bot user' row in index table, only display error if no bot user
1 parent 412b436 commit 43cabd9

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

index.php

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,38 @@
7171
$eta = floor($duration / $progress + $crawlstart);
7272

7373
$robot = $DB->get_record('user', ['username' => $config->botusername]);
74-
if (!$robot) {
75-
$robot = new stdClass();
76-
$robot->id = get_string('botusermissing', 'tool_crawler');
77-
$robot->username = get_string('botusermissing', 'tool_crawler');
74+
$botrowdata = array(get_string('botuser', 'tool_crawler'));
75+
76+
// Do not display links to bot user if it doesn't exist
77+
if ($robot) {
78+
$botrowdata[] = implode(' | ', array(
79+
$robot->username,
80+
$boterror ? $boterror : get_string('good', 'tool_crawler'),
81+
html_writer::link(
82+
new moodle_url(
83+
'/user/editadvanced.php',
84+
['id' => $robot->id, 'courseid' => 1]
85+
),
86+
get_string('useraccount', 'tool_crawler')
87+
),
88+
html_writer::link(
89+
new moodle_url(
90+
'/admin/roles/usersroles.php',
91+
['userid' => $robot->id, 'courseid' => 1]
92+
),
93+
get_string('roles')
94+
),
95+
));
96+
} else {
97+
$botrowdata[] = $boterror;
7898
}
7999

80100
$table = new html_table();
81101
$table->head = [get_string('robotstatus', 'tool_crawler')];
82102
$table->headspan = [2, 1];
83103
$table->attributes['class'] = 'generaltable table table-hover w-auto';
84104
$table->data = [
85-
[
86-
get_string('botuser', 'tool_crawler'),
87-
$robot->username
88-
. ' | ' . ($boterror ? $boterror : get_string('good', 'tool_crawler'))
89-
. ' | ' . html_writer::link(new moodle_url(
90-
'/user/editadvanced.php',
91-
['id' => $robot->id, 'courseid' => 1]
92-
), get_string('useraccount', 'tool_crawler'))
93-
. ' | ' . html_writer::link(new moodle_url(
94-
'/admin/roles/usersroles.php',
95-
['userid' => $robot->id, 'courseid' => 1]
96-
), get_string('roles')),
97-
],
105+
$botrowdata,
98106
[
99107
get_string('progress', 'tool_crawler'),
100108

0 commit comments

Comments
 (0)