remove old readme
[atutor.git] / docs / mods / _core / courses / html / course_properties.inc.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13 if (!defined('AT_INCLUDE_PATH')) { exit; }
14
15 require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
16 require_once(AT_INCLUDE_PATH.'../mods/_core/cats_categories/lib/admin_categories.inc.php');
17 require_once(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
18 //require_once(AT_INCLUDE_PATH.'lib/course_icon.inc.php');
19
20 $_GET['show_courses'] = $addslashes(intval($_GET['show_courses']));
21 $_GET['current_cat'] = $addslashes(intval($_GET['current_cat']));
22
23 if (!isset($_REQUEST['setvisual']) && !isset($_REQUEST['settext'])) {
24         if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 1) {
25                 $_POST['formatting'] = 1;
26                 $_REQUEST['settext'] = 0;
27                 $_REQUEST['setvisual'] = 0;
28
29         } else if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 2) {
30                 $_POST['formatting'] = 1;
31                 $_POST['settext'] = 0;
32                 $_POST['setvisual'] = 1;
33
34         } else { // else if == 0
35                 $_POST['formatting'] = 0;
36                 $_REQUEST['settext'] = 0;
37                 $_REQUEST['setvisual'] = 0;
38         }
39 }
40
41 if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']) {
42         load_editor(false, 'banner');
43 }
44
45 if (!isset($isadmin, $course, $db)) {
46         return; 
47 }
48
49 if (isset($_POST['form_course'])) {
50
51         $row['course_id']                       = $_POST['course'];
52         $row['title']                           = $_POST['title'];
53         $row['primary_language']        = $_POST['primary_language'];
54         $row['member_id']                       = $_POST['member_id'];
55         $row['description']                     = $_POST['description'];
56         $row['course_dir_name']         = $_POST['course_dir_name'];
57         $row['cat_id']                          = $_POST['cat_id'];
58         $row['content_packaging']       = $_POST['content_packaging'];
59
60         $row['access']                          = $_POST['access'];
61         $row['notify']                          = $_POST['notify'];
62
63         $row['max_quota']                       = $_POST['max_quota'];
64         $row['max_file_size']           = $_POST['max_file_size'];
65
66         $row['created_date']            = date('Y-m-d H:i:s');
67         $row['primary_language']    = $_POST['pri_lang'];
68         $row['rss']                 = $_POST['rss'];
69
70         $row['copyright']                       = $_POST['copyright'];
71         $row['icon']                            = $_POST['icon'];
72         $row['banner']              = stripcslashes($_POST['banner']);
73
74         if (intval($_POST['release_date'])) {
75                 $day_release    = intval($_POST['day_release']);
76                 $month_release  = intval($_POST['month_release']);
77                 $year_release   = intval($_POST['year_release']);
78                 $hour_release   = intval($_POST['hour_release']);
79                 $min_release    = intval($_POST['min_release']);
80
81                 if (strlen($month_release) == 1){
82                         $month_release = "0$month_release";
83                 }
84                 if (strlen($day_release) == 1){
85                         $day_release = "0$day_release";
86                 }
87                 if (strlen($hour_release) == 1){
88                         $hour_release = "0$hour_release";
89                 }
90                 if (strlen($min_release) == 1){
91                         $min_release = "0$min_release";
92                 }
93                 $row['release_date'] = "$year_release-$month_release-$day_release $hour_release:$min_release:00";
94         } else {
95                 $row['release_date'] = 0;
96         }
97
98         if (intval($_POST['end_date'])) {
99                 $day_end        = intval($_POST['day_end']);
100                 $month_end      = intval($_POST['month_end']);
101                 $year_end       = intval($_POST['year_end']);
102                 $hour_end       = intval($_POST['hour_end']);
103                 $min_end        = intval($_POST['min_end']);
104
105                 if (strlen($month_end) == 1){
106                         $month_end = "0$month_end";
107                 }
108                 if (strlen($day_end) == 1){
109                         $day_end = "0$day_end";
110                 }
111                 if (strlen($hour_end) == 1){
112                         $hour_end = "0$hour_end";
113                 }
114                 if (strlen($min_end) == 1){
115                         $min_end = "0$min_end";
116                 }
117                 $row['end_date'] = "$year_end-$month_end-$day_end $hour_end:$min_end:00";
118         } else {
119                 $row['end_date'] = 0;
120         }
121
122 } else if ($course) {
123         $sql    = "SELECT *, DATE_FORMAT(release_date, '%Y-%m-%d %H:%i:00') AS release_date, DATE_FORMAT(end_date, '%Y-%m-%d %H:%i:00') AS end_date  FROM ".TABLE_PREFIX."courses WHERE course_id=$course";
124         $result = mysql_query($sql, $db);
125         if (!($row      = mysql_fetch_assoc($result))) {
126                 echo _AT('no_course_found');
127                 return;
128         }
129
130 } else {
131         //new course defaults
132         $row['content_packaging']       = 'top';
133         $row['access']                          = 'protected';
134         $row['notify']                          = '';
135         $row['hide']                            = '';
136
137         $row['max_quota']                       = AT_COURSESIZE_DEFAULT;
138         $row['max_file_size']           = AT_FILESIZE_DEFAULT;
139
140         $row['primary_language']        = $_SESSION['lang'];
141         $row['created_date']            = date('Y-m-d H:i:s');
142         $row['rss']                 = 0; // default to off
143         $row['release_date']            = '0';
144         $row['end_date']            = '0';
145 }
146 /*
147 if (($_POST['setvisual'] || $_POST['settext']) && !$_POST['submit']){
148         $anchor =  "#banner";
149 } */
150
151 if ($_POST['customicon']) {
152     echo "<script language='javascript' type='text/javascript'>document.getElementById('uploadform').focus();</script>";
153 }
154 $savant->assign('row', $row);
155 $savant->display('admin/courses/edit_course.tmpl.php');
156 ?>
157
158 <script language="javascript" type="text/javascript">
159 <!--
160 function enableNotify() {
161         document.course_form.notify.disabled = false;
162         document.course_form.hide.disabled = false;
163 }
164
165 function disableNotify() {
166         document.course_form.notify.disabled = true;
167         document.course_form.hide.disabled = true;
168 }
169
170 function enableOther()          { document.course_form.quota_entered.disabled = false; }
171 function disableOther()         { document.course_form.quota_entered.disabled = true; }
172 function enableOther2()         { document.course_form.filesize_entered.disabled = false; }
173 function disableOther2()        { document.course_form.filesize_entered.disabled = true; }
174
175 function enableRelease() { 
176         document.course_form.day_release.disabled = false; 
177         document.course_form.month_release.disabled = false; 
178         document.course_form.year_release.disabled = false; 
179         document.course_form.hour_release.disabled = false; 
180         document.course_form.min_release.disabled = false; 
181 }
182 function disableRelease() { 
183         document.course_form.day_release.disabled = true; 
184         document.course_form.month_release.disabled = true; 
185         document.course_form.year_release.disabled = true; 
186         document.course_form.hour_release.disabled = true; 
187         document.course_form.min_release.disabled = true; 
188 }
189
190 function SelectImg() {
191     // UPDATED by Martin Turlej - for custom course icon
192
193     var boolForce = document.getElementById('boolForce').value;
194         if (document.course_form.icon.options[document.course_form.icon.selectedIndex].value == "") {
195                 document.getElementById('i0').src = "images/clr.gif";
196                 document.getElementById('i0').alt = "";
197         } else {
198         var iconIndx = document.course_form.icon.selectedIndex;
199         var custIndx = document.getElementById('custOptCount').value;
200         var courseId = document.getElementById('courseId').value;
201
202         // if icon is part of custom icons choose corresponding directory
203         if (iconIndx <= custIndx && boolForce != '') {                  
204             var dir = (boolForce == 1) ? "get_course_icon.php/?id="+courseId : "/content/"+courseId+"/custom_icons/";
205         } else {
206             var dir = "images/courses/";
207         }
208
209                 document.getElementById('i0').src = dir + document.course_form.icon.options[iconIndx].value;
210                 document.getElementById('i0').alt = document.course_form.icon.options[iconIndx].value;
211         }
212 }
213
214 function toggleFrm(id) {
215     if (document.getElementById(id).style.display == "none") {
216                 //show
217                 document.getElementById(id).style.display='';   
218
219                 if (id == "c_folder") {
220                         document.form0.new_folder_name.focus();
221                 } else if (id == "upload") {
222                         document.form0.file.focus();
223                 }
224
225         } else {
226                 //hide
227                 document.getElementById(id).style.display='none';
228         }
229 }
230 // -->
231 </script>