changed git call from https to git readonly
[atutor.git] / mods / photo_album / handler / file_upload.php
1 <?php\r
2 /*==============================================================\r
3   Photo Album\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
8                                                                \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
13  */\r
14 // $Id:\r
15 \r
16 /**\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
21  * @license GNU\r
22  */\r
23  \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
28 \r
29 ?>\r
30 \r
31 <?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
36         \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
40         \r
41         /* mode add */  \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
45                 }\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
53                 \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
58                 } else {\r
59                         $action=ATUTOR_PREFIX.BASE_PATH.'index.php';\r
60                 }       \r
61                 \r
62                 $template->setVariable("CANCEL_STRING", _AT('cancel'));\r
63                 \r
64                 $template->parseCurrentBlock("UPLOAD_PART");\r
65                 $template->parseCurrentBlock();\r
66                 $template->show();\r
67                 $_SESSION['pa']['mode']='add';\r
68                 $_SESSION['pa']['choose']=IMAGE;\r
69                 \r
70         /* mode edit */\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
74                         if (!$auth){\r
75                                 $msg->addError('pa_user_image_not_allowed');\r
76                                 redirect('view.php?image_id='.$_POST['image_id']);\r
77                         } else {\r
78                                 $_SESSION['pa']['image_id']=intval($_POST['image_id']);\r
79                         }\r
80                 }\r
81                 if (!isset($_POST['mode']) && ($_SESSION['pa']['mode']=='edit')){\r
82                         $template->setVariable("FILE_FADE", "class=\"fade\"");\r
83                 }       \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
91                 \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
97                 \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
102                 \r
103                 $template->setVariable("CANCEL_STRING", _AT('cancel'));\r
104                 \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
110                 \r
111         } else {\r
112                 $msg->addError('pa_var_unauthorized');\r
113                 out();\r
114         }\r
115 ?>\r
116         \r
117 <?php require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>