2 /*==============================================================
\r
4 ==============================================================
\r
5 Copyright (c) 2006 by Dylan Cheon & Kelvin Wong
\r
6 Institute for Assistive Technology / University of Victoria
\r
7 http://www.canassist.ca/
\r
9 This program is free software. You can redistribute it and/or
\r
10 modify it under the terms of the GNU General Public License
\r
11 as published by the Free Software Foundation.
\r
12 ==============================================================
\r
17 * @desc This file generates the image file upload page
\r
18 * @author Dylan Cheon & Kelvin Wong
\r
19 * @copyright 2006, Institute for Assistive Technology / University of Victoria
\r
20 * @link http://www.canassist.ca/
\r
24 define('AT_INCLUDE_PATH', '../../../include/');
\r
25 require_once(AT_INCLUDE_PATH.'vitals.inc.php');
\r
26 $_custom_css = $_base_path . 'mods/photo_album/module.css'; // use a custom stylesheet
\r
27 require_once (AT_INCLUDE_PATH.'header.inc.php');
\r
32 require_once ('../define.php');
\r
33 require_once ('../include/general_func.php');
\r
34 require_once ('../include/data_func.php');
\r
35 require_once ('../HTML/Template/ITX.php');
\r
37 $template= new HTML_Template_ITX("../Template");
\r
38 $template->loadTemplatefile("file_upload.tpl.php");
\r
39 $template->setVariable("JAVA_SRC", BASE_PATH.'handler/fat.js');
\r
42 if ((($_POST['mode']=='add') && ($_POST['choose']==IMAGE)) || (($_SESSION['pa']['mode']=='add') && ($_SESSION['pa']['choose']==IMAGE))){
\r
43 if (!isset($_POST['mode']) && ($_SESSION['pa']['mode']=='add')){
\r
44 $template->setVariable("FILE_FADE", "class=\"fade\"");
\r
46 $template->setVariable("MESSAGE", _AT('pa_note_file_upload_add'));
\r
47 $template->setCurrentBlock("UPLOAD_PART");
\r
48 $template->setVariable("REQUIRED_SYMBOL", "<div class=\"required\">*</div>");
\r
49 $template->setVariable("FILE_LABEL", _AT('pa_label_file'));
\r
50 $template->setVariable("UPLOAD_FORM", "upload_form");
\r
51 $template->setVariable("UPLOAD_ACTION", ADD_ACTION);
\r
52 $template->setVariable("SUBMIT_MESSAGE", _AT('pa_button_upload_image'));
\r
54 if ($_SESSION['pa']['administrator_mode']==true){
\r
55 $action=ATUTOR_PREFIX.BASE_PATH.'admin_image_list.php';
\r
56 } else if ($_SESSION['pa']['instructor_mode']==true){
\r
57 $action=ATUTOR_PREFIX.BASE_PATH.'instructor_image.php';
\r
59 $action=ATUTOR_PREFIX.BASE_PATH.'index.php';
\r
62 $template->setVariable("CANCEL_STRING", _AT('cancel'));
\r
64 $template->parseCurrentBlock("UPLOAD_PART");
\r
65 $template->parseCurrentBlock();
\r
67 $_SESSION['pa']['mode']='add';
\r
68 $_SESSION['pa']['choose']=IMAGE;
\r
71 } else if ((($_POST['mode']=='edit') && ($_POST['choose']==IMAGE)) || (($_SESSION['pa']['mode']=='edit') && ($_SESSION['pa']['choose']==IMAGE))){
\r
72 if (($_POST['mode']=='edit') && ($_POST['choose']==IMAGE)){
\r
73 $auth=user_own(IMAGE, $_POST['image_id'], $_SESSION['pa']['course_id']);
\r
75 $msg->addError('pa_user_image_not_allowed');
\r
76 redirect('view.php?image_id='.$_POST['image_id']);
\r
78 $_SESSION['pa']['image_id']=intval($_POST['image_id']);
\r
81 if (!isset($_POST['mode']) && ($_SESSION['pa']['mode']=='edit')){
\r
82 $template->setVariable("FILE_FADE", "class=\"fade\"");
\r
84 $template->setVariable("MESSAGE", _AT('pa_note_file_upload_edit'));
\r
85 $image_array=get_single_data(IMAGE, $_SESSION['pa']['image_id'], $_SESSION['pa']['course_id']);
\r
86 $template->setCurrentBlock("IMAGE_DISPLAY");
\r
87 $img_src=$get_file.$image_array['location'].urlencode($image_array['thumb_image_name']);
\r
88 $template->setVariable("IMAGE_SRC", $img_src);
\r
89 $template->setVariable("ALT", $image_array['alt']);
\r
90 $template->parseCurrentBlock("IMAGE_DISPLAY");
\r
92 $template->setCurrentBlock("UPLOAD_PART");
\r
93 $template->setVariable("FILE_LABEL", _AT('pa_label_file'));
\r
94 $template->setVariable("UPLOAD_FORM", "upload_form");
\r
95 $template->setVariable("UPLOAD_ACTION", EDIT_ACTION);
\r
96 $template->setVariable("SUBMIT_MESSAGE", _AT('pa_button_update_image'));
\r
98 //display image skip button
\r
99 $template->setCurrentBlock("SKIP_UPLOAD");
\r
100 $template->setVariable("SUBMIT_MESSAGE2", _AT('pa_button_skip_upload_image'));
\r
101 $template->parseCurrentBlock("SKIP_UPLOAD");
\r
103 $template->setVariable("CANCEL_STRING", _AT('cancel'));
\r
105 $template->parseCurrentBlock("UPLOAD_PART");
\r
106 $template->parseCurrentBlock();
\r
107 $template->show();
\r
108 $_SESSION['pa']['mode']='edit';
\r
109 $_SESSION['pa']['choose']=IMAGE;
\r
112 $msg->addError('pa_var_unauthorized');
\r
117 <?php require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>