Exemplo n.º 1
0
	/**
	 * Notifies connection changes
	 *
	 * @param  int      $userId
	 * @param  int      $connectionId
	 * @param  string   $msg
	 * @param  string   $subject
	 * @param  string   $messageHTML
	 * @param  string   $messageText
	 * @param  string   $userMessage
	 * @return boolean
	 */
	protected function _notifyConnectionChange( $userId, $connectionId, $msg, $subject, $messageHTML, $messageText, $userMessage = null )
	{
		global $_CB_framework, $ueConfig;

		$rowFrom				=	new UserTable();
		$rowFrom->load( (int) $userId );

		$fromName				=	getNameFormat( $rowFrom->name, $rowFrom->username, $ueConfig['name_format'] );
		$fromURL				=	'index.php?option=com_comprofiler&view=userprofile&user='******'&tab=1' . getCBprofileItemid(true);
		$fromURL				=	cbSef( $fromURL );

		if ( strncasecmp( 'http', $fromURL, 4 ) != 0 ) {
			$fromURL			=	$_CB_framework->getCfg( 'live_site' ) . '/' . $fromURL;
		}

		$subject				=	sprintf( $subject, $fromName );

		if ( $userMessage != null ) {
			$messageHTML		.=	sprintf( str_replace( "\n", "\n<br />", CBTxt::T( 'UE_CONNECTIONMSGPREFIX', "  %s included the following personal message:\n\n%s" ) ),
											 htmlspecialchars( $fromName ),
											 '<strong>' . htmlspecialchars( $userMessage ) . '</strong>' );
			$messageText		.=	sprintf( str_replace( "\n", "\r\n", CBTxt::T( 'UE_CONNECTIONMSGPREFIX', "  %s included the following personal message:\n\n%s" ) ),
											 $fromName,
											 $userMessage );
		}

		$notificationMsgHTML	=	sprintf( $messageHTML, '<strong><a href="' . $fromURL . '">' . htmlspecialchars( $fromName ) . '</a></strong>' );
		$notificationMsgText	=	sprintf( $messageText, $fromName );

		$manageURL				=	'index.php?option=com_comprofiler&amp;view=manageconnections' . getCBprofileItemid( true );
		$manageURL				=	cbSef( $manageURL );

		if ( strncasecmp( 'http', $manageURL, 4 ) != 0 ) {
			$manageURL			=	$_CB_framework->getCfg( 'live_site' ) . '/' . $manageURL;
		}

		$notificationMsgHTML	=	$notificationMsgHTML
								.	"\n<br /><br /><a href=\"" . $manageURL . '">'
								.	CBTxt::T( 'UE_MANAGECONNECTIONS_LINK UE_MANAGECONNECTIONS', 'Manage Connections' )
								.	"</a>\n";

		$notificationMsgText	=	$notificationMsgText
								.	"\r\n\r\n\r\n" . $fromName . ' '
								.	CBTxt::T( 'CONNECTION_PROFILE UE_PROFILE', 'Profile' )
								.	': '
								.	cbUnHtmlspecialchars( $fromURL );

		$notificationMsgText	=	$notificationMsgText
								.	"\r\n\r\n"
								.	CBTxt::T( 'UE_MANAGECONNECTIONS_URL_LABEL UE_MANAGECONNECTIONS', 'Manage Connections' )
								.	': '
								.	cbUnHtmlspecialchars( $manageURL )
								.	"\r\n";

		$notificationMsgHTML	=	'<div style="padding: 4px; margin: 4px 3px 6px 0px; background: #C44; font-weight: bold;" class="cbNotice">'
			. CBTxt::T( 'UE_SENDPMSNOTICE', 'NOTE: This is a message generated automatically by the Connections system. It has the connecting user\'s address, so you can conveniently reply if you wish to.' )
			. "</div>\n\n"
			. $notificationMsgHTML;

		$cbNotification			=	new cbNotification();
		$cbNotification->sendFromUser( $connectionId, $userId, $subject, $notificationMsgHTML, $notificationMsgText );

		$this->_setUserMSG( $msg );

		return true;
	}
 function _notifyConnectionChange($userid, $connectionid, $msg, $subject, $messageHTML, $messageText, $userMessage = null)
 {
     global $_CB_framework, $_CB_database, $ueConfig;
     $rowFrom = new moscomprofilerUser($_CB_database);
     $rowFrom->load((int) $userid);
     $fromname = getNameFormat($rowFrom->name, $rowFrom->username, $ueConfig['name_format']);
     $fromURL = "index.php?option=com_comprofiler&amp;task=userProfile&amp;user="******"&amp;tab=1" . getCBprofileItemid(true);
     $fromURL = cbSef($fromURL);
     if (strncasecmp("http", $fromURL, 4) != 0) {
         $fromURL = $_CB_framework->getCfg('live_site') . "/" . $fromURL;
     }
     $subject = sprintf($subject, $fromname);
     if ($userMessage != null) {
         $messageHTML .= sprintf(str_replace("\n", "\n<br />", _UE_CONNECTIONMSGPREFIX), $fromname, "<strong>" . htmlspecialchars($userMessage) . "</strong>");
         $messageText .= sprintf(str_replace("\n", "\r\n", _UE_CONNECTIONMSGPREFIX), $fromname, $userMessage);
     }
     $nmsgHTML = sprintf($messageHTML, '<strong><a href="' . $fromURL . '">' . $fromname . '</a></strong>');
     $nmsgText = sprintf($messageText, $fromname);
     $manageURL = 'index.php?option=com_comprofiler&amp;task=manageConnections' . getCBprofileItemid(true);
     $manageURL = cbSef($manageURL);
     if (strncasecmp("http", $manageURL, 4) != 0) {
         $manageURL = $_CB_framework->getCfg('live_site') . "/" . $manageURL;
     }
     $nmsgHTML = $nmsgHTML . "\n<br /><br /><a href=\"" . $manageURL . "\">" . _UE_MANAGECONNECTIONS . "</a>\n";
     $nmsgText = $nmsgText . "\r\n\r\n\r\n" . $fromname . " " . _UE_PROFILE . ": " . cbUnHtmlspecialchars($fromURL);
     $nmsgText = $nmsgText . "\r\n\r\n" . _UE_MANAGECONNECTIONS . ": " . cbUnHtmlspecialchars($manageURL) . "\r\n";
     $nmsgHTML = '<div style="padding: 4px; margin: 4px 3px 6px 0px; background: #C44; font-weight: bold;" class="cbNotice">' . _UE_SENDPMSNOTICE . "</div>\n\n" . $nmsgHTML;
     $cbNotification = new cbNotification();
     $cbNotification->sendFromUser($connectionid, $userid, $subject, $nmsgHTML, $nmsgText);
     $this->_setUserMSG($msg);
     return true;
 }