@@ -404,17 +404,33 @@ public function savequeryAction()
404
404
$ store = $ this ->_erfurt ->getStore ();
405
405
$ storeGraph = $ this ->_owApp ->selectedModel ;
406
406
$ graphUri = (string )$ this ->_owApp ->selectedModel ;
407
-
408
407
$ res = "json or desc missing " ;
409
408
// checking for post data to save queries
410
409
$ 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
+ }
413
418
// store in the model itself - everybody can see it
414
419
$ storeGraph = $ this ->_owApp ->selectedModel ;
415
420
} 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
+ }
418
434
}
419
435
420
436
// checking whether any queries exist yet in this store
@@ -581,6 +597,8 @@ public function savequeryAction()
581
597
} else {
582
598
$ res = 'Save failed. (Query with same pattern exists) ' ;
583
599
}
600
+ } else {
601
+ $ res = 'You dont have the permissions to save your Queries non-shared. ' ;
584
602
}
585
603
$ response ->setBody ($ res );
586
604
}
@@ -693,12 +711,12 @@ private function createUserQueryDB()
693
711
$ proposedDBname = $ this ->_userDbUri ;
694
712
695
713
$ store = $ this ->_erfurt ->getStore ();
696
- $ newModel = $ store ->getNewModel ($ proposedDBname );
714
+ $ newModel = $ store ->getNewModel ($ proposedDBname, null , null , true );
697
715
698
716
$ object = array ();
699
717
700
718
// add english label for this db
701
- $ object ['object_type ' ] = Erfurt_Store:: TYPE_LITERAL ;
719
+ $ object ['type ' ] = ' literal ' ;
702
720
$ object ['value ' ] = 'GQB Query DB of ' . $ this ->_userName ;
703
721
$ newModel ->addStatement ($ proposedDBname , EF_RDFS_LABEL , $ object );
704
722
@@ -714,7 +732,7 @@ private function createUserQueryDB()
714
732
715
733
//domain of this db (needed?)
716
734
$ object ['value ' ] = $ this ->_privateConfig ->saving ->baseQueryDbUri ;
717
- $ object ['object_type ' ] = Erfurt_Store:: TYPE_IRI ;
735
+ $ object ['type ' ] = ' uri ' ;
718
736
$ newModel ->addStatement ($ proposedDBname , EF_RDFS_DOMAIN , $ object );
719
737
720
738
//add owner/maker of this db
0 commit comments