Skip to content

Commit

Permalink
repairs the non-share version of saving queries, though it isn't fully
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shinobu committed Aug 31, 2016
1 parent 554b5d1 commit 6c88936
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
22 changes: 18 additions & 4 deletions extensions/queries/QueriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,25 @@ public function savequeryAction()
$res = "json or desc missing";
// checking for post data to save queries
$params = $this->_request->getParams();
if (isset($params['json']) && isset($params['json'])) {
$hasAC = !(
empty(Erfurt_App::getInstance()->isActionAllowed('ModelManagement'))
&& ($params['share'] == 'false')
) || ($this->findDB($this->_userDbUri) != null);
if (isset($params['json']) && $hasAC) {
if ($this->_request->getParam('share') == "true") {
if (!$this->_owApp->selectedModel->isEditable()) {
$res = "The Query cannot be shared, because the Model is not editable.";
return $res;
}
// store in the model itself - everybody can see it
$storeGraph = $this->_owApp->selectedModel;
} else {
//private db - should be configured so only the user can see it
$storeGraph = $this->getUserQueryDB();
if (!$storeGraph->isEditable()) {
$res = "Your Personal Query DB is not writeable. You should ask the Admin about this.";
return $res;
}
}

// checking whether any queries exist yet in this store
Expand Down Expand Up @@ -581,6 +593,8 @@ public function savequeryAction()
} else {
$res = 'Save failed. (Query with same pattern exists)';
}
} else {
$res = 'You dont have the permissions to save your Queries non-shared.';
}
$response->setBody($res);
}
Expand Down Expand Up @@ -693,12 +707,12 @@ private function createUserQueryDB()
$proposedDBname = $this->_userDbUri;

$store = $this->_erfurt->getStore();
$newModel = $store->getNewModel($proposedDBname);
$newModel = $store->getNewModel($proposedDBname, null, null, true);

$object = array();

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

Expand All @@ -714,7 +728,7 @@ private function createUserQueryDB()

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

//add owner/maker of this db
Expand Down
7 changes: 3 additions & 4 deletions extensions/queries/resources/savepartial.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $(document).ready(function() {
success: function(msg){
//TODO check for status
if(msg != "All OK")
alert("Fehler "+msg);
alert("Error "+msg);
//open(urlBase + "querybuilding/listquery");
}
});
Expand All @@ -46,8 +46,7 @@ $(document).ready(function() {
name: $('#qname').val(),
"query": editor.getValue(),
generator: "qe",
//share: $("#savequerysharecheckbox").is(':checked') ? "true" : "false"
share: "true"
share: $("#savequerysharecheckbox").is(':checked') ? "true" : "false"
}),
dataType: "text",
error: function(xmlHttpObj, type, error){
Expand All @@ -56,7 +55,7 @@ $(document).ready(function() {
success: function(msg){
//TODO check for status
if (msg != "All OK") {
alert("Fehler " + msg);
alert("Error " + msg);
} else {
$('.innercontent').prepend("<p class=\"messagebox info\" id=\"savequerynotification\">The Query was saved</p>");

Expand Down
2 changes: 1 addition & 1 deletion extensions/queries/templates/savequery.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
</p><p>
<input id="hidden_query" type="hidden" value=""/>
<input id="hidden_json" type="hidden" value=""/>
<input id="savequerysharecheckbox" type="checkbox"> share with others
<input id="savequerysharecheckbox" type="checkbox" checked> share with others
</p>
<a id = 'savequerybutton' class="button submit"><span><?php echo $this->_('Save Query'); ?></span></a>

0 comments on commit 6c88936

Please sign in to comment.