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