-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounselling.blocks.inc
56 lines (46 loc) · 1.3 KB
/
counselling.blocks.inc
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
<?php
use Drupal\counselling\CounsellingManager;
/**
* Implements hook_block_info().
*
* To create new Counselling promotional block.
*/
function counselling_block_info() {
$blocks['counselling_promotional_block'] = array(
'info' => t('Counselling promotional block'),
'cache' => DRUPAL_NO_CACHE,
);
$blocks['counselling_donation_block'] = array(
'info' => t('Counselling donation block'),
'cache' => DRUPAL_NO_CACHE,
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function counselling_block_view($delta = '') {
$block = [];
global $user;
$manager = new CounsellingManager();
$system_is_enabled = $manager->getSystemStatus();
switch ($delta) {
case 'counselling_promotional_block':
if ($system_is_enabled && !user_is_anonymous()) {
$block = [
'subject' => t('Online bereavement counselling service'),
'content' => theme('counselling__promotional_block', $block),
];
}
break;
case 'counselling_donation_block':
if ($system_is_enabled && !user_is_anonymous() && patient_has_profile($user->uid)) {
$block = [
'subject' => t('Can you help?'),
'content' => theme('counselling__donation_block', $block),
];
}
break;
}
return $block;
}