diff --git a/config/config.ini b/config/config.ini index 2b7106a..8caffac 100644 --- a/config/config.ini +++ b/config/config.ini @@ -111,11 +111,9 @@ browseToUnitFolder = default [email] ; email settings -emailServer = localhost -emailFrom = kt@${serverName} +emailServer = none +emailFrom = kt@example.org emailFromName = KnowledgeTree Document Management System -emailAdmin = kt@${serverName} -emailAdminName = DMS Administrator ; Set to true to allow users to send attachments from the document ; management system allowAttachment = default diff --git a/lib/email/Email.inc b/lib/email/Email.inc index f2f1b53..ccf525d 100644 --- a/lib/email/Email.inc +++ b/lib/email/Email.inc @@ -52,6 +52,15 @@ class Email { $this->oMailer->WordWrap = 100; $this->oMailer->IsHTML(true); $this->oMailer->SetLanguage('en', KT_DIR . '/phpmailer/language/'); + $this->bEmailDisabled = false; + $oConfig =& KTConfig::getSingleton(); + $sEmailServer = $oConfig->get('email/emailServer'); + if ($sEmailServer == 'none') { + $this->bEmailDisabled = true; + } + if (empty($sEmailServer)) { + $this->bEmailDisabled = true; + } } /** @@ -65,6 +74,9 @@ class Email { * @return boolean true on email successfully sent, false otherwise and set $_SESSION["errorMessage"] */ function send($mToEmail, $sSubject, $sBody) { + if ($this->bEmailDisabled) { + return PEAR::raiseError(_kt("Email is not configured.")); + } global $default; if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || @@ -116,6 +128,9 @@ class Email { * @return boolean true on email successfully sent, false otherwise and set $_SESSION["errorMessage"] */ function sendAttachment($mToEmail, $sSubject, $sBody, $sDocumentPath, $sDocumentName) { + if ($this->bEmailDisabled) { + return PEAR::raiseError(_kt("Email is not configured.")); + } global $default; if ( (is_string($mToEmail) && (strlen($mToEmail) > 0)) || @@ -173,6 +188,9 @@ class Email { * @todo need to test this on multiple mail clients, not just Outlook */ function sendHyperLink($FromEmail, $FromName, $ToEmail, $Subj, $EmailBody, $hyperlink) { + if ($this->bEmailDisabled) { + return PEAR::raiseError(_kt("Email is not configured.")); + } global $default; //get info from relevant fields. @@ -205,6 +223,9 @@ class Email { * @todo need to test this on multiple mail clients, not just Outlook */ function sendHelpEmail($FromEmail, $FromName, $ToEmail, $Subj, $EmailBody, $hyperlink) { + if ($this->bEmailDisabled) { + return PEAR::raiseError(_kt("Email is not configured.")); + } global $default; //get info from relevant fields. @@ -223,6 +244,9 @@ class Email { } function sendEmail($FromEmail, $FromName, $ToEmail, $Subj, $EmailBody) { + if ($this->bEmailDisabled) { + return PEAR::raiseError(_kt("Email is not configured.")); + } global $default; //get info from relevant fields. diff --git a/plugins/ktcore/KTCorePlugin.php b/plugins/ktcore/KTCorePlugin.php index b27fe93..a27d8e9 100644 --- a/plugins/ktcore/KTCorePlugin.php +++ b/plugins/ktcore/KTCorePlugin.php @@ -73,6 +73,7 @@ class KTCorePlugin extends KTPlugin { $this->registerDashlet('KTNotificationDashlet', 'ktcore.dashlet.notifications', 'KTDashlets.php'); $this->registerDashlet('KTCheckoutDashlet', 'ktcore.dashlet.checkout', 'KTDashlets.php'); $this->registerDashlet('KTIndexerStatusDashlet', 'ktcore.dashlet.indexer_status', 'KTDashlets.php'); + $this->registerDashlet('KTMailServerDashlet', 'ktcore.dashlet.mail_server', 'KTDashlets.php'); $this->registerAdminPage('authentication', 'KTAuthenticationAdminPage', 'principals', _kt('Authentication'), _kt('By default, KnowledgeTree controls its own users and groups and stores all information about them inside the database. In many situations, an organisation will already have a list of users and groups, and needs to use that existing information to allow access to the DMS. These Authentication Sources allow the system administrator to specify additional sources of authentication data.'), 'authentication/authenticationadminpage.inc.php'); diff --git a/plugins/ktcore/KTDashlets.php b/plugins/ktcore/KTDashlets.php index 8e8ea69..4bf1e65 100644 --- a/plugins/ktcore/KTDashlets.php +++ b/plugins/ktcore/KTDashlets.php @@ -229,4 +229,29 @@ class KTIndexerStatusDashlet extends KTBaseDashlet { } } +// replace the old checked-out docs. +class KTMailServerDashlet extends KTBaseDashlet { + + function is_active($oUser) { + $oConfig =& KTConfig::getSingleton(); + $sEmailServer = $oConfig->get('email/emailServer'); + if ($sEmailServer == 'none') { + return true; + } + if (empty($sEmailServer)) { + return true; + } + return false; + } + + function render() { + $oTemplating =& KTTemplating::getSingleton(); + $oTemplate = $oTemplating->loadTemplate("ktcore/dashlets/mailserver"); + $aTemplateData = array( + "context" => $this, + ); + return $oTemplate->render($aTemplateData); + } +} + ?> diff --git a/templates/ktcore/dashlets/mailserver.smarty b/templates/ktcore/dashlets/mailserver.smarty new file mode 100644 index 0000000..a5830a3 --- /dev/null +++ b/templates/ktcore/dashlets/mailserver.smarty @@ -0,0 +1,12 @@ +

{i18n}Mail server status{/i18n}

+ +
+ +

{i18n}Email has not been configured on this server. Emailing of +documents and sending of notifications are disabled.{/i18n}

+ +{if $admin} +

{i18n}Edit the [email] section of the config.ini file to set your email +server and the sending address of the KnowledgeTree server.{/i18n}

+{/if} +