added version

This commit is contained in:
Ralf Becker 2008-07-30 06:49:55 +00:00
parent a17e5ebad0
commit 72e99175e9
2 changed files with 26 additions and 24 deletions

View File

@ -7,6 +7,7 @@
* @subpackage backends * @subpackage backends
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Christian Binder <christian@jaytraxx.de> * @author Christian Binder <christian@jaytraxx.de>
* @version $Id$
*/ */
/** /**
@ -18,28 +19,28 @@ class notifications_email implements notifications_iface {
* Appname * Appname
*/ */
const _appname = 'notifications'; const _appname = 'notifications';
/** /**
* holds account object for user who sends the message * holds account object for user who sends the message
* *
* @var object * @var object
*/ */
private $sender; private $sender;
/** /**
* holds account object for user to notify * holds account object for user to notify
* *
* @var object * @var object
*/ */
private $recipient; private $recipient;
/** /**
* holds config object (sitewide application config) * holds config object (sitewide application config)
* *
* @var object * @var object
*/ */
private $config; private $config;
/** /**
* holds preferences object of user to notify * holds preferences object of user to notify
* *
@ -53,7 +54,7 @@ class notifications_email implements notifications_iface {
* @var object * @var object
*/ */
private $mail; private $mail;
/** /**
* constructor of notifications_email * constructor of notifications_email
* *
@ -74,7 +75,7 @@ class notifications_email implements notifications_iface {
$this->mail = new send(); $this->mail = new send();
} }
} }
/** /**
* sends notification * sends notification
* *
@ -86,7 +87,7 @@ class notifications_email implements notifications_iface {
public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) { public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) {
$body_plain = $_messages['plain'].$this->render_links($_links, false, $this->preferences->external_mailclient); $body_plain = $_messages['plain'].$this->render_links($_links, false, $this->preferences->external_mailclient);
$body_html = "<html><body>\n".$_messages['html'].$this->render_links($_links, true, $this->preferences->external_mailclient)."</body>\n</html>\n"; $body_html = "<html><body>\n".$_messages['html'].$this->render_links($_links, true, $this->preferences->external_mailclient)."</body>\n</html>\n";
$this->mail->ClearAddresses(); $this->mail->ClearAddresses();
$this->mail->ClearAttachments(); $this->mail->ClearAttachments();
$this->mail->IsHTML(true); $this->mail->IsHTML(true);
@ -106,7 +107,7 @@ class notifications_email implements notifications_iface {
throw new Exception("Failed sending notification message via email.$error"); throw new Exception("Failed sending notification message via email.$error");
} }
} }
/** /**
* renders plaintext/html links from given link array * renders plaintext/html links from given link array
* *
@ -117,14 +118,14 @@ class notifications_email implements notifications_iface {
*/ */
private function render_links($_links = false, $_render_html = false, $_render_external = true) { private function render_links($_links = false, $_render_html = false, $_render_external = true) {
if(!is_array($_links) || count($_links) == 0) { return false; } if(!is_array($_links) || count($_links) == 0) { return false; }
// provide defaults if given arguments are null // provide defaults if given arguments are null
// php distinguishes between missing and present(null) arguments // php distinguishes between missing and present(null) arguments
if(is_null($_render_html)) { $_render_html = false; } if(is_null($_render_html)) { $_render_html = false; }
if(is_null($_render_external)) { $_render_external = true; } if(is_null($_render_external)) { $_render_external = true; }
$newline = $_render_html ? "<br />" : "\n"; $newline = $_render_html ? "<br />" : "\n";
$hruler = $_render_html ? html::hr() : ''; $hruler = $_render_html ? html::hr() : '';
$rendered_links = array(); $rendered_links = array();
foreach($_links as $link) { foreach($_links as $link) {
if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; } if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }

View File

@ -7,6 +7,7 @@
* @subpackage backends * @subpackage backends
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Christian Binder <christian@jaytraxx.de> * @author Christian Binder <christian@jaytraxx.de>
* @version $Id$
*/ */
/** /**
@ -18,44 +19,44 @@ class notifications_winpopup implements notifications_iface {
* Appname * Appname
*/ */
const _appname = 'notifications'; const _appname = 'notifications';
/** /**
* Login table in SQL database * Login table in SQL database
*/ */
const _login_table = 'egw_access_log'; const _login_table = 'egw_access_log';
/** /**
* holds account object for user who sends the message * holds account object for user who sends the message
* *
* @var object * @var object
*/ */
private $sender; private $sender;
/** /**
* holds account object for user to notify * holds account object for user to notify
* *
* @var object * @var object
*/ */
private $recipient; private $recipient;
/** /**
* holds config object (sitewide application config) * holds config object (sitewide application config)
* *
* @var object * @var object
*/ */
private $config; private $config;
/** /**
* holds preferences object of user to notify * holds preferences object of user to notify
* *
* @var object * @var object
*/ */
private $preferences; private $preferences;
/** /**
* holds the netbios command to be executed on notification * holds the netbios command to be executed on notification
* *
* @abstract * @abstract
* Example: $netbios_command = "/bin/echo [MESSAGE] | /usr/bin/smbclient -M computer-[4] -I [IP] -U [SENDER]"; * Example: $netbios_command = "/bin/echo [MESSAGE] | /usr/bin/smbclient -M computer-[4] -I [IP] -U [SENDER]";
* *
* Placeholders are: * Placeholders are:
@ -68,7 +69,7 @@ class notifications_winpopup implements notifications_iface {
* @var string * @var string
*/ */
private $netbios_command = "/bin/echo [MESSAGE] >> /Users/jaytraxx/winpopup.out"; private $netbios_command = "/bin/echo [MESSAGE] >> /Users/jaytraxx/winpopup.out";
/** /**
* constructor of notifications_winpopup * constructor of notifications_winpopup
* *
@ -90,7 +91,7 @@ class notifications_winpopup implements notifications_iface {
$this->config = $_config; $this->config = $_config;
$this->preferences = $_preferences; $this->preferences = $_preferences;
} }
/** /**
* sends notification * sends notification
* *
@ -110,11 +111,11 @@ class notifications_winpopup implements notifications_iface {
} }
} }
if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup"); if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions ); $this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
return true; return true;
} }
/** /**
* sends the winpopup message via command line string netbios_command specified above * sends the winpopup message via command line string netbios_command specified above
* *
@ -144,7 +145,7 @@ class notifications_winpopup implements notifications_iface {
} }
} }
} }
/** /**
* checks for a valid IPv4-address without CIDR notation * checks for a valid IPv4-address without CIDR notation
* *
@ -154,7 +155,7 @@ class notifications_winpopup implements notifications_iface {
private function valid_ip($_ip) { private function valid_ip($_ip) {
return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip); return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
} }
/** /**
* renders additional info from subject * renders additional info from subject
* *
@ -162,7 +163,7 @@ class notifications_winpopup implements notifications_iface {
* @return plain rendered info as complete string * @return plain rendered info as complete string
*/ */
private function render_infos($_subject = false) { private function render_infos($_subject = false) {
$newline = "\n"; $newline = "\n";
if(!empty($_subject)) { return $_subject.$newline; } if(!empty($_subject)) { return $_subject.$newline; }
return false; return false;
} }