/**
  * Notifies a single user of the changes made to properties in a single edit.
  *
  * @since 0.1
  *
  * @param SWLGroup $group
  * @param User $user
  * @param SWLChangeSet $changeSet
  * @param boolean $describeChanges
  *
  * @return Status
  */
 public static function notifyUser(SWLGroup $group, User $user, SWLChangeSet $changeSet, $describeChanges)
 {
     global $wgLang, $wgPasswordSender, $wgPasswordSenderName;
     $emailText = wfMsgExt('swl-email-propschanged-long', 'parse', $GLOBALS['wgSitename'], $changeSet->getEdit()->getUser()->getName(), SpecialPage::getTitleFor('SemanticWatchlist')->getFullURL(), $wgLang->time($changeSet->getEdit()->getTime()), $wgLang->date($changeSet->getEdit()->getTime()));
     if ($describeChanges) {
         $emailText .= '<h3> ' . wfMsgExt('swl-email-changes', 'parse', $changeSet->getEdit()->getTitle()->getFullText(), $changeSet->getEdit()->getTitle()->getFullURL()) . ' </h3>';
         $emailText .= self::getChangeListHTML($changeSet, $group);
     }
     $title = wfMsgReal('swl-email-propschanged', array($changeSet->getEdit()->getTitle()->getFullText()), true, $user->getOption('language'));
     wfRunHooks('SWLBeforeEmailNotify', array($group, $user, $changeSet, $describeChanges, &$title, &$emailText));
     return UserMailer::send(new MailAddress($user), new MailAddress($wgPasswordSender, $wgPasswordSenderName), $title, $emailText, null, 'text/html; charset=ISO-8859-1');
 }
コード例 #2
0
 /**
  * Handles group notification.
  *
  * @since 0.1
  *
  * @param SWLGroup $group
  * @param array $userIDs
  * @param SMWChangeSet $changes
  *
  * @return true
  */
 public static function onGroupNotify(SWLGroup $group, array $userIDs, SWLChangeSet $changes)
 {
     global $egSWLMailPerChange, $egSWLMaxMails;
     foreach ($userIDs as $userID) {
         $user = User::newFromId($userID);
         if ($user->getOption('swl_email', false)) {
             if ($user->getName() != $changes->getEdit()->getUser()->getName() || $GLOBALS['egSWLEnableSelfNotify']) {
                 if (!method_exists('Sanitizer', 'validateEmail') || Sanitizer::validateEmail($user->getEmail())) {
                     $lastNotify = $user->getOption('swl_last_notify');
                     $lastWatch = $user->getOption('swl_last_watch');
                     if (is_null($lastNotify) || is_null($lastWatch) || $lastNotify < $lastWatch) {
                         $mailCount = $user->getOption('swl_mail_count', 0);
                         if ($egSWLMailPerChange || $mailCount < $egSWLMaxMails) {
                             SWLEmailer::notifyUser($group, $user, $changes, $egSWLMailPerChange);
                             $user->setOption('swl_last_notify', wfTimestampNow());
                             $user->setOption('swl_mail_count', $mailCount + 1);
                             $user->saveSettings();
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
コード例 #3
0
	/**
	 * Gets the HTML for a single change set (edit).
	 * 
	 * @since 0.1
	 * 
	 * @param SWLChangeSet $changeSet
	 * 
	 * @return string
	 */
	protected function getChangeSetHTML( SWLChangeSet $changeSet ) {
		global $wgLang;
		
		$edit = $changeSet->getEdit();
		
		$html = '';
		
		$html .= '<li>';
		
		$html .= 
			'<p>' .
				$wgLang->time( $edit->getTime(), true ) . ' ' .
				Html::element(
					'a',
					array( 'href' => $edit->getTitle()->getLocalURL() ),
					$edit->getTitle()->getText()
				) . ' (' .
				Html::element(
					'a',
					array( 'href' => $edit->getTitle()->getLocalURL( 'action=history' ) ),
					wfMsg( 'hist' )
				) . ') . . ' .
				Html::element(
					'a',
					array( 'href' => $edit->getUser()->getUserPage()->getLocalURL() ),
					$edit->getUser()->getName()
				) . ' (' .
				Html::element(
					'a',
					array( 'href' => $edit->getUser()->getTalkPage()->getLocalURL() ),
					wfMsg( 'talkpagelinktext' )
				) . ' | ' .
				( $edit->getUser()->isAnon() ? '' :
					Html::element(
						'a',
						array( 'href' => SpecialPage::getTitleFor( 'Contributions', $edit->getUser()->getName() )->getLocalURL() ),
						wfMsg( 'contribslink' )						
					) . ' | '
				) .
				Html::element(
					'a',
					array( 'href' => SpecialPage::getTitleFor( 'Block', $edit->getUser()->getName() )->getLocalURL() ),
					wfMsg( 'blocklink' )
				) . ')' .
				( $edit->getTime() > $this->lastViewed ? ' [NEW]' : '' )	.
			'</p>'
		;
		
		$propertyHTML= array();
		
		foreach ( $changeSet->getAllProperties() as /* SMWDIProperty */ $property ) {
			$propertyHTML[] = $this->getPropertyHTML( $property, $changeSet->getAllPropertyChanges( $property ) );
		}
		
		$html .= implode( '', $propertyHTML );
		
		$html .=  '</li>';
		
		return $html;
	}