Extension:Prefix Security/GroupsAdministration v1.2.0/es


 * Copie el código en un archivo (GroupsAdmini≥|stration.php)

 " );                               }                                else {                                        $wgOut->addWikiText( wfMsg( 'groupsadministration-none' ) );                                }                                $dbr->freeResult( $res );                                $wgOut->addHTML( "   " );                       }

#=====================================================#			# GET REQUESTS #=====================================================#			if( $_SERVER['REQUEST_METHOD'] == 'GET' ) {

# GET REQUEST: delete group - question #============================================#				if( $wgRequest->getText( 'action' ) == "delete_group" ) { $group_name = $wgRequest->getText( 'group_name' ); $action = $wgTitle->escapeLocalURL; $wgOut->addWikiText( wfMsg( 'groupsadministration-delete-areyousure', $group_name ) ); $wgOut->addHTML( "												                                               											" ); }

# GET REQUEST: edit group #============================================#				if( $wgRequest->getText( 'action' ) == "edit_group" ) { $this->edit_group( "", $textbox_width ); }

# GET REQUEST: edit group #============================================#				if( $wgRequest->getText( 'edit_group' ) != "" || $wgRequest->getText( 'add_new_user' ) != ""					|| $wgRequest->getText( 'find_user' ) != "" || $wgRequest->getText( 'delete_selected_users' )					|| $wgRequest->getText( 'delete_user_yes' ) || $wgRequest->getText( 'delete_user_no' ) ) { $this->edit_group( "", $textbox_width ); }

# PRE GET REQUEST: remove user from group - question #============================================#				if ( ( $group_name = $wgRequest->getText( 'group_name' ) )					&& ( $remove_user = $wgRequest->getText( 'remove_user' ) ) ) { $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-delete-user-areyousure2' ) ); $wgOut->addHTML( "																								                                               											" ); }			}

#=====================================================#			# POST REQUESTS #=====================================================#			if ( $wgRequest->wasPosted ) {

# POST REQUEST: create new group #============================================#				if( $wgRequest->getText( 'create_new_group' ) != "" ) { if( $operand == 0 ) $wgOut->addWikiText( wfMsg( 'groupsadministration-missing' ) ); else if( $operand == 1 ) { $this->edit_group( $wgRequest->getText( 'new_group' ), $textbox_width ); }					else $wgOut->addWikiText( wfMsg( 'groupsadministration-failed', $wgRequest->getText( 'new_group' ) ) ); return; }

# POST REQUEST: delete group - yes #============================================#				if( $wgRequest->getText( 'delete_group_yes' ) != "" ) { $wgOut->addWikiText( wfMsg( 'groupsadministration-delete-ok', $wgRequest->getText( 'group_name' ) ) ); return; }

# POST REQUEST: edit group #============================================#				if( $wgRequest->getText( 'edit_group' ) != "" || $wgRequest->getText( 'add_new_user' ) != ""					|| $wgRequest->getText( 'find_user' ) != "" || $wgRequest->getText( 'delete_selected_users' )					|| $wgRequest->getText( 'delete_user_yes' ) || $wgRequest->getText( 'delete_user_no' ) ) { $this->edit_group( "", $textbox_width ); }

# POST REQUEST: edit group - add user #============================================#				if( $wgRequest->getText( 'add_new_user' ) != "" ) { switch( $operand ) { case 0 : $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-new-user-added', $add_user_name, $group_name ) ); return; case 1 : $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-new-user-exist', $add_user_name, $group_name ) ); return; case 2 : $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-new-user-not-found', $add_user_name ) ); return; case 3 : $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-new-user-invalid', $add_user_name ) ); return; case 4 : $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-new-user-missing' ) ); return; }				}

# POST REQUEST: edit group - find user #============================================#				if( $wgRequest->getText( 'find_user' ) != "" ) { switch( $operand ) { case 0 : $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-find-user-list' ) ); foreach( $finded_users_array as $finded ) { $wgOut->addWikiText( "* ".$finded ); }							return; case 1 : $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-find-user-nothing' ) ); return; case 2 : $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-new-user-missing' ) ); return; }				}

# POST REQUEST: edit group - delete selected users - question #============================================#				if( $wgRequest->getText( 'delete_selected_users' ) != "" ) { if( $operand == 0 ) { $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-delete-user-choose' ) ); return; }					else if( $operand == 1 ) { $action = $wgTitle->escapeLocalURL; $user_number = $wgRequest->getInt( 'user_number' ); $group_name = $wgRequest->getText( 'group_name' ); if( $user_number == $num_to_delete ) $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-delete-user-areyousure1' ) ); else $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-delete-user-areyousure2' ) ); $wgOut->addHTML( "																					<input type='hidden' name='users_to_delete' value=\"$users_to_delete\">							<input type='submit' name='delete_user_yes' value='S&iacute;'>							<input type='submit' name='delete_user_no' value='No'>						" ); }				}

# POST REQUEST: edit group - delete yes #============================================#				if( $wgRequest->getText( 'delete_user_yes' ) != "" ) { if( $operand == 1 ) $wgOut->addWikiText( wfMsg( 'groupsadministration-edit-delete-ok', "user has" ) ); return; }			}		}

/**		 * Function: edit_group * - Creates edit area upon edit button click *		 * @param $group_name: String name of the group * @param $textbox_width: String textbox width */		function edit_group( $group_name = "", $textbox_width = "size='20'" ) { global $wgRequest; global $wgTitle; global $wgOut; global $wgUser; global $wgArticlePath; global $wgGroupPermissions;

$server_param = strstr( $wgArticlePath, "?" ) ? "&" : "?";			if( $group_name == "" ) $group_name = $wgRequest->getText( 'group_name' );

$dbr =& wfGetDB( DB_SLAVE ); $res = $dbr->query( "SELECT * FROM ".$this->DatabasePrefixExists."user_groups WHERE ug_group='$group_name'" ); $count = $dbr->numRows( $res ); if( $count == 0 ) return; $user_id_array = array; while( $row = $dbr->fetchObject( $res ) ) { $user_id_array[] = $row->ug_user; }			$dbr->freeResult( $res );

$num = 0; $action = $wgTitle->escapeLocalUrl; $wgOut->addHTML( "				<form name='form_delete_selected' method='post' action='$action'>				 Group \"".$group_name."\" 				Users:				<ul>			" );

$remove_action = $action.$server_param."edit_group=true&group_name=$group_name&"; foreach( $user_id_array as $user_id ) { $num++; $user_name = $wgUser->whoIs( $user_id ); $name_u = "user_name_".$num; $name_c = "delete_checkbox_".$num; $wgOut->addHTML( "					<input type='hidden' name='$name_u' value='$user_name'>					<li>{$user_name} (<a href='{$remove_action}remove_user={$user_id}'>quitar usuario</a>)</li>				" ); }			$wgOut->addHTML( "</ul> " );

if( $count == 0 ) { $wgOut->addWikiText( " No hay usuarios en este grupo." ); $wgOut->addHTML( "					<input type='hidden' name='user_number' value='$num'>					<input type='hidden' name='group_name' value='$group_name'>					<input type='text' name='new_user' title='Para agregar o buscar un usuario escriba aqu&iacute; el nombre' $textbox_width>					<input type='submit' name='add_new_user' value='Agregar Usuario'>					<input type='submit' name='find_user' value='Buscar'>				" ); }			else { $wgOut->addHTML( "					<input type='hidden' name='user_number' value='$num'>					<input type='hidden' name='group_name' value='$group_name'>					<input type='text' name='new_user' title='Para agregar o buscar un usuario escriba aqu&iacute; el nombre' $textbox_width>					<input type='submit' name='add_new_user' value='Agregar Usuario'>					<input type='submit' name='find_user' value='Buscar'> 				" ); }			$wgOut->addHTML( "				<font size='1'> * Precauci&oacute;n: si borra todos los usuarios, el grupo también será borrado!!! 			" ); }

/**		 * Function: canAdministrate * - Retrieves username listed in $wgGroupPermissions['logged']['prefixAdministration'] array * - If this array does not exist then only Sysops can Administrate */		function canAdministrate { global $wgUser; global $wgOut; global $wgGroupPermissions;

if( isset( $wgGroupPermissions['logged']['prefixAdministration'] ) ) { $username = $wgUser->whoIs( $wgUser->getId ); if( in_array( $username, $wgGroupPermissions['logged']['prefixAdministration'] ) ) return true; else if( !$wgUser->isAllowed("userrights") ) return false; }			else { if( !$wgUser->isAllowed("userrights") ) { return false; }			}			return true; }

/**		 * Function: DatabasePrefixExists * - Returns the database table prefix if exist, else returns "" */		function DatabasePrefixExists { global $wgGroupPermissions; if( isset( $wgGroupPermissions['logged']['databasePrefix'] ) ) return $wgGroupPermissions['logged']['databasePrefix']; return ""; }	} }

else { echo( "&Eacute;sta es una extensi&oacute;n del paquete MediaWiki y no podrá usarse por separado.\n" ); die( -1 ); }

?>