11 #include "blockuser.hpp"
12 #include "ui_blockuser.h"
15 using namespace Huggle;
17 BlockUser::BlockUser(QWidget *parent) : QDialog(parent), ui(new Ui::
BlockUser)
21 this->blocktoken =
"";
26 ui->comboBox->addItem(Configuration::LocalConfig_BlockReason);
29 BlockUser::~BlockUser()
35 void BlockUser::SetWikiUser(
WikiUser *User)
38 if (this->user->
IsIP())
40 ui->checkBox_5->setEnabled(
true);
49 b->
Parameters =
"prop=info&intoken=block&titles=User:" +
50 QUrl::toPercentEncoding(this->user->
Username);
57 this->
t0 =
new QTimer(
this);
58 connect(this->
t0, SIGNAL(timeout()),
this, SLOT(onTick()));
63 void BlockUser::on_pushButton_2_clicked()
68 void BlockUser::onTick()
70 switch (this->QueryPhase)
100 QDomNodeList l = d.elementsByTagName(
"user");
105 Failed(
"no user info was present in query (are you sysop?)");
108 QDomElement element = l.at(0).toElement();
109 if (!element.attributes().contains(
"blocktoken"))
115 this->blocktoken = element.attribute(
"blocktoken");
126 tb->
Parameters =
"action=block&user=" + QUrl::toPercentEncoding(this->user->
Username) +
"reason="
127 + QUrl::toPercentEncoding(Configuration::LocalConfig_BlockReason) +
"expiry="
128 + QUrl::toPercentEncoding(Configuration::LocalConfig_BlockTimeAnon) +
"token="
129 + QUrl::toPercentEncoding(blocktoken);
133 tb->
Parameters =
"action=block&user=" + QUrl::toPercentEncoding(this->user->
Username) +
"reason="
134 + QUrl::toPercentEncoding(Configuration::LocalConfig_BlockReason) +
"token="
135 + QUrl::toPercentEncoding(blocktoken);
147 if (this->
tb == NULL)
163 ui->pushButton->setText(
"Blocked");
169 void BlockUser::Failed(QString reason)
171 QMessageBox *_b =
new QMessageBox();
172 _b->setWindowTitle(
"Unable to block user");
173 _b->setText(
"Unable to block the user because " + reason);
179 ui->pushButton->setEnabled(
true);
184 if (this->
tb != NULL)
192 void BlockUser::on_pushButton_clicked()
195 this->sendBlockNotice(dependency);
197 ui->pushButton->setEnabled(
false);
200 void BlockUser::sendBlockNotice(
ApiQuery *dependency)
205 blocknotice = Configuration::LocalConfig_BlockMessage;
208 blocknotice = Configuration::LocalConfig_BlockMessageIndef;
210 QString blocksum = Configuration::LocalConfig_BlockSummary;
QString Target
This is optional property which contains a label of target this query is for.
virtual bool Processed()
Returns true in case that query is processed.
This form can be used to block users from editing, which requires the block permission.
bool IsIP()
Returns true in case the current user is IP user.
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...
QString Username
Username.
static Message * MessageUser(WikiUser *user, QString message, QString title, QString summary, bool section=true, Query *dependency=NULL)
MessageUser Message user.
void SetAction(const Action action)
Change the action type.
bool UsingPOST
Whether the query will submit parameters using POST data.
static void DebugLog(QString Message, unsigned int Verbosity=1)
This log is only shown if verbosity is same or larger than requested verbosity.
QString ErrorMessage
If query is in error the reason for error is stored here.
QString Parameters
Parameters for action, for example page title.
This class can be used to execute any kind of api query on any wiki.
QString Data
Data retrieved by query.
QueryResult * Result
Result of query, see documentation of QueryResult for more.