Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email templates user signature #252

Open
wants to merge 12 commits into
base: feature-branch-for-aged-PR's
Choose a base branch
from
42 changes: 39 additions & 3 deletions lib/EmailTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ public function replaceVariables($text)
$email = $_SESSION['CATS']->getEmail();
$siteName = $_SESSION['CATS']->getSiteName();
$fullName = $_SESSION['CATS']->getFullName();
$emailSignature = $this->getEmailSignature();

if ($_SESSION['CATS']->isDateDMY())
{
Expand All @@ -275,7 +276,8 @@ public function replaceVariables($text)
'%DATETIME%',
'%SITENAME%',
'%USERFULLNAME%',
'%USERMAIL%'
'%USERMAIL%',
'%USEREMAILSIGNATURE%'
);

if ($isLoggedIn)
Expand All @@ -284,7 +286,8 @@ public function replaceVariables($text)
DateUtility::getAdjustedDate($dateFormat . ' g:i A'),
$siteName,
$fullName,
'<a href="mailto:'. $email .'">'. $email .'</a>'
'<a href="mailto:'. $email .'">'. $email .'</a>',
$emailSignature
);
}
else
Expand Down Expand Up @@ -391,7 +394,40 @@ public function getAll()

return $this->_db->getAllAssoc($sql);
}


public function getEmailSignature(){
$sql = sprintf(
"SELECT
settings.value AS value
FROM
settings
WHERE
settings.site_id = %s
AND
settings.settings_type = %s
AND
settings.setting = %s",
$this->_siteID,
SETTINGS_MAILER,
$this->_db->makeQueryString("emailSignature_".$_SESSION['CATS']->getUserID())
);
$rs = $this->_db->getAllAssoc($sql);
if(empty($rs) || !$rs){
return "";
}
return $rs[0]['value'];
}

public function saveEmailSignature($signature){
if(strlen($signature) > 254){
return -1;
} else {
$mailerSettings = new MailerSettings($this->_siteID);
$mailerSettings->set("emailSignature_" . $_SESSION['CATS']->getUserID(), $signature);
return 0;
}
}

public function getAllCustom()
{
$sql = sprintf(
Expand Down
2 changes: 1 addition & 1 deletion lib/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public function set($setting, $value)
AND
site_id = %s
AND
settings_type",
settings_type = %s",
$this->_db->makeQueryStringOrNULL($setting),
$this->_siteID,
SETTINGS_MAILER
Expand Down
82 changes: 82 additions & 0 deletions modules/settings/EmailSignature.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php /* $Id: EmailSignature.tpl $ */ ?>
<?php TemplateUtility::printHeader('Settings', array('modules/settings/validator.js', 'js/sorttable.js', 'ckeditor/ckeditor.js')); ?>
<?php TemplateUtility::printHeaderBlock(); ?>
<?php TemplateUtility::printTabs($this->active, $this->subActive); ?>
<div id="main">
<?php TemplateUtility::printQuickSearch(); ?>

<div id="contents">
<table>
<tr>
<td width="3%">
<img src="images/settings.gif" width="24" height="24" border="0" alt="Settings" style="margin-top: 3px;" />&nbsp;
</td>
<td><h2>Settings: E-Mail Signature</h2></td>
</tr>
</table>

<p class="note">My E-Mail Signature</p>

<form name="changeEmailSignatureForm" id="changeEmailSignatureForm" action="<?php echo(CATSUtility::getIndexName()); ?>?m=settings&amp;a=myProfile&amp;s=emailSignature" method="post">
<input type="hidden" name="postback" id="postback" value="postback" />

<?php if ($this->isDemoUser): ?>
Note that as a demo user, you do not have privileges to modify any settings.
<br /><br />
<?php endif; ?>

<table class="searchTable">
<tr>
<td colspan="4">
<span class="bold">Change Signature</span>
<br />
<br />
<span id='passwordErrorMessage' style="font:smaller; color: red">
<?php if (isset($this->errorMessage)): ?>
<?php $this->_($this->errorMessage); ?>
<?php endif; ?>
</span>
</td>
</tr>


<tr>
<td>
<label id="signatureLabel" for="signature">Current Signature:</label>&nbsp;
</td>
<td>
<textarea rows=7 cols=60 class="inputbox" id="signature" name="signature"><?php echo $this->emailSignature; ?></textarea>
</td>
</tr>

<tr>
<td colspan="2">
<br />
<input type="submit" class="button" id="changeSignature" name="action" value="Save" />
<input type="button" name="back" class = "button" value="Back" onclick="document.location.href='<?php echo(CATSUtility::getIndexName()); ?>?m=settings';" />
</td>
</tr>
</table>
</form>
</div>
</div>
<script type="text/javascript">
CKEDITOR.replace( 'signature' );
CKEDITOR.on('instanceReady', function(ev)
{
var tags = ['p', 'ol', 'ul', 'li']; // etc.

for (var key in tags) {
ev.editor.dataProcessor.writer.setRules(
tags[key],
{
indent : false,
breakBeforeOpen : false,
breakAfterOpen : false,
breakBeforeClose : false,
breakAfterClose : false,
});
}
});
</script>
<?php TemplateUtility::printFooter(); ?>
1 change: 1 addition & 0 deletions modules/settings/EmailTemplates.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<?php generateInsertAtCursorLink($data, 'Site Name', '%SITENAME%'); ?>
<?php generateInsertAtCursorLink($data, 'Recruiter/Current User Name', '%USERFULLNAME%'); ?>
<?php generateInsertAtCursorLink($data, 'Recruiter/Current User E-Mail Link', '%USERMAIL%'); ?>
<?php generateInsertAtCursorLink($data, 'Current User E-Mail Signature', '%USEREMAILSIGNATURE%'); ?>
<?php endif; ?>

<?php /* Template specific vars */ ?>
Expand Down
10 changes: 10 additions & 0 deletions modules/settings/MyProfile.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
Change your CATS login password.
</td>
</tr>
<tr>
<td width="230">
<a href="<?php echo(CATSUtility::getIndexName()); ?>?m=settings&amp;a=myProfile&amp;s=emailSignature">
<img src="images/bullet_black.gif" alt="" border="0" />Change E-mail Signature
</a>
</td>
<td>
Change the signature that can be used with e-mail templates sent from your account.
</td>
</tr>
<!--<tr>
<td>
<a href="<?php echo(CATSUtility::getIndexName()); ?>?m=settings&amp;a=myProfile&amp;s=notificationOptions">
Expand Down
18 changes: 18 additions & 0 deletions modules/settings/SettingsUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,24 @@ private function myProfile()
$templateFile = './modules/settings/ChangePassword.tpl';
break;

case 'emailSignature':
$emailTemplates = new EmailTemplates($this->_siteID);
$emailSignature = $_POST['signature'];
if($this->isPostBack()){
$result = $emailTemplates->saveEmailSignature($emailSignature);
if($result == -1){
$this->_template->assign('errorMessage', "The signature text is too long.");

} else {
CATSUtility::transferRelativeURI("m=settings&a=myProfile");
}
} else {
$emailSignature = $emailTemplates->getEmailSignature();
}
$this->_template->assign('emailSignature', $emailSignature);
$templateFile = './modules/settings/EmailSignature.tpl';
break;

default:
$templateFile = './modules/settings/MyProfile.tpl';
break;
Expand Down