Added mail helper

This commit is contained in:
Frederic Guillot
2016-06-01 21:28:24 -04:00
parent ca87b1b60f
commit c50255813b
8 changed files with 103 additions and 35 deletions

View File

@@ -27,6 +27,7 @@ use Pimple\Container;
* @property \Kanboard\Helper\LayoutHelper $layout
* @property \Kanboard\Helper\ProjectHeaderHelper $projectHeader
* @property \Kanboard\Helper\ProjectActivityHelper $projectActivity
* @property \Kanboard\Helper\MailHelper $mail
*/
class Helper
{

View File

@@ -12,26 +12,6 @@ use Pimple\Container;
*/
class Tool
{
/**
* Get the mailbox hash from an email address
*
* @static
* @access public
* @param string $email
* @return string
*/
public static function getMailboxHash($email)
{
if (! strpos($email, '@') || ! strpos($email, '+')) {
return '';
}
list($local_part, ) = explode('@', $email);
list(, $identifier) = explode('+', $local_part);
return $identifier;
}
/**
* Build dependency injection container from an array
*

48
app/Helper/MailHelper.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace Kanboard\Helper;
use Kanboard\Core\Base;
/**
* Class MailHelper
*
* @package Kanboard\Helper
* @author Frederic Guillot
*/
class MailHelper extends Base
{
/**
* Get the mailbox hash from an email address
*
* @access public
* @param string $email
* @return string
*/
public function getMailboxHash($email)
{
if (! strpos($email, '@') || ! strpos($email, '+')) {
return '';
}
list($localPart, ) = explode('@', $email);
list(, $identifier) = explode('+', $localPart);
return $identifier;
}
/**
* Filter mail subject
*
* @access public
* @param string $subject
* @return string
*/
public function filterSubject($subject)
{
$subject = str_replace('RE: ', '', $subject);
$subject = str_replace('FW: ', '', $subject);
return $subject;
}
}

View File

@@ -89,6 +89,22 @@ class SwimlaneModel extends Base
->findOne();
}
/**
* Get first active swimlane for a project
*
* @access public
* @param integer $project_id
* @return array
*/
public function getFirstActiveSwimlane($project_id)
{
return $this->db->table(self::TABLE)
->eq('is_active', self::ACTIVE)
->eq('project_id', $project_id)
->orderBy('position', 'asc')
->findOne();
}
/**
* Get default swimlane properties
*

View File

@@ -37,6 +37,7 @@ class HelperProvider implements ServiceProviderInterface
$container['helper']->register('avatar', '\Kanboard\Helper\AvatarHelper');
$container['helper']->register('projectHeader', '\Kanboard\Helper\ProjectHeaderHelper');
$container['helper']->register('projectActivity', '\Kanboard\Helper\ProjectActivityHelper');
$container['helper']->register('mail', '\Kanboard\Helper\MailHelper');
$container['template'] = new Template($container['helper']);