Passed
Push — gcconnex ( e80bf3...4a2546 )
by
unknown
17:21
created

hooks.php ➔ email_system()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 4
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Beck24\MemberSelfDelete;
4
5
/**
6
 *  check if the user is inactive
7
 *  if so we're not sending email
8
 * 
9
 * @param type $hook
10
 * @param type $type
11
 * @param type $return
12
 * @param type $params
13
 * @return boolean
14
 */
15
function email_system($hook, $type, $return, $params) {
16
	$email = $params['to'];
17
18
	$user = get_user_by_email($email);
19
20
	if ($user[0]->member_selfdelete == "anonymized") {
21
		return false;
22
	}
23
24
	return $return;
25
}
26
27
28
/**
29
 * called on 'register', 'menu:user_hover'
30
 * 
31
 * @param type $hook
32
 * @param type $type
33
 * @param type $return
34
 * @param type $params
35
 * @return type
36
 */
37
function hover_menu($hook, $type, $return, $params) {
38
39
	if (is_array($return) && $params['entity']->member_selfdelete == "anonymized") {
40
		foreach ($return as $key => $item) {
41
			if ($item->getSection() != "admin") {
42
				unset($return[$key]);
43
			}
44
		}
45
	}
46
47
	return $return;
48
}
49