Commit c33fb3ac authored by Luke081515's avatar Luke081515

Add "getCreatedPages"

* Fixes #84
parent 3b086446
Pipeline #2183 passed with stages
in 2 minutes and 54 seconds
......@@ -888,6 +888,30 @@ class Core extends Password {
}
return $result['query']['users'][0]['gender'];
}
/** getCreatedPages
* returns all created pages of a user
* @author Luke081515
* @param $username – The username of the user
* @param [optional: null] - if set, restricts the results to the selected namespaces
* @return an array with the pagetitles, or false if no pages got created yet
*/
public function getCreatedPages($user, $namespace = null) {
if ($namespace === null) {
$result = $this->httpRequest("action=query&format=json&list=usercontribs&uclimit=max&ucuser=" . urlencode($user)
. "&ucdir=older&ucshow=new", $this->job, "GET");
} else {
$result = $this->httpRequest("action=query&format=json&list=usercontribs&uclimit=max&ucuser=" . urlencode($user)
. "&ucdir=older&ucshow=new&ucnamespace=" . $namespace, $this->job, "GET");
}
$result = json_decode($result, true);
for ($a = 0; isset($result["query"]["usercontribs"][$a]["title"]); $a++) {
$createResults[$a] = $result["query"]["usercontribs"][$a]["title"];
}
if (!isset($createResults[0])) {
return false;
}
return $createResults;
}
/** checkTemplate
* checks if a template is used at a page (transcluded)
* @author Luke081515
......
......@@ -399,6 +399,22 @@ class Debug extends Core {
$this->processError($e, $starttime, $endtime);
}
break;
case 'getCreatedPages':
$required = array("user");
$optional = array("namespace");
$optvalues = array(null);
$Param = $this->getParams($required, $optional, $optvalues);
$this->echoMsg("Starting the function call of getCreatedPages...", "notice");
$starttime = microtime (true);
try {
$ret = $this->getCreatedPages($Param[0], $Param[1]);
$endtime = microtime (true);
$this->processFunction($ret, $starttime, $endtime);
} catch (Exception $e) {
$endtime = microtime (true);
$this->processError($e, $starttime, $endtime);
}
break;
// Query functions
case 'checkTemplate':
$required = array("page", "template");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment