40937bd9f2a59f4be8cf2d4c358a60e1c5956fc8
[atutor.git] / docs / mods / _core / courses / users / create_course.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id$
14 $_user_location = 'users';
15 define('AT_INCLUDE_PATH', '../../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 require(AT_INCLUDE_PATH.'../mods/_core/backups/classes/Backup.class.php');
18 require(AT_INCLUDE_PATH.'../mods/_core/courses/lib/course.inc.php');
19
20 /* verify that this user has status to create courses */
21
22 if (get_instructor_status() === FALSE) {
23         require(AT_INCLUDE_PATH.'header.inc.php');
24
25         if (defined('ALLOW_INSTRUCTOR_REQUESTS') && ALLOW_INSTRUCTOR_REQUESTS) {
26                 $sql    = "SELECT member_id FROM ".TABLE_PREFIX."instructor_approvals WHERE member_id=$_SESSION[member_id]";
27                 $result = mysql_query($sql, $db);
28                 if (!($row = mysql_fetch_array($result))) : ?>
29                         <form action="mods/_core/courses/users/request_instructor.php" method="post">
30                         <input type="hidden" name="form_request_instructor" value="true" />
31                         <div class="input-form">
32                                 <div class="row">
33                                         <p><?php echo _AT('request_instructor'); ?></p>
34                                 </div>
35
36                                 <div class="row">
37                                         <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="desc"><?php echo _AT('give_description'); ?></label><br />
38                                         <textarea cols="40" rows="2" id="desc" name="description"></textarea>
39                                 </div>
40
41                                 <div class="row buttons">
42                                         <input type="submit" name="submit" value="<?php echo _AT('send'); ?>" />
43                                         <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
44                                 </div>
45                         </div>
46                         </form>
47                 <?php else : ?>
48                         <div class="input-form">
49                                 <div class="row">
50                                         <p><?php echo _AT('request_instructor_pending'); ?></p>
51                                 </div>
52                         </div>
53                 <?php endif; ?>
54 <?php
55         }
56         require(AT_INCLUDE_PATH.'footer.inc.php');
57         exit;
58 }
59
60 $course = 0;
61 $isadmin   = FALSE;
62
63 if (isset($_POST['cancel'])) {
64         $msg->addFeedback('CANCELLED');
65         header('Location: index.php');
66         exit;
67 }else if (isset($_POST['form_course']) && $_POST['submit'] != '') {
68         $_POST['instructor'] = $_SESSION['member_id'];
69
70                 $errors = add_update_course($_POST);
71
72         if ($errors !== FALSE) {
73                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
74                 header('Location: '.AT_BASE_HREF.'bounce.php?course='.$addslashes($errors).SEP.'p='.urlencode('index.php'));
75                 exit;
76         }
77
78 }
79
80 $onload = 'document.course_form.title.focus();';
81
82 require(AT_INCLUDE_PATH.'header.inc.php');
83
84 require(AT_INCLUDE_PATH.'../mods/_core/courses/html/course_properties.inc.php');
85 require(AT_INCLUDE_PATH.'footer.inc.php');
86 ?>