-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.php
262 lines (221 loc) · 7.38 KB
/
main.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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
// main.php - Front page
//
// SiT (Support Incident Tracker) - Support call tracking system
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
//
// Author: Ivan Lucas <ivanlucas[at]users.sourceforge.net>
// Author: Paul Heaney <paulheaney[at]users.sourceforge.net>
// This Page Is *NOT* Valid XHTML 1.0 Transitional!
$permission=0; // not required
require ('core.php');
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');
// --------------------------------------------------------------------------------------------
// Dashboard widgets
$sql = "SELECT * FROM `{$dbDashboard}` WHERE enabled='true' ORDER BY id";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
while ($dashboard = mysql_fetch_object($result))
{
include (APPLICATION_PLUGINPATH . "dashboard_{$dashboard->name}.php");
$DASHBOARDCOMP["dashboard_{$dashboard->name}"] = "dashboard_{$dashboard->name}";
}
// Valid user
$pagescripts = array('scriptaculous/scriptaculous.js?load=effects,dragdrop');
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
$sql = "SELECT dashboard FROM `{$dbUsers}` WHERE id = '".$_SESSION['userid']."'";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
$dashboardcomponents = array();
if (mysql_num_rows($result) > 0)
{
$obj = mysql_fetch_object($result);
$dashboardcomponents = explode(",",$obj->dashboard);
}
$col0 = 0;
$col1 = 0;
$col2 = 0;
$cols0 = '';
$cols1 = '';
$cols2 = '';
foreach ($dashboardcomponents AS $db)
{
$c = explode("-",$db);
switch ($c[0])
{
case 0: $col0++;
$cols0 .= $c[1].",";
break;
case 1: $col1++;
$cols1 .= $c[1].",";
break;
case 2: $col2++;
$cols2 .= $c[1].",";
break;
}
}
$colstr = $col0.",".$col1.",".$col2;
$cols0 = substr($cols0, 0, -1);
$cols1 = substr($cols1, 0, -1);
$cols2 = substr($cols2, 0, -1);
echo "<p id='pageoptions'>".help_link("Dashboard")." <a href='manage_user_dashboard.php' title='{$strManageYourDashboard}'>";
echo icon('dashboardadd', 16)."</a> ";
echo "<a href=\"javascript:save_layout();\" id='savelayout' title='{$strSaveDashbaordLayout}'>".icon('save', 16)."</a></p>";
echo "<table border=\"0\" width=\"99%\" id='cols'><tr>"; //id='dashboardlayout'
echo "<td width=\"33%\" valign='top' id='col0'>";
$arr = explode(",",$cols0);
foreach ($arr AS $a)
{
show_dashboard_component(0, $a);
}
echo "</td><td width=\"33%\" valign='top' id='col1'>";
$arr = explode(",",$cols1);
foreach ($arr AS $a)
{
show_dashboard_component(1, $a);
}
echo "</td><td width=\"33%\" valign=\"top\" id='col2'>";
$arr = explode(",",$cols2);
foreach ($arr AS $a)
{
show_dashboard_component(2, $a);
}
echo "</td></tr></table>\n";
// Users Login Details
echo "<div id='userbar'>";
if (user_accepting($sit[2])!='Yes')
{
$userstatus = "<span class='error'>{$strNotAcceptingIncidents}</span>";
}
else
{
$userstatus = "<strong>{$strAcceptingIncidents}</strong>";
}
echo sprintf($strLoggedInAsXAndCurrentlyXAndX,
"<strong>{$sit[0]}</strong>",
"<strong>".userstatus_name(user_status($sit[2]))."</strong>",
$userstatus);
if ($sit[3] == 'public')
{
echo "- {$strPublicSharedComputerIncreasedSecurity}";
}
echo "</div>\n";
?>
<script type="text/javascript">
/* <![CDATA[ */
//var cols = [1,3,1];
var cols = [<?php echo $colstr; ?>];
var cols0 = [<?php echo $cols0; ?>];
var cols1 = [<?php echo $cols1; ?>];
var cols2 = [<?php echo $cols2; ?>];
var dashlets = $$('div.windowbox');
var contain0 = ['col1', 'col2'];
var contain1 = ['col0', 'col2'];
var contain2 = ['col0', 'col1'];
Droppables.add('col0', {ghosting: true, onDrop: moveItem, hoverclass: 'droptarget', containment: contain0});
Droppables.add('col1', {ghosting: true, onDrop: moveItem, hoverclass: 'droptarget', containment: contain1});
Droppables.add('col2', {ghosting: true, onDrop: moveItem, hoverclass: 'droptarget', containment: contain2});
Sortable.create('col0', { tag:'div', only:'windowbox', onUpdate: save_layout});
Sortable.create('col1', { tag:'div', only:'windowbox', onUpdate: save_layout});
Sortable.create('col2', { tag:'div', only:'windowbox', onUpdate: save_layout});
// Set drop area by default non cleared.
$('col0').cleared = false;
$('col1').cleared = false;
$('col2').cleared = false;
$('savelayout').style.display='none';
window.onload = function() {
dashlets.each(
function(item) {
new Draggable(item, {revert: true});
}
);
}
// The target drop area contains a snippet of instructional
// text that we want to remove when the first item
// is dropped into it.
function moveItem( draggable,droparea){
// if (!droparea.cleared) {
// // droparea.innerHTML = '';
// droparea.cleared = true;
// }
// // draggable.parentNode.removeChild(draggable);
droparea.appendChild(draggable);
save_layout();
}
function save_layout(){
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}
var toPass = '';
for (var i = 0; i < 3; i++)
{
colid = 'col' + i;
var col = $(colid).childNodes;
var s = '';
// alert(colid + '=' + col.length);
for (var x = 0; x < col.length; x++){
// s = s+col.item(x).id.substr(5)+"-";
// alert('x = '+x + col.item(x).id);
s = s+i+"-"+col.item(x).id.substr(5)+",";
}
//alert(s);
toPass = toPass+s.substr(0,s.length-1)+",";
}
xmlhttp.open("GET", "ajaxdata.php?action=storedashboard&id="+<?php echo $_SESSION['userid']; ?>+"&val="+escape(toPass), true);
xmlhttp.onreadystatechange=function() {
//remove this in the future after testing
if (xmlhttp.readyState==4) {
if (xmlhttp.responseText != ''){
//alert(xmlhttp.responseText);
}
}
}
xmlhttp.send(null);
$('savelayout').style.display='none';
}
/* ]]> */
</script>
<?php
echo "<div id='footerbar'>";
echo "<form action='{$_SERVER['PHP_SELF']}'>";
echo "{$strSetYourStatus}: ";
if (isset($sit[2]))
{
echo userstatus_bardrop_down("status", user_status($sit[2])).help_link("SetYourStatus");
}
echo "</form>\n";
echo "</div>\n";
if ($CONFIG['debug']) $dbg .= "\nLang: {$_SESSION['lang']}\n";
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
?>