remove old readme
[atutor.git] / docs / themes / default / admin / courses / create_course.tmpl.php
1
2 <?php global $languageManager,  $_config, $MaxCourseSize, $MaxFileSize;
3
4 ?>
5 <form method="post" action="<?php echo $_SERVER['PHP_SELF'];  ?>" name="course_form" enctype="multipart/form-data">
6         <input type="hidden" name="form_course" value="true" />
7         <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_config['prof_pic_max_file_size']; ?>" />
8         <input type="hidden" name="course" value="<?php echo $this->course; ?>" />
9         <input type="hidden" name="old_access" value="<?php echo $this->row['access']; ?>" />
10         <input type="hidden" name="created_date" value="<?php echo $this->row['created_date']; ?>" />
11         <input type="hidden" name="show_courses" value="<?php echo $_GET['show_courses']; ?>" />
12         <input type="hidden" name="current_cat" value="<?php echo $_GET['current_cat']; ?>" />
13         <input type="submit" name="submit" style="display:none;"/>
14
15 <div class="input-form">
16         <fieldset class="group_form"><legend class="group_form"><?php echo _AT('properties'); ?></legend>
17 <?php if ($this->isadmin): ?>
18         <div class="row">
19                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="inst"><?php echo  _AT('instructor'); ?></label><br />
20                         <?php 
21                 
22                         if ($instructor_row = mysql_fetch_assoc($this->result)) {
23                                 echo '<select name="instructor" id="inst">';
24                                 do {
25                                         if ($instructor_row['member_id'] == $this->row['member_id']) {
26                                                 echo '<option value="'.$instructor_row['member_id'].'" selected="selected">'.$instructor_row['login'].'</option>';
27                                         } else {
28                                                 echo '<option value="'.$instructor_row['member_id'].'">'.$instructor_row['login'].'</option>';
29                                         }
30                                 } while($instructor_row = mysql_fetch_assoc($this->result));
31                                 echo '</select>';
32                         } else {
33                                 echo '<span id="inst">'._AT('none_found').'</span>';
34                         }
35                         ?>
36         </div>
37 <?php endif; ?>
38
39         <div class="row">
40                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="title"><?php echo _AT('title'); ?></label><br />
41                 <input type="text" id="title" name="title" size="40" value="<?php echo htmlspecialchars($this->row['title']); ?>" />
42         </div>
43
44         <div class="row">
45                 <label for="pri_lang"><?php  echo _AT('primary_language'); ?></label><br />
46                 <?php $languageManager->printDropdown($this->row['primary_language'], 'pri_lang', 'pri_lang'); ?>
47         </div>
48
49         <div class="row">
50                 <label for="description"><?php echo _AT('description'); ?></label><br />
51                 <textarea id="description" cols="45" rows="2" name="description"><?php echo $this->row['description']; ?></textarea>
52         </div>
53
54         <?php if ($_config['course_dir_name']): ?>
55         <div class="row">
56                 <label for="course_dir_name"><?php echo _AT('course_dir_name'); ?></label><br />
57                 <input type="text" id="course_dir_name" name="course_dir_name" size="40" value="<?php echo htmlspecialchars($this->row['course_dir_name']); ?>" />
58         </div>
59         <?php endif; ?>
60
61         <?php $categories = get_categories(); ?>
62         <?php if (is_array($categories)): ?>
63                 <div class="row">
64                 <label for="cat"><?php echo _AT('category'); ?></label><br />
65                         <select name="category_parent" id="cat">
66                                 <option value="0">&nbsp;&nbsp;&nbsp;[&nbsp;&nbsp;<?php echo _AT('cats_uncategorized'); ?>&nbsp;&nbsp;]&nbsp;&nbsp;&nbsp;</option>
67                                 <?php select_categories($categories, 0, $this->row['cat_id'], false); ?>
68
69                         </select>
70                 </div>
71         <?php endif; ?>
72
73         <div class="row">
74                 <?php  echo _AT('export_content'); ?><br />
75                 <?php
76                         switch ($this->row['content_packaging']) {
77                                 case 'none':
78                                                 $none = ' checked="checked"';
79                                                 break;
80
81                                 case 'top':
82                                                 $top     = ' checked="checked"';
83                                                 break;
84
85                                 case 'all':
86                                                 $all    = ' checked="checked"';
87                                                 break;
88                         }
89                         ?>
90                 <label><input type="radio" name="content_packaging" value="none" id="none" <?php echo $none; ?> /><?php echo _AT('content_packaging_none'); ?></label><br />
91                 <label><input type="radio" name="content_packaging" value="top" id="ctop"  <?php echo $top; ?> /><?php  echo _AT('content_packaging_top'); ?></label><br />
92                 <label><input type="radio" name="content_packaging" value="all" id="all" <?php echo $all; ?> /><?php  echo _AT('content_packaging_all'); ?></label>
93         </div>
94
95         <div class="row">
96                 <?php echo _AT('syndicate_announcements'); ?><br />
97                 <?php
98                                 $rss_no = $rss_yes = '';
99
100                                 if ($this->row['rss']) {
101                                         $rss_yes = ' checked="checked"';
102                                 } else {
103                                         $rss_no = ' checked="checked"';
104                                 }
105                 ?>
106                 <label><input type="radio" name="rss" value="1" id="rss_y" <?php echo $rss_yes; ?> /><?php echo _AT('enable_syndicate'); ?></label><br />
107                 <label><input type="radio" name="rss" value="0" id="rss_n"  <?php echo $rss_no; ?> /><?php  echo _AT('disable_syndicate'); ?></label>
108         </div>
109
110         <div class="row">
111                 <?php echo _AT('access'); ?><br />
112                 <?php
113                                 switch ($this->row['access']) {
114                                         case 'public':
115                                                         $pub = ' checked="checked"';
116                                                         $disable = 'disabled="disabled"'; // disable the nofity box
117                                                         break;
118
119                                         case 'protected':
120                                                         $prot    = ' checked="checked"';
121                                                         $disable = 'disabled="disabled"'; // disable the nofity box
122                                                         break;
123
124                                         case 'private':
125                                                         $priv   = ' checked="checked"';
126                                                         break;
127                                 }
128
129                                 if ($this->row['notify']) {
130                                         $notify = ' checked="checked"';
131                                 }
132
133                                 if ($this->row['hide']) {
134                                         $hide = ' checked="checked"';
135                                 }
136                 ?>
137                 <input type="radio" name="access" value="public" id="pub" onclick="disableNotify();" <?php echo $pub; ?> /><label for="pub"><strong> <?php echo  _AT('public'); ?>: </strong></label><?php echo  _AT('about_public'); ?><br /><br />
138
139                 <input type="radio" name="access" value="protected" id="prot" onclick="disableNotify();" <?php echo $prot; ?> /><label for="prot"><strong><?php echo  _AT('protected'); ?>:</strong></label> <?php echo _AT('about_protected'); ?><br /><br />
140
141                 <input type="radio" name="access" value="private" id="priv" onclick="enableNotify();" <?php echo $priv; ?> /><label for="priv"><strong><?php echo  _AT('private'); ?>:</strong></label> <?php echo  _AT('about_private'); ?><br />
142                 <input type="checkbox" name="notify" id="notify" value="1" <?php
143                         echo $disable;
144                         echo $notify; ?> /><label for="notify"><?php echo  _AT('email_approvals'); ?></label>
145                 <br />
146                 <input type="checkbox" name="hide" id="hide" value="1" <?php
147                 echo $disable;
148                 echo $hide; ?> /><label for="hide"><?php echo  _AT('hide_course'); ?></label>.
149         </div>
150
151         <div class="row">
152                 <?php echo _AT('release_date'); ?><br />
153                 <?php
154                         $rel_no = $rel_yes = '';
155
156                         if (intval($this->row['release_date'])) {
157                                 $rel_yes = ' checked="checked"';
158
159                                 $today_day   = substr($this->row['release_date'], 8, 2);
160                                 $today_mon   = substr($this->row['release_date'], 5, 2);
161                                 $today_year  = substr($this->row['release_date'], 0, 4);
162
163                                 $today_hour  = substr($this->row['release_date'], 11, 2);
164                                 $today_min   = substr($this->row['release_date'], 14, 2);
165                         } else {
166                                 $rel_no = ' checked="checked"'; 
167                                 $today_year  = date('Y');
168                         }
169
170                 ?>
171
172                 <input type="radio" name="release_date" value="0" id="release_now" <?php echo $rel_no; ?> /> <label for="release_now"><?php echo _AT('available_immediately'); ?></label><br />
173
174
175                 <input type="radio" name="release_date" value="1" id="release_later" <?php echo $rel_yes; ?> /> <label for="release_later"><?php echo _AT('release_on'); ?></label> 
176                 <?php
177                         $name = '_release';
178                         require(AT_INCLUDE_PATH.'html/release_date.inc.php');
179                 ?>
180         </div>
181
182         <div class="row">
183                 <?php echo _AT('end_date'); ?><br />
184                 <?php
185                         $end_no = $end_yes = '';
186
187                         if (intval($this->row['end_date'])) {
188                                 $end_yes = ' checked="checked"';
189
190                                 $today_day   = substr($this->row['end_date'], 8, 2);
191                                 $today_mon   = substr($this->row['end_date'], 5, 2);
192                                 $today_year  = substr($this->row['end_date'], 0, 4);
193
194                                 $today_hour  = substr($this->row['end_date'], 11, 2);
195                                 $today_min   = substr($this->row['end_date'], 14, 2);
196                         } else {
197                                 $end_no = ' checked="checked"'; 
198                                 $today_year  = date('Y')+1;
199                         }
200
201                 ?>
202
203                 <input type="radio" name="end_date" value="0" id="end_now" <?php echo $end_no; ?> /> <label for="end_now"><?php echo _AT('no_end_date'); ?></label><br />
204
205                 <input type="radio" name="end_date" value="1" id="end_later" <?php echo $end_yes; ?> /> <label for="end_later"><?php echo _AT('end_on'); ?></label> 
206                 <?php
207                         $name = '_end';
208                         require(AT_INCLUDE_PATH.'html/release_date.inc.php');
209                 ?>
210         </div>
211
212         <div class="row">
213                 <?php
214                         if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']){
215                                 echo '<input type="hidden" name="setvisual" value="'.$_POST['setvisual'].'" />';
216                                 echo '<input type="submit" name="settext" value="'._AT('switch_text').'"  class="button"/>';
217                         } else {
218                                 echo '<input type="submit" name="setvisual" value="'._AT('switch_visual').'" class="button"/>';
219                         }
220                 ?>
221         </div>
222         <div class="row">
223
224                 <label for="banner"><?php echo _AT('banner'); ?></label><br />
225                 <textarea id="banner" cols="45" rows="15" name="banner"><?php echo $this->row['banner']; ?></textarea>
226         </div>
227
228 <?php if (!$this->course) : ?>
229         <div class="row">
230                 <label for="initial_content"><?php echo _AT('initial_content'); ?></label><br />
231                 <select name="initial_content" id="initial_content" size="5">
232                         <option value="0"><?php echo _AT('empty'); ?></option>
233                         <option value="1" selected="selected"><?php echo _AT('create_basic'); ?></option>
234                 <?php 
235                         $Backup = new Backup($db);
236
237                         if ($isadmin) {
238                                 $sql    = "SELECT course_id, title FROM ".TABLE_PREFIX."courses ORDER BY title";
239                         } else {
240                                 $sql    = "SELECT course_id, title FROM ".TABLE_PREFIX."courses WHERE member_id=$_SESSION[member_id] ORDER BY title";
241                         }
242
243                         $result = mysql_query($sql, $db);
244
245                         if ($course_row = mysql_fetch_assoc($result)) {
246                                 do {
247                                         $Backup->setCourseID($course_row['course_id']);
248                                         $list = $Backup->getAvailableList();
249
250                                         if (!empty($list)) { 
251                                                 echo '<optgroup label="'. _AT('restore').': '.$course_row['title'].'">';
252                                                 foreach ($list as $list_item) {
253                                                         echo '<option value="'.$list_item['backup_id'].'_'.$list_item['course_id'].'">'.$list_item['file_name'].' - '.get_human_size($list_item['file_size']).'</option>';
254                                                 }
255                                                 echo '</optgroup>';
256                                         }
257                                 } while ($course_row = mysql_fetch_assoc($result));
258                         }
259                         ?>
260                         </select>
261         </div>
262 <?php endif; // !$course_id ?>
263
264 <?php if ($this->isadmin) : ?>
265         <div class="row">
266                 <?php  echo _AT('course_quota'); ?><br />
267                 <?php 
268                         if ($this->row['max_quota'] == AT_COURSESIZE_UNLIMITED) { 
269                                 $c_unlim = ' checked="checked" ';
270                                 $c_oth2 = ' disabled="disabled" ';
271                         } elseif ($this->row['max_quota'] == AT_COURSESIZE_DEFAULT) {
272                                 $c_def = ' checked="checked" ';
273                                 $c_oth2 = ' disabled="disabled" ';
274                         } else {
275                                 $c_oth = ' checked="checked" ';
276                                 $c_oth2 = '';
277                         }
278
279                         if ($this->course > 0) {
280                                 $course_size = dirsize(AT_CONTENT_DIR . $this->course.'/');
281                         } else {
282                                 $course_size = 0;
283                         }
284
285                         if ($this->course) {
286                                 echo _AT('current_course_size') .': '.get_human_size($course_size).'<br />'; 
287                         }
288                 ?>
289
290                 <input type="radio" id="c_default" name="quota" value="<?php echo AT_COURSESIZE_DEFAULT; ?>" onclick="disableOther();" <?php echo $c_def;?> /><label for="c_default"> <?php echo _AT('default') . ' ('.get_human_size($MaxCourseSize).')'; ?></label> <br />
291                 <input type="radio" id="c_unlim" name="quota" value="<?php echo AT_COURSESIZE_UNLIMITED; ?>" onclick="disableOther();" <?php echo $c_unlim;?>/><label for="c_unlim"> <?php echo _AT('unlimited'); ?></label> <br />
292                 <input type="radio" id="c_other" name="quota" value="2" onclick="enableOther();" <?php echo $c_oth;?>/><label for="c_other"> <?php echo _AT('other'); ?> </label> - 
293                 <input type="text" id="quota_entered" name="quota_entered" <?php echo $c_oth2?> value="<?php if ($this->row['max_quota']!=AT_COURSESIZE_UNLIMITED && $this->row['max_quota']!=AT_COURSESIZE_DEFAULT) { echo bytes_to_megabytes($this->row['max_quota']); } ?>" size="4" /> <?php echo _AT('mb'); ?>
294         </div>
295
296         <div class="row">
297                 <?php  echo _AT('max_file_size'); ?><br />
298                 <?php 
299                         $max_allowed = megabytes_to_bytes(substr(ini_get('upload_max_filesize'), 0, -1));
300
301                         if ($this->row['max_file_size'] == AT_FILESIZE_DEFAULT) { 
302                                 $f_def = ' checked="checked" ';
303                                 $f_oth2 = ' disabled="disabled" ';
304                         } elseif ($this->row['max_file_size'] == AT_FILESIZE_SYSTEM_MAX) {
305                                 $f_max = ' checked="checked" ';
306                                 $f_oth2 = ' disabled="disabled" ';
307                         } else {
308                                 $f_oth = ' checked="checked" ';
309                                 $f_oth2 = '';
310                         }
311                 ?>
312                 <input type="radio" id="f_default" name="filesize" value="<?php echo AT_FILESIZE_DEFAULT; ?>" onclick="disableOther2();" <?php echo $f_def;?> /><label for="f_default"> <?php echo _AT('default') . ' ('.get_human_size($MaxFileSize).')'; ?></label> <br />
313                 <input type="radio" id="f_maxallowed" name="filesize" value="<?php echo AT_FILESIZE_SYSTEM_MAX; ?>" onclick="disableOther2();" <?php echo $f_max;?>/><label for="f_maxallowed"> <?php echo _AT('max_file_size_system') . ' ('.get_human_size($max_allowed).')'; ?></label> <br />
314                 <input type="radio" id="f_other" name="filesize" value="2" onclick="enableOther2();" <?php echo $f_oth;?>/><label for="f_other"> <?php echo _AT('other'); ?> </label> - 
315                 <input type="text" id="filesize_entered" name="filesize_entered" <?php echo $f_oth2?> value="<?php if ($this->row['max_file_size']!=AT_FILESIZE_DEFAULT && $this->row['max_file_size']!=AT_FILESIZE_SYSTEM_MAX) { echo bytes_to_megabytes($this->row['max_file_size']); } ?>" size="4" /> <?php echo _AT('mb'); ?>
316         </div>
317
318 <?php else: ?>
319         <input type="hidden" name="quota" value="<?php echo $this->row['max_quota']; ?>" />
320         <input type="hidden" name="filesize" value="<?php echo $this->row['max_file_size']; ?>" />
321         <input type="hidden" name="tracking" value="<?php echo $this->row['tracking']; ?>" />
322 <?php endif; ?>
323
324         <div class="row">
325                 <label for="copyright"><?php echo _AT('course_copyright'); ?></label><br />
326                 <textarea name="copyright" rows="2" cols="65" id="copyright"><?php echo $this->row['copyright']; ?></textarea>
327         </div>
328         <div class="row">
329                 <?php 
330             if ($this->row['icon'] != ''): 
331                 $path = AT_CONTENT_DIR.$this->row['course_id']."/custom_icons/";
332                 if (file_exists($path.$this->row['icon'])) {
333                     if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
334                         $custom_icon_path = 'get_course_icon.php/?id='.$this->row['course_id'];
335                     } else {
336                         $_base_href = 'content/' . $this->row['course_id'] . '/';
337                     }
338                 } else {
339                     $_base_href = "images/courses/";    //$_base_href = 'get_course_icon.php/?id='.$row['course_id'];
340                 }
341
342             $force_get = (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) ? true : false;
343             echo "<input type='hidden' name='boolForce' id='boolForce' value='$force_get' />";
344         
345        //include(AT_INCLUDE_PATH.'html/course_icon.inc.php');        
346         ?>
347                 <img id="i0" src="<?php echo ($custom_icon_path=='')?$_base_href.$this->row['icon']:$custom_icon_path; ?>" alt="<?php echo $this->row['icon']; ?>" border="1" height="79" width="79"  style="float: left; margin: 2px;" />
348
349                 <?php else: ?>
350                         <img id="i0" src="images/clr.gif" alt="" style="float: left; margin: 2px;" border="1" height="79" width="79"  />
351                         <input type='hidden' name='boolForce' id='boolForce' value='' />
352                 <?php endif; ?>
353                 <div style="width:40%; float:left;">
354                 <label for="icons"><?php echo _AT('icon'); ?></label><br />
355                 <select name="icon" id="icons" onchange="SelectImg()">
356                         <option value=""><?php echo _AT('no_icon'); ?></option>
357             <?php // ------------- custom course icons
358                 $path = AT_CONTENT_DIR.$this->row['course_id']."/custom_icons/";
359                 $boolCustom = false;
360                 $optCount = 0;
361
362                 if (is_dir($path)) {
363                     $boolCustom = true;  // true if custom icons are uploaded, otherwise false
364                     
365                     /*$files = scandir($path);  //SCANDIR STOPS ATUTOR WHEN RUN AS INSTRUCTOR, BUT NOT AS ADMIN. WHY? -Gorzan */
366                     
367                     /* PHP 4 REPLACEMENT FOR SCANDIR */
368                                         $dh  = opendir($path);
369                                         while (false !== ($filename = readdir($dh))) {
370                                                 $files[] = $filename;
371                                         }
372
373                                         /*END PHP 4 REPLACEMENT FOR SCANDIR*/
374                     echo "<optgroup label='"._AT('custom_icons')."'>";
375                     foreach($files as $val) {
376                                                 $file_ext = substr(strtolower($val), -3);
377                         if ($file_ext == "jpg" || $file_ext == "png" || $file_ext == "gif") {
378                             $optCount++;
379                             echo "<option value='".$val."'";
380                             if ($val == $this->row['icon']) {
381                                 echo 'selected="selected"';
382                             }
383                             echo ">".$val."</option>";
384                         }
385                     }
386                     echo "</optgroup>";
387                 }
388                 
389             ?>
390                         <?php // ------------- other icons
391
392                                 $course_imgs = array();
393                                 if ($dir = opendir(AT_INCLUDE_PATH.'../images/courses/')) {
394                                         while (false !== ($file = readdir($dir)) ) {
395                                                 if( ($file == '.') || ($file == '..')) { 
396                                                         continue;
397                                                 }
398                                                 $course_imgs[] = $file;
399                                         }               
400                                         closedir($dir); 
401                                 }
402                                 sort($course_imgs);
403                 if ($boolCustom == true) {
404                     echo "<optgroup label='"._AT('builtin_icons')."'>";
405                 }
406                                 foreach ($course_imgs as $file) {
407                                         echo '<option value="' . $file . '" ';
408                                         if ($file == $this->row['icon']) { 
409                                                 echo 'selected="selected"'; 
410                                         }
411                                         echo ' >' . $file . '</option>';        
412                                 }
413                 if ($boolCustom == true) {
414                     echo "</optgroup>";
415                 }
416                         ?>
417                 </select><?php echo "&nbsp;&nbsp;&nbsp; "._AT('or'); ?>
418         </div>
419             <!-- div class="row" style="float:right;width:40%;">
420             <?php echo _AT('upload_icon'); ?><br />
421                 <input type="file" name="customicon" id="customicon" value="<?php echo $_POST['customicon']; ?>"/><br />
422                 <small><?php echo _AT('upload_icon_text'); ?></small>
423             </div -->
424
425         <?php  require_once(AT_INCLUDE_PATH.'../mods/_core/courses/html/course_icon.inc.php'); ?>
426
427         <br style="clear: left;" />
428
429         </div>
430
431     <div style="clear: both;"></div>
432
433     
434
435         <div class="buttons">
436                 <?php
437             echo "<input type='hidden' name='custOptCount' id='custOptCount' value='".$optCount."' />";
438             echo "<input type='hidden' name='courseId' id='courseId' value='".$this->row['course_id']."' />";
439                 ?>
440
441                 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" /> 
442                 <input type="submit" name="cancel" value="<?php echo _AT('cancel');?>" />
443         </div>
444     </fieldset>
445 </div>
446
447 </form>