Skip to content

Commit

Permalink
Merge pull request #107 from ushahidi/email-dev
Browse files Browse the repository at this point in the history
Email dev
  • Loading branch information
David Kobia committed Nov 19, 2013
2 parents 3ca1cf5 + 75806f5 commit e296fa9
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 82 deletions.
49 changes: 49 additions & 0 deletions application/classes/Controller/Info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');

/**
* Info Controller
* Render Terms of Service, Privacy Policies, Refund Policies here
*
* @author Ushahidi Team <[email protected]>
* @package Ushahidi\Application\Controllers
* @copyright Ushahidi - http://www.ushahidi.com
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
*/
class Controller_Info extends Controller_PingApp {

private $_title;
private $_content;

public $auth_required = FALSE;

public function before()
{
parent::before();

$this->template->content = View::factory('pages/info/view')
->bind('title', $this->_title)
->bind('content', $this->_content);
}

/**
* List People
*
* @return void
*/
public function action_tos()
{
$this->_title = 'Terms of Service';
$this->_content = nl2br(PingApp_Settings::get('tos'));
}

/**
* List People
*
* @return void
*/
public function action_privacy()
{
$this->_title = 'Privacy Policy';
$this->_content = nl2br(PingApp_Settings::get('privacy'));
}
}
33 changes: 20 additions & 13 deletions application/classes/Controller/PingApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public function before()
// Check user auth and role
$action_name = Request::current()->action();

// Okay User is Logged In -- On to ACL
if (Auth::instance()->logged_in())
// Is Access Restricted?
if ($this->auth_required !== FALSE)
{
$this->user = Auth::instance()->get_user();

// Is Access Restricted?
if ($this->auth_required !== FALSE)
// Okay User is Logged In -- On to ACL
if (Auth::instance()->logged_in())
{
$this->user = Auth::instance()->get_user();

$access = FALSE;
// Verify That User Has Correct Role
foreach ($this->auth_required as $role)
Expand Down Expand Up @@ -119,10 +119,14 @@ public function before()
$this->_login_required();
}
}
else
{
$this->_login_required();
}
}
else
{
$this->_login_required();
$this->user = Auth::instance()->get_user();
}

if ($this->auto_render)
Expand All @@ -139,13 +143,16 @@ public function before()
->bind('role', $role);
$nav->feedback_email = PingApp_Settings::get('feedback_email');

if ($this->user->has('roles', ORM::factory('Role')->where('name', '=', 'admin')->find() ))
if ( $this->user AND $this->user->loaded() )
{
$role = 'admin';
}
else
{
$role = 'member';
if ($this->user->has('roles', ORM::factory('Role')->where('name', '=', 'admin')->find() ))
{
$role = 'admin';
}
else
{
$role = 'member';
}
}
}
}
Expand Down
18 changes: 10 additions & 8 deletions application/classes/PingApp/Ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function process($ping_id = 0)
{
$pings_repings_delay = 5;
}
echo $pings_repings_delay."\n";

if ( ( time() - strtotime($_ping->updated) ) < ($pings_repings_delay * 60) )
{
return;
Expand Down Expand Up @@ -208,19 +208,21 @@ private static function _email($ping, $contact)
$sender_email = $ping->message->user->email;
$sender = ($sender_name != ' ') ? $sender_name : $sender_email;

$prepend = 'Ping requested by: '.$sender."\n\n";

$body = PingApp_Settings::get('message_email');
$body = str_replace('{{name}}', $person->name, $body);
$body = str_replace('{{message}}', $ping->message->message, $body);
$body = $prepend.$body."\n\n\n".' [{'.$tracking_id.'}]';$body."\n\n\n".' [{'.$tracking_id.'}]';
$body = View::factory('email/layout');
$body->name = $person->name;
$body->message = $ping->message->message;
$body->sender = $ping->message->user;
$body->tracking_id = $tracking_id;
$body->site_url = rtrim(PingApp_Settings::get('site_url'), '/');


$from = PingApp_Settings::get('email_from');
$from_name = PingApp_Settings::get('email_from_name');

try
{
$result = Email::factory($title, $body)
$result = Email::factory($title, $body->render(), 'text/html')
->to($contact->contact)
->from($from, $sender)
->send();
Expand Down Expand Up @@ -252,7 +254,7 @@ public static function tracking_id($type = 'email')
$code = NULL;
while ( ! $unique)
{
$code = Text::random('alnum', 32);
$code = Text::random('alnum', 16);
$ping = ORM::factory('Ping')
->where('type', '=', $type)
->where('tracking_id', '=', $code)
Expand Down
4 changes: 2 additions & 2 deletions application/views/common/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</div>
<div class="footer-links">
<ul class="footer-links-list">
<li><a href="/terms">Terms</a></li>
<li><a href="/info/tos">Terms</a></li>
<li>|</li>
<li><a href="/privacy">Privacy</a></li>
<li><a href="/info/privacy">Privacy</a></li>
</ul>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions application/views/common/nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</ul>
<section class="top-bar-section">
<ul class="right">
<?php if ( $user AND $user->loaded() ): ?>
<li class="divider hide-for-small"></li>
<li><a href="/people">People</a></li>
<li><a href="/groups">Groups</a></li>
Expand All @@ -30,6 +31,9 @@
<li class="signout"><a href="/logout">Sign Out</a></li>
</ul>
</li>
<?php else: ?>
<li class=""><a href="/login">Log In</a></li>
<?php endif; ?>
</ul>
</section>
</nav>
12 changes: 6 additions & 6 deletions application/views/email/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
<table class="container" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: inherit; width: 600px; margin: 0 auto; padding: 0;"><tr style="vertical-align: top; text-align: left; padding: 0;" align="left"><td class="wrapper last" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; position: relative; padding: 10px 0px 0px;" align="left" valign="top">

<table class="twelve columns" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 580px; margin: 0; padding: 0;"><tr style="vertical-align: top; text-align: left; padding: 0;" align="left"><td class="six sub-columns" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; width: 50% !important; padding: 0px 3.448276% 10px 0px;" align="left" valign="top">
<img height="111" width="270" src="http://ping.ushahidi.com/media/images/ping-logo.png" style="outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; width: auto; max-width: 100%; float: left; clear: both; display: block;" align="left" /></td>
<img height="111" width="270" src="<?php echo $site_url; ?>/media/images/ping-logo.png" style="outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; width: auto; max-width: 100%; float: left; clear: both; display: block;" align="left" /></td>
</tr></table></td>
</tr></table></center>
</td>
Expand All @@ -236,25 +236,25 @@
<table class="row" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 100%; position: relative; display: block; padding: 0px;"><tr style="vertical-align: top; text-align: left; padding: 0;" align="left"><td class="wrapper last" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; position: relative; padding: 10px 0px 0px;" align="left" valign="top">

<table class="twelve columns" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 580px; margin: 0; padding: 0;"><tr style="vertical-align: top; text-align: left; padding: 0;" align="left"><td style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; padding: 0px 0px 10px;" align="left" valign="top">
<h3 style="color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; text-align: left; line-height: 1.3; word-break: normal; font-size: 37px; margin: 0; padding: 0;" align="left">Hi, user name here</h3>
<p style="color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; text-align: left; line-height: 19px; font-size: 14px; margin: 0; padding: 0 0 10px;" align="left">email message here</p>
<h3 style="color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; text-align: left; line-height: 1.3; word-break: normal; font-size: 37px; margin: 0; padding: 0;" align="left">Hi, <?php echo $name; ?></h3>
<p style="color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; text-align: left; line-height: 19px; font-size: 14px; margin: 0; padding: 0 0 10px;" align="left"><?php echo $message; ?></p>
</td>
<td class="expander" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; visibility: hidden; width: 0px; padding: 0;" align="left" valign="top"></td>
</tr></table></td>
</tr></table><table class="row footer" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 100%; position: relative; display: block; padding: 0px;"><tr style="vertical-align: top; text-align: left; padding: 0;" align="left"><td class="wrapper" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; position: relative; background: #ebebeb; padding: 10px 20px 0px 0px;" align="left" bgcolor="#ebebeb" valign="top">

<table class="twelve columns" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 580px; margin: 0; padding: 0;"><tr style="vertical-align: top; text-align: left; padding: 0;" align="left"><td class="left-text-pad" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; padding: 0px 0px 10px 10px;" align="left" valign="top">
<h5 style="color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; text-align: left; line-height: 1.3; word-break: normal; font-size: 23px; margin: 0; padding: 0 0 10px;" align="left">Contact Info:</h5>
<p style="color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; text-align: left; line-height: 19px; font-size: 14px; margin: 0; padding: 0 0 10px;" align="left">Phone: phone # here</p>
<p style="color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; text-align: left; line-height: 19px; font-size: 14px; margin: 0; padding: 0 0 10px;" align="left">Email: <a href="email address here" style="color: #2ba6cb; text-decoration: none !important;">email address here</a></p>
<p style="color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; text-align: left; line-height: 19px; font-size: 14px; margin: 0; padding: 0 0 10px;" align="left">Name: <?php echo $sender->first_name.' '.$sender->last_name; ?></p>
<p style="color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; text-align: left; line-height: 19px; font-size: 14px; margin: 0; padding: 0 0 10px;" align="left">Email: <a href="email address here" style="color: #2ba6cb; text-decoration: none !important;"><?php echo $sender->email; ?></a></p>
</td>
<td class="expander" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; visibility: hidden; width: 0px; padding: 0;" align="left" valign="top"></td>
</tr></table></td>
</tr></table><table class="row" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 100%; position: relative; display: block; padding: 0px;"><tr style="vertical-align: top; text-align: left; padding: 0;" align="left"><td class="wrapper last" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; position: relative; padding: 10px 0px 0px;" align="left" valign="top">

<table class="twelve columns" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 580px; margin: 0; padding: 0;"><tr style="vertical-align: top; text-align: left; padding: 0;" align="left"><td align="center" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; padding: 0px 0px 10px;" valign="top">
<center style="width: 100%; min-width: 580px;">
<p style="text-align: center; color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; line-height: 19px; font-size: 14px; margin: 0; padding: 0 0 10px;" align="center"><a href="#" style="color: #2ba6cb; text-decoration: none !important;">Terms</a> | <a href="#" style="color: #2ba6cb; text-decoration: none !important;">Privacy</a> | <a href="#" style="color: #2ba6cb; text-decoration: none !important;">Unsubscribe</a></p>
<p style="text-align: center; color: #222222; display: block; font-family: 'Helvetica', 'Arial', sans-serif; font-weight: normal; line-height: 19px; font-size: 14px; margin: 0; padding: 0 0 10px;" align="center"><a href="<?php echo $site_url; ?>/info/tos" style="color: #2ba6cb; text-decoration: none !important;">Terms</a> | <a href="<?php echo $site_url; ?>/info/privacy" style="color: #2ba6cb; text-decoration: none !important;">Privacy</a> | <a href="#" style="color: #2ba6cb; text-decoration: none !important;">Unsubscribe</a></p>
</center>
</td>
<td class="expander" style="word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; vertical-align: top; text-align: left; visibility: hidden; width: 0px; padding: 0;" align="left" valign="top"></td>
Expand Down
9 changes: 9 additions & 0 deletions application/views/pages/info/view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h4><?php echo $title ?></h4>
<ul class="breadcrumbs">
<li><a href="/">Home</a></li>
<li class="current"><?php echo $title ?></li>
</ul>

<p>
<?php echo $content; ?>
</p>
8 changes: 8 additions & 0 deletions application/views/pages/settings/extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@

<?php echo Form::open(NULL, array('class' => 'custom')); ?>
<?php echo Form::hidden('token', Security::token()); ?>
<fieldset>
<legend>Site URL</legend>
<div class="site-url-row">
<div class="site-url">
<?php echo Form::input('settings[site_url]', (isset($post['settings']['site_url'])) ? $post['settings']['site_url'] : '', array('placeholder' => 'http://www.example.com')); ?>
</div>
</div>
</fieldset>
<fieldset>
<legend>Feedback Email Address</legend>
<div class="feedback-email-address-row">
Expand Down
54 changes: 1 addition & 53 deletions httpdocs/media/css/app.css

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions httpdocs/media/scss/pages/settings/_extras.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@



/*------------------------------------*\
$SITE URL
\*------------------------------------*/

.site-url-row {
@include grid-row();
}

.site-url {
@include grid-column(12);
}



/*------------------------------------*\
$FEEDBACK
Expand Down

0 comments on commit e296fa9

Please sign in to comment.