changed git call from https to git readonly
[atutor.git] / mods / photos / addComment.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2009                                                                                         */
6 /* Adaptive Technology Resource Centre / Inclusive Design Institution  */
7 /* http://atutor.ca                                                                                                        */
8 /*                                                                                                                                         */
9 /* This program is free software. You can redistribute it and/or           */
10 /* modify it under the terms of the GNU General Public License             */
11 /* as published by the Free Software Foundation.                                           */
12 /***********************************************************************/
13 // $Id$
14 $_user_location = 'public';
15 define('AT_INCLUDE_PATH', '../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
18
19 //check what comment this is for. Album or Photo.
20 $pid = intval($_POST['pid']);
21 $aid = intval($_POST['aid']);
22
23 if (isset($_POST['pid']) && $pid>0){
24         $isPhoto = true;
25         $id = $pid;
26 } else {
27         $isPhoto = false;
28         $id = $aid;
29 }
30
31
32 //Error checking
33 if (trim($_POST['comment']) == ''){
34         //if comment is empty
35         $msg->addError('PA_EMPTY_COMMENT'); //sql
36 } else {
37         $pa = new PhotoAlbum();
38         $result = $pa->addComment($id, $_POST['comment'], $_SESSION['member_id'], $isPhoto);
39
40         if ($result){
41                 //TODO: AJAX
42                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
43         } else {
44                 $msg->addError('PA_ADD_COMMENT_FAILED'); //sql
45         }
46 }
47
48 if ($isPhoto){
49         header('Location: photo.php?pid='.$pid.SEP.'aid='.$aid);
50 } else {
51         header('Location: albums.php?id='.$aid);
52 }
53 exit;
54 ?>