diff --git a/e107_admin/notify.php b/e107_admin/notify.php index 1829cab9f..0324880ea 100644 --- a/e107_admin/notify.php +++ b/e107_admin/notify.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/notify.php,v $ -| $Revision: 1.2 $ -| $Date: 2008-04-04 21:40:37 $ -| $Author: e107steved $ +| $Revision: 1.3 $ +| $Date: 2008-04-26 14:34:17 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ require_once('../class2.php'); @@ -25,12 +25,20 @@ if (!getperms('O')) { $e_sub_cat = 'notify'; require_once('auth.php'); + require_once(e_HANDLER.'userclass_class.php'); require_once(e_HANDLER.'form_handler.php'); $rs = new form; $nc = new notify_config; -if (isset($_POST['update'])) { - $nc -> update(); +$uc = new user_class; + +$uc->fixed_classes['email'] = 'Email Address =>'; +$uc->text_class_link['email'] = 'email'; + +if (isset($_POST['update'])) +{ + $message = ($nc -> update()) ? LAN_UPDATED : LAN_UPDATED_FAILED; + $ns -> tablerender($message,"
".$message."
"); } $nc -> config(); @@ -54,7 +62,7 @@ class notify_config { require_once(e_PLUGIN.$val.'/e_notify.php'); foreach ($config_events as $event_id => $event_text) { - $this -> notify_prefs['event'][$event_id] = array('type' => 'off', 'class' => '254', 'email' => ''); + $this -> notify_prefs['event'][$event_id] = array('class' => '255', 'email' => ''); } $recalibrate = true; } @@ -110,14 +118,16 @@ class notify_config { $text .= $this -> render_event('fileupload', NF_LAN_2); - foreach ($this -> notify_prefs['plugins'] as $plugin_id => $plugin_settings) { + foreach ($this -> notify_prefs['plugins'] as $plugin_id => $plugin_settings) + { if(is_readable(e_PLUGIN.$plugin_id.'/e_notify.php')) { require(e_PLUGIN.$plugin_id.'/e_notify.php'); $text .= " ".$config_category." "; - foreach ($config_events as $event_id => $event_text) { + foreach ($config_events as $event_id => $event_text) + { $text .= $this -> render_event($event_id, $event_text); } } @@ -134,47 +144,67 @@ class notify_config { } function render_event($id, $description) { - global $rs, $tp; - $text .= " - - ".$description.": - - - notify_prefs['event'][$id]['type'] == 'off' || !$this -> notify_prefs['event'][$id]['type']) ? " checked='checked'" : "")." /> ".NT_LAN_3." - notify_prefs['event'][$id]['type'] == 'main' ? " checked='checked'" : "")." /> ".NT_LAN_4." - notify_prefs['event'][$id]['type'] == 'class' ? " checked='checked'" : "")." /> ".NT_LAN_5.": - ".r_userclass('event['.$id.'][class]', $this -> notify_prefs['event'][$id]['class'], 'off', 'member,admin,classes')." - notify_prefs['event'][$id]['type'] == 'email' ? " checked='checked'" : "")." /> ".NT_LAN_6.": - ".$rs -> form_text('event['.$id.'][email]', 40, $tp -> toForm($this -> notify_prefs['event'][$id]['email']), 150)." - + global $rs, $tp, $uc; + $text .= " + + ".$description.": + + ".$uc->uc_dropdown('event['.$id.'][class]', $this -> notify_prefs['event'][$id]['class'],"nobody,main,admin,member,classes,email","onchange=\"mail_field(this.value,'event_".$id."');\" "); + + if($this -> notify_prefs['event'][$id]['class'] == 'email') + { + $disp='display:visible'; + $value = $tp -> toForm($this -> notify_prefs['event'][$id]['email']); + } + else + { + $disp = "display:none'"; + $value= ""; + } + + $text .= "\n"; + + $text .= " "; return $text; } function update() { global $sql, $pref, $tp, $eArrayStorage; - foreach ($_POST['event'] as $key => $value) { - if ($this -> update_event($key)) { + foreach ($_POST['event'] as $key => $value) + { + if ($this -> update_event($key)) + { $active = TRUE; } } - + if ($active) + { + $pref['notify'] = TRUE; + } + else + { + $pref['notify'] = FALSE; + } + save_prefs(); $s_prefs = $tp -> toDB($this -> notify_prefs); $s_prefs = $eArrayStorage -> WriteArray($s_prefs); - $sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'"); - if ($active) { - $pref['notify'] = TRUE; - } else { - $pref['notify'] = FALSE; + if($sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'")!==FALSE) + { + return TRUE; } - save_prefs(); + else + { + return FALSE; + } + } function update_event($id) { - $this -> notify_prefs['event'][$id]['type'] = $_POST['event'][$id]['type']; - $this -> notify_prefs['event'][$id]['class'] = $_POST['event'][$id]['class']; + + $this -> notify_prefs['event'][$id]['class'] = $_POST['event'][$id]['class']; $this -> notify_prefs['event'][$id]['email'] = $_POST['event'][$id]['email']; - if ($this -> notify_prefs['event'][$id]['type'] != 'off') { + if ($this -> notify_prefs['event'][$id]['class'] != 255) { return TRUE; } else { return FALSE; @@ -183,5 +213,26 @@ class notify_config { } require_once('footer.php'); +function headerjs() +{ + $js = " + "; + + return $js; +} ?> diff --git a/e107_handlers/notify_class.php b/e107_handlers/notify_class.php index 489626519..64312d7f8 100644 --- a/e107_handlers/notify_class.php +++ b/e107_handlers/notify_class.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/notify_class.php,v $ -| $Revision: 1.2 $ -| $Date: 2007-03-22 21:26:14 $ -| $Author: e107steved $ +| $Revision: 1.3 $ +| $Date: 2008-04-26 14:34:17 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -23,41 +23,51 @@ class notify { var $notify_prefs; - function notify() { + function notify() + { global $sysprefs, $e_event, $eArrayStorage; $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['type'] != 'off') { + foreach ($this -> notify_prefs['event'] as $id => $status) + { + if ($status['class'] != 255) + { $e_event -> register($id, 'notify_'.$id); } } - if(defined("e_LANGUAGE") && is_readable(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php')) { - include_once(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php'); - } else { - include_once(e_LANGUAGEDIR.'English/lan_notify.php'); - } + include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php'); } function send($id, $subject, $message) { global $sql,$tp; e107_require_once(e_HANDLER.'mail.php'); $subject = SITENAME.': '.$subject; - if ($this -> notify_prefs['event'][$id]['type'] == 'main') { + if ($this -> notify_prefs['event'][$id]['class'] == 250) + { sendemail(SITEADMINEMAIL, $tp->toEmail($subject), $tp->toEmail($message)); - } else if ($this -> notify_prefs['event'][$id]['type'] == 'class') { - if ($this -> notify_prefs['event'][$id]['class'] == '254') { + } + else if (is_numeric($this -> notify_prefs['event'][$id]['class'])) + { + if ($this -> notify_prefs['event'][$id]['class'] == '254') + { $sql -> db_Select('user', 'user_email', "user_admin = 1"); - } else if ($this -> notify_prefs['event'][$id]['class'] == '253') { - $sql -> db_Select('user', 'user_email'); - } else { + } + else if ($this -> notify_prefs['event'][$id]['class'] == '253') + { + $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'].")(,|$)'"); } - 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]['type'] == 'email') { + } + else if ($this -> notify_prefs['event'][$id]['class'] == 'email') + { sendemail($this -> notify_prefs['event'][$id]['email'], $tp->toEmail($subject), $tp->toEmail($message)); } }