-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex_admin.php
More file actions
269 lines (251 loc) · 13.6 KB
/
index_admin.php
File metadata and controls
269 lines (251 loc) · 13.6 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
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
263
264
265
266
267
268
269
<?php
define('AT_INCLUDE_PATH', '../../include/');
require (AT_INCLUDE_PATH.'vitals.inc.php');
admin_authenticate(AT_ADMIN_PRIV_GAMEME);
require_once(AT_INCLUDE_PATH.'../mods/gameme/gamify.lib.php');
$_custom_css = $_base_path . 'mods/gameme/module.css'; // use a custom stylesheet
$_custom_head = '<script type="text/javascript" src="'.$_base_path .'jscripts/lib/jquery.1.10.1.min.js"></script>'."\n";
$_custom_head.= '<script type="text/javascript" src="'.$_base_path .'mods/gameme/gamify.js"></script>'."\n";
$_custom_head .= '<script type="text/javascript" src="'.$_base_path.'mods/gameme/inline_edit/jquery-quickedit.js"></script>'."\n";
$_custom_head .= '<script type="text/javascript" src="'.$_base_path.'mods/gameme/jquery/js.cookie-min.js"></script>'."\n";
$_custom_head .= '<script type="text/javascript" src="'.$_base_path.'mods/gameme/dropzone.js"></script>'."\n";
$_custom_head.='
<script type="text/javascript">
//<!--
jQuery.noConflict();
//-->
function showEdit(editableObj) {
//$(editableObj).css("background","#eee");
}
function saveEvent(editableObj,column,id) {
cellvalue = editableObj.innerText;
cellvalue = cellvalue.replace(/<br>/g,"");
//$(editableObj).css("background","#FFF url('.$_base_path.'mods/gameme/images/loaderIcon.gif) no-repeat right");
$.ajax({
url: "'.$_base_path.'mods/gameme/save_event.php",
type: "POST",
data:"column="+column+"&editval="+cellvalue+"&id="+id,
success: function(data){
$(editableObj).css("background","#FDFDFD");
},
error: function(data){
//console.log(data);
}
});
}
function saveBadge(editableObj,column,id) {
cellvalue = editableObj.innerText;
cellvalue = cellvalue.replace(/<br>/g,"");
$(editableObj).css("background","#FFF url('.$_base_path.'mods/gameme/images/loaderIcon.gif) no-repeat right");
$.ajax({
url: "'.$_base_path.'mods/gameme/save_badge.php",
type: "POST",
data:"column="+column+"&editval="+cellvalue+"&id="+id,
success: function(data){
$(editableObj).css("background","#FDFDFD");
},
error: function(data){
//console.log(data);
}
});
}
function saveLevel(editableObj,column,id) {
cellvalue = editableObj.innerText;
cellvalue = cellvalue.replace(/<br>/g,"");
$(editableObj).css("background","#FFF url('.$_base_href.'mods/gameme/images/loaderIcon.gif) no-repeat right");
$.ajax({
url: "'.$_base_path.'mods/gameme/save_level.php",
type: "POST",
data:"column="+column+"&editval="+cellvalue+"&id="+id,
success: function(data){
$(editableObj).css("background","#FDFDFD");
},
error: function(data){
//console.log(data);
}
});
}
</script>';
if(isset($_POST['submit'])){
if (isset($_POST['instructor_edit']) && ($stripslashes($_POST['instructor_edit']) != $value)) {
$sql = 'REPLACE INTO %sconfig VALUES ("%s", "%s")';
$num_rows = queryDB($sql, array(TABLE_PREFIX, 'instructor_edit', $_POST['instructor_edit']));
write_to_log(AT_ADMIN_LOG_REPLACE, 'config', $num_rows, $sqlout);
$msg->addFeedback('GM_CONFIG_UPDATED');
header('Location:'.$_SERVER['PHP_SELF']);
exit;
} else if (!isset($_POST['instructor_edit'])) {
$sql = "DELETE FROM %sconfig WHERE name='%s'";
$num_rows = queryDB($sql, array(TABLE_PREFIX, 'instructor_edit'));
write_to_log(AT_ADMIN_LOG_DELETE, 'config', $num_rows, $sqlout);
$msg->addFeedback('GM_CONFIG_UPDATED');
header('Location:'.$_SERVER['PHP_SELF']);
exit;
}
}
require (AT_INCLUDE_PATH.'header.inc.php');
global $_base_path;
$this_path = preg_replace ('#/get.php#','',$_SERVER['DOCUMENT_ROOT'].$_base_path);
//$active = " active";
?>
<ul class="tablist " role="tablist" id="subnavlist">
<li id="tab1" class="tab" aria-controls="panel1" aria-selected="true" tabindex="0" role="tab" onclick="javascript:Cookies.set('activetab', 'tab1');">
<?php echo _AT('gm_events'); ?></li>
<li id="tab2" class="tab" aria-controls="panel2" role="tab" tabindex="0" aria-selected="false" onclick="javascript:Cookies.set('activetab', 'tab2');">
<?php echo _AT('gm_badges'); ?></li>
<li id="tab3" class="tab" aria-controls="panel3" role="tab" tabindex="0" aria-selected="false" onclick="javascript:Cookies.set('activetab', 'tab3');">
<?php echo _AT('gm_levels'); ?></li>
<li id="tab4" class="tab" aria-controls="panel4" role="tab" tabindex="0" aria-selected="false" onclick="javascript:Cookies.set('activetab', 'tab4');">
<?php echo _AT('gm_options'); ?></li>
</ul>
<div id="panel1" class="panel" aria-labelledby="tab1" role="tabpanel" aria-hidden="false">
<a href="mods/gameme/edit_event.php" style="float:right;"><?php echo _AT('gm_addplus'); ?></a>
<?php
if($_SESSION['inline_edit']){ ?>
<a href="javascript:;" onclick="" id="inline_edit_toggle"><?php echo _AT('gm_enable_edit'); ?></a>
<?php } ?>
<h3><?php echo _AT('gm_default_events'); ?></h3>
<?php $msg->printInfos('GM_ENABLE_EDIT_TEXT'); ?>
<?php //require_once($this_path.'mods/gameme/gamify.lib.php');
//require_once(AT_INCLUDE_PATH.'../mods/gameme/gamify.lib.php');
?>
<table class="table table-hover table-bordered col-sm-12 data" >
<tr>
<th><?php echo _AT('gm_alias'); ?></th>
<th><?php echo _AT('gm_description'); ?></th>
<th><?php echo _AT('gm_repetition'); ?></th>
<th><?php echo _AT('gm_reach_reps'); ?></th>
<th><?php echo _AT('gm_max_points'); ?></th>
<th><?php echo _AT('gm_each_badge'); ?></th>
<th><?php echo _AT('gm_reach_badge'); ?></th>
<th><?php echo _AT('gm_each_points'); ?></th>
<th><?php echo _AT('gm_reach_points'); ?></th>
<th><?php echo _AT('gm_each_callback'); ?></th>
<th><?php echo _AT('gm_reach_callback'); ?></th>
<th><?php echo _AT('gm_reach_message'); ?></th>
<th></th>
</tr>
<?php
$sql = "SELECT * from %sgm_events";
$all_events = queryDB($sql, array(TABLE_PREFIX));
$count = 0;
foreach($all_events as $key=>$event){
echo '<tr>
<td contenteditable="true" onBlur="saveEvent(this,\'alias\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['alias'].'</td>
<td contenteditable="true" onBlur="saveEvent(this,\'description\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['description'].'</td>
<td style="text-align:center;" contenteditable="true" onBlur="saveEvent(this,\'allow_repetitions\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['allow_repetitions'].'</td>
<td style="text-align:center;" contenteditable="true" onBlur="saveEvent(this,\'reach_required_repetitions\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['reach_required_repetitions'].'</td>
<td style="text-align:center;" contenteditable="true" onBlur="saveEvent(this,\'max_points\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['max_points'].'</td>
<td style="text-align:center;" contenteditable="true" onBlur="saveEvent(this,\'id_each_badge\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['id_each_badge'].'</td>
<td style="text-align:center;" contenteditable="true" onBlur="saveEvent(this,\'id_reach_badge\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['id_reach_badge'].'</td>
<td style="text-align:center;" contenteditable="true" onBlur="saveEvent(this,\'each_points\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['each_points'].'</td>
<td style="text-align:center;" contenteditable="true" onBlur="saveEvent(this,\'reach_points\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['reach_points'].'</td>
<td contenteditable="true" onBlur="saveEvent(this,\'each_callback\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['each_callback'].'</td>
<td contenteditable="true" onBlur="saveEvent(this,\'reach_callback\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['reach_callback'].'</td>
<td contenteditable="true" onBlur="saveEvent(this,\'reach_message\',\''.$event['id'].' \')" onClick="showEdit(this);">'.$event['reach_message'].'</td>
<td><!--<a href="mods/gameme/edit_event.php?id='.$event['id'].'">'._AT('gm_edit').'</a>--> <a href="mods/gameme/delete_event.php?id='.$event['id'].'">'._AT('gm_delete').'</a></td>
</tr>';
}
?>
</table>
</div>
<div id="panel2" class="panel" aria-labelledby="tab2" role="tabpanel" aria-hidden="true">
<a href="mods/gameme/edit_badge.php" style="float:right;"><?php echo _AT('gm_addplus'); ?></a>
<h3><?php echo _AT('gm_default_badges'); ?></h3>
<?php $msg->printInfos('GM_EDIT_BADGE_TEXT'); ?>
<table class="table table-hover table-bordered col-sm-12 data">
<tr>
<th><?php echo _AT('gm_badge'); ?></th>
<th><?php echo _AT('gm_id'); ?></th>
<th><?php echo _AT('gm_alias'); ?></th>
<th><?php echo _AT('gm_title'); ?></th>
<th><?php echo _AT('gm_description'); ?></th>
<th></th>
</tr>
<?php
$sql = "SELECT * from %sgm_badges WHERE course_id = 0";
$all_badges = queryDB($sql, array(TABLE_PREFIX));
foreach($all_badges as $badge){
if(!file_get_contents($_base_href.$badge['image_url'])){
$content_dir = explode('/',AT_CONTENT_DIR);
array_pop($content_dir);
$badge_file_name = explode("/",$badge['image_url']);
//$badge_file = end($content_dir).'/0/gameme/badges/'.end($badge_file_name);
$badge_file = $_base_href.'mods/gameme/get_badge_icon.php?badge_id='.$badge['id'];
} else{
$badge_file = $_base_href.$badge['image_url'];
}
echo '<tr>
<!--<td contenteditable="true" onBlur="saveBadge(this,\'image_url\',\''.$badge['id'].' \')" onClick="showEdit(this);"><img src="'.$badge['image_url'].'" alt="" /></td> -->
<td contenteditable="true" onClick="showEdit(this);"><form action="'.$_base_href.'mods/gameme/upload_badge.php"
class="dropzone"
id="my-awesome-dropzone" style="background-image:url('.$badge_file.');background-repeat:no-repeat;" method="post">
<input type="hidden" name="course_id" value="0" />
<input type="hidden" name="badge_id" value="'.$badge['id'].' " />
<div class="fallback">
<input name="file" type="file" />
</div>
</form></td>
<td>'.$badge['id'].'</td>
<td contenteditable="true" onBlur="saveBadge(this,\'alias\',\''.$badge['id'].' \')" onClick="showEdit(this);">'.$badge['alias'].'</td>
<td contenteditable="true" onBlur="saveBadge(this,\'title\',\''.$badge['id'].' \')" onClick="showEdit(this);">'.$badge['title'].'</td>
<td contenteditable="true" onBlur="saveBadge(this,\'description\',\''.$badge['id'].' \')" onClick="showEdit(this);">'.$badge['description'].'</td>
<td><!-- <a href="mods/gameme/edit_badge.php?id='.$badge['id'].'">'._AT('gm_edit').'</a> --><a href="mods/gameme/delete_badge.php?id='.$badge['id'].'">'._AT('gm_delete').'</a></td>
</tr>';
}
?>
</table>
</div>
<div id="panel3" class="panel" aria-labelledby="tab3" role="tabpanel" aria-hidden="true">
<a href="mods/gameme/edit_level.php" style="float:right;"><?php echo _AT('gm_addplus'); ?></a>
<h3><?php echo _AT('gm_default_levels'); ?></h3>
<?php $msg->printInfos('GM_LEVELS_TEXT'); ?>
<table class="table table-hover table-bordered col-sm-12 data">
<tr>
<th><?php echo _AT('gm_icon'); ?></th>
<th><?php echo _AT('gm_level_name'); ?></th>
<th><?php echo _AT('gm_description'); ?></th>
<th><?php echo _AT('gm_points_threshold'); ?></th>
<th></th>
</tr>
<?php
if($_SESSION['course_id'] > 0){
$course_id = $_SESSION['course_id'];
} else{
$course_id = 0;
}
$sql = "SELECT * from %sgm_levels WHERE course_id = %d ORDER BY points desc";
$all_levels = queryDB($sql, array(TABLE_PREFIX, $course_id));
foreach($all_levels as $level){
echo '<tr>
<td><form action="'.$_base_href.'mods/gameme/upload_level_icon.php"
class="dropzone"
id="level'.$level['id'].'" style="background-image:url('.star_file($level['id']).');background-repeat:no-repeat;background-position: center; " method="post" tabindex="0">
<input type="hidden" name="course_id" value="0" />
<input type="hidden" name="level_id" value="'.$level['id'].' " />
<div class="fallback">
<input name="file" type="file" id="theFile" onclick="performKeyPress(\'theFile\')";/>
</div>
</form></td>
<td contenteditable="true" onBlur="saveLevel(this,\'title\',\''.$level['id'].' \')" onClick="showEdit(this);">'.$level['title'].'</td>
<td contenteditable="true" onBlur="saveLevel(this,\'description\',\''.$level['id'].' \')" onClick="showEdit(this);">'.$level['description'].'</td>
<td contenteditable="true" onBlur="saveLevel(this,\'points\',\''.$level['id'].' \')" onClick="showEdit(this);">'.$level['points'].'</td>
<td><a href="mods/gameme/delete_level.php?id='.$level['id'].SEP.'course_id=0">'._AT('gm_delete').'</a></td>
</tr>';
}
?>
</table>
</div>
<div id="panel4" class="panel" aria-labelledby="tab4" role="tabpanel" aria-hidden="true">
<h3><?php echo _AT('gm_options'); ?></h3>
<?php $msg->printInfos('GM_OPTIONS_TEXT'); ?>
<br style="clear:both;" />
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="checkbox" name="instructor_edit" id="instructor_edit" <?php if($_config['instructor_edit']){echo 'checked="checked"';}?>/>
<label for="instructor_edit"><?php echo _AT('gm_disallow_instructors'); ?></label>
<input type="submit" name="submit" value="<?php echo _AT('gm_update_options'); ?>" />
</form>
</div>
<script src="<?php echo $_base_href; ?>mods/gameme/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo $_base_path; ?>mods/gameme/inline_edit/jquery-quickedit.js"></script>
<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>