-
Notifications
You must be signed in to change notification settings - Fork 0
/
block_application_statuses.php
60 lines (51 loc) · 1.55 KB
/
block_application_statuses.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* A block which displays current Application Statuses
*
* @package block_application_statuses
* @author James Byrne
*/
class block_application_statuses extends block_list
{
public function init()
{
$this->title = get_string('pluginname', 'block_application_statuses');
}
public function specialization()
{
if (isset($this->config)) {
if (!empty($this->config->title)) {
$this->title = $this->config->title;
}
}
}
public function get_content()
{
if ($this->content !== null) {
return $this->content;
}
$this->content = new stdClass;
$this->getApplications();
return $this->content;
}
/**
* Gets applciations from db for user. Sets public $content to null if no applications found.
*
* @return null
*/
private function getApplications()
{
global $DB, $USER;
if ($applications = $DB->get_records('block_application_statuses', ['userid' => $USER->id])) {
if (empty($applications)) {
$this->content = null;
return;
}
$this->content->items = array();
foreach ($applications as $application) {
$this->content->items[] = html_writer::tag('a', $application->prospect_title, ['href' => $application->link, 'target' => '_blank', 'class' => 'application-prospect']);
$this->content->items[] = html_writer::div($application->status);
}
}
}
}