Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit b0d23d2

Browse files
committed
repairs the non-share version of saving queries, though it isn't fully
supported right now. This creates a db for users (with AC check) who are allowed to creade them, the checkbox is prechecked as most user won't have the permission to create their own dbs. Fixes Wrong Parameters and some Typos as well.
1 parent 456a819 commit b0d23d2

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

extensions/queries/QueriesController.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,11 @@ public function savequeryAction()
408408
$res = "json or desc missing";
409409
// checking for post data to save queries
410410
$params = $this->_request->getParams();
411-
if (isset($params['json']) && isset($params['json'])) {
411+
$hasAC = !(
412+
empty(Erfurt_App::getInstance()->isActionAllowed('ModelManagement'))
413+
&& ($params['share'] == 'false')
414+
);
415+
if (isset($params['json']) && $hasAC) {
412416
if ($this->_request->getParam('share') == "true") {
413417
// store in the model itself - everybody can see it
414418
$storeGraph = $this->_owApp->selectedModel;
@@ -581,6 +585,8 @@ public function savequeryAction()
581585
} else {
582586
$res = 'Save failed. (Query with same pattern exists)';
583587
}
588+
} else {
589+
$res = 'You dont have the permissions to save your Queries non-shared.';
584590
}
585591
$response->setBody($res);
586592
}
@@ -693,12 +699,12 @@ private function createUserQueryDB()
693699
$proposedDBname = $this->_userDbUri;
694700

695701
$store = $this->_erfurt->getStore();
696-
$newModel = $store->getNewModel($proposedDBname);
702+
$newModel = $store->getNewModel($proposedDBname, null, null, true);
697703

698704
$object = array();
699705

700706
// add english label for this db
701-
$object['object_type'] = Erfurt_Store::TYPE_LITERAL;
707+
$object['type'] = 'literal';
702708
$object['value'] = 'GQB Query DB of ' . $this->_userName;
703709
$newModel->addStatement($proposedDBname, EF_RDFS_LABEL, $object);
704710

@@ -714,7 +720,7 @@ private function createUserQueryDB()
714720

715721
//domain of this db (needed?)
716722
$object['value'] = $this->_privateConfig->saving->baseQueryDbUri;
717-
$object['object_type'] = Erfurt_Store::TYPE_IRI;
723+
$object['type'] = 'uri';
718724
$newModel->addStatement($proposedDBname, EF_RDFS_DOMAIN, $object);
719725

720726
//add owner/maker of this db

extensions/queries/resources/savepartial.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $(document).ready(function() {
2222
success: function(msg){
2323
//TODO check for status
2424
if(msg != "All OK")
25-
alert("Fehler "+msg);
25+
alert("Error "+msg);
2626
//open(urlBase + "querybuilding/listquery");
2727
}
2828
});
@@ -46,8 +46,7 @@ $(document).ready(function() {
4646
name: $('#qname').val(),
4747
"query": editor.getValue(),
4848
generator: "qe",
49-
//share: $("#savequerysharecheckbox").is(':checked') ? "true" : "false"
50-
share: "true"
49+
share: $("#savequerysharecheckbox").is(':checked') ? "true" : "false"
5150
}),
5251
dataType: "text",
5352
error: function(xmlHttpObj, type, error){
@@ -56,7 +55,7 @@ $(document).ready(function() {
5655
success: function(msg){
5756
//TODO check for status
5857
if (msg != "All OK") {
59-
alert("Fehler " + msg);
58+
alert("Error " + msg);
6059
} else {
6160
$('.innercontent').prepend("<p class=\"messagebox info\" id=\"savequerynotification\">The Query was saved</p>");
6261

extensions/queries/templates/savequery.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
</p><p>
55
<input id="hidden_query" type="hidden" value=""/>
66
<input id="hidden_json" type="hidden" value=""/>
7-
<input id="savequerysharecheckbox" type="checkbox"> share with others
7+
<input id="savequerysharecheckbox" type="checkbox" checked> share with others
88
</p>
99
<a id = 'savequerybutton' class="button submit"><span><?php echo $this->_('Save Query'); ?></span></a>

0 commit comments

Comments
 (0)