-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview-action.php
More file actions
executable file
·129 lines (120 loc) · 2.8 KB
/
view-action.php
File metadata and controls
executable file
·129 lines (120 loc) · 2.8 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/*
* This file is part of Monkeychow - http://shokk.wordpress.com/tag/monkeychow/
*
* view-action.php - marks selected items as read (or unread)
*
*
* Copyright (C) 2006 Ernie Oporto
* ernieoporto@yahoo.com - http://shokk.wordpress.com
*
* Copyright (C) 2004 Stephen Minutillo
* steve@minutillo.com - http://minutillo.com/steve/
*
* Distributed under the GPL - see LICENSE
*
*/
include_once("fof-main.php");
include_once("init.php");
header("Content-Type: text/html; charset=utf-8");
/* See what we've been asked to do */
switch ($_REQUEST['action'])
{
case 'read':
$to_set = '1';
$who_set = '';
break;
case 'publish':
$to_set = '3';
$who_set = '';
break;
case 'star':
$to_set = '2';
$who_set = '';
break;
case 'unread':
$who_set = '1';
$to_set = '0';
break;
case 'unpublish':
$who_set = '3';
$to_set = '0';
break;
case 'unstar':
$who_set = '2';
$to_set = '0';
break;
default:
/* XXX - Probably ought to complain */
break;
}
/* Build lists of all of the checked and starred items we need to
* apply the action to.
*/
$ids = array();
$idcount=0;
while (list($key, $val) = each ($_REQUEST))
{
if ($val == "checked")
{
if (eregi("_",$key))
{
$ids[] = substring_between($key,"c","_");
}
else
{
$ids[] = substr($key, 1);
}
}
elseif ($val == "starred")
$ids[] = substr($key, 4);
}
/* Now apply the action to all of the items. */
#$id_list = implode(",", $ids);
# foreach through the ids to build the correct query
#INSERT INTO `$FOF_ITEM_TABLE` (`user_id`, `item_id`, `flag_id`) VALUES ('2', '843132', '1'), ('2', '843131', '1');
switch ($_REQUEST['action'])
{
case 'read':
case 'star':
case 'publish':
$sql = "INSERT IGNORE INTO `$FOF_USERITEM_TABLE` (`user_id`, `item_id`, `flag_id`) VALUES ";
$sqlvalues="";
if (count($ids))
{
foreach ($ids as $id)
{
if ($sqlvalues == "")
{
$sqlvalues = "('" . current_user() . "', '" . $id . "', '" . $to_set . "')";
}
else
{
$sqlvalues .= ", ('" . current_user() . "', '" . $id . "', '" . $to_set . "')";
}
}
$sql .= $sqlvalues;
}
else
{
header("Location: " . urldecode($_REQUEST['return']));
}
break;
case 'unread':
case 'unstar':
case 'unpublish':
foreach ($ids as $id)
{
$sql .= "DELETE FROM `$FOF_USERITEM_TABLE` WHERE `user_id`=" . current_user() . " AND `item_id`=" . $id . " AND `flag_id`=" . $who_set . "; ";
}
break;
}
fof_do_query($sql);
?>
<script>
//alert("<?php echo "hi"?>");
window.location.replace("<?php echo urldecode($_REQUEST['return'])?>");
</script>
<?php
//header("Location: " . urldecode($_REQUEST['return']), 'true');
?>