From bff3545a74b081efddbe5ba1d51b1537d4eee201 Mon Sep 17 00:00:00 2001 From: Newnius Date: Wed, 23 Nov 2022 14:29:31 +0000 Subject: [PATCH] [to #8] multiset check permission & support more params --- ajax.php | 3 +++ index.php | 30 +++++++++++++++++++++++++++++- init.inc.php | 1 + link.logic.php | 11 +++++++++++ static/main.js | 14 +++++++++++++- 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/ajax.php b/ajax.php index f0655b3..5c29efb 100644 --- a/ajax.php +++ b/ajax.php @@ -81,6 +81,9 @@ function print_response($res) foreach ($urls as $url) { $link = new CRObject(); $link->set('url', $url); + $link->set('remark', cr_get_POST('remark')); + $link->set('valid_from', cr_get_POST('valid_from')); + $link->set('valid_to', cr_get_POST('valid_to')); $links[] = $link; } $res = link_multiadd($links); diff --git a/index.php b/index.php index d899f04..e8ae495 100644 --- a/index.php +++ b/index.php @@ -97,9 +97,37 @@ + +
+ + +
+ +
+
+ + +
+ +
+
+
+ +
+
+ + +
+ +
+
+
* 仅对部分用户开放
diff --git a/init.inc.php b/init.inc.php index 988c766..65c9481 100644 --- a/init.inc.php +++ b/init.inc.php @@ -87,6 +87,7 @@ function init_accessMap() /* link */ 'link.set' => array('root', 'admin', 'developer', 'normal', 'visitor'), + 'link.multiset' => array('root', 'admin', 'developer', 'normal'), 'link.get' => array('root', 'admin', 'developer', 'normal', 'visitor'), 'link.update' => array('root', 'admin', 'developer', 'normal'), 'link.remove' => array('root', 'admin', 'developer', 'normal'), diff --git a/link.logic.php b/link.logic.php index d3b5034..80391a6 100644 --- a/link.logic.php +++ b/link.logic.php @@ -57,6 +57,10 @@ function link_add(CRObject $link) } function link_multiadd(/* array(CRObject) */ $links) { + if (!AccessController::hasAccess(Session::get('role', 'visitor'), 'link.multiset')) { + $res['errno'] = Code::NO_PRIVILEGE; + return $res; + } $res['errno'] = Code::SUCCESS; $url_token_pairs = array(); foreach($links as $link) { @@ -68,6 +72,13 @@ function link_multiadd(/* array(CRObject) */ $links) { $url_token_pairs[] = array($link->get('url', ''), $r['token']); } $res['url_token_pairs'] = $url_token_pairs; + + $log = new CRObject(); + $log->set('scope', Session::get('uid')); + $log->set('tag', 'link.multiadd'); + $content = array('url_token_pairs' => $url_token_pairs, 'response' => $res['errno']); + $log->set('content', json_encode($content)); + CRLogger::log($log); return $res; } diff --git a/static/main.js b/static/main.js index 0173ebd..99c1677 100644 --- a/static/main.js +++ b/static/main.js @@ -113,13 +113,25 @@ $(function () { $("#modal-msg").modal('show'); return false; } + var remark = $('#form-multiset-remark').val(); + var valid_from = $('#form-multiset-valid-from').val(); + if (valid_from.length !== 0) { + valid_from = moment(valid_from).unix(); + } + var valid_to = $('#form-multiset-valid-to').val(); + if (valid_to.length !== 0) { + valid_to = moment(valid_to).unix(); + } $("#form-multiset-submit").attr("disabled", "disabled"); var ajax = $.ajax({ url: window.config.BASE_URL + "/service?action=multiset", type: 'POST', data: { - urls: urls + urls: urls, + remark: remark, + valid_from: valid_from, + valid_to: valid_to } }); ajax.done(function (res) {