Skip to content
Snippets Groups Projects
Commit 3369d841 authored by Frank Duncan's avatar Frank Duncan
Browse files

Add resetting choices

parent a503eea6
No related branches found
No related tags found
No related merge requests found
{
"name": "Deliberation",
"version": "0.2.0",
"version": "0.2.1",
"author": [
"Open Tech Strategies"
],
......@@ -44,6 +44,7 @@
"DeliberationSummary": "includes/specials/DeliberationSummary.php",
"DeliberationHooks": "includes/DeliberationHooks.php",
"DeliberationWidgetTemplate": "includes/templates/DeliberationWidgetTemplate.php",
"DeliberationDelete": "includes/api/DeliberationDelete.php",
"DeliberationWrite": "includes/api/DeliberationWrite.php"
},
"ResourceFileModulePaths": {
......@@ -53,13 +54,11 @@
"ParserFirstCallInit": "DeliberationHooks::onParserFirstCallInit",
"LoadExtensionSchemaUpdates": "DeliberationHooks::onLoadExtensionSchemaUpdates"
},
"DeliberationWrite": {
"deliberationwrite": "DeliberationWrite"
},
"config": {
"DeliberationChoices": false
},
"APIModules": {
"deliberationdelete": "DeliberationDelete",
"deliberationwrite": "DeliberationWrite"
},
"manifest_version": 1,
......
......@@ -8,6 +8,7 @@
"deliberation-desc": "Specialized Extension to choose pages for purposes of voting",
"deliberation-choose": "Choose",
"deliberation-reject": "Reject",
"deliberation-reset": "Reset",
"deliberationsummary": "Deliberation Summary",
"deliberationsummary-allpages": "All Pages"
}
......@@ -15,6 +15,18 @@ class Deliberation {
}
}
public static function remove($user, $title) {
// No deliberation on special pages!!
if($title->getArticleID() != 0) {
$lb = \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancer();
$dbw = $lb->getConnectionRef(DB_MASTER);
$dbw->delete("Deliberation", [
'page_id' => $title->getArticleID(),
'user_id' => $user->getId(),
]);
}
}
public static function limitHit($user, $value) {
$limit = false;
foreach(Self::getConfiguredChoices() as $choice) {
......
<?php
class DeliberationDelete extends APIBase {
public function __construct($main, $action) {
parent::__construct($main, $action);
}
public function execute() {
parent::checkUserRightsAny(["deliberation-write"]);
$user = $this->getUser();
$title = Title::newFromText($this->getParameter('title'));
Deliberation::remove($user, $title);
}
public function mustBePosted() {
return true;
}
public function getAllowedParams() {
return [
"title" => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => 'true'
]
];
}
}
?>
......@@ -27,6 +27,9 @@ class DeliberationWidgetTemplate extends QuickTemplate {
}
?>
</ul>
<div class="deliberation-reset">
<a href="#" class="reset-link"><?php echo wfMessage("deliberation-reset");?></span>
</div>
</div>
<hr>
<?php
......
(function ($, mw) {
$(function() {
var api = new mw.Api();
$(".deliberation input").change(function(e) {
var api = new mw.Api();
var elem = $(this);
api.post({
action: "deliberationwrite",
......@@ -9,6 +9,14 @@
title: mw.config.values.wgTitle
});
});
$(".deliberation a.reset-link").click(function(e) {
$(".deliberation input").prop("checked", false);
api.post({
action: "deliberationdelete",
title: mw.config.values.wgTitle
});
return false;
});
});
}(jQuery, mediaWiki));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment