diff --git a/lib/email/Email.inc b/lib/email/Email.inc index f8939c3..ee34c33 100644 --- a/lib/email/Email.inc +++ b/lib/email/Email.inc @@ -8,31 +8,31 @@ * Document Management Made Simple * Copyright (C) 2008, 2009 KnowledgeTree Inc. * Portions copyright The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original + * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ */ @@ -49,7 +49,7 @@ class Email { * with default system information * * @param string the sender's email address (optional) - * @param string the sender's name (optional) + * @param string the sender's name (optional) */ function Email($sFromEmail = "", $sFromName = "") { global $default; @@ -66,8 +66,8 @@ class Email { $this->oMailer->IsHTML(true); $this->oMailer->SetLanguage('en', KT_DIR . '/thirdparty/phpmailer/language/'); $this->bEmailDisabled = false; - - $oConfig =& KTConfig::getSingleton(); + + $oConfig =& KTConfig::getSingleton(); $sEmailServer = $oConfig->get('email/emailServer'); if ($sEmailServer == 'none') { $this->bEmailDisabled = true; @@ -90,7 +90,7 @@ class Email { $this->oMailer->Password = $sEmailPass; } } - + /** * Sends an email to a specified recipient. * @@ -98,7 +98,7 @@ class Email { * @param string the subject of the email * @param string the body of the email * @param string the sender's email address (optional) - * @param string the sender's name (optional) + * @param string the sender's name (optional) * @return boolean true on email successfully sent, false otherwise and set $_SESSION["errorMessage"] */ function send($mToEmail, $sSubject, $sBody) { @@ -106,9 +106,9 @@ class Email { return PEAR::raiseError(_kt("Email is not configured.")); } global $default; - - if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || - (is_array($mToEmail) && (count($mToEmail) > 0)) ) { + + if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || + (is_array($mToEmail) && (count($mToEmail) > 0)) ) { $aEmailAddresses = array(); // just one email address, add it @@ -118,7 +118,7 @@ class Email { // if we're passed an array, then use it if (is_array($mToEmail)) { $aEmailAddresses = $mToEmail; - // if there are multiple addresses (; separated), explode it + // if there are multiple addresses (; separated), explode it } elseif (strpos($mToEmail, ";") > 0) { $aEmailAddresses = explode(";", $mToEmail); } @@ -128,9 +128,11 @@ class Email { } } + $body = $this->makeEmailTemplate(stripslashes($sBody)); $this->oMailer->Subject = stripslashes($sSubject); - $this->oMailer->Body = stripslashes($sBody); - +// $this->oMailer->Body = stripslashes($sBody); + $this->oMailer->Body = $body; + //send the email if(!$this->oMailer->Send()) { $default->log->error("Error sending mail to $mToEmail; mailer error code=" . $this->oMailer->ErrorInfo); @@ -160,9 +162,9 @@ class Email { return PEAR::raiseError(_kt("Email is not configured.")); } global $default; - - if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || - (is_array($mToEmail) && (count($mToEmail) > 0)) ) { + + if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || + (is_array($mToEmail) && (count($mToEmail) > 0)) ) { // just one email address, add it if (is_string($mToEmail) && (strpos($mToEmail, ";") === false)) { @@ -172,7 +174,7 @@ class Email { // if we're passed an array, then use it if (is_array($mToEmail)) { $aEmailAddresses = $mToEmail; - // if there are multiple addresses (; separated), explode it + // if there are multiple addresses (; separated), explode it } elseif (strpos($mToEmail, ";") > 0) { $aEmailAddresses = explode(";", $mToEmail); } @@ -182,10 +184,12 @@ class Email { } } + $body = $this->makeEmailTemplate(stripslashes($sBody)); $this->oMailer->Subject = stripslashes($sSubject); - $this->oMailer->Body = stripslashes($sBody); +// $this->oMailer->Body = stripslashes($sBody); + $this->oMailer->Body = $body; $this->oMailer->AddAttachment($sDocumentPath, $sDocumentName); - + //send the email if(!$this->oMailer->Send()) { $default->log->error("Error sending mail to $mToEmail; mailer error code=" . $this->oMailer->ErrorInfo); @@ -211,7 +215,7 @@ class Email { * @param The hyperlink that should be sent * * @return boolean true on email successfully sent, false otherwise and set $_SESSION["errorMessage"] - * + * * @todo check for special characters (including encoding the link correctly???) * @todo need to test this on multiple mail clients, not just Outlook */ @@ -221,12 +225,15 @@ class Email { } global $default; + $body = $this->makeEmailTemplate(stripslashes($EmailBody).'

'.$hyperlink); + //get info from relevant fields. $this->oMailer->From = $FromEmail; $this->oMailer->FromName = $FromName; $this->oMailer->AddAddress($ToEmail); $this->oMailer->Subject = stripslashes($Subj); - $this->oMailer->Body = stripslashes($EmailBody) . ' ' . $hyperlink; +// $this->oMailer->Body = stripslashes($EmailBody) . ' ' . $hyperlink; + $this->oMailer->Body = $body; //send the email if(!$this->oMailer->Send()) { @@ -236,7 +243,7 @@ class Email { return true; } /** - * Sends an email ment for administration, + * Sends an email ment for administration, * * @param The sender's email address * @param The sender's Name @@ -246,7 +253,7 @@ class Email { * @param The hyperlink that should be sent * * @return boolean true on email successfully sent, false otherwise and set $_SESSION["errorMessage"] - * + * * @todo check for special characters (including encoding the link correctly???) * @todo need to test this on multiple mail clients, not just Outlook */ @@ -256,12 +263,15 @@ class Email { } global $default; + $body = $this->makeEmailTemplate(stripslashes($EmailBody) . "
" . _kt("This bug can be found on this page") . ": " . "". $hyperlink .""); + //get info from relevant fields. $this->oMailer->From = $FromEmail; $this->oMailer->FromName = $FromName; $this->oMailer->AddAddress($ToEmail); $this->oMailer->Subject = stripslashes($Subj) . ' ' . $hyperlink; //only difference from above - $this->oMailer->Body = stripslashes($EmailBody) . "
" . _kt("This bug can be found on this page") . ": " . "". $hyperlink .""; +// $this->oMailer->Body = stripslashes($EmailBody) . "
" . _kt("This bug can be found on this page") . ": " . "". $hyperlink .""; + $this->oMailer->Body = $body; //send the email if(!$this->oMailer->Send()) { @@ -277,12 +287,14 @@ class Email { } global $default; + $body = $this->makeEmailTemplate(stripslashes($EmailBody)); + //get info from relevant fields. $this->oMailer->From = $FromEmail; $this->oMailer->FromName = $FromName; $this->oMailer->AddAddress($ToEmail); $this->oMailer->Subject = stripslashes($Subj); - $this->oMailer->Body = stripslashes($EmailBody); + $this->oMailer->Body = $body; //send the email if(!$this->oMailer->Send()) { @@ -291,6 +303,48 @@ class Email { } return true; } -} -?> + /* + * This method builds the email template + * + * @author KnowledgeTree Team + * @access public + * @param string $email The email to be sent + * @return string $str The html string that will be sent via email + */ + public function makeEmailTemplate($email) + { + $rootUrl = KTUtil::kt_url(); + + $oKTConfig =& KTConfig::getSingleton(); + $mainLogo = $oKTConfig->get('mainLogo'); + $appName = $oKTConfig->get('appName'); + $companyLogoTitle = $oKTConfig->get('companyLogoTitle'); + $mainLogoTitle = $oKTConfig->get('mainLogoTitle'); + + if($mainLogo != ''){ + $logo = ''.$companyLogoTitle.''; + }else{ + $logo = ''; + } + + $str = ' + + + + + + + + +
+ '.$logo.' +
+ '.$email.' +
+ + '; + return $str; + } +} +?> \ No newline at end of file diff --git a/lib/subscriptions/subscriptions.inc.php b/lib/subscriptions/subscriptions.inc.php index 30a6acf..e56bb80 100644 --- a/lib/subscriptions/subscriptions.inc.php +++ b/lib/subscriptions/subscriptions.inc.php @@ -431,10 +431,171 @@ class SubscriptionContent { ); } + /** + * This function generates the email that will be sent for subscription notifications + * + * @author KnowledgeTree Team + * @access public + * @param object $oKTNotification: The notification object + * @return string $str: The html string that will be sent via email + */ function getEmailAlertContent($oKTNotification) { - // we can re-use the normal template. + // set up logo and title + $rootUrl = KTUtil::kt_url(); + + $info = $this->_getSubscriptionData($oKTNotification); + + // set up email text + $addFolderText = _kt('The folder "').$info['object_name']._kt('" was added'); + $removeSubscribedFolderText = _kt('The folder "').$info['object_name']._kt('" to which you were subscribed, has been removed'); + $removeChildFolderText = _kt('The folder "').$info['object_name']._kt('" has been removed'); + $addDocumentText = _kt('The document "').$info['object_name']._kt('" was added'); + $removeSubscribedDocumentText = _kt('The document "').$info['object_name']._kt('" to which you were subscribed, has been removed'); + $removeChildDocumentText = _kt('The document "').$info['object_name']._kt('" has been removed'); + $modifyDocumentText = _kt('The document "').$info['object_name']._kt('" has been changed'); + $checkInDocumentText = _kt('The document "').$info['object_name']._kt('" has been checked in'); + $checkOutDocumentText = _kt('The document "').$info['object_name']._kt('" has been checked out'); + $moveDocumentText = _kt('The document "').$info['object_name']._kt('" has been moved'); + $copiedDocumentText = _kt('The document "').$info['object_name']._kt('" has been copied'); + $archivedDocumentText = _kt('The document "').$info['object_name']._kt('"'); + $restoreArchivedDocumentText = _kt('The document "').$info['object_name']._kt('" has been restored by an administrator'); + $downloadDocumentText = _kt('The document "').$info['object_name']._kt('"'); + $documentAlertText = _kt('An alert on the document "').$info['object_name']._kt('" has been added or modified'); + + if($info['location_name'] !== NULL){ + $addFolderText .= _kt(' to "').$info['location_name']._kt('"'); + $removeChildFolderText .= _kt(' from the folder "').$info['location_name']._kt('"'); + $addDocumentText .= _kt(' to "').$info['location_name']._kt('"'); + $removeChildDocumentText .= _kt(' from the folder "').$info['location_name']._kt('" to which you are subscribed'); + $modifyDocumentText .= _kt(' in the folder "').$info['location_name']._kt('"'); + $checkInDocumentText .= _kt(', in the folder "').$info['location_name']._kt('"'); + $checkOutDocumentText .= _kt(', from the folder "').$info['location_name']._kt('"'); + $moveDocumentText .= _kt(' to the folder "').$info['location_name']._kt('"'); + $copiedDocumentText .= _kt(' to the folder "').$info['location_name']._kt('"'); + $archivedDocumentText .= _kt(' in the folder "').$info['location_name']._kt('" has been archived'); + $downloadDocumentText .= _kt(' in the folder "').$info['location_name']._kt('" has been downloaded'); + $documentAlertText .= _kt(' in the folder "').$info['location_name']._kt('"'); + } + + // set up links + switch($info['event_type']){ + case 'AddFolder': + $text = $addFolderText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View New Folder').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'RemoveSubscribedFolder': + $text = $removeSubscribedFolderText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links = ''._kt('Clear Alert').''; + break; + case 'RemoveChildFolder': + $text = $removeChildFolderText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View Folder').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'AddDocument': + $text = $addDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View Document').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'RemoveSubscribedDocument': + $text = $removeSubscribedDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links = ''._kt('Clear Alert').''; + break; + case 'RemoveChildDocument': + $text = $removeChildDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links = ''._kt('Clear Alert').''; + break; + case 'ModifyDocument': + $text = $modifyDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View Document').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'CheckInDocument': + $text = $checkInDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View Document').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'CheckOutDocument': + $text = $checkOutDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View Document').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'MovedDocument': + $text = $modifyDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View New Location').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'CopiedDocument': + $text = $copiedDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View Document').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'ArchivedDocument': + $text = $archivedDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links = ''._kt('Clear Alert').''; + break; + case 'RestoreArchivedDocument': + $text = $restoreArchivedDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View Document').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'DownloadDocument': + $text = $downloadDocumentText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View Document').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + break; + case 'ModifyDocumentAlert': + $text = $documentAlertText; + $url = $rootUrl.'/notify.php?id='.$info['notify_id']; + $links = ''._kt('View Document').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=clear'; + $links .= ' | '._kt('Clear Alert').''; + $url = $rootUrl.'/notify.php?id='.$info['notify_id'].'¬ify_action=viewall'; + $links .= ' | '._kt('View all alerts on this document').''; + } + + if($info['actor_name'] !== NULL && $info['event_type'] != 'RestoredArchivedDocument'){ + $text .= _kt(', by ').$info['actor_name']; + } + + // we can re-use the normal template. // however, we need to wrap it - no need for a second template here. - $str = '' . $this->getNotificationAlertContent($oKTNotification) . ''; + //$str = '' . $this->getNotificationAlertContent($oKTNotification) . ''; + $str = '
+     '._kt('Subscription notification').': '.$this->_eventTypeNames[$info['event_type']].' +
+
+     '.$text.' +
+
+     '.$links.' +
+
'; return $str; } @@ -450,7 +611,7 @@ class SubscriptionContent { $oTemplate = $oTemplating->loadTemplate("kt3/notifications/subscriptions." . $info['event_type']); // if, for some reason, this doesn't actually work, use the "generic" title. if (PEAR::isError($oTemplate)) { - $oTemplate = $oTemplating->loadTemplate("kt3/notifications/subscriptions.generic"); + $oTemplate = $oTemplating->loadTemplate("kt3/notifications/subscriptions.generic"); } // FIXME we need to specify the i18n by user. @@ -487,7 +648,9 @@ class SubscriptionContent { function _getSubscriptionData($oKTNotification) { - $info = array( + $appName = APP_NAME; + + $info = array( 'object_name' => $oKTNotification->getLabel(), 'event_type' => $oKTNotification->getStrData1(), 'location_name' => $oKTNotification->getStrData2(), @@ -497,7 +660,9 @@ class SubscriptionContent { 'notify_id' => $oKTNotification->getId(), ); - $info['title'] = KTUtil::arrayGet($this->_eventTypeNames, $info['event_type'], 'Subscription alert:') .': ' . $info['object_name']; +// $info['title'] = KTUtil::arrayGet($this->_eventTypeNames, $info['event_type'], 'Subscription alert:') .': ' . $info['object_name']; + $info['title'] = $appName.': '._kt('Subscription notification for').' "'.$info['object_name'].'" - '.$this->_eventTypeNames[$info['event_type']]; + if ($info['actor_id'] !== null) { $oTempUser = User::get($info['actor_id']); diff --git a/plugins/ktstandard/KTEmail.php b/plugins/ktstandard/KTEmail.php index 8b0c581..8b9a358 100644 --- a/plugins/ktstandard/KTEmail.php +++ b/plugins/ktstandard/KTEmail.php @@ -140,6 +140,7 @@ function sendExternalEmails($aEmailAddresses, $iDocumentID, $sDocumentName, $sCo $oSendingUser = User::get($_SESSION['userID']); // Create email content +/* $sMessage = ''; $sMessage .= sprintf(_kt("Your colleague, %s, wishes you to view the document entitled '%s'."), $oSendingUser->getName(), $sDocumentName); $sMessage .= " \n"; @@ -148,6 +149,25 @@ function sendExternalEmails($aEmailAddresses, $iDocumentID, $sDocumentName, $sCo $sMsgEnd .= ''; $sTitle = sprintf(_kt("Link (ID %s): %s from %s"), $iDocumentID, $sDocumentName, $oSendingUser->getName()); +*/ + $sTitle = sprintf(_kt("%s wants to share a document using KnowledgeTree"), $oSendingUser->getName()); + + $sMessage = '
+     '._kt('Hello').', +
+
+     '.sprintf(_kt('A KnowledgeTree user, %s, wants to share a document with you entitled "%s".'), $oSendingUser->getName(), $sDocumentName).' +
+
+     '._kt('Message').': +
+
+     '.$sComment.' +
+
+     '._kt('KnowledgeTree is easy to use open source document management software
    that helps businesses collaborate, securely store all critical documents, address
    compliance challenges, and improve business processes.').' +
+
'; $sEmail = null; $sEmailFrom = null; @@ -172,9 +192,13 @@ function sendExternalEmails($aEmailAddresses, $iDocumentID, $sDocumentName, $sCo $oDownloadManager->set_session($session); $link = $oDownloadManager->allow_download($iDocumentID); - $link = "{$link}"; +// $link = "{$link}"; + $links = '    '._kt('Learn More').''; + $links.= " | "._kt('View Document').""; + $links .= ' | '._kt('Download Free Trial').'

'; - $sMsg = $sMessage.$link.$sMsgEnd; +// $sMsg = $sMessage.$link.$sMsgEnd; + $sMsg = $sMessage.$links; $res = $oEmail->send(array($sAddress), $sTitle, $sMsg); if (PEAR::isError($res)) { diff --git a/resources/css/kt-framing.css b/resources/css/kt-framing.css index 3c9f6da..bbf97bb 100644 --- a/resources/css/kt-framing.css +++ b/resources/css/kt-framing.css @@ -52,8 +52,8 @@ body min-height: 800px; min-width: 600px; height: auto; - background-image: url(../../resources/graphics/page_bg.png); - background-repeat: repeat-x; +/* background-image: url(../../resources/graphics/page_bg.png);*/ +/* background-repeat: repeat-x;*/ z-index: 1; } diff --git a/resources/graphics/ktlogo-topbar-right-transparent.png b/resources/graphics/ktlogo-topbar-right-transparent.png new file mode 100644 index 0000000..3340c89 --- /dev/null +++ b/resources/graphics/ktlogo-topbar-right-transparent.png diff --git a/templates/kt3/notifications/subscriptions.DownloadDocument.smarty b/templates/kt3/notifications/subscriptions.DownloadDocument.smarty new file mode 100644 index 0000000..9865c3c --- /dev/null +++ b/templates/kt3/notifications/subscriptions.DownloadDocument.smarty @@ -0,0 +1,27 @@ +
{$info.title|sanitize}
+
+ + + {i18n arg_object_name=$info.object_name|sanitize}The document "#object_name#" {/i18n}{if ($info.location_name !== null)} {i18n arg_location_name=$info.location_name}in the folder "#location_name#" has been downloaded {/i18n}{/if}{if ($info.has_actor)} {i18n arg_actor_name=$info.actor_name}by #actor_name#{/i18n}{/if}. +
+
+ {if !$is_broken} + {i18n}View Document{/i18n} + {else} + {i18n}Document is no longer available{/i18n} + {/if} + +  |  + +
+
+ + + {i18n}Clear Alert{/i18n} + + + +
+
+