Skip to content

Commit

Permalink
all or none checkbox javascript done
Browse files Browse the repository at this point in the history
  • Loading branch information
Lance Gatlin committed Jul 8, 2011
1 parent 739c027 commit 23619a1
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 69 deletions.
2 changes: 1 addition & 1 deletion SpecialAddUser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @link http://www.mediawiki.org/wiki/Extension:UserAdmin Documentation
* @author Lance Gatlin <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 0.1.0
* @version 1.0.0
*/

/*
Expand Down
2 changes: 1 addition & 1 deletion SpecialDeleteUser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @link http://www.mediawiki.org/wiki/Extension:UserAdmin Documentation
* @author Lance Gatlin <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 0.1.0
* @version 1.0.0
*/

/*
Expand Down
2 changes: 1 addition & 1 deletion SpecialEditUser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @link http://www.mediawiki.org/wiki/Extension:UserAdmin Documentation
* @author Lance Gatlin <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 0.1.0
* @version 1.0.0
*/

/*
Expand Down
2 changes: 1 addition & 1 deletion SpecialUADMBase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @link http://www.mediawiki.org/wiki/Extension:UserAdmin Documentation
* @author Lance Gatlin <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 0.1.0
* @version 1.0.0
*/

/*
Expand Down
33 changes: 27 additions & 6 deletions SpecialUserAdminPanel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @link http://www.mediawiki.org/wiki/Extension:UserAdmin Documentation
* @author Lance Gatlin <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 0.1.0
* @version 1.0.0
*/

/*
Expand Down Expand Up @@ -160,6 +160,8 @@ function validateGETParams()
*/
function doGET()
{
global $wgOut;

$this->validateGETParams();

// Load the users from database according to pagination parameters
Expand Down Expand Up @@ -201,6 +203,23 @@ function doGET()
$groupsfieldHTML = $this->groupsfield;
$lastEditDatefieldHTML = $this->lasteditdatefield;

$wgOut->includeJQuery();

$allOrNoneScript = <<<EOT
<script language="javascript" type="text/javascript">
var allOrNoneToggle = true;
jQuery( document ).ready( function( $ ) {
$("#allornone").click(
function() {
$(".selusr").attr('checked', allOrNoneToggle);
allOrNoneToggle = !allOrNoneToggle;
}
);
});
</script>
EOT;
$wgOut->addScript($allOrNoneScript);

return <<<EOT
$pageNavHTML
$pageSizerHTML
Expand All @@ -212,7 +231,7 @@ function doGET()
<table>
<tr>
<th><button type="submit" name="action" value="newuser">$this->uapnewuseractionlabel</button></th>
<th><input type="checkbox" name="allOrNone"/></th>
<th><input id="allornone" type="checkbox" name="allOrNone" onclick="all()"/></th>
<th>$idfieldHTML</th>
<th>$userNamefieldHTML</th>
<th>$realNamefieldHTML</th>
Expand Down Expand Up @@ -266,7 +285,7 @@ function getUsersFromDb()

// SQL WHERE based on filter
$sqlConds = '';
if (!empty($this->filtertext)) {
if (strlen($this->filtertext) > 0) {
$sqlConds = $this->mLookupUserField[$this->filterby] . ' ';

if($this->filterneg)
Expand All @@ -276,8 +295,10 @@ function getUsersFromDb()

$sqlConds .= $dbr->addQuotes($this->filtertext);
}

$estRowCount = $dbr->estimateRowCount('user', '*', $sqlConds);

$result = $dbr->select('user', 'user_id', $sqlConds);
$estRowCount = $result->numRows();
// $estRowCount = $dbr->estimateRowCount('user', '*', $sqlConds);

// SQL LIMIT based on pagenum/pagesize
if ($this->pagesize != 'all')
Expand Down Expand Up @@ -391,7 +412,7 @@ function getUserRowHTML($user)
return <<<EOT
<tr>
<td><a href="$editHref">($this->editactionlabel</a> | <a href="$contribsHref">$this->contributionsactionlabel</a> | <a href="$logsHref">$this->logsactionlabel</a>)</td>
<td><input type="checkbox" name="userids[]" value="$id"/></td>
<td><input class="selusr" type="checkbox" name="userids[]" value="$id"/></td>
<td>$id</td>
<td><a href="$userPageURL">$userName</a></td>
<td>$realName</td>
Expand Down
2 changes: 1 addition & 1 deletion UserAdmin.i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @link http://www.mediawiki.org/wiki/Extension:UserAdmin Documentation
* @author Lance Gatlin <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 0.1.0
* @version 1.0.0
*/

$aliases = array();
Expand Down
82 changes: 24 additions & 58 deletions UserAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* @link http://www.mediawiki.org/wiki/Extension:UserAdmin Documentation
* @author Lance Gatlin <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 0.1.0
* @version 1.0.0
*/

# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
if (!defined('MEDIAWIKI')) {
echo <<<EOT
To install the UserAdmin extension, put the following line in LocalSettings.php:
require_once( "\$IP/extensions/UserAdmin/UserAdmin.php" );
require_once( "$IP/extensions/UserAdmin/UserAdmin.php" );
EOT;
exit( 1 );
}
Expand All @@ -38,64 +38,30 @@

$dir = dirname(__FILE__) . '/';

$wgExtensionMessagesFiles['UserAdmin'] = $dir . 'UserAdmin.i18n.php'; # Location of a messages file (Tell MediaWiki to load this file)
$wgExtensionMessagesFiles['UserAdmin'] = $dir . 'UserAdmin.i18n.php';

$wgAutoloadClasses['SpecialUserAdminPanel'] = $dir . 'SpecialUserAdminPanel.class.php'; # Location of the SpecialMyExtension class (Tell MediaWiki to load this file)
$wgAutoloadClasses['SpecialAddUser'] = $dir . 'SpecialAddUser.class.php'; # Location of the SpecialMyExtension class (Tell MediaWiki to load this file)
$wgAutoloadClasses['SpecialDeleteUser'] = $dir . 'SpecialDeleteUser.class.php'; # Location of the SpecialMyExtension class (Tell MediaWiki to load this file)
$wgAutoloadClasses['SpecialEditUser'] = $dir . 'SpecialEditUser.class.php'; # Location of the SpecialMyExtension class (Tell MediaWiki to load this file)
$wgAutoloadClasses['SpecialUADMBase'] = $dir . 'SpecialUADMBase.class.php'; # Location of the SpecialMyExtension class (Tell MediaWiki to load this file)
$wgAutoloadClasses['SpecialUserAdminPanel'] = $dir . 'SpecialUserAdminPanel.class.php';
$wgAutoloadClasses['SpecialAddUser'] = $dir . 'SpecialAddUser.class.php';
$wgAutoloadClasses['SpecialDeleteUser'] = $dir . 'SpecialDeleteUser.class.php';
$wgAutoloadClasses['SpecialEditUser'] = $dir . 'SpecialEditUser.class.php';
$wgAutoloadClasses['SpecialUADMBase'] = $dir . 'SpecialUADMBase.class.php';
$wgAutoloadClasses['UADMLogActionHandler'] = $dir . 'UserAdminLogActionHandler.class.php';

$wgSpecialPages['UserAdmin'] = 'SpecialUserAdminPanel'; # Tell MediaWiki about the new special page and its class name
$wgSpecialPages['AddUser'] = 'SpecialAddUser'; # Tell MediaWiki about the new special page and its class name
$wgSpecialPages['DeleteUser'] = 'SpecialDeleteUser'; # Tell MediaWiki about the new special page and its class name
$wgSpecialPages['EditUser'] = 'SpecialEditUser'; # Tell MediaWiki about the new special page and its class name
$wgSpecialPages['UserAdmin'] = 'SpecialUserAdminPanel';
$wgSpecialPages['AddUser'] = 'SpecialAddUser';
$wgSpecialPages['DeleteUser'] = 'SpecialDeleteUser';
$wgSpecialPages['EditUser'] = 'SpecialEditUser';

$wgSpecialPageGroups['UserAdmin'] = 'users'; # Place this under the users grouping in special pages
$wgSpecialPageGroups['AddUser'] = 'users'; # Place this under the users grouping in special pages
$wgSpecialPageGroups['DeleteUser'] = 'users'; # Place this under the users grouping in special pages
$wgSpecialPageGroups['EditUser'] = 'users'; # Place this under the users grouping in special pages
$wgSpecialPageGroups['UserAdmin'] = 'users';
$wgSpecialPageGroups['AddUser'] = 'users';
$wgSpecialPageGroups['DeleteUser'] = 'users';
$wgSpecialPageGroups['EditUser'] = 'users';

$wgLogActionsHandlers['rights/uadm-changeduserpasswordlog'] = 'UADM_logActionHandler';
$wgLogActionsHandlers['rights/uadm-changeduseremaillog'] = 'UADM_logActionHandler';
$wgLogActionsHandlers['rights/uadm-changedusernamelog'] = 'UADM_logActionHandler';
$wgLogActionsHandlers['rights/uadm-changeduserrealnamelog'] = 'UADM_logActionHandler';
$wgLogActionsHandlers['rights/uadm-emailpasswordlog'] = 'UADM_logActionHandler';
$wgLogActionsHandlers['rights/uadm-emailwelcomelog'] = 'UADM_logActionHandler';
$wgLogActionsHandlers['rights/uadm-usersdeletedlog'] = 'UADM_logActionHandler';
$wgLogActionsHandlers['rights/uadm-changeduserpasswordlog'] = 'UADMLogActionHandler::logActionHandler';
$wgLogActionsHandlers['rights/uadm-changeduseremaillog'] = 'UADMLogActionHandler::logActionHandler';
$wgLogActionsHandlers['rights/uadm-changedusernamelog'] = 'UADMLogActionHandler::logActionHandler';
$wgLogActionsHandlers['rights/uadm-changeduserrealnamelog'] = 'UADMLogActionHandler::logActionHandler';
$wgLogActionsHandlers['rights/uadm-emailpasswordlog'] = 'UADMLogActionHandler::logActionHandler';
$wgLogActionsHandlers['rights/uadm-emailwelcomelog'] = 'UADMLogActionHandler::logActionHandler';
$wgLogActionsHandlers['rights/uadm-usersdeletedlog'] = 'UADMLogActionHandler::logActionHandler';

/*
* Formats log messages when invoked by MW
*
* @param $type unused
* @param $action string the log message type
* @param $title Title object
* @param $skin Skin objec
* @param $params array of string parameters for message
* @return string formatted log message
*/
function UADM_logActionHandler($type, $action, $title, $skin, $params)
{
foreach($params as &$param)
if($param == '')
$param = '(empty)';

$options = array('parseinline', 'replaceafter');
switch($action)
{
case 'uadm-usersdeletedlog' :
return wfMsgExt($action, $options, $params[0]);

case 'uadm-emailpasswordlog' :
case 'uadm-emailwelcomelog' :
case 'uadm-changeduserpasswordlog' :
return wfMsgExt($action, $options, $title->getPrefixedText());

case 'uadm-changedusernamelog' :
return wfMsgExt($action, $options, $params[0], $params[1], $params[2]);

case 'uadm-changeduseremaillog' :
case 'uadm-changeduserrealnamelog' :
return wfMsgExt($action, $options, $title->getPrefixedText(), $params[0], $params[1]);
}
}
63 changes: 63 additions & 0 deletions UserAdminLogActionHandler.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* UserAdmin is a MediaWiki extension which allows administrators to add and
* delete users (e.g. spam or unused accounts), change user passwords, edit user
* details (e.g. username, real name or email), edit user groups, resend emails
* (e.g. reset password email or welcome message email). This extension is
* primarily for administrators of private wikis that require tighter control of
* user accounts.
*
* Usage:
* require_once("extensions/UserAdmin/UserAdmin.php"); in LocalSettings.php
*
* @file
* @ingroup Extensions
* @link http://www.mediawiki.org/wiki/Extension:UserAdmin Documentation
* @author Lance Gatlin <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.0.0
*/

class UADMLogActionHandler {

/*
* Formats log messages when invoked by MW
*
* @param $type unused
* @param $action string the log message type
* @param $title Title object
* @param $skin Skin objec
* @param $params array of string parameters for message
* @return string formatted log message
*/
static function UlogActionHandler($type, $action, $title, $skin, $params)
{
foreach($params as &$param)
if($param == '')
$param = '(empty)';

$options = array('parseinline', 'replaceafter');
switch($action)
{
case 'uadm-usersdeletedlog' :
return wfMsgExt($action, $options, $params[0]);

case 'uadm-emailpasswordlog' :
case 'uadm-emailwelcomelog' :
case 'uadm-changeduserpasswordlog' :
return wfMsgExt($action, $options, $title->getPrefixedText());

case 'uadm-changedusernamelog' :
return wfMsgExt($action, $options, $params[0], $params[1], $params[2]);

case 'uadm-changeduseremaillog' :
case 'uadm-changeduserrealnamelog' :
return wfMsgExt($action, $options, $title->getPrefixedText(), $params[0], $params[1]);
}

}

}

?>

0 comments on commit 23619a1

Please sign in to comment.