Rjain has uploaded a new change for review.
https://gerrit.wikimedia.org/r/75106
Change subject: Added the update class
......................................................................
Added the update class
Change-Id: Ia2b75ff666dc6e0fe2299c1611a29a7a4b855dcf
---
M Annotator.php
A api/ApiAnnotatorUpdate.php
M modules/Annotator.js
3 files changed, 48 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Annotator
refs/changes/06/75106/1
diff --git a/Annotator.php b/Annotator.php
index 7549fb4..0028730 100755
--- a/Annotator.php
+++ b/Annotator.php
@@ -27,6 +27,7 @@
$wgAutoloadClasses['ApiAnnotatorRead'] = $dir . 'api/ApiAnnotatorRead.php';
$wgAutoloadClasses['ApiAnnotatorSearch'] = $dir . 'api/ApiAnnotatorSearch.php';
$wgAutoloadClasses['ApiAnnotatorDestroy'] = $dir .
'api/ApiAnnotatorDestroy.php';
+$wgAutoloadClasses['ApiAnnotatorUpdate'] = $dir . 'api/ApiAnnotatorUpdate.php';
//Hooks
$wgHooks['BeforePageDisplay'][] = 'AnnotatorHooks::onBeforePageDisplay';
@@ -35,4 +36,5 @@
$wgAPIModules['annotator-create'] = 'ApiAnnotatorCreate';
$wgAPIModules['annotator-read'] = 'ApiAnnotatorRead';
$wgAPIModules['annotator-search'] = 'ApiAnnotatorSearch';
-$wgAPIModules['annotator-destroy'] = 'ApiAnnotatorDestroy';
\ No newline at end of file
+$wgAPIModules['annotator-destroy'] = 'ApiAnnotatorDestroy';
+$wgAPIModules['annotator-update'] = 'ApiAnnotatorUpdate';
\ No newline at end of file
diff --git a/api/ApiAnnotatorUpdate.php b/api/ApiAnnotatorUpdate.php
new file mode 100644
index 0000000..3ac18be
--- /dev/null
+++ b/api/ApiAnnotatorUpdate.php
@@ -0,0 +1,44 @@
+<?php
+class ApiAnnotatorUpdate extends ApiBase {
+ public function execute() {
+ $params = $this->extractRequestParams();
+ $id = $params['id'];
+
+ //get the annotation object
+ $annotation_json = $this->getRawPostString();
+
+ //get the user object
+ $user = $this->getUser();
+
+ //checks user log in
+ if( !$user->isLoggedIn() ) {
+ $this->dieUsage( "Log in to delete annotation",
'user_not_logged_in', 401 );
+ }
+
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->update(
+ 'annotator',
+ array(
+ 'annotation_json' => $annotation_json
+ ),
+ array(
+ 'annotation_id' => $id
+ )
+ );
+
+ return true;
+ }
+
+ public function getRawPostString() {
+ return file_get_contents('php://input');
+ }
+
+ public function getAllowedParams() {
+ return array(
+ 'id' =>array(
+ ApiBase::PARAM_TYPE => 'integer',
+ ApiBase::PARAM_REQUIRED => true
+ )
+ );
+ }
+}
\ No newline at end of file
diff --git a/modules/Annotator.js b/modules/Annotator.js
index 1f66d8f..fc3f6f4 100755
--- a/modules/Annotator.js
+++ b/modules/Annotator.js
@@ -14,7 +14,7 @@
prefix: this.apiUrl,
urls: {
create: '?action=annotator-create&format=json&revid=' + revid,
- update: '',
+ update: '?action=annotator-update&format=json&id=:id',
read: '?action=annotator-read&format=json&id=:id',
destroy: '?action=annotator-destroy&format=json&id=:id',
search: '?action=annotator-search&format=json'
--
To view, visit https://gerrit.wikimedia.org/r/75106
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2b75ff666dc6e0fe2299c1611a29a7a4b855dcf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Annotator
Gerrit-Branch: master
Gerrit-Owner: Rjain <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits