Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Added postal component for email notifications.
Browse files Browse the repository at this point in the history
Added email notification for page posts.
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Oct 23, 2010
1 parent 347c4dd commit 0e898a5
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 4 deletions.
34 changes: 31 additions & 3 deletions components/page/controllers/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ private function _Prep ( ) {
$row->Find ( '[name=Context]', 0 )->value = $this->Get ( 'Context' );
$row->Find ( '[name=Identifier]', 0 )->value = $Identifier;

$row->Find ( '.delete', 0 )->action = $this->GetSys ( "Router" )->Get ( "Base" );

$li->innertext .= $row->outertext;
unset ( $row );
}
Expand Down Expand Up @@ -132,11 +130,41 @@ public function Share ( $pView = null, $pData = array ( ) ) {

$this->Model->Post ( $Content, $Privacy, $this->_Focus->Id, $Owner, $Current );

$Identifier = $this->Model->Get ( 'Identifier' );

// Don't send an email if we're posting on our own page.
if ( $this->_Current->Account != $this->_Focus->Account ) {
$this->_Email ( $Content, $Identifier );
}

$redirect = $this->GetSys ( "Router" )->Get ( "Request" );
header ( 'Location:' . $redirect );
exit;
}

private function _Email ( $pContent, $pIdentifier) {
$data = array ( 'account' => $this->_Current->Account, 'source' => ASD_DOMAIN, 'request' => $this->_Current->Account );
$CurrentInfo = $this->GetSys ( 'Event' )->Trigger ( 'On', 'User', 'Info', $data );
$SenderFullname = $CurrentInfo->fullname;
$SenderNameParts = explode ( ' ', $CurrentInfo->fullname );
$SenderFirstName = $SenderNameParts[0];

$SenderAccount = $this->_Current->Account;

$RecipientEmail = $this->_Focus->Email;
$MailSubject = __( "Someone Posted On Your Page", array ( "fullname" => $SenderFullname ) );
$Byline = __( "Posted On Your Page" );
$Subject = __( "Someone Said", array ( "firstname" => $SenderFirstName ) );
$Body = $pContent;
$LinkDescription = __( "Click Here" );
$Link = 'http://' . ASD_DOMAIN . '/profile/' . $this->_Focus->Username . '/page/' . $pIdentifier;

$Message = array ( 'Type' => 'User', 'SenderFullname' => $SenderFullname, 'SenderAccount' => $SenderAccount, 'RecipientEmail' => $RecipientEmail, 'MailSubject' => $MailSubject, 'Byline' => $Byline, 'Subject' => $Subject, 'Body' => $Body, 'LinkDescription' => $LinkDescription, 'Link' => $Link );
$this->Talk ( 'Postal', 'Send', $Message );

return ( true );
}

public function _CheckEditor () {
$this->_Focus = $this->Talk ( 'User', 'Focus' );
$this->_Current = $this->Talk ( 'User', 'Current' );
Expand All @@ -162,7 +190,7 @@ public function Remove ( $pData = null ) {

$this->Model->Remove ( $Identifier, $this->_Focus->Id );

$redirect = $this->GetSys ( "Router" )->Get ( "Base" );
$redirect = $this->GetSys ( "Router" )->Get ( "Request" );
header ( 'Location:' . $redirect );
exit;
}
Expand Down
8 changes: 7 additions & 1 deletion components/page/languages/en-US/page.lang
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ SUBMIT_POST="Share"
ADD_COMMENT="Comment"
DELETE_POST="Remove"

WHAT_IS_ON_YOUR_MIND="What's on your mind?"
WHAT_IS_ON_YOUR_MIND="What's on your mind?"

[notifications]
SOMEONE_POSTED_ON_YOUR_PAGE="%fullname$s posted on your page."
POSTED_ON_YOUR_PAGE="posted on your page."
SOMEONE_SAID="%firstname$s said:"
CLICK_HERE="Click here to view post:"
40 changes: 40 additions & 0 deletions components/postal/controllers/postal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @version $Id$
* @package Appleseed.Components
* @subpackage Postal
* @copyright Copyright (C) 2004 - 2010 Michael Chisari. All rights reserved.
* @link http://opensource.appleseedproject.org
* @license GNU General Public License version 2.0 (See LICENSE.txt)
*/

// Restrict direct access
defined( 'APPLESEED' ) or die( 'Direct Access Denied' );

/** Postal Component Controller
*
* Postal Component Controller Class
*
* @package Appleseed.Components
* @subpackage Postal
*/
class cPostalPostalController extends cController {

var $_Component = 'postal';

/**
* Constructor
*
* @access public
*/
public function __construct ( ) {
parent::__construct( );
}

public function Display ( $pView = null, $pData = array ( ) ) {
$pView = 'user';
return ( parent::Display ( $pView, $pData ) );
}

}

Empty file.
2 changes: 2 additions & 0 deletions components/postal/postal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; Enabled by default
enabled="true"
88 changes: 88 additions & 0 deletions components/postal/postal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/**
* @version $Id$
* @package Appleseed.Components
* @subpackage Postal
* @copyright Copyright (C) 2004 - 2010 Michael Chisari. All rights reserved.
* @link http://opensource.appleseedproject.org
* @license GNU General Public License version 2.0 (See LICENSE.txt)
*/

// Restrict direct access
defined( 'APPLESEED' ) or die( 'Direct Access Denied' );

/** Postal Component
*
* Postal Component Entry Class
*
* @package Appleseed.Components
* @subpackage Postal
*/
class cPostal extends cComponent {

/**
* Constructor
*
* @access public
*/
public function __construct ( ) {
parent::__construct();
}

public function Send ( $pData = array ( ) ) {

include_once ( ASD_PATH . 'components/postal/controllers/postal.php' );
$Controller = new cPostalPostalController();

$Type = strtolower ( $pData['Type'] );
$SenderFullname = $pData['SenderFullname'];
$SenderAccount = $pData['SenderAccount'];
$RecipientEmail = $pData['RecipientEmail'];
$MailSubject = $pData['MailSubject'];
$Byline = $pData['Byline'];
$Subject = $pData['Subject'];
$Body = $pData['Body'];
$LinkDescription = $pData['LinkDescription'];
$Link = $pData['Link'];
$Stamp = $this->GetSys ( 'Date' )->Format ( NOW(), true );
$data = array ( 'account' => $SenderAccount, 'source' => ASD_DOMAIN );
$AccountLink = $this->GetSys ( 'Event' )->Trigger ( 'Create', 'User', 'Link', $data );

$View = $Controller->GetView ( $Type );

list ( $username, $domain ) = explode ( '@', $SenderAccount );
$IconData = array ( 'username' => $username, 'domain' => $domain, 'width' => 64, 'height' => 64 );
$View->Find ( '.icon', 0 )->src = $this->GetSys ( 'Event' )->Trigger ( 'On', 'User', 'Icon', $IconData );

$View->Find ( '.fullname', 0 )->innertext = $SenderFullname;
$View->Find ( '.fullname', 0 )->href = $AccountLink;
$View->Find ( '.account', 0 )->innertext = $SenderAccount;
$View->Find ( '.account', 0 )->href = $AccountLink;
$View->Find ( '.byline-description', 0 )->innertext = $Byline;
$View->Find ( '.subject', 0 )->innertext = $Subject;
$View->Find ( '.body', 0 )->innertext = $Body;

$View->Find ( '.stamp', 0 )->innertext = $Stamp;

$View->Find ( '.link-description', 0 )->innertext = $LinkDescription;
$View->Find ( '.link', 0 )->src = $Link;
$View->Find ( '.link', 0 )->innertext = $Link;

$from = "no-reply@" . ASD_DOMAIN;
$fromName = "Appleseed";
$to = $RecipientEmail;
$toName = $RecipientEmail;
$subject = $MailSubject;
$body = $View->Buffer();

$Mailer = $this->GetSys ( "Mailer" );

if ( !$Mailer->Send ( $from, $fromName, $to, $toName, $subject, $body ) ) {
return ( false );
}

return ( true );
}

}

50 changes: 50 additions & 0 deletions components/postal/views/user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<html>
<head>
<style>
a { color:#406300; text-decoration:none; }
a:hover { color:#406300; text-decoration:underline; }
body { width:100%; float:left; background-color:#fafafa; font-family:Arial; font-size:12px; color:#000000; }
#outline { margin:20px 0 20px 20px; float:left; width:100%; background-color:#ffffff; width:600px; border:1px solid #406300; }
#outline { -webkit-box-shadow: rgba(0, 0, 0, .40) 3px 3px 6px; -moz-box-shadow: rgba(0, 0, 0, .40) 3px 3px 6px; -o-box-shadow: rgba(0, 0, 0, .40) 3px 3px 6px; box-shadow: rgba(0, 0, 0, .40) 3px 3px 6px; }
#heading { padding:2px 6px 2px 12px; background-color:#80af1f; color:#ffffff; font-weight:bold; font-size:18px; }
#main { }
#header { float:left; margin:10px; padding-bottom:2px; border-bottom:1px solid #c0d895;}
.icon-area { float:left; width:64px; }
.icon-area .icon { width:64px; height:64px; }
.byline { margin-left:10px; float:left; width:506px; color:#406300; }
.byline .fullname { font-weight:bold; }
.stamp { margin-left:10px; float:left; width:506px; color:#8a8a8a; font-size:11px; }
.subject { margin-left:10px; float:left; width:506px; margin-top:25px;}
.body { float:left; margin-left:84px; width:504px; min-height:140px; margin-bottom:10px; }
#footer { float:left; margin:0 10px 15px 84px; background-color:#c0d895; border:1px solid #80af1f; width:494px; color:#000000; padding:4px 5px; }
#footer { -webkit-box-shadow: rgba(0, 0, 0, .50) 0 0 6px; -moz-box-shadow: rgba(0, 0, 0, .50) 0 0 6px; -o-box-shadow: rgba(0, 0, 0, .50) 0 0 6px; box-shadow: rgba(0, 0, 0, .50) 0 0 6px; }
.link-description { float:left; clear:both; }
.link-area { float:left; clear:both; margin-top:5px; }
</style>
</head>

<body style="float:left; width:100%; background-color:#fafafa; font-family:Arial; font-size:12px; color:#000000;">
<div id="outline" style="margin:20px 0 20px 20px; float:left; width:100%; background-color:#ffffff; width:600px; border:1px solid #406300; -webkit-box-shadow: rgba(0, 0, 0, .40) 3px 3px 6px; -moz-box-shadow: rgba(0, 0, 0, .40) 3px 3px 6px; -o-box-shadow: rgba(0, 0, 0, .40) 3px 3px 6px; box-shadow: rgba(0, 0, 0, .40) 3px 3px 6px;">
<div id="heading" style="padding:2px 6px 2px 12px; background-color:#80af1f; color:#ffffff; font-weight:bold; font-size:18px;">Appleseed</div>
<div id="header" style="float:left; margin:10px; padding-bottom:2px; border-bottom:1px solid #c0d895;">
<span class="icon-area" style="float:left; width:64px;">
<img class="icon" style="width:64px; height:64px;" src="" />
</span>
<span class="byline" style="margin-left:10px; float:left; width:506px; color:#406300;">
<a href="#" class="fullname" style="font-weight:bold; color:#406300; text-decoration:none;">#</a> (<a href="#" style="color:#406300; text-decoration:none;" class="account">#</a>) <span class="byline-description">#</span>
</span>
<span class="stamp" style="margin-left:10px; float:left; width:506px; color:#8a8a8a; font-size:11px;"> # </span>
<span class="subject" style="margin-left:10px; float:left; width:506px; margin-top:25px;"> # </span>
</div>
<div id="main">
<span class="body" style="float:left; margin-left:84px; width:504px; min-height:140px; margin-bottom:10px;"> # </span>
</div>
<div id="footer" style="float:left; margin:0 10px 15px 84px; background-color:#c0d895; border:1px solid #80af1f; width:494px; color:#000000; padding:4px 5px; -webkit-box-shadow: rgba(0, 0, 0, .50) 0 0 6px; -moz-box-shadow: rgba(0, 0, 0, .50) 0 0 6px; -o-box-shadow: rgba(0, 0, 0, .50) 0 0 6px; box-shadow: rgba(0, 0, 0, .50) 0 0 6px;">
<span class="link-description" style="float:left; clear:both;">#</span>
<span class="link-area" style="float:left; clear:both; margin-top:5px;">
<a href="#" style="color:#406300; text-decoration:none;" class="link"> # </a>
</span>
</div>
</div>
</body>
</html>

0 comments on commit 0e898a5

Please sign in to comment.