-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.processcats.php
More file actions
83 lines (77 loc) · 2.59 KB
/
Copy pathaction.processcats.php
File metadata and controls
83 lines (77 loc) · 2.59 KB
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
<?php
#----------------------------------------------------------------------
# Module: MBVFaq - a simple FAQ module
# Action: updateitem
# Modify or delete or export selected categories
#----------------------------------------------------------------------
# See file MBVFaq.module.php for full details of copyright, licence, etc.
#----------------------------------------------------------------------
if (isset($params['cancel'])) { // if cancel was pressed don't do anything
$this->Redirect($id, 'defaultadmin');
}
if (!isset($params['selgrps'])) {
$this->Redirect($id, 'defaultadmin');
}
if (isset($params['update'])) {
//update selected categories
$tasktype = 1;
} elseif (isset($params['delete'])) {
//delete selected categories
$tasktype = 2;
} elseif (isset($params['sort'])) { //sort selected categories
$funcs = new MBVForder();
$funcs->SortCategories($this, $selected);
$this->Redirect($id, 'defaultadmin', '', array('showtab' => 1));
} elseif (isset($params['export'])) {//export selected categories
$tasktype = 3;
$data = '';
$csvfuncs = new MBVFcsv();
} else {
$this->Redirect($id, 'defaultadmin');
}
$names = $params['category_names'];
if (isset($params['owner_ids'])) {
$owners = $params['owner_ids'];
} else {
$owners = NULL;
}
foreach ($params['selgrps'] as $k=>$category_id) {
$thisname = $names[$k];
if ($thisname != '') {
$thisid = (int)$category_id;
//deprecated PHP $thisname = $db->quote($thisname, get_magic_quotes_runtime());
switch ($tasktype) {
case 1: //update
if ($thisid > -1) {
if ($owners != NULL) {
$sql = "UPDATE $this->CatTable SET name=?, owner=? WHERE category_id=?";
$db->Execute($sql, array($thisname, $owners[$k], $thisid));
} else {
$sql = "UPDATE $this->CatTable SET name=? WHERE category_id=?";
$db->Execute($sql, array($thisname, $thisid));
}
} else { //new category
if ($owners != NULL) {
$sql = "INSERT INTO $this->CatTable (category_id, name, vieworder, owner) VALUES (?,?,?,?)";
$category_id = $db->GenID($this->CatTable.'_seq');
$db->Execute($sql, array($thisid, $thisname, $thisid, $owners[$k]));
} else {
$sql = "INSERT INTO $this->CatTable (category_id, name, vieworder) VALUES (?,?,?)";
$category_id = $db->GenID($this->CatTable.'_seq');
$db->Execute($sql, array($thisid, $thisname, $thisid));
}
}
break;
case 2: //delete
$this->_DeleteCategory($thisid);
break;
case 3: //export
$data .= $csvfuncs->ListCategory($this, $thisid);
break;
}
}
}
if ($tasktype != 3) {
$this->Redirect($id, 'defaultadmin', '', array('showtab' => 1));
}
$csvfuncs->Save($this, $data);