remove old readme
[atutor.git] / docs / mods / _standard / basiclti / tool / admin_create.php
1 <?php
2 define('AT_INCLUDE_PATH', '../../../../include/');
3 require(AT_INCLUDE_PATH.'vitals.inc.php');
4 admin_authenticate(AT_ADMIN_PRIV_BASICLTI);
5
6 require_once('forms.php');
7 if($_POST['submit']){
8         // filter all POST data
9         $_POST['form_basiclti'] = $addslashes($_POST['form_basiclti']);
10         $_POST['title'] = $addslashes($_POST['title']);
11         $_POST['toolid'] = $addslashes($_POST['toolid']);
12         $_POST['description'] = $addslashes($_POST['description']);
13         $_POST['toolurl'] = $addslashes($_POST['toolurl']);
14         $_POST['resourcekey'] = $addslashes($_POST['resourcekey']);
15         $_POST['password'] = $addslashes($_POST['password']);
16         $_POST['preferheight'] = intval($_POST['preferheight']);
17         $_POST['allowpreferheight'] = intval($_POST['allowpreferheight']);
18         $_POST['launchinpopup'] = intval($_POST['launchinpopup']);
19         $_POST['debuglaunch'] = intval($_POST['debuglaunch']);
20         $_POST['sendname'] = intval($_POST['sendname']);
21         $_POST['sendemailaddr'] = intval($_POST['sendemailaddr']);
22         $_POST['acceptgrades'] = intval($_POST['acceptgrades']);
23         $_POST['allowroster'] = intval($_POST['allowroster']);
24         $_POST['allowsetting'] = intval($_POST['allowsetting']);
25         $_POST['allowcustomparameters'] = intval($_POST['allowcustomparameters']);
26 //      $_POST['customparameters'] = $addslashes($_POST['customparameters']);
27         $_POST['organizationid'] = $addslashes($_POST['organizationid']);
28         $_POST['organizationurl'] = $addslashes($_POST['organizationurl']);
29         $_POST['organizationdescr'] = $addslashes($_POST['organizationdescr']);
30         $_POST['submit'] = $addslashes($_POST['submit']);
31 }
32
33 if (isset($_POST['cancel'])) {
34         $msg->addFeedback('CANCELLED');
35         header('Location: '.AT_BASE_HREF.'mods/_standard/basiclti/index_admin.php');
36         exit;
37 } else if (isset($_POST['form_basiclti'])) {
38
39     if ( at_form_validate($blti_admin_form, $msg) ) {
40         $sql = "SELECT count(*) cnt FROM ".TABLE_PREFIX."basiclti_tools WHERE toolid = '".
41                 mysql_real_escape_string($_POST['toolid'])."';";
42         $result = mysql_query($sql, $db) or die(mysql_error());
43         $row = mysql_fetch_assoc($result);
44
45         if ($row["cnt"] != 0) {
46            $msg->addFeedback('NEED_UNIQUE_TOOLID');
47         } else {
48             $sql = at_form_insert($_POST, $blti_admin_form);
49             $sql = 'INSERT INTO '.TABLE_PREFIX."basiclti_tools ".$sql;
50             $result = mysql_query($sql, $db) or die(mysql_error());
51             write_to_log(AT_ADMIN_LOG_INSERT, 'basiclti_create', mysql_affected_rows($db), $sql);
52             $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
53
54
55             header('Location: '.AT_BASE_HREF.'mods/_standard/basiclti/index_admin.php');
56             exit;
57         }
58     }
59 }
60
61 include(AT_INCLUDE_PATH.'header.inc.php');
62
63 $msg->printAll();
64
65 ?>
66 <form method="post" action="<?php echo $_SERVER['PHP_SELF'];  ?>" name="basiclti_form" enctype="multipart/form-data">
67   <input type="hidden" name="form_basiclti" value="true" />
68   <div class="input-form">
69     <fieldset class="group_form"><legend class="group_form"><?php echo _AT('properties'); ?></legend>
70 <?php at_form_generate($_POST, $blti_admin_form); ?>
71         <div class="buttons">
72                 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
73                 <input type="submit" name="cancel" value="<?php echo _AT('cancel');?>" />
74         </div>
75     </fieldset>
76   </div>
77 </form>
78
79 <?php
80 require(AT_INCLUDE_PATH.'footer.inc.php');