3 set_include_path(get_include_path() . PATH_SEPARATOR
. '../lib' . PATH_SEPARATOR
. '../lang');
5 include("aur.inc"); # access AUR common functions
6 include("pkgfuncs.inc"); # use some form of this for i18n support
7 include("pkgedit_po.inc"); # i18n translations for this script
8 set_lang(); # this sets up the visitor's language
9 check_sid(); # see if they're still logged in
10 html_header(); # print out the HTML header
11 $svn_idstr = "\$Id: pkgedit.php 295 2006-08-08 00:59:10Z pjmattal $";
20 # Make sure this visitor is logged in
22 if (isset($_COOKIE["AURSID"])) {
23 $atype = account_from_sid($_COOKIE["AURSID"]);
28 print __("You must be logged in before you can edit package information.");
30 html_footer($svn_idstr);
34 # Must know what package to operate on throughout this entire script
36 if (!$_REQUEST["ID"]) {
37 print __("Missing package ID.");
39 html_footer($svn_idstr);
43 # Delete a comment for this package
45 if ($_REQUEST["del_Comment"]) {
46 if ($_REQUEST["comment_id"]) {
47 if (canDeleteComment($_REQUEST["comment_id"], $atype, $_COOKIE["AURSID"])) {
49 $uid = uid_from_sid($_COOKIE["AURSID"]);
50 $q = "UPDATE PackageComments ";
51 $q.= "SET DelUsersID = ".$uid." ";
52 $q.= "WHERE ID = ".intval($_REQUEST["comment_id"]);
54 print __("Comment has been deleted.")."<br />\n";
56 print __("You are not allowed to delete this comment.")."<br />\n";
59 print __("Missing comment ID.")."<br />\n";
61 pkgdetails_link($_REQUEST["ID"]);
62 html_footer($svn_idstr);
66 # Add a comment to this package
68 if ($_REQUEST["add_Comment"]) {
69 if ($_REQUEST["comment"]) {
73 $q = "INSERT INTO PackageComments ";
74 $q.= "(PackageID, UsersID, Comments, CommentTS) VALUES (";
75 $q.= intval($_REQUEST["ID"]).", ".uid_from_sid($_COOKIE["AURSID"]) . ", ";
76 $q.= "'".mysql_real_escape_string($_REQUEST["comment"])."', ";
77 $q.= "UNIX_TIMESTAMP())";
79 print __("Comment has been added.")."<br /> <br />\n";
80 pkgdetails_link($_REQUEST["ID"]);
82 # Send email notifications
84 $q = "SELECT CommentNotify.*, Users.Email ";
85 $q.= "FROM CommentNotify, Users ";
86 $q.= "WHERE Users.ID = CommentNotify.UserID ";
87 $q.= "AND CommentNotify.UserID != ".uid_from_sid($_COOKIE["AURSID"])." ";
88 $q.= "AND CommentNotify.PkgID = ".intval($_REQUEST["ID"]);
89 $result = db_query($q, $dbh);
91 if (mysql_num_rows($result)) {
92 while ($row = mysql_fetch_assoc($result)) {
93 array_push($bcc, $row['Email']);
95 $q = "SELECT Packages.Name ";
96 $q.= "FROM Packages ";
97 $q.= "WHERE Packages.ID = ".intval($_REQUEST["ID"]);
98 $result = db_query($q, $dbh);
99 $row = mysql_fetch_assoc($result);
100 #TODO: native language emails for users, based on their prefs
101 # Simply making these strings translatable won't work, users would be
102 # getting emails in the language that the user who posted the comment was in
103 $body = "A comment has been added to ".$row['Name'].", you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=".$_REQUEST["ID"]."\n\n\n---\nYou received this e-mail because you chose to recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the UnNotify.";
104 $body = wordwrap($body, 70);
105 $bcc = implode(', ', $bcc);
106 $headers = "Bcc: $bcc\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
107 @mail
(' ', "AUR Comment Notification for ".$row['Name'], $body, $headers);
111 # Prompt visitor for comment
113 print "<form action='/pkgedit.php' method='post'>\n";
114 print "<input type='hidden' name='add_Comment' value='1'>\n";
115 print "<input type='hidden' name='ID' value=\"".$_REQUEST["ID"]."\">\n";
116 print __("Enter your comment below.")."<br /> <br />\n";
117 print "<textarea name='comment' rows='10' cols='50'></textarea>\n";
118 print "<br /> <br />\n";
119 print "<input type='submit' value=\"".__("Submit")."\">\n";
120 print "<input type='reset' value=\"".__("Reset")."\">\n";
123 html_footer($svn_idstr);
127 # Change package category
129 if ($_REQUEST["change_Category"]) {
130 $cat_array = pkgCategories();
133 if ($_REQUEST["category_id"]) {
134 # Try and set the requested category_id
136 if (array_key_exists($_REQUEST["category_id"], $cat_array)) {
137 $q = "UPDATE Packages SET CategoryID = ".intval($_REQUEST["category_id"]);
138 $q.= " WHERE ID = ".intval($_REQUEST["ID"]);
140 print __("Package category updated.")."<br />\n";
143 print __("Invalid category ID.")."<br />\n";
145 pkgdetails_link($_REQUEST["ID"]);
148 # Prompt visitor for new category_id
150 $q = "SELECT CategoryID FROM Packages WHERE ID = ".intval($_REQUEST["ID"]);
151 $result = db_query($q, $dbh);
152 if ($result != NULL) {
153 $catid = mysql_fetch_row($result);
155 print "<form action='/pkgedit.php' method='post'>\n";
156 print "<input type='hidden' name='change_Category' value='1'>\n";
157 print "<input type='hidden' name='ID' value=\"".$_REQUEST["ID"]."\">\n";
158 print __("Select new category").": \n";
159 print "<select name='category_id'>\n";
160 while (list($id,$cat) = each($cat_array)) {
161 print "<option value='".$id."'";
162 if ($id == $catid[0]) {
165 print "> ".$cat."</option>\n";
168 print "<br /> <br />\n";
169 print "<input type='submit' value=\"".__("Submit")."\">\n";
170 print "<input type='reset' value=\"".__("Reset")."\">\n";
174 html_footer($svn_idstr);
178 print __("You've found a bug if you see this....")."<br />\n";
180 html_footer($svn_idstr); # Use the $Id: pkgedit.php 295 2006-08-08 00:59:10Z pjmattal $ keyword
181 # NOTE: when checking in a new file, use
182 # 'svn propset svn:keywords "Id" filename.php'
183 # to tell svn to expand the "Id" keyword.
185 # vim: ts=2 sw=2 noet ft=php