From 1c428e1d5a423249ae35669df51dbd57ac4a3e06 Mon Sep 17 00:00:00 2001 From: mcfly Date: Sun, 21 Dec 2008 18:15:04 +0000 Subject: [PATCH] Reformat of code, small changes --- e107_handlers/notify_class.php | 130 ++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 58 deletions(-) diff --git a/e107_handlers/notify_class.php b/e107_handlers/notify_class.php index 64312d7f8..6382e044d 100644 --- a/e107_handlers/notify_class.php +++ b/e107_handlers/notify_class.php @@ -1,82 +1,85 @@ notify_prefs = $sysprefs -> get('notify_prefs'); - $this -> notify_prefs = $eArrayStorage -> ReadArray($this -> notify_prefs); - foreach ($this -> notify_prefs['event'] as $id => $status) + $this->notify_prefs = $sysprefs->get('notify_prefs'); + $this->notify_prefs = $eArrayStorage->ReadArray($this->notify_prefs); + foreach ($this->notify_prefs['event'] as $id => $status) { if ($status['class'] != 255) { - $e_event -> register($id, 'notify_'.$id); + $e_event->register($id, 'notify_'.$id); } } include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php'); } - function send($id, $subject, $message) { + function send($id, $subject, $message) + { global $sql,$tp; e107_require_once(e_HANDLER.'mail.php'); $subject = SITENAME.': '.$subject; - if ($this -> notify_prefs['event'][$id]['class'] == 250) + if ($this->notify_prefs['event'][$id]['class'] == 250) { sendemail(SITEADMINEMAIL, $tp->toEmail($subject), $tp->toEmail($message)); } else if (is_numeric($this -> notify_prefs['event'][$id]['class'])) { - if ($this -> notify_prefs['event'][$id]['class'] == '254') + if ($this->notify_prefs['event'][$id]['class'] == '254') { - $sql -> db_Select('user', 'user_email', "user_admin = 1"); + $sql->db_Select('user', 'user_email', "user_admin = 1"); } - else if ($this -> notify_prefs['event'][$id]['class'] == '253') + else if ($this->notify_prefs['event'][$id]['class'] == '253') { - $sql -> db_Select('user', 'user_email',"user_ban= 0 "); + $sql->db_Select('user', 'user_email',"user_ban= 0 "); } else { - $sql -> db_Select('user', 'user_email', "user_class REGEXP '(^|,)(".$this -> notify_prefs['event'][$id]['class'].")(,|$)'"); + $sql->db_Select('user', 'user_email', "user_class REGEXP '(^|,)(".$this->notify_prefs['event'][$id]['class'].")(,|$)'"); } - while ($email = $sql -> db_Fetch()) + while ($email = $sql->db_Fetch()) { sendemail($email['user_email'], $tp->toEmail($subject), $tp->toEmail($message)); } } - else if ($this -> notify_prefs['event'][$id]['class'] == 'email') + else if ($this->notify_prefs['event'][$id]['class'] == 'email') { - sendemail($this -> notify_prefs['event'][$id]['email'], $tp->toEmail($subject), $tp->toEmail($message)); + sendemail($this->notify_prefs['event'][$id]['email'], $tp->toEmail($subject), $tp->toEmail($message)); } } } -global $nt; -$nt = new notify; -function notify_usersup($data) { +global $nt; +$e107->notify = new notify; +$nt = &$e107->notify; + + +function notify_usersup($data) +{ global $nt; foreach ($data as $key => $value) { @@ -84,9 +87,9 @@ function notify_usersup($data) { { if(is_array($value)) // show user-extended values. { - foreach($value as $k => $v) + foreach($value as $k => $v) { - $message .= str_replace("user_","",$k).': '.$v.'
'; + $message .= str_replace("user_","",$k).': '.$v.'
'; } } else @@ -95,69 +98,80 @@ function notify_usersup($data) { } } } - $nt -> send('usersup', NT_LAN_US_1, $message); + $nt->send('usersup', NT_LAN_US_1, $message); } -function notify_userveri($data) { +function notify_userveri($data) +{ global $nt, $e107; $msgtext = NT_LAN_UV_2.$data['user_id']."\n"; $msgtext .= NT_LAN_UV_3.$data['user_loginname']."\n"; $msgtext .= NT_LAN_UV_4.$e107->getip(); - $nt -> send('userveri', NT_LAN_UV_1, $msgtext); + $nt->send('userveri', NT_LAN_UV_1, $msgtext); } -function notify_login($data) { +function notify_login($data) +{ global $nt; foreach ($data as $key => $value) { $message .= $key.': '.$value.'
'; } - $nt -> send('login', NT_LAN_LI_1, $message); + $nt->send('login', NT_LAN_LI_1, $message); } -function notify_logout() { +function notify_logout() +{ global $nt; - $nt -> send('logout', NT_LAN_LO_1, USERID.'. '.USERNAME.' '.NT_LAN_LO_2); + $nt->send('logout', NT_LAN_LO_1, USERID.'. '.USERNAME.' '.NT_LAN_LO_2); } -function notify_flood($data) { +function notify_flood($data) +{ global $nt; - $nt -> send('flood', NT_LAN_FL_1, NT_LAN_FL_2.': '.$data); + $nt->send('flood', NT_LAN_FL_1, NT_LAN_FL_2.': '.$data); } -function notify_subnews($data) { +function notify_subnews($data) +{ global $nt,$tp; foreach ($data as $key => $value) { $message .= $key.': '.$value.'
'; } - $nt -> send('subnews', NT_LAN_SN_1, $message); + $nt->send('subnews', NT_LAN_SN_1, $message); } -function notify_newspost($data) { +function notify_newspost($data) +{ global $nt; $message = ''.$data['news_title'].'

'.$data['news_summary'].'

'.$data['data'].'

'.$data['news_extended']; - $nt -> send('newspost', $data['news_title'], $message); + $nt->send('newspost', $data['news_title'], $message); } -function notify_newsupd($data) { +function notify_newsupd($data) +{ global $nt; $message = ''.$data['news_title'].'

'.$data['news_summary'].'

'.$data['data'].'

'.$data['news_extended']; - $nt -> send('newsupd', NT_LAN_NU_1.': '.$data['news_title'], $message); + $nt->send('newsupd', NT_LAN_NU_1.': '.$data['news_title'], $message); } -function notify_newsdel($data) { +function notify_newsdel($data) +{ global $nt; - $nt -> send('newsdel', NT_LAN_ND_1, NT_LAN_ND_2.': '.$data); + $nt->send('newsdel', NT_LAN_ND_1, NT_LAN_ND_2.': '.$data); } -function notify_fileupload($data) { +function notify_fileupload($data) +{ global $nt; $message = ''.$data['upload_name'].'

'.$data['upload_description'].'

'.$data['upload_size'].'

'.$data['upload_user']; - $nt -> send('fileupload', $data['upload_name'], $message); + $nt->send('fileupload', $data['upload_name'], $message); } -if (isset($nt -> notify_prefs['plugins'])) { - foreach ($nt -> notify_prefs['plugins'] as $plugin_id => $plugin_settings) { +if (isset($nt->notify_prefs['plugins'])) +{ + foreach ($nt->notify_prefs['plugins'] as $plugin_id => $plugin_settings) + { if(is_readable(e_PLUGIN.$plugin_id.'/e_notify.php')) { require_once(e_PLUGIN.$plugin_id.'/e_notify.php'); @@ -165,4 +179,4 @@ if (isset($nt -> notify_prefs['plugins'])) { } } -?> +?> \ No newline at end of file