11 #include "protectpage.hpp"
12 #include "ui_protectpage.h"
14 using namespace Huggle;
24 this->ui->comboBox_3->addItem(
"Everyone (no protection)");
26 this->ui->comboBox_3->addItem(
"Autoconfirmed (semi)");
28 this->ui->comboBox_3->addItem(
"Sysops (full)");
29 this->ui->comboBox_3->setCurrentIndex(2);
30 this->protecttoken =
"";
32 ui->comboBox->addItem(Configuration::LocalConfig_ProtectReason);
35 ProtectPage::~ProtectPage()
58 this->
tt =
new QTimer(
this);
59 connect(this->
tt, SIGNAL(timeout()),
this, SLOT(onTick()));
60 this->PtQueryPhase = 0;
64 void ProtectPage::onTick()
66 switch(this->PtQueryPhase)
96 QDomNodeList l = r.elementsByTagName(
"page");
101 Failed(
"No page info was available (are you an admin?)");
104 QDomElement element = l.at(0).toElement();
105 if (!element.attributes().contains(
"protecttoken"))
110 this->protecttoken = element.attribute(
"protecttoken");
111 this->PtQueryPhase++;
117 QString protection =
"edit=sysop|move=sysop";
118 switch (this->ui->comboBox_3->currentIndex())
121 protection =
"edit=all|move=all";
124 protection =
"edit=autoconfirmed|move=autoconfirmed";
128 +
"&reason=" + QUrl::toPercentEncoding(Configuration::LocalConfig_ProtectReason)
129 +
"&expiry=" + QUrl::toPercentEncoding(ui->comboBox_2->currentText())
130 +
"&protections=" + QUrl::toPercentEncoding(protection)
131 +
"&token=" + QUrl::toPercentEncoding(protecttoken);
138 void ProtectPage::on_pushButton_clicked()
143 void ProtectPage::on_pushButton_2_clicked()
146 this->ui->pushButton_2->setEnabled(
false);
151 QMessageBox *_pmb =
new QMessageBox();
153 _pmb->setWindowTitle(
"Unable to protect page");
155 _pmb->setText(
"Unable to protect the page because " + reason);
161 ui->pushButton->setEnabled(
true);
162 if (this->
ptkq != NULL)
166 if (this->
ptpt != NULL)
190 ui->pushButton_2->setText(
"Page has been protected");
void setPageToProtect(WikiPage *Page)
set a page that is supposed to be protected, this needs to be called by owner who created this form ...
QString Target
This is optional property which contains a label of target this query is for.
ApiQuery * ptkk
Pointer for second token.
ProtectPage(QWidget *parent=0)
virtual bool Processed()
Returns true in case that query is processed.
void UnregisterConsumer(const int consumer)
This function will remove a string which prevent the object from being removed.
void RegisterConsumer(const int consumer)
Registers a consumer.
static void AppendQuery(Query *item)
Insert a query to internal list of running queries, so that they can be watched This will insert it t...
void checkTokenToProtect()
void SetAction(const Action action)
Change the action type.
The ProtectPage class display a window where user can protect a page given they have the permissions ...
ApiQuery * ptpt
Pointer for protection.
static void DebugLog(QString Message, unsigned int Verbosity=1)
This log is only shown if verbosity is same or larger than requested verbosity.
WikiPage * ptpge
DOCUMENT ME.
QString ErrorMessage
If query is in error the reason for error is stored here.
QString Parameters
Parameters for action, for example page title.
QString PageName
Name of page.
This class can be used to execute any kind of api query on any wiki.
ApiQuery * ptkq
Pointer to get first token.
void Failed(QString reason)
QString Data
Data retrieved by query.
QueryResult * Result
Result of query, see documentation of QueryResult for more.