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