File: comment.php

package info (click to toggle)
zoph 0.6-2.1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 1,716 kB
  • ctags: 2,283
  • sloc: php: 8,560; perl: 1,601; sh: 760; sql: 382; python: 338; makefile: 71
file content (144 lines) | stat: -rw-r--r-- 4,693 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/*
 * This file is part of Zoph.
 *
 * Zoph is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * Zoph is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with Zoph; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
    require_once("include.inc.php");

    if (!ALLOW_COMMENTS) {
        header("Location: " . add_sid("zoph.php"));
    }

    $comment_id = getvar("comment_id");
    $comment = new comment($comment_id);
    if ($comment_id) {
        $comment->lookup();
	$comment_user=new user($comment->get("user_id"));
	$comment_user->lookup();
    }

    if(!$user->is_admin() && (!$comment->is_owner($user)) && ($_action!="new") && $_action!="insert") {
       $_action="display";
    }

    if(!$user->is_admin() && !$user->get("leave_comments") && ($_action=="new" || $_action=="insert")) {
        header("Location: " . add_sid("zoph.php"));
    }

    $photo=$comment->get_photo();

    if ($photo) {
       $photo_id=$photo->get("photo_id");
       if(!$user->get_permissions_for_photo($photo_id) && !$user->is_admin()) {
           header("Location: " . add_sid("zoph.php"));
       }
    } else {
       $photo_id = getvar("photo_id");
       $photo = new photo($photo_id);
       $photo->lookup();
    }

    $request_vars["photo_id"]=NULL;


    $redirect = "comment.php";
    if ($_action == "insert") {
        $comment->set("user_id", $user->get("user_id"));
    }
    
    $obj = &$comment;

    require_once("actions.inc.php");

    if($_action == "insert") {
	$comment->add_comment_to_photo($photo_id);
    }
    
    if ($_action != "new") {
        $title = $comment->get("subject");
    } else {
        $title = translate("Add comment");
    }
    require_once("header.inc.php");
?>
<?php
if ($action == "confirm") {
?>
          <h1><?php echo translate("delete comment") ?></h1>
            <div class="main">
               <span class="actionlink">
                 <a href="comment.php?_action=confirm&amp;comment_id=<?php echo $comment->get("comment_id") ?>"><?php echo translate("delete") ?></a> |
                 <a href="comment.php?_action=edit&amp;comment_id=<?php echo $comment->get("comment_id") ?>"><?php echo translate("cancel") ?></a>
               </span>
               <?php echo sprintf(translate("Confirm deletion of comment '<b>%s</b>' by '<b>%s</b>'"), $comment->get("subject"), $comment_user->get("user_name")) ?>
             </div>
<?php
    }
    else if ($action == "display") {
?>
          <h1>
<?php
        if ($user->is_admin() || $comment->is_owner($user)) {
?>
            <span class="actionlink">
              <a href="photo.php?photo_id=<?php echo $photo_id ?>"><?php echo translate("return") ?></a> |
              <a href="comment.php?_action=edit&amp;comment_id=<?php echo $comment->get("comment_id") ?>"><?php echo translate("edit") ?></a> |
              <a href="comment.php?_action=delete&amp;comment_id=<?php echo $comment->get("comment_id") ?>"><?php echo translate("delete") ?></a>
            </span>
<?php
     }
     echo $title;
?>
          </h1>
      <div class="main">
      <br>
<?php
    echo $photo->get_midsize_img();
?>
<br>
      <table>
<?php echo create_field_html($comment->get_display_array($user)) ?>
</table>
  </div>
<?php
    }
    else {
?>
    <h1>
        <?php echo $title ?>
    </h1>
    <div class="main">
    <br>
<?php
    echo $photo->get_midsize_img();
?>
    <br>

        <form action="comment.php">
            <input type="hidden" name="_action" value="<?php echo $action ?>">
            <input type="hidden" name="comment_id" value="<?php echo $comment->get("comment_id") ?>">
            <input type="hidden" name="photo_id" value="<?php echo $photo_id ?>">
            <label for="subject"><?php echo translate("subject") ?></label>
            <?php echo create_text_input("subject", $comment->get("subject")) ?><br>
            <label for="comment"><?php echo translate("comment") ?></label> 
            <textarea name="comment" rows="8" cols="80"><?php echo $comment->get("comment") ?></textarea><br>
            <input type="submit" value="<?php echo translate($action, 0) ?>">
        </form>
    </div>

<?php
}
    require_once("footer.inc.php");
?>