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