move code up one directory
[atutor.git] / mods / _standard / photos / edit_comment.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010                                             */
6 /* Inclusive Design Institute                                          */
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
16 define('AT_INCLUDE_PATH', '../../../include/');
17 require (AT_INCLUDE_PATH.'vitals.inc.php');
18 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
19
20 //check what comment this is for. Album or Photo.
21 $pid = intval($_POST['pid']);
22 $aid = intval($_POST['aid']);
23 $cid = $_POST['cid'];
24 $comment = $_POST['comment'];
25
26 if (isset($_POST['pid']) && $pid>0){
27         $isPhoto = true;
28 } else {
29         $isPhoto = false;
30 }
31 $cid = intval(str_replace('cid_', '', $cid));
32
33 $pa = new PhotoAlbum($aid);
34 //validates
35 if ($pa->checkAlbumPriv($_SESSION['member_id']) || $pa->checkCommentPriv($cid, $_SESSION['member_id'], $isPhoto)){
36         $result = $pa->editComment($cid, $comment, $isPhoto);
37 }
38
39 if ($result===true){
40         //TODO: AJAX
41         header('HTTP/1.0 200 OK');
42 } else {
43         header('HTTP/1.0 404 Not Found');
44 }
45 exit;
46 ?>