-
Notifications
You must be signed in to change notification settings - Fork 188
[DQT] add delete feature #8078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[DQT] add delete feature #8078
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8d60d40
add delete button
kongtiaowang 78568f6
css
kongtiaowang 583958f
tools
kongtiaowang 9b7fb35
public delete
kongtiaowang b8d5642
cs
kongtiaowang 460f486
cs for tools
kongtiaowang dad3354
Update react.savedqueries.js
kongtiaowang 9913660
Update dqt_setup.class.inc
kongtiaowang 89b67c5
Update dqt_setup.class.inc
kongtiaowang 5e1833e
Update dqt_setup.class.inc
kongtiaowang baf7010
add user permisison check
kongtiaowang 9db6ba8
Update DeleteDoc.php
kongtiaowang ac0b5d2
cs
kongtiaowang 9ab6cc9
Update react.tabs.js
kongtiaowang 7261f8d
add CHANGELOG
kongtiaowang 0de9f54
Update react.tabs.js
maltheism d63d9e3
Update dqt_delete_saved_query.php
kongtiaowang 8f11c53
Update DeleteDoc.php
kongtiaowang f61d8d2
add 404 and check delete status
kongtiaowang d419afa
add 404 and check delete status
kongtiaowang 8cf6dae
update 404
kongtiaowang 7b2f52b
indentation
kongtiaowang 983c89f
Update DeleteDoc.php
kongtiaowang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
kongtiaowang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * Data Querying Module | ||
| * | ||
| * PHP Version 5 | ||
| * | ||
| * @category Data_Querying_Module | ||
| * @package Loris | ||
| * @author Loris Team <loris-dev@bic.mni.mcgill.ca> | ||
| * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
| * @link https://www.github.com/aces/Loris/ | ||
| */ | ||
| header("Content-Type: application/json"); | ||
| $config = \NDB_Config::singleton(); | ||
| $couchConfig = $config->getSetting('CouchDB'); | ||
| $cdb = \NDB_Factory::singleton()->couchDB( | ||
| $couchConfig['dbName'], | ||
| $couchConfig['hostname'], | ||
| intval($couchConfig['port']), | ||
| $couchConfig['admin'], | ||
| $couchConfig['adminpass'] | ||
| ); | ||
| $is_author = false; | ||
| $docID = urlencode($_REQUEST['DocID']); | ||
| $user = User::singleton(); | ||
| $tmp_author = explode("_", $docID); | ||
| $doc_author = str_replace("global:", '', $tmp_author[0]); | ||
| if ($doc_author == $user->getUsername()) { | ||
| $is_author = true; | ||
| } | ||
|
|
||
| if ($user->hasPermission('superuser') || $is_author) { | ||
| $results = $cdb->deleteDoc($docID); | ||
| print json_encode($results); | ||
| } else { | ||
| header("HTTP/1.1 403 Forbidden"); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <?php | ||
| /** | ||
| * Data Querying Module | ||
| * | ||
| * PHP Version 7.4 | ||
| * | ||
| * @category Data_Querying_Module | ||
| * @package Loris | ||
| * @author Loris Team <loris-dev@bic.mni.mcgill.ca> | ||
| * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
| * @link https://www.github.com/aces/Loris/ | ||
| */ | ||
| require_once __DIR__ . '/../vendor/autoload.php'; | ||
| header("Content-Type: application/json"); | ||
kongtiaowang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $config = \NDB_Config::singleton(); | ||
| $couchConfig = $config->getSetting('CouchDB'); | ||
| $cdb = \NDB_Factory::singleton()->couchDB( | ||
| $couchConfig['dbName'], | ||
| $couchConfig['hostname'], | ||
| intval($couchConfig['port']), | ||
| $couchConfig['admin'], | ||
| $couchConfig['adminpass'] | ||
| ); | ||
| echo "Deleting a saved query in DQT.\n"; | ||
|
|
||
| $user = readline("Please input the author of the saved query:"); | ||
| $name = readline("Please input the name of the saved query:"); | ||
| $global = readline("If the saved query is global then input 'y':"); | ||
| if ($global) { | ||
| $docID = urlencode("global:".$user."_".$name); | ||
| } else { | ||
| $docID = urlencode($user."_".$name); | ||
| } | ||
| $results = $cdb->deleteDoc( | ||
| $docID | ||
| ); | ||
|
|
||
|
|
||
| if (json_encode($results) == "true") { | ||
| echo $name." has been deleted in DQT.\n"; | ||
| } else { | ||
| echo "There is no query named ".$name." in DQT.\n"; | ||
| }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.