User:Jack Phoenix/patches/SpecialPrivateDomains

Index: SpecialPrivateDomains.i18n.php

=
====================================================== --- SpecialPrivateDomains.i18n.php	(revision 115) +++ SpecialPrivateDomains.i18n.php	(working copy) @@ -1,18 +1,22 @@  " Sorry, you do not have enough rights to manage the allowed private domains for this wiki. Only wiki bureaucrats and staff members have access. If you aren't logged in, you probably should. ", + +/** English + * @author Inez Korczyński + */ +$messages['en'] = array( +	'privatedomains-nomanageaccess' => " Sorry, you do not have enough rights to manage the allowed private domains for this wiki. Only wiki bureaucrats and staff members have access. If you aren't logged in, you probably should. ", 'privatedomains' => 'Manage Private Domains', -	'privatedomains_ifemailcontact' => " Otherwise, please contact $1 if you have any questions. ", -	'saveprivatedomains_success' => "Private Domains changes saved.", -	'privatedomains_invalidemail' => " Sorry, access to this wiki is restricted to members of $1. If you have an email address affiliated with $1, you can enter or reconfirm your email address on your account preference page here. You can still view pages on this wiki, but you will be unable to edit. ", -	'privatedomains_affiliatenamelabel' => " Name of organization: ", -	'privatedomains_emailadminlabel' => " Contact username for access problems or queries: ", +	'privatedomains-ifemailcontact' => ' Otherwise, please contact $1 if you have any questions. ', +	'saveprivatedomains-success' => 'Private Domains changes saved.', +	'privatedomains-invalidemail' => " Sorry, access to this wiki is restricted to members of $1. If you have an email address affiliated with $1, you can enter or reconfirm your email address on your account preference page here. You can still view pages on this wiki, but you will be unable to edit. ", +	'privatedomains-affiliatenamelabel' => ' Name of organization: ', +	'privatedomains-emailadminlabel' => ' Contact username for access problems or queries: ', 'privatedomainsinstructions' => "

Below is the list of email domains allowed for editors of this wiki. Each line designates an email suffix that is given access for editing. This should be formatted with one suffix per line. For example: cs.stanford.edu stanfordalumni.org This would allow edits from anyone with the email address whatever@cs.stanford.edu or whatever@stanfordalumni.org  Enter the allowed domains in the text box below, and click \"save\". " -); +); \ No newline at end of file Index: SpecialPrivateDomains.php

=
====================================================== --- SpecialPrivateDomains.php	(revision 115) +++ SpecialPrivateDomains.php	(working copy) @@ -1,9 +1,11 @@  'PrivateDomains', +	'version' => '1.0', +	'author' => 'Inez Korczyński', +	'url' => 'http://www.mediawiki.org/wiki/Extension:PrivateDomains', +	'description' => 'Allows to restrict editing to users with a certain e-mail address', +); + -$dir = dirname( __FILE__ ); -$wgAutoloadClasses["PrivateDomains"] = $dir. "/SpecialPrivateDomains_body.php"; -$wgExtensionMessagesFiles["PrivateDomains"] = $dir. "/SpecialPrivateDomains.i18n.php"; -$wgSpecialPages['PrivateDomains'] = array( 'SpecialPage', 'PrivateDomains', 'PrivateDomains' ); +$dir = dirname(__FILE__). '/'; +$wgAutoloadClasses['PrivateDomains'] = $dir. 'SpecialPrivateDomains_body.php'; +$wgExtensionMessagesFiles['PrivateDomains'] = $dir. 'SpecialPrivateDomains.i18n.php'; +$wgSpecialPages['PrivateDomains'] = array( 'SpecialPage', 'PrivateDomains', 'privatedomains' ); $wgHooks['AlternateEdit'][] = 'pd_AlternateEdit'; // Occurs whenever action=edit is called $wgHooks['UserLoginComplete'][] = 'pd_UserLoginComplete'; // Occurs after a user has successfully logged in $wgHooks['ConfirmEmailComplete'][] = 'pd_UserLoginComplete'; // Occurs after a user has successfully confirm email (not standard hook) -# set 'PrivateDomains' right to users in staff or bureaucrat group -$wgAvailableRights [] = 'PrivateDomains'; -$wgGroupPermissions ['staff']['PrivateDomains'] = true; -$wgGroupPermissions ['bureaucrat']['PrivateDomains'] = true; +# set 'privatedomains' right to users in staff or bureaucrat group +$wgAvailableRights[] = 'privatedomains'; +$wgGroupPermissions['staff']['privatedomains'] = true; +$wgGroupPermissions['bureaucrat']['privatedomains'] = true; $wgGroupPermissions['staff']['edit'] = true; @@ -65,21 +75,22 @@ */ function pd_AlternateEdit(&$editpage) { global $wgUser; +	wfLoadExtensionMessages( 'PrivateDomains' ); $groups = $wgUser->getGroups; if ( $wgUser->isLoggedIn && !in_array('privatedomains', $groups) && !in_array('staff', $groups) && !in_array('bureaucrat', $groups)) { global $wgOut; $privatedomains_affiliatename = PrivateDomains::getParam("privatedomains_affiliatename"); $wgOut->addHTML(' '); -		$wgOut->addHTML(wfMsg('privatedomains_invalidemail', $privatedomains_affiliatename)); -		$wgOut->addHTML('   '); +		$wgOut->addHTML(wfMsg('privatedomains-invalidemail', $privatedomains_affiliatename)); +		$wgOut->addHTML('
 * 1) set function to call when loading extension
 * 1) overwrite standard groups permissions

'); 		return false; 	} 	return true; } -/* - * If user have confirmed and allowed address email - * then add him to privatedomains user group. +/** + * If user has confirmed and allowed address email + * then add him/her to privatedomains user group. */ function pd_UserLoginComplete($user) { 	if( $user->isEmailConfirmed ) { @@ -106,4 +117,4 @@ function wfSpecialPrivateDomains {     $page = new PrivateDomains;     $page->execute; -} +} \ No newline at end of file Index: SpecialPrivateDomains_body.php

=
====================================================== --- SpecialPrivateDomains_body.php	(revision 115) +++ SpecialPrivateDomains_body.php	(working copy) @@ -1,8 +1,7 @@ <?php /** * - * @package MediaWiki - * @subpackage SpecialPage + * @ingroup Extensions * @author Inez Korczyński (inez@wikia.com) * * Add 'wfRunHooks('ConfirmEmailComplete', array(&$user));' in SpecialConfirmemail.php at 86 line. @@ -12,15 +11,13 @@ 	die; /* - * - * @package MediaWiki - * @subpackage SpecialPage + * @ingroup Extensions */ class PrivateDomains extends SpecialPage { function PrivateDomains { -		wfLoadExtensionMessages( "PrivateDomains" ); -		SpecialPage::SpecialPage( "PrivateDomains" ); +		SpecialPage::SpecialPage( 'PrivateDomains' ); +		wfLoadExtensionMessages( 'PrivateDomains' ); } 	function saveParam($name, $value) { @@ -45,7 +42,7 @@ 	} 	function execute { -		global $wgRequest,$wgUser,$wgOut; +		global $wgRequest, $wgUser, $wgOut; $wgOut->setPageTitle( wfMsg('privatedomains') ); $wgOut->setRobotpolicy( 'noindex,nofollow' ); @@ -58,11 +55,11 @@ 				global $wgMessageCache; -				$this->saveParam('privatedomains_domains', $wgRequest->getText('listdata')); -				$this->saveParam('privatedomains_affiliatename', $wgRequest->getText('affiliateName')); -				$this->saveParam('privatedomains_emailadmin', $wgRequest->getText('optionalPrivateDomainsEmail')); +				$this->saveParam('privatedomains-domains', $wgRequest->getText('listdata')); +				$this->saveParam('privatedomains-affiliatename', $wgRequest->getText('affiliateName')); +				$this->saveParam('privatedomains-emailadmin', $wgRequest->getText('optionalPrivateDomainsEmail')); -				$msg = wfMsgHtml('saveprivatedomains_success'); +				$msg = wfMsgHtml('saveprivatedomains-success'); } 		} 		$this->mainForm( $msg ); @@ -72,7 +69,7 @@ 	 * @access private */ 	function mainForm( $msg ) { -		global $wgUser, $wgOut, $wgLang, $wgDBname, $wgMessageCache; +		global $wgUser, $wgOut, $wgLang, $wgDBname; $titleObj = Title::makeTitle( NS_SPECIAL, 'PrivateDomains' ); $action = $titleObj->escapeLocalUrl('action=submit'); @@ -80,25 +77,25 @@ 		$userGroups = $wgUser->getGroups; if ( !in_array('staff', $userGroups ) && !in_array('bureaucrat', $userGroups) ) { -			$wgOut->addHTML(wfMsg('privatedomains_ifemailcontact')); +			$wgOut->addHTML(wfMsg('privatedomains-ifemailcontact')); $privatedomains_emailadmin = PrivateDomains::getParam("privatedomains_emailadmin"); if ($privatedomains_emailadmin != '') { -				$wgOut->addWikiText(wfMsg('privatedomains_ifemailcontact', $privatedomains_emailadmin)); +				$wgOut->addWikiText(wfMsg('privatedomains-ifemailcontact', $privatedomains_emailadmin)); } 			return false; } 		if ( $msg != '' ) { -			$wgOut->addHTML(' ' . $msg . '   '); +			$wgOut->addHTML(' ' . $msg . '

'); 		} -		$wgOut->addHTML("". wfMsg('privatedomains_affiliatenamelabel'). " getParam('privatedomains_affiliatename') ."\">". wfMsg('privatedomains_emailadminlabel'). " getParam('privatedomains_emailadmin') . "\">"); +		$wgOut->addHTML("<form name=\"privatedomains\" id=\"privatedomains\" method=\"post\" action=\"{$action}\"><label for=\"affiliateName\">". wfMsg('privatedomains-affiliatenamelabel'). " <input type='text' name=\"affiliateName\" width=30 value=\"" . $this->getParam('privatedomains_affiliatename') ."\"><label for=\"optionalEmail\">". wfMsg('privatedomains-emailadminlabel'). " <input type='text' name=\"optionalPrivateDomainsEmail\" value=\"" . $this->getParam('privatedomains_emailadmin') . "\">"); 		$wgOut->addHTML(wfMsg('privatedomainsinstructions')); 		$wgOut->addHTML("<textarea name='listdata' rows=10 cols=40>". $this->getParam('privatedomains_domains'). " "); -		$wgOut->addHTML(" <input type='submit' name=\"saveList\" value=\"" . wfMsgHtml('saveprefs') . "\" />"); +		$wgOut->addHTML(" <input type='submit' name=\"saveList\" value=\"" . wfMsgHtml('saveprefs') . "\" />"); 		$wgOut->addHTML(" "); 	} }