Signed-off-by: Marcel Korpel <[email protected]>
---
 web/lib/aurjson.class.php | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index a272741..cdb5d7e 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', 'save-comment'
        );
        private static $exposed_fields = array(
                'name', 'name-desc'
@@ -477,5 +477,38 @@ class AurJSON {
 
                return json_encode($result_array);
        }
+
+       private function load_comment($http_data) {
+               $comment_id = $http_data['arg'];
+               list($user_id, $comment) = comment_by_id($comment_id);
+
+               if (!has_credential(CRED_COMMENT_EDIT, array($user_id)) || 
is_null($comment)) {
+                       $output = false;
+               } else {
+                       ob_start();
+                       include('pkg_comment_form.php');
+                       $html = ob_get_clean();
+                       $output = array('form' => $html);
+               }
+
+               return json_encode($output);
+       }
+
+       private function save_comment($http_data) {
+               include_once('pkgbasefuncs.inc.php');
+               $argument_array = $http_data['arg'];
+               $comment = $argument_array['comment'];
+               $comment_id = $argument_array['id'];
+
+               list($success, $message) = pkgbase_edit_comment($comment, 
$comment_id);
+               if ($success) {
+                       $html = parse_comment($comment);
+                       $output = array('success' => 1, 'html' => $html);
+               } else {
+                       $output = array('success' => 0, 'error' => $message);
+               }
+
+               return json_encode($output);
+       }
 }
 
-- 
2.4.6

Reply via email to