Signed-off-by: Marcel Korpel <[email protected]>
---
Changes since v1:
* Drop any POST method.
* Drop save_comment() method and use the normal web form for submission.

 web/lib/aurjson.class.php | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index a272741..a4f78d4 100644
--- a/web/lib/aurjson.class.php
+++ b/web/lib/aurjson.class.php
@@ -14,7 +14,7 @@ class AurJSON {
        private $version = 1;
        private static $exposed_methods = array(
                'search', 'info', 'multiinfo', 'msearch', 'suggest',
-               'suggest-pkgbase'
+               'suggest-pkgbase', 'load-comment'
        );
        private static $exposed_fields = array(
                'name', 'name-desc'
@@ -477,5 +477,29 @@ class AurJSON {
 
                return json_encode($result_array);
        }
+
+       private function load_comment($http_data) {
+               $comment_id = $http_data['arg'];
+               if (isset($_GET['base_id']) && isset($_GET['pkgbase_name'])) {
+                       $base_id = $_GET['base_id'];
+                       $pkgbase_name = $_GET['pkgbase_name'];
+
+                       list($user_id, $comment) = comment_by_id($comment_id);
+
+                       if (!has_credential(CRED_COMMENT_EDIT, array($user_id)) 
|| is_null($comment)) {
+                               $output = false;
+                       } else {
+                               $no_header = true;
+                               ob_start();
+                               include('pkg_comment_form.php');
+                               $html = ob_get_clean();
+                               $output = array('form' => $html);
+                       }
+               } else {
+                       $output = false;
+               }
+
+               return json_encode($output);
+       }
 }
 
-- 
2.4.6

Reply via email to