-
Notifications
You must be signed in to change notification settings - Fork 4
/
edit_level.php
77 lines (68 loc) · 3.3 KB
/
edit_level.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
<?php
namespace gameme\PHPGamification;
use Exception;
use gameme\PHPGamification;
use gameme\PHPGamification\Model;
use gameme\PHPGamification\Model\Level;
define('AT_INCLUDE_PATH', '../../include/');
require (AT_INCLUDE_PATH.'vitals.inc.php');
admin_authenticate(AT_ADMIN_PRIV_GAMEME);
$_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">
//<!--
jQuery.noConflict();
//-->
</script>';
if($_POST['cancel']){
$msg->addFeedback('cancelled');
header('Location:'.$_base_href.'mods/gameme/index_admin.php?tab=3');
exit;
}
if($_POST['submit']){
global $_base_path;
// this line is a hack
$this_path = preg_replace ('#/get.php#','',$_SERVER['DOCUMENT_ROOT'].$_base_path);
require_once($this_path.'mods/gameme/gamify.lib.php');
require_once($this_path.'mods/gameme/PHPGamification/PHPGamification.class.php');
$gamification = new PHPGamification();
$gamification->setDAO(new DAO(DB_HOST, DB_NAME, DB_USER, DB_PASSWORD));
if(!empty($_POST['title']) && !empty($_POST['points']) && settype($_POST['points'], 'integer')){
$gamification->addLevel($_POST['points'], $_POST['title'], $_POST['description']);
$msg->addFeedback('GM_LEVEL_ADDED');
header('Location:'.$_base_href.'mods/gameme/index_admin.php?tab=3');
exit;
} else {
$msg->addError("GM_LEVEL_REQUIREMENTS");
//$gamification->addLevel(0, 'No Star');
}
}
require (AT_INCLUDE_PATH.'header.inc.php');
$sql = "SELECT * FROM %sgm_levels WHERE id = %d";
$this_level = queryDB($sql, array(TABLE_PREFIX, $_GET['id']), TRUE);
?>
<form name="form" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<input type="hidden" id="id" name="id" value="<?php echo $this_level['id']; ?>" />
<div class="input-form">
<fieldset class="group_form">
<legend class="group_form"><?php echo _AT('gm_edit_level'); ?></legend>
<span title="required">*</span><label for="title"><?php echo _AT('gm_level_title'); ?></label><br />
<?php
if(!isset($_GET['id'])){?>
<input type="text" id="title" name="title" value="<?php echo $this_level['title']; ?>" aria-required="true" />
<?php } else { ?>
<strong><?php echo $this_level['title']; ?></strong>
<input type="hidden" id="title" name="title" value="<?php echo $this_level['title']; ?>" />
<?php } ?>
<br /><br />
<label for="description"><?php echo _AT('gm_short_description'); ?></label><br />
<input type="text" id="description" name="description" value="<?php echo $this_level['description']; ?>" size="48"/><br />
<span title="required">*</span><label for="points"><?php echo _AT('gm_points_reached'); ?></label> <br />
<input type="text" id="points" name="points" value="<?php echo $this_level['points']; ?>" maxlength="8" size="8" aria-required="true"/><br />
<input type="submit" name="submit" value="<?php echo _AT('gm_update_level'); ?>" /><input type="submit" name="cancel" value="<?php echo _AT('gm_cancel'); ?>"/>
</fieldset>
</div>
</form>
<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>