/** * Sends notification e-mail to the user with the ID $user_id_to whenever * they get a new system gift (award) if their e-mail address is confirmed * and they have opted in to these notifications on their social * preferences. * * @param $user_id_to Integer: user ID of the recipient * @param $gift_id Integer: system gift ID number */ public function sendGiftNotificationEmail( $user_id_to, $gift_id ) { $gift = SystemGifts::getGift( $gift_id ); $user = User::newFromId( $user_id_to ); $user->loadFromDatabase(); if ( $user->isEmailConfirmed() && $user->getIntOption( 'notifygift', 1 ) ) { $gifts_link = SpecialPage::getTitleFor( 'ViewSystemGifts' ); $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' ); $subject = wfMsgExt( 'system_gift_received_subject', 'parsemag', $gift['gift_name'] ); if ( trim( $user->getRealName() ) ) { $name = $user->getRealName(); } else { $name = $user->getName(); } $body = wfMsgExt( 'system_gift_received_body', 'parsemag', $name, $gift['gift_name'], $gift['gift_description'], $gifts_link->getFullURL(), $update_profile_link->getFullURL() ); $user->sendMail( $subject, $body ); } }
/** * Sends notification echo to the user with the ID $user_id_to whenever * they get a new system gift (award) if their e-mail address is confirmed * and they have opted in to these notifications on their social * preferences. * * @param $user_id_to Integer: user ID of the recipient * @param $gift_id Integer: system gift ID number */ public function sendGiftNotificationEmail($user_id_to, $gift_id) { $gift = SystemGifts::getGift($gift_id); $user = User::newFromId($user_id_to); $user->loadFromDatabase(); //send an echo notification $giftsLink = SpecialPage::getTitleFor('ViewSystemGift'); EchoEvent::create(array('type' => 'system-gift-receive', 'extra' => array('gift-user-id' => $user_id_to, 'gift-id' => $gift_id), 'title' => $giftsLink)); // if ( $user->isEmailConfirmed() && $user->getIntOption( 'notifygift', 1 ) ) { // $gifts_link = SpecialPage::getTitleFor( 'ViewSystemGifts' ); // $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' ); // $subject = wfMessage( 'system_gift_received_subject', // $gift['gift_name'] // )->text(); // if ( trim( $user->getRealName() ) ) { // $name = $user->getRealName(); // } else { // $name = $user->getName(); // } // $body = wfMessage( 'system_gift_received_body', // $name, // $gift['gift_name'], // $gift['gift_description'], // $gifts_link->getFullURL(), // $update_profile_link->getFullURL() // )->text(); // // The email contains HTML, so actually send it out as such, too. // // That's why this no longer uses User::sendMail(). // // @see https://bugzilla.wikimedia.org/show_bug.cgi?id=68045 // global $wgPasswordSender; // $sender = new MailAddress( $wgPasswordSender, // wfMessage( 'emailsender' )->inContentLanguage()->text() ); // $to = new MailAddress( $user ); // UserMailer::send( $to, $sender, $subject, $body, null, 'text/html; charset=UTF-8' ); // } }
function displayForm($gift_id) { global $wgUploadPath; $form = '<div><b><a href="' . $this->getTitle()->escapeFullURL() . '">' . wfMsg('ga-viewlist') . '</a></b></div>'; if ($gift_id) { $gift = SystemGifts::getGift($gift_id); } $form .= '<form action="" method="post" enctype="multipart/form-data" name="gift"> <table border="0" cellpadding="5" cellspacing="0" width="500"> <tr> <td width="200" class="view-form">' . wfMsg('ga-giftname') . '</td> <td width="695"><input type="text" size="45" class="createbox" name="gift_name" value="' . (isset($gift['gift_name']) ? $gift['gift_name'] : '') . '"/></td> </tr> <tr> <td width="200" class="view-form" valign="top">' . wfMsg('ga-giftdesc') . '</td> <td width="695"><textarea class="createbox" name="gift_description" rows="2" cols="30">' . (isset($gift['gift_description']) ? $gift['gift_description'] : '') . '</textarea></td> </tr> <tr> <td width="200" class="view-form">' . wfMsg('ga-gifttype') . '</td> <td width="695"> <select name="gift_category">' . "\n"; $g = new SystemGifts(); foreach ($g->getCategories() as $category => $id) { $sel = ''; if (isset($gift['gift_category']) && $gift['gift_category'] == $id) { $sel = ' selected="selected"'; } $indent = "\t\t\t\t\t\t"; $form .= $indent . '<option' . $sel . " value=\"{$id}\">{$category}</option>\n"; } $form .= "\t\t\t\t\t" . '</select> </td> </tr> <tr> <td width="200" class="view-form">' . wfMsg('ga-threshold') . '</td> <td width="695"><input type="text" size="25" class="createbox" name="gift_threshold" value="' . (isset($gift['gift_threshold']) ? $gift['gift_threshold'] : '') . '"/></td> </tr>'; if ($gift_id) { $sgml = SpecialPage::getTitleFor('SystemGiftManagerLogo'); $gift_image = '<img src="' . $wgUploadPath . '/awards/' . SystemGifts::getGiftImage($gift_id, 'l') . '" border="0" alt="gift" />'; $form .= '<tr> <td width="200" class="view-form" valign="top">' . wfMsg('ga-giftimage') . '</td> <td width="695">' . $gift_image . '<a href="' . $sgml->escapeFullURL('gift_id=' . $gift_id) . '">' . wfMsg('ga-img') . '</a> </td> </tr>'; } if (isset($gift['gift_id'])) { $button = wfMsg('edit'); } else { $button = wfMsg('ga-create-gift'); } $form .= '<tr> <td colspan="2"> <input type="hidden" name="id" value="' . (isset($gift['gift_id']) ? $gift['gift_id'] : '') . '" /> <input type="button" class="createbox" value="' . $button . '" size="20" onclick="document.gift.submit()" /> <input type="button" class="createbox" value="' . wfMsg('cancel') . '" size="20" onclick="history.go(-1)" /> </td> </tr> </table> </form>'; return $form; }
/** * Displays the main form for removing a system gift permanently. * * @return String: HTML output */ function displayForm() { global $wgOut, $wgUploadPath; $gift = SystemGifts::getGift( $this->gift_id ); $giftImage = '<img src="' . $wgUploadPath . '/awards/' . SystemGifts::getGiftImage( $this->gift_id, 'l' ) . '" border="0" alt="gift" />'; $wgOut->setPageTitle( wfMsg( 'ga-remove-title', $gift['gift_name'] ) ); $output = '<div class="back-links"> <a href="' . SpecialPage::getTitleFor( 'SystemGiftManager' )->escapeFullURL() . '">' . wfMsg( 'ga-viewlist' ) . '</a> </div> <form action="" method="post" enctype="multipart/form-data" name="form1"> <div class="ga-remove-message">' . wfMsg( 'ga-delete-message', $gift['gift_name'] ) . '</div> <div class="ga-container">' . $giftImage . '<div class="ga-name">' . $gift['gift_name'] . '</div> </div> <div class="cleared"></div> <div class="ga-buttons"> <input type="button" class="site-button" value="' . wfMsg( 'ga-remove' ) . '" size="20" onclick="document.form1.submit()" /> <input type="button" class="site-button" value="' . wfMsg( 'ga-cancel' ) . '" size="20" onclick="history.go(-1)" /> </div> </form>'; return $output; }