User:Agbad/SandBox
For the extension "Lock User Space":
New SpecialPages list[edit]
- Special:RightsToSpace
Rights[edit]
- makerightsspace
- lockspace
LockUserSpace.php[edit]
Index: trunk/extensions/lockspace/LockUserSpace.php
===================================================================
+++ trunk/extensions/lockspace/LockUserSpace.php (working copy)
@@ +1,55 @@
+<?php
+if( !defind('MEDIAWIKI') ) die( -1 );
+$wgExtensionCredits['specialpage'][] = array(
+ 'name' => 'Lock User Space',
+ 'author' => 'Agbad',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Lock_User_Space',
+ 'description' => 'Make an option for regular user to (un)protect/delete their pages.',
+ 'descriptionmsg' => 'LockUser-msg',
+ 'svn-date' => '$LastChangedDate$',
+ 'svn-revision' => '$LastChangedRevision$',
+);
+$folder = dirname(__FILE__);
+$wgAvailabelRights[] = 'makerightsspace';
+$wgAvailabelRights[] = 'lockspace';
+$wgGroupPermissions['bureaucrat']['makerightsspace'] = true;
+$wgGroupPermissions['stweard']['makerightsspace'] = true;
+$wgGroupPermissions['lockspace']['lockspace'] = true;
+function addRightOtomat() {
+ global $wgUser;
+ if ( !$wgUser->isBlocked() && !$wgUser->isAnon() && !$wgUser->isAllowed( 'protect' ) && ($wgUser->getOption( 'canlockspace' ) == true or $wgUser->getOptions( 'canlockspace' ) == NULL) ) {
+ $wgUser->addGroup( 'lockspace' );
+ } else {
+ $wgUser->removeGroup( 'lockspace' );
+ }
+}
+$wgSpecialPages['makeRightsSpace'] = 'MakeRightsSpacePage';
+$wgSpecialPagesGroup['makeRightsSpace'] = 'users';
+$wgAutoloadClasses['SpecialMakeRightsSpace'] = '$folder/SpecialMakeRightsSpace.php';
+$wgExtensionMessagesFiles['LockSpace'] = '$folder/LockUserSpace.i18n.php';
+// Logs
+$wgLogTypes[] = 'rightsspace';
+$wgLogNames['rightsspace'] = 'rightsspace-logpage';
+$wgLogHeaders['rightsspace'] = 'rightsspace-logpagetext';
+$wgLogAction['rightsspace/add'] = 'rightsspace-logaddtext';
+$wgLogAction['rightsspace/remove'] = 'rightsspace-logremovetext';
+function RightsForRight() {
+ global $wgTitle, $wgUser;
+ $name = $wgUser->getName();
+ $lockspace = $wgUser->isAllowed( 'lockspace' );
+ if ( $lockspace ) {
+ if( ( $wgTitle->getNameSpace() == NS_USER or $wgTitle->getNameSpace() == NS_USER_TALK ) && $wgTitle->getBasePage() == $name ) {
+ $wgGroupPermissions['lockspace']['protect'] = true;
+ $wgGroupPermissions['lockspace']['delete'] = true;
+ $wgGroupPermissions['lockspace']['autoconfirmed'] = true;
+ $wgGroupPermissions['lockspace']['editprotected'] = true;
+ } else {
+ $wgGroupPermissions['lockspace']['protect'] = false;
+ $wgGroupPermissions['lockspace']['delete'] = false;
+ $wgGroupPermissions['lockspace']['editprotected'] = false;
+ if ( !$wgUser->isAllowed( 'move' ) { //If the user isn't old user
+ $wgGroupPermissions['lockspace']['autoconfirmed'] = false;
+ }
+ }
+ }
+}
SpecialMakeRightsSpace.php[edit]
Index: trunk/extensions/lockspace/SpecialMakeRightsSpace.php
===================================================================
+++ trunk/extensions/lockspace/SpecialMakeRightsSpace.php (working copy)
@@ +1,73 @@
+<?php
+if( !defind('MEDIAWIKI') ) die( -1 );
+class SpecialMakeRightsSpace extends SpecialPage {
+ function __construct() {
+ parent::__construct( 'MakeRightsSpace' );
+ wfLoadExtensionMessages( 'LockSpace' );
+ }
+ function execute( $subpages ) {
+ global $wgOut, $wgUser, $wgRequest, $wgAuth, $wgScript;
+ if( !$wgUser->isAllowed( 'makerightsspace' ) ) {
+ $wgOut->permissionRequired( 'makerightsspace' );
+ return;
+ }
+ if( $wgRequest->getVal( 'user' ) <> NULL ) {
+ $user = $wgRequest->getVal( 'user' );
+ } elseif ( $subpages <> NULL ) {
+ $user = $subpages;
+ } else {
+ $user = NULL;
+ }
+ if( $wgRequest->getVal( 'action' ) == 'submit' && $wgRequest->wasPosted() ) {
+ $action = 'submit';
+ } else {
+ $action = 'work';
+ }
+ if( !is_null( $user ) && !$wgAuth->userExsits( $user ) ) {
+ $wgOut->showErrorPage( 'lock-nouser', 'lock-nousertext' );
+ return;
+ }
+ if( is_null( $user ) ) {
+ $wgOut->showErrorPage( 'lock-notwriteuser', 'lock-notwriteusertext' );
+ return;
+ }
+ $u = User::newFromName( $user );
+ if( $u->isAllowed( 'protect' ) ) {
+ $wgOut->showErrorPage( 'lockspace-cant', 'lockspace-canttext' );
+ return;
+ }
+ if( $action == 'work' ) {
+ $wgOut->setPageTitle( wfMsg( 'RightsToSpace' ) );
+ if ( $u->isAllowed( 'lockspace' ) ) {
+ $before = wfMsg( 'lockuser-true' );
+ $after = wfMsg( 'lockuser-false-after' );
+ } else {
+ $before = wfMsg( 'lockuser-false' );
+ $after = wfMsg( 'lockuser-true-after' );
+ }
+ $linkToUserPage = $wgUser->getSkin()->makeKnownLinkObj( Title::MakeTitle( NS_USER, $u->getName() ), $u->getName() );
+ $wgOut->addWikiText( wfMsg( 'rightsTolock-text', $linkToUserPage, $before, $after ) );
+ $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $wgScript ) ) .
+ Xml::inputLabel( wfMsg( 'lockuser-reason' ), 'wpReason', 'wpReason', 100, $reason, array( 'maxlegnth' => '100' ) ) .
+ Xml::submitButoon( wfMsg( 'lock-submit' ) ) .
+ Xml::closeElement( 'form' );
+ $wgOut->addHtml( $form );
+ } elseif( $action == 'submit' ) {
+ $log = new LogPage( 'rightsspace' );
+ if ( $u->isAllowed( 'lockspace' ) {
+ $after = wfMsg( 'lock-removefrom' );
+ $actionLog = 'remove';
+ $u->removeGroup( 'lockspace' );
+ $u->setOption( 'canlockspace', false );
+ } else {
+ $after = wfMsg( 'lock-addto' );
+ $actionLog = 'add';
+ $u->addGroup( 'lockspace' );
+ $u->setOption( 'canlockspace', true );
+ }
+ $log->addEntry( $actionLog, $wgUser->getUserPage(), wfMsg( 'lockuser-log-change', $after ), $reason );
+ $wgOut->showErrorPage( 'lockpermissions-complete', 'lockpermissions-completetext' ) //This isn't error page, but I need its format
+ }
+ }
+ }
+}
Messages:[edit]
Message Name | Content (en) | Content (he) |
---|---|---|
LockUser-msg | Make an option for regular users to (un)protect/delete their pages. | ืืืฆืจ ืืคืฉืจืืช ืืืฉืชืืฉืื ืจืืืืื (ืื) ืืืื/ืืืืืง ืืคืื ืืืจืื ืืืฉืชืืฉ ืฉืืื. |
rightsspace-logpage | Permissions for user space | ืืจืฉืืืช ืืืจืื ืืืฉืชืืฉ |
rightsspace-logpagetext | ืืืืื ืื ืืืคืืขืื ืืฉืื ืืืื ืืืจืฉืืืช ืฉื ืืืฉืชืืฉืื ืื ืืืข ืืืืืงื/ืืื ื ืขืฆืืืช ืฉื ืืคืืื. | |
rightsspace-logaddtext | ืืื ืืืคืืขืื ืื ืชืืกืคืืช ืืจืฉืืช ืืืื ื/ืืืืงื ืขืฆืืืช ืืืจืื ืืืฉืชืืฉ. | |
rightsspace-logremovetext | ืืื ืืืคืืขืื ืื ืืืจืืืช ืืจืฉืืช ืืืื ื/ืืืืงื ืขืฆืืืช ืืืจืื ืืืฉืชืืฉ. | |
lock-nouser | ืืื ืืฉืชืืฉ ืืื | |
lock-nousertext | ืฉื ืืืฉืชืืฉ ืฉืืืจืช ืืฉื ืืช ืื ืืช ืืืจืฉืื ืืื ื ืงืืื. | |
lock-notwriteuser | You did'nt choose username | ืื ืืืจืช ืฉื ืืฉืชืืฉ |
lock-notwriteusertext | ืื ืืืจืช ืฉื ืืฉืชืืฉ ืืฉืื ืื ืืืจืฉืืืช ืฉืื ืืขื ืืื ืืืืืงื/ืืื ื ืืืจืื ืืืืฉื. | |
lockspace-cant | ืืฉืชืืฉ ืื ืืื ื ืืืื ืืงืื ืืืจืฉืื | |
lockspace-canttext | ืืื ืืืคืฉืจืืชื ืืฉื ืืช ืืืฉืชืืฉ ืื ืืช ืืจืฉืืืชืื ืื ืืืข ืืืื ื/ืืืืงื ืืืจืื ืืืืฉื. | |
RightsToSpace | ืืจืฉืืืช ืื ืขืืื ืืืฉืืช ืฉื ืืืจืื ืืืืฉื | |
lockuser-true | ื ืืชื ื ืืืจืฉืื | |
lockuser-false | ืื ื ืืชื ื ืืืจืฉืื | |
lockuser-false-after | ืชืืืงื ืืืฉืชืืฉ ืืืจืฉืื | |
lockuser-true-after | ืชืื ืชื ืืืฉืชืืฉ ืืืจืฉืื | |
rightsTolock-text | ืืืฉืชืืฉ $1 $2 ืืืืืง/ืืืื ืขื ืืืคืื ืฉืืืจืืื ืืืืฉื. ืื ืืจืฆืื ื ืืฉื ืืช ืืช ืืจืฉืืืชืื ืฉื ืืืฉืชืืฉ, ืืื $3. | |
lock-submit | Change the permissions | ืฉื ื ืืช ืืืจืฉืืืช |
lock-addto | added to | ืืืกืืฃ ื |
lock-removefrom | removed from | ืืกืืจ ื |
lockuser-reason | Reason: | ืกืืื: |
lockpermissions-complete | ืืฉืื ืื ืืืจืฉืืืช ืืืฉืื | |
lockpermissions-completetext | ืืฉืื ืื ืืืจืฉืืช ืืืื ื/ืืืืงื ืืืจืื ืืืืฉื ืขืืจื ืืืฆืืื. | |
right-lockspace | Protect/delete pages in their space. | ืืืืืง/ืืืื ืขื ืืคืื ืืืจืื ืืืืฉื ืฉืืื. |
right-makerightsspace | Add/remove the permission "lockspace". | ืืืกืคื/ืืกืจื ืฉื ืืืจืฉืื "lockspace". |
group-lockspace | Admins in their space | ืืคืขืืืื ืืืจืืื |
group-lockspsace-member | Admin to his space | ืืคืขืื ืืืจืืื |
grouppage-lockspace | Project:Admin to his space | Project:ืืคืขืื ืืืจืืื |