-
Notifications
You must be signed in to change notification settings - Fork 0
/
member_status_change.php
66 lines (54 loc) · 2.06 KB
/
member_status_change.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
61
62
63
64
65
66
<?php
include_once("includes/inc.global.php");
include_once("classes/class.listing.php");
$cUser->MustBeLevel(2);
$p->site_section = ADMINISTRATION;
$member = new cMember;
$member->LoadMember($_REQUEST["member_id"]);
if($member->status == 'A')
$p->page_title = "Inactivate ";
else
$p->page_title = "Re-activate ";
$p->page_title .= $member->PrimaryName() ." (". $member->member_id .")";
include("includes/inc.forms.php");
include_once("classes/class.news.php");
$form->addElement("hidden", "member_id", $_REQUEST["member_id"]);
if($member->status == 'A') {
$form->addElement("static", null, "Are you sure you want to inactivate this member? They will no longer be able to use this website, and all their listings will be inactivated as well.", null);
$form->addElement("static", null, null, null);
$form->addElement('submit', 'btnSubmit', 'Inactivate');
} else {
$form->addElement("static", null, "Are you sure you want to re-activate this member? Their listings will need to be reactivated individually or new ones created.", null);
$form->addElement("static", null, null, null);
$form->addElement('submit', 'btnSubmit', 'Re-activate');
}
if ($form->validate()) { // Form is validated so processes the data
$form->freeze();
$form->process("process_data", false);
} else { // Display the form
$p->DisplayPage($form->toHtml());
}
function process_data ($values) {
global $p, $member;
if($member->status == 'A') {
$success = $member->DeactivateMember();
$listings = new cListingGroup(OFFER_LISTING);
$listings->LoadListingGroup(null,null,$member->member_id);
$date = new cDateTime("yesterday");
if($success)
$success = $listings->ExpireAll($date);
if($success) {
$listings = new cListingGroup(WANT_LISTING);
$listings->LoadListingGroup(null,null,$member->member_id);
$success = $listings->ExpireAll($date);
}
} else {
$success = $member->ReactivateMember();
}
if($success)
$output = "Changes to member status saved.";
else
$output = "There was an error changing the member's status. Please try again later.";
$p->DisplayPage($output);
}
?>