Commit b2f76da6456974e33b0e27cb221e4d0b3f454285
1 parent
763d526d
added contructor and send method
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@901 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
36 additions
and
7 deletions
lib/subscriptions/alert/EmailAlert.inc
| 1 | 1 | <?php |
| 2 | -require_once("$default->owl_fs_root/lib/users/User.inc"); | |
| 3 | -require_once("$default->owl_fs_root/lib/documentmanagement/Document.inc"); | |
| 4 | -require_once("$default->owl_fs_root/lib/foldermanagement/Folder.inc"); | |
| 5 | -require_once("$default->owl_fs_root/lib/subscriptions/DocumentSubscription.inc"); | |
| 6 | -require_once("$default->owl_fs_root/lib/subscriptions/FolderSubscription.inc"); | |
| 7 | 2 | require_once("$default->owl_fs_root/lib/email/Email.inc"); |
| 8 | 3 | |
| 9 | 4 | /** |
| 10 | 5 | * |
| 11 | 6 | * $Id$ |
| 12 | 7 | * |
| 13 | - * Facilitates adding and removing file and folder subscriptions. | |
| 8 | + * Sends an email (subscription) alert. | |
| 14 | 9 | * |
| 15 | 10 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 16 | 11 | * |
| ... | ... | @@ -20,5 +15,39 @@ require_once("$default->owl_fs_root/lib/email/Email.inc"); |
| 20 | 15 | * @package lib.subscriptions.alert |
| 21 | 16 | */ |
| 22 | 17 | class EmailAlert { |
| 23 | - function EmailAlert($sAddress, $sContent) {} | |
| 18 | + var $sAddress; | |
| 19 | + var $sSubject; | |
| 20 | + var $sContent; | |
| 21 | + var $oEmail; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * Default constructor | |
| 25 | + * | |
| 26 | + * @param string the address to send the email alert to | |
| 27 | + * @param string the email subject | |
| 28 | + * @param string the content to send. | |
| 29 | + */ | |
| 30 | + function EmailAlert($sAddress, $sSubject, $sContent) { | |
| 31 | + $this->sAddress = $sAddress; | |
| 32 | + $this->sSubject = $sSubject; | |
| 33 | + $this->sContent = $sContent; | |
| 34 | + $this->oEmail= new Email(); | |
| 35 | + } | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * Sends the email. | |
| 39 | + * | |
| 40 | + * @return true on successful email send, false otherwise. | |
| 41 | + */ | |
| 42 | + function send() { | |
| 43 | + global $default; | |
| 44 | + | |
| 45 | + if ($this->oEmail->send($this->sAddress, $this->sSubject, $this->sContent)) { | |
| 46 | + $default->log->debug("EmailAlert::EmailAlert successfully sent email to $this->sAddress"); | |
| 47 | + return true; | |
| 48 | + } else { | |
| 49 | + $default->log->error("EmailAlert::EmailAlert failed sending email to $this->sAddress, text=$this->sContent"); | |
| 50 | + return false; | |
| 51 | + } | |
| 52 | + } | |
| 24 | 53 | } | ... | ... |