コード例 #1
0
 /**
  * Main execution function
  *
  * @param $par Mixed: Parameters passed to the page
  */
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest, $wgEnableEmail, $wgContactUser;
     if (!$wgEnableEmail || !$wgContactUser) {
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $action = $wgRequest->getVal('action');
     $nu = User::newFromName($wgContactUser);
     if (is_null($nu) || !$nu->canReceiveEmail()) {
         wfDebug("Target is invalid user or can't receive.\n");
         $wgOut->showErrorPage('noemailtitle', 'noemailtext');
         return;
     }
     // Blocked users cannot use the contact form if they're disabled from sending email.
     if ($wgUser->isBlockedFromEmailuser()) {
         $wgOut->blockedPage();
         return;
     }
     $f = new EmailContactForm($nu, $par);
     if ('success' == $action) {
         wfDebug(__METHOD__ . ": success.\n");
         $f->showSuccess();
     } elseif ('submit' == $action && $wgRequest->wasPosted() && $f->hasAllInfo()) {
         $token = $wgRequest->getVal('wpEditToken');
         if ($wgUser->isAnon()) {
             # Anonymous users may not have a session
             # open. Check for suffix anyway.
             $tokenOk = EDIT_TOKEN_SUFFIX == $token;
         } else {
             $tokenOk = $wgUser->matchEditToken($token);
         }
         if (!$tokenOk) {
             wfDebug(__METHOD__ . ": bad token (" . ($wgUser->isAnon() ? 'anon' : 'user') . "): {$token}\n");
             $wgOut->addWikiMsg('sessionfailure');
             $f->showForm();
         } elseif (!$f->passCaptcha()) {
             wfDebug(__METHOD__ . ": captcha failed");
             $wgOut->addWikiMsg('contactpage-captcha-failed');
             $f->showForm();
         } else {
             wfDebug(__METHOD__ . ": submit\n");
             $f->doSubmit();
         }
     } else {
         wfDebug(__METHOD__ . ": form\n");
         $f->showForm();
     }
 }
コード例 #2
0
 /**
  * Main execution function
  * @param $par Parameters passed to the page
  */
 function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest, $wgEnableEmail, $wgContactUser, $wgContactSender;
     wfLoadExtensionMessages('ContactPage');
     $fname = "SpecialContact::execute";
     if (!$wgEnableEmail || !$wgContactUser || !$wgContactSender) {
         $wgOut->showErrorPage("nosuchspecialpage", "nospecialpagetext");
         return;
     }
     $action = $wgRequest->getVal('action');
     $nu = User::newFromName($wgContactUser);
     if (is_null($nu) || !$nu->canReceiveEmail()) {
         wfDebug("Target is invalid user or can't receive.\n");
         $wgOut->showErrorPage("noemailtitle", "noemailtext");
         return;
     }
     $f = new EmailContactForm($nu);
     if ("success" == $action) {
         wfDebug("{$fname}: success.\n");
         $f->showSuccess();
     } else {
         if ("submit" == $action && $wgRequest->wasPosted()) {
             #
             $token = $wgRequest->getVal('wpEditToken');
             if ($wgUser->isAnon()) {
                 # Anonymous users may not have a session
                 # open. Check for suffix anyway.
                 $tokenOk = EDIT_TOKEN_SUFFIX == $token;
             } else {
                 $tokenOk = $wgUser->matchEditToken($token);
             }
             if (!$tokenOk) {
                 wfDebug("{$fname}: bad token (" . ($wgUser->isAnon() ? 'anon' : 'user') . "): {$token}\n");
                 $wgOut->addWikiText(wfMsg('sessionfailure'));
                 $f->showForm();
             } else {
                 if (!$f->passCaptcha()) {
                     wfDebug("{$fname}: captcha failed");
                     $wgOut->addWikiText(wfMsg('contactpage-captcha-failed'));
                     //TODO: provide a message for this!
                     $f->showForm();
                 } else {
                     wfDebug("{$fname}: submit\n");
                     $f->doSubmit();
                 }
             }
         } else {
             wfDebug("{$fname}: form\n");
             $f->showForm();
         }
     }
 }
コード例 #3
0
 /**
  * Main execution function
  * @param $par Parameters passed to the page
  */
 function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest, $wgEnableEmail, $wgContactUser;
     $fname = "SpecialContact::execute";
     if ($wgRequest->wasPosted()) {
         $nu = User::newFromName($wgContactUser);
         $f = new EmailContactForm($nu);
         $form['name'] = $wgRequest->getVal('name');
         $form['age'] = $wgRequest->getVal('age');
         $form['email'] = $wgRequest->getVal('email');
         $form['location'] = $wgRequest->getVal('location');
         $form['story'] = $wgRequest->getVal('story');
         $form['followup'] = $wgRequest->getVal('followup');
         $form['username'] = $wgRequest->getVal('username');
         $form['country'] = $wgRequest->getVal('country');
         $text = '';
         foreach ($form as $key => $value) {
             $text .= sprintf("%10s : %s\n", $key, $value);
         }
         $f->setText($text);
         $f->doSubmit();
     }
     if (!$wgEnableEmail || !$wgContactUser) {
         $wgOut->showErrorPage("nosuchspecialpage", "nospecialpagetext");
         return;
     }
     $action = $wgRequest->getVal('action');
     $nu = User::newFromName($wgContactUser);
     if (is_null($nu) || !$nu->canReceiveEmail()) {
         wfDebug("Target is invalid user or can't receive.\n");
         $wgOut->showErrorPage("noemailtitle", "noemailtext");
         return;
     }
     $f = new EmailContactForm($nu);
     if ("success" == $action) {
         wfDebug("{$fname}: success.\n");
         $f->showSuccess();
     } elseif ("submit" == $action && $wgRequest->wasPosted() && $f->hasAllInfo()) {
         $token = $wgRequest->getVal('wpEditToken');
         if ($wgUser->isAnon()) {
             # Anonymous users may not have a session
             # open. Check for suffix anyway.
             $tokenOk = EDIT_TOKEN_SUFFIX == $token;
         } else {
             $tokenOk = $wgUser->matchEditToken($token);
         }
         if (!$tokenOk) {
             wfDebug("{$fname}: bad token (" . ($wgUser->isAnon() ? 'anon' : 'user') . "): {$token}\n");
             $wgOut->addWikiText(wfMsg('sessionfailure'));
             $f->showForm();
         } elseif (!$f->passCaptcha()) {
             wfDebug("{$fname}: captcha failed");
             $wgOut->addWikiText(wfMsg('contactpage-captcha-failed'));
             //TODO: provide a message for this!
             $f->showForm();
         } else {
             wfDebug("{$fname}: submit\n");
             $f->doSubmit();
         }
     } else {
         wfDebug("{$fname}: form\n");
         $f->showForm();
     }
 }