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

start.php ➔ selfdelete_page_handler()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Beck24\MemberSelfDelete;
4
5
const PLUGIN_ID = 'member_selfdelete';
6
7
require_once __DIR__ . '/lib/hooks.php';
8
require_once __DIR__ . '/lib/events.php';
9
10
elgg_register_event_handler('init', 'system', __NAMESPACE__ . '\\init');
11
12
function init() {
13
14
	// prevent people from seeing the profile of disabled users
15
	elgg_extend_view('profile/details', 'member_selfdelete/pre_userdetails', 0);
16
17
	elgg_extend_view('forms/account/settings','member_selfdelete/deactivate_settings');
18
19
	elgg_register_page_handler('selfdelete', __NAMESPACE__ . '\\selfdelete_page_handler');
20
	elgg_register_page_handler('gcreactivate',__NAMESPACE__ . '\\gcreactivate_page_handler');
21
22
	elgg_register_action("selfdelete", __DIR__ . "/actions/delete.php");
23
	elgg_register_action('selfdelete/feedback/delete', __DIR__ . '/actions/feedback/delete.php', 'admin');
24
25
	elgg_register_action('selfdelete/reactivate_toggle', __DIR__ .'/actions/reactivate_toggle.php');
26
    elgg_register_action('selfdelete/changegroupowner', __DIR__ . '/actions/changegroupowner.php');
27
	elgg_register_event_handler('pagesetup', 'system', __NAMESPACE__ . '\\pagesetup');
28
29
	elgg_register_plugin_hook_handler('register', 'menu:user_hover', __NAMESPACE__ . '\\hover_menu', 1000);
30
	elgg_register_plugin_hook_handler('email', 'system', __NAMESPACE__ . '\\email_system', 0);
31
32
	elgg_register_event_handler("create", "friendrequest", "friend_request_deactivated_user");
33
34
	elgg_register_event_handler('login:before', 'user', 'gc_deactivated_login', 501);
35
}
36
37
function selfdelete_page_handler($page) {
38
	if (!include(elgg_get_plugins_path() . "member_selfdelete/pages/form.php")) {
39
		return FALSE;
40
	}
41
	return TRUE;
42
}
43
function gcreactivate_page_handler($page) {
44
	if (!include(elgg_get_plugins_path() . "member_selfdelete/pages/reactivate.php")) {
45
		return FALSE;
46
	}
47
	return TRUE;
48
}
49
50
function friend_request_deactivated_user($event, $object_type, $object){
51
		$user = get_user($object->guid_two);
52
		if($user->gcdeactivated = true){
53
			system_message('this user is also deactivated');
54
		}
55
		system_message('is this even doing anything?');
56
}
57
function gc_deactivated_login($event, $type, $user){
58
	if(($user instanceof ElggUser) && $user->gcdeactivate == true){
0 ignored issues
show
Bug introduced by
The class Beck24\MemberSelfDelete\ElggUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
59
		return FALSE;
60
		throw new LoginException(elgg_echo('uservalidationbyemail:login:fail'));
0 ignored issues
show
Unused Code introduced by
throw new \Beck24\Member...nbyemail:login:fail')); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
61
	
62
	}
63
	//return TRUE;
64
	throw new LoginException(elgg_echo('uservalidationbyemail:login:fail'));
65
	return FALSE;
0 ignored issues
show
Unused Code introduced by
return FALSE; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
66
67
}
68