-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlisting_delete.php
86 lines (66 loc) · 2.36 KB
/
listing_delete.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
include_once("includes/inc.global.php");
$cUser->MustBeLoggedOn();
$p->site_section = LISTINGS;
$p->page_title = 'Delete '. $_REQUEST['type'] .'ed Listings';
include("classes/class.listing.php");
include("includes/inc.forms.php");
$message = "";
// First, need to change the default form template so checkbox comes before the label
$renderer->setElementTemplate('<TR><TD>{element}<!-- BEGIN required --><font> *</font><!-- END required --></FONT><!-- BEGIN error --><font color=RED size=2> *{error}*</font><br /><!-- END error --> <FONT SIZE=2>{label}</FONT></TD></TR>');
$form->addElement('hidden','type',$_REQUEST['type']);
$form->addElement('hidden','mode',$_REQUEST['mode']);
$member = new cMember;
if($_REQUEST["mode"] == "admin") {
$cUser->MustBeLevel(1);
$member->LoadMember($_REQUEST["member_id"]);
}
else {
$member = $cUser;
}
$form->addElement('hidden','member_id',$member->member_id);
$title_list = new cTitleList($_REQUEST['type']);
$titles = $title_list->MakeTitleArray($member->member_id);
$listings_exist = false;
while (list($key, $title) = each ($titles)) {
if($title != "") {
$form->addElement('checkbox', $key, $title);
$listings_exist=true;
}
}
if ($listings_exist) {
$form->addElement('static', null, null);
$form->addElement('submit', 'btnSubmit', 'Delete');
} else {
if($_REQUEST["mode"] == "self")
$text = "You don't ";
else
$text = $member->PrimaryName() . " doesn't ";
$message = $text ."currently have any ". strtolower($_REQUEST['type']) ."ed listings.";
}
if ($form->validate()) { // Form is validated so processes the data
$form->freeze();
$form->process('process_data', false);
} else {
$p->DisplayPage($form->toHtml() ."<BR>". $message); // just display the form
}
function process_data ($values) {
global $p, $cErr, $titles, $member;
$list = "";
$deleted = 0;
$listing = new cListing;
while (list ($key, $value) = each ($values)) {
$affected = 0;
if(is_numeric($key)) // Two of the values are hidden fields. Need to skip those.
$affected = $listing->DeleteListing($titles[$key],$member->member_id,substr($_REQUEST['type'],0,1));
$deleted += $affected;
}
if($deleted == 1)
$list .= "1 listing deleted.";
elseif($deleted > 1)
$list .= $deleted . " listings deleted.";
else
$cErr->Error("There was an error deleting the listings. Did you check any boxes?");
$p->DisplayPage($list);
}
?>