Source for file users.php
Documentation is available at users.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* MediaWiki API Users class for the Joomla Platform.
* @package Joomla.Platform
* Method to login and get authentication tokens.
* @param string $lgname User Name.
* @param string $lgpassword Password.
* @param string $lgdomain Domain (optional).
public function login($lgname, $lgpassword, $lgdomain =
null)
// Build the request path.
$path =
'?action=login&lgname=' .
$lgname .
'&lgpassword=' .
$lgpassword;
$path .=
'&lgdomain=' .
$lgdomain;
// Request path with login token.
$path =
'?action=login&lgname=' .
$lgname .
'&lgpassword=' .
$lgpassword .
'&lgtoken=' .
$this->validateResponse($response)->login['token'];
$path .=
'&lgdomain=' .
$lgdomain;
// Set the session cookies returned.
$headers = (array)
$this->options->get('headers');
$headers['Cookie'] =
!empty($headers['Cookie']) ?
empty($headers['Cookie']) :
'';
$headers['Cookie'] =
$headers['Cookie'] .
$response->headers['Set-Cookie'];
$this->options->set('headers', $headers);
// Send the request again with the token.
$headers = (array)
$this->options->get('headers');
$cookie_prefix =
$response_body->login['cookieprefix'];
$cookie =
$cookie_prefix .
'UserID=' .
$response_body->login['lguserid'] .
'; ' .
$cookie_prefix
.
'UserName=' .
$response_body->login['lgusername'];
$headers['Cookie'] =
$headers['Cookie'] .
'; ' .
$response->headers['Set-Cookie'] .
'; ' .
$cookie;
$this->options->set('headers', $headers);
* Method to logout and clear session data.
// Build the request path.
// @TODO clear internal data as well
* Method to get user information.
* @param array $ususers A list of users to obtain the same information for.
* @param array $usprop What pieces of information to include.
public function getUserInfo(array $ususers, array $usprop =
null)
// Build the request path.
$path =
'?action=query&list=users';
// Append users to the request.
$path .=
'&ususers=' .
$this->buildParameter($ususers);
* Method to get current user information.
* @param array $uiprop What pieces of information to include.
// Build the request path.
$path =
'?action=query&meta=userinfo';
* Method to get user contributions.
* @param string $ucuser The users to retrieve contributions for.
* @param string $ucuserprefix Retrieve contibutions for all users whose names begin with this value.
* @param integer $uclimit The users to retrieve contributions for.
* @param string $ucstart The start timestamp to return from.
* @param string $ucend The end timestamp to return to.
* @param boolean $uccontinue When more results are available, use this to continue.
* @param string $ucdir In which direction to enumerate.
* @param array $ucnamespace Only list contributions in these namespaces.
* @param array $ucprop Include additional pieces of information.
* @param array $ucshow Show only items that meet this criteria.
* @param string $uctag Only list revisions tagged with this tag.
* @param string $uctoponly Only list changes which are the latest revision
public function getUserContribs($ucuser =
null, $ucuserprefix =
null, $uclimit =
null, $ucstart =
null, $ucend =
null, $uccontinue =
null,
$ucdir =
null, array $ucnamespace =
null, array $ucprop =
null, array $ucshow =
null, $uctag =
null, $uctoponly =
null)
// Build the request path.
$path =
'?action=query&list=usercontribs';
$path .=
'&ucuser=' .
$ucuser;
if (isset
($ucuserprefix))
$path .=
'&ucuserprefix=' .
$ucuserprefix;
$path .=
'&uclimit=' .
$uclimit;
$path .=
'&ucstart=' .
$ucstart;
$path .=
'&ucend=' .
$ucend;
$path .=
'&ucdir=' .
$ucdir;
$path .=
'&uctag=' .
$uctag;
$path .=
'&uctoponly=' .
$uctoponly;
* Method to block a user.
* @param string $user Username, IP address or IP range you want to block.
* @param string $expiry Relative expiry time, Default: never.
* @param string $reason Reason for block (optional).
* @param boolean $anononly Block anonymous users only.
* @param boolean $nocreate Prevent account creation.
* @param boolean $autoblock Automatically block the last used IP address, and any subsequent IP addresses they try to login from.
* @param boolean $noemail Prevent user from sending e-mail through the wiki.
* @param boolean $hidename Hide the username from the block log.
* @param boolean $allowusertalk Allow the user to edit their own talk page.
* @param boolean $reblock If the user is already blocked, overwrite the existing block.
* @param boolean $watchuser Watch the user/IP's user and talk pages.
public function blockUser($user, $expiry =
null, $reason =
null, $anononly =
null, $nocreate =
null, $autoblock =
null, $noemail =
null,
$hidename =
null, $allowusertalk =
null, $reblock =
null, $watchuser =
null)
$token =
$this->getToken($user, 'block');
// Build the request path.
$path =
'?action=unblock';
// Build the request data.
'autoblock' =>
$autoblock,
'allowusetalk' =>
$allowusertalk,
'watchuser' =>
$watchuser
* Method to unblock a user.
* @param string $user Username, IP address or IP range you want to unblock.
* @param string $reason Reason for unblock (optional).
$token =
$this->getToken($user, 'unblock');
// Build the request path.
$path =
'?action=unblock';
// Build the request data.
* Method to unblock a user.
* @param int $id Username, IP address or IP range you want to unblock.
* @param string $reason Reason for unblock (optional).
$token =
$this->getToken($id, 'unblock');
// Build the request path.
$path =
'?action=unblock';
// Build the request data.
// TODO: $data doesn't seem to be used!
* Method to assign a user to a group.
* @param string $username User name.
* @param array $add Add the user to these groups.
* @param array $remove Remove the user from these groups.
* @param string $reason Reason for the change.
public function assignGroup($username, $add =
null, $remove =
null, $reason =
null)
$token =
$this->getToken($username, 'unblock');
// Build the request path.
$path =
'?action=userrights';
// Build the request data.
* Method to email a user.
* @param string $target User to send email to.
* @param string $subject Subject header.
* @param string $text Mail body.
* @param boolean $ccme Send a copy of this mail to me.
public function emailUser($target, $subject =
null, $text =
null, $ccme =
null)
$token =
$this->getToken($target, 'emailuser');
// Build the request path.
$path =
'?action=emailuser';
// Build the request data.
* Method to get access token.
* @param string $user The User to get token.
* @param string $intoken The type of token.
public function getToken($user, $intoken)
// Build the request path.
$path =
'?action=query&prop=info&intoken=' .
$intoken .
'&titles=User:' .
$user;
return (string)
$this->validateResponse($response)->query->pages->page[$intoken .
'token'];
Documentation generated on Tue, 19 Nov 2013 15:16:40 +0100 by phpDocumentor 1.4.3