-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.swapcats.php
More file actions
42 lines (35 loc) · 1.57 KB
/
Copy pathaction.swapcats.php
File metadata and controls
42 lines (35 loc) · 1.57 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
<?php
#----------------------------------------------------------------------
# Module: MBVFaq - a simple FAQ module
# Action: swapcats
# Swap the order-numbers of two categories, specified in $params['item_id'] etc
#----------------------------------------------------------------------
# See file MBVFaq.module.php for full details of copyright, licence, etc.
#----------------------------------------------------------------------
if (!isset($params['category_id'])) {
$this->Redirect($id, 'defaultadmin', '', array('showtab' => 1, 'message'=>'Parameter error'));
} //TODO error message
$othercat = array();
if (isset($params['next_category_id'])) {
$othercat[] = $params['next_category_id'];
} elseif (isset($params['prev_category_id'])) {
$othercat[] = $params['prev_category_id'];
} else {
$this->Redirect($id, 'defaultadmin', '', array('showtab' => 1));
}
$sql = "SELECT vieworder FROM $this->CatTable WHERE category_id=?";
$num2 = $db->GetOne($sql, $othercat);
if ($num2 === FALSE) {
$this->Redirect($id, 'defaultadmin', '', array('showtab' => 1, 'message'=>'Parameter error'));
} //TODO error message
$thiscat = array($params['category_id']);
$num1 = $db->GetOne($sql, $thiscat);
if ($num1 === FALSE) {
$this->Redirect($id, 'defaultadmin', '', array('showtab' => 1, 'message'=>'Parameter error'));
} //TODO error message
array_unshift($thiscat, $num2);
array_unshift($othercat, $num1);
$sql = "UPDATE $this->CatTable SET vieworder=? WHERE category_id=?";
$db->Execute($sql, $thiscat);
$db->Execute($sql, $othercat);
$this->Redirect($id, 'defaultadmin', '', array('showtab' => 1));