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

Commit 27b3784

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 cdf4577 commit 27b3784

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

extensions/queries/QueriesController.php

+26-8
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,33 @@ public function savequeryAction()
404404
$store = $this->_erfurt->getStore();
405405
$storeGraph = $this->_owApp->selectedModel;
406406
$graphUri = (string)$this->_owApp->selectedModel;
407-
408407
$res = "json or desc missing";
409408
// checking for post data to save queries
410409
$params = $this->_request->getParams();
411-
if (isset($params['json']) && isset($params['json'])) {
412-
if ($this->_request->getParam('share') == "true") {
410+
if (isset($params['json'])) {
411+
if ($this->_request->getParam('share') == 'true') {
412+
//The User wants to story the Query in the DB he is querying -> check if he can edit it
413+
if (!$this->_owApp->selectedModel->isEditable()) {
414+
$res = "The Query cannot be shared, because the Model is not editable.";
415+
$response->setBody($res);
416+
return;
417+
}
413418
// store in the model itself - everybody can see it
414419
$storeGraph = $this->_owApp->selectedModel;
415420
} else {
416-
//private db - should be configured so only the user can see it
417-
$storeGraph = $this->getUserQueryDB();
421+
//the User wants to Store the Query in his private DB -> check rights/if it already exists
422+
if (!Erfurt_App::getInstance()->isActionAllowed('ModelManagement')) {
423+
if ($this->findDB($this->_userDbUri) == null) {
424+
$res = 'You dont have the Permission to create a DB for your Queries,'
425+
. ' ask your Admin about it.';
426+
$response->setBody($res);
427+
return;
428+
} else {
429+
$storeGraph = $this->getUserQueryDB();
430+
}
431+
} else {
432+
$storeGraph = $this->getUserQueryDB();
433+
}
418434
}
419435

420436
// checking whether any queries exist yet in this store
@@ -581,6 +597,8 @@ public function savequeryAction()
581597
} else {
582598
$res = 'Save failed. (Query with same pattern exists)';
583599
}
600+
} else {
601+
$res = 'You dont have the permissions to save your Queries non-shared.';
584602
}
585603
$response->setBody($res);
586604
}
@@ -693,12 +711,12 @@ private function createUserQueryDB()
693711
$proposedDBname = $this->_userDbUri;
694712

695713
$store = $this->_erfurt->getStore();
696-
$newModel = $store->getNewModel($proposedDBname);
714+
$newModel = $store->getNewModel($proposedDBname, null, null, true);
697715

698716
$object = array();
699717

700718
// add english label for this db
701-
$object['object_type'] = Erfurt_Store::TYPE_LITERAL;
719+
$object['type'] = 'literal';
702720
$object['value'] = 'GQB Query DB of ' . $this->_userName;
703721
$newModel->addStatement($proposedDBname, EF_RDFS_LABEL, $object);
704722

@@ -714,7 +732,7 @@ private function createUserQueryDB()
714732

715733
//domain of this db (needed?)
716734
$object['value'] = $this->_privateConfig->saving->baseQueryDbUri;
717-
$object['object_type'] = Erfurt_Store::TYPE_IRI;
735+
$object['type'] = 'uri';
718736
$newModel->addStatement($proposedDBname, EF_RDFS_DOMAIN, $object);
719737

720738
//add owner/maker of this db

extensions/queries/resources/savepartial.js

+3-4
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

+1-1
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)