MediaWiki  1.23.2
SpecialConfirmemail.php
Go to the documentation of this file.
1 <?php
33  public function __construct() {
34  parent::__construct( 'Confirmemail', 'editmyprivateinfo' );
35  }
36 
42  function execute( $code ) {
43  $this->setHeaders();
44 
45  $this->checkReadOnly();
46  $this->checkPermissions();
47 
48  $this->requireLogin( 'confirmemail_needlogin' );
49 
50  // This could also let someone check the current email address, so
51  // require both permissions.
52  if ( !$this->getUser()->isAllowed( 'viewmyprivateinfo' ) ) {
53  throw new PermissionsError( 'viewmyprivateinfo' );
54  }
55 
56  if ( $code === null || $code === '' ) {
57  if ( Sanitizer::validateEmail( $this->getUser()->getEmail() ) ) {
58  $this->showRequestForm();
59  } else {
60  $this->getOutput()->addWikiMsg( 'confirmemail_noemail' );
61  }
62  } else {
63  $this->attemptConfirm( $code );
64  }
65  }
66 
70  function showRequestForm() {
71  $user = $this->getUser();
72  $out = $this->getOutput();
73 
74  if ( $this->getRequest()->wasPosted() &&
75  $user->matchEditToken( $this->getRequest()->getText( 'token' ) )
76  ) {
77  $status = $user->sendConfirmationMail();
78  if ( $status->isGood() ) {
79  $out->addWikiMsg( 'confirmemail_sent' );
80  } else {
81  $out->addWikiText( $status->getWikiText( 'confirmemail_sendfailed' ) );
82  }
83  } elseif ( $user->isEmailConfirmed() ) {
84  // date and time are separate parameters to facilitate localisation.
85  // $time is kept for backward compat reasons.
86  // 'emailauthenticated' is also used in SpecialPreferences.php
87  $lang = $this->getLanguage();
88  $emailAuthenticated = $user->getEmailAuthenticationTimestamp();
89  $time = $lang->userTimeAndDate( $emailAuthenticated, $user );
90  $d = $lang->userDate( $emailAuthenticated, $user );
91  $t = $lang->userTime( $emailAuthenticated, $user );
92  $out->addWikiMsg( 'emailauthenticated', $time, $d, $t );
93  } else {
94  if ( $user->isEmailConfirmationPending() ) {
95  $out->wrapWikiMsg(
96  "<div class=\"error mw-confirmemail-pending\">\n$1\n</div>",
97  'confirmemail_pending'
98  );
99  }
100 
101  $out->addWikiMsg( 'confirmemail_text' );
103  'form',
104  array( 'method' => 'post', 'action' => $this->getPageTitle()->getLocalURL() )
105  ) . "\n";
106  $form .= Html::hidden( 'token', $user->getEditToken() ) . "\n";
107  $form .= Xml::submitButton( $this->msg( 'confirmemail_send' )->text() ) . "\n";
108  $form .= Html::closeElement( 'form' ) . "\n";
109  $out->addHTML( $form );
110  }
111  }
112 
119  function attemptConfirm( $code ) {
121  if ( !is_object( $user ) ) {
122  $this->getOutput()->addWikiMsg( 'confirmemail_invalid' );
123 
124  return;
125  }
126 
127  $user->confirmEmail();
128  $user->saveSettings();
129  $message = $this->getUser()->isLoggedIn() ? 'confirmemail_loggedin' : 'confirmemail_success';
130  $this->getOutput()->addWikiMsg( $message );
131 
132  if ( !$this->getUser()->isLoggedIn() ) {
133  $title = SpecialPage::getTitleFor( 'Userlogin' );
134  $this->getOutput()->returnToMain( true, $title );
135  }
136  }
137 }
138 
146  public function __construct() {
147  parent::__construct( 'Invalidateemail', 'editmyprivateinfo' );
148  }
149 
150  function execute( $code ) {
151  $this->setHeaders();
152  $this->checkReadOnly();
153  $this->checkPermissions();
154  $this->attemptInvalidate( $code );
155  }
156 
163  function attemptInvalidate( $code ) {
165  if ( !is_object( $user ) ) {
166  $this->getOutput()->addWikiMsg( 'confirmemail_invalid' );
167 
168  return;
169  }
170 
171  $user->invalidateEmail();
172  $user->saveSettings();
173  $this->getOutput()->addWikiMsg( 'confirmemail_invalidated' );
174 
175  if ( !$this->getUser()->isLoggedIn() ) {
176  $this->getOutput()->returnToMain();
177  }
178  }
179 }
EmailInvalidation\attemptInvalidate
attemptInvalidate( $code)
Attempt to invalidate the user's email address and show success or failure as needed; if successful,...
Definition: SpecialConfirmemail.php:163
EmailConfirmation\__construct
__construct()
Definition: SpecialConfirmemail.php:33
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:488
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:535
UnlistedSpecialPage
Shortcut to construct a special page which is unlisted by default.
Definition: UnlistedSpecialPage.php:29
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
$form
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead $form
Definition: hooks.txt:2573
SpecialPage\checkPermissions
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
Definition: SpecialPage.php:287
Sanitizer\validateEmail
static validateEmail( $addr)
Does a string look like an e-mail address?
Definition: Sanitizer.php:1830
EmailConfirmation\showRequestForm
showRequestForm()
Show a nice form for the user to request a confirmation mail.
Definition: SpecialConfirmemail.php:70
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
EmailConfirmation\execute
execute( $code)
Main execution point.
Definition: SpecialConfirmemail.php:42
Html\hidden
static hidden( $name, $value, $attribs=array())
Convenience function to produce an input element with type=hidden.
Definition: Html.php:662
PermissionsError
Show an error when a user tries to do something they do not have the necessary permissions for.
Definition: PermissionsError.php:28
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:578
SpecialPage\requireLogin
requireLogin( $reasonMsg=null, $titleMsg=null)
If the user is not logged in, throws UserNotLoggedIn error.
Definition: SpecialPage.php:321
EmailInvalidation\__construct
__construct()
Definition: SpecialConfirmemail.php:146
Html\closeElement
static closeElement( $element)
Returns "</$element>", except if $wgWellFormedXml is off, in which case it returns the empty string w...
Definition: Html.php:235
Html\openElement
static openElement( $element, $attribs=array())
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:166
$out
$out
Definition: UtfNormalGenerate.php:167
EmailConfirmation\attemptConfirm
attemptConfirm( $code)
Attempt to confirm the user's email address and show success or failure as needed; if successful,...
Definition: SpecialConfirmemail.php:119
User\newFromConfirmationCode
static newFromConfirmationCode( $code)
Factory method to fetch whichever user has a given email confirmation code.
Definition: User.php:429
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:352
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:545
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
EmailInvalidation\execute
execute( $code)
Default execute method Checks user permissions, calls the function given in mFunction.
Definition: SpecialConfirmemail.php:150
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:609
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:525
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
EmailConfirmation
Special page allows users to request email confirmation message, and handles processing of the confir...
Definition: SpecialConfirmemail.php:32
EmailInvalidation
Special page allows users to cancel an email confirmation using the e-mail confirmation code.
Definition: SpecialConfirmemail.php:145
Xml\submitButton
static submitButton( $value, $attribs=array())
Convenience function to build an HTML submit button.
Definition: Xml.php:463
SpecialPage\checkReadOnly
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
Definition: SpecialPage.php:300
$t
$t
Definition: testCompression.php:65