1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

Simplified admin->notify interface.

This commit is contained in:
CaMer0n
2008-04-26 14:34:17 +00:00
parent b248121505
commit 2960b6c3b9
2 changed files with 113 additions and 52 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/notify.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/notify.php,v $
| $Revision: 1.2 $ | $Revision: 1.3 $
| $Date: 2008-04-04 21:40:37 $ | $Date: 2008-04-26 14:34:17 $
| $Author: e107steved $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
require_once('../class2.php'); require_once('../class2.php');
@@ -25,12 +25,20 @@ if (!getperms('O')) {
$e_sub_cat = 'notify'; $e_sub_cat = 'notify';
require_once('auth.php'); require_once('auth.php');
require_once(e_HANDLER.'userclass_class.php'); require_once(e_HANDLER.'userclass_class.php');
require_once(e_HANDLER.'form_handler.php'); require_once(e_HANDLER.'form_handler.php');
$rs = new form; $rs = new form;
$nc = new notify_config; $nc = new notify_config;
if (isset($_POST['update'])) { $uc = new user_class;
$nc -> update();
$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,"<div style='text-align:center'>".$message."</div>");
} }
$nc -> config(); $nc -> config();
@@ -54,7 +62,7 @@ class notify_config {
require_once(e_PLUGIN.$val.'/e_notify.php'); require_once(e_PLUGIN.$val.'/e_notify.php');
foreach ($config_events as $event_id => $event_text) 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; $recalibrate = true;
} }
@@ -110,14 +118,16 @@ class notify_config {
$text .= $this -> render_event('fileupload', NF_LAN_2); $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')) if(is_readable(e_PLUGIN.$plugin_id.'/e_notify.php'))
{ {
require(e_PLUGIN.$plugin_id.'/e_notify.php'); require(e_PLUGIN.$plugin_id.'/e_notify.php');
$text .= "<tr> $text .= "<tr>
<td colspan='2' class='forumheader'>".$config_category."</td> <td colspan='2' class='forumheader'>".$config_category."</td>
</tr>"; </tr>";
foreach ($config_events as $event_id => $event_text) { foreach ($config_events as $event_id => $event_text)
{
$text .= $this -> render_event($event_id, $event_text); $text .= $this -> render_event($event_id, $event_text);
} }
} }
@@ -134,47 +144,67 @@ class notify_config {
} }
function render_event($id, $description) { function render_event($id, $description) {
global $rs, $tp; global $rs, $tp, $uc;
$text .= "<tr> $text .= "
<td class='forumheader3' style='width: 30%'> <tr>
".$description.": <td class='forumheader3' style='width: 40%'>".$description.": </td>
</td> <td class='forumheader3' style='width: 60%; white-space: nowrap'>
<td class='forumheader3' style='width: 70%; white-space: nowrap'> ".$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."');\" ");
<input type='radio' name='event[".$id."][type]' value='off' ".(($this -> notify_prefs['event'][$id]['type'] == 'off' || !$this -> notify_prefs['event'][$id]['type']) ? " checked='checked'" : "")." /> ".NT_LAN_3."
<input type='radio' name='event[".$id."][type]' value='main' ".($this -> notify_prefs['event'][$id]['type'] == 'main' ? " checked='checked'" : "")." /> ".NT_LAN_4." if($this -> notify_prefs['event'][$id]['class'] == 'email')
<input type='radio' name='event[".$id."][type]' value='class' ".($this -> 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')." $disp='display:visible';
<input type='radio' name='event[".$id."][type]' value='email' ".($this -> notify_prefs['event'][$id]['type'] == 'email' ? " checked='checked'" : "")." /> ".NT_LAN_6.": $value = $tp -> toForm($this -> notify_prefs['event'][$id]['email']);
".$rs -> form_text('event['.$id.'][email]', 40, $tp -> toForm($this -> notify_prefs['event'][$id]['email']), 150)." }
</td> else
{
$disp = "display:none'";
$value= "";
}
$text .= "<input type='text' style='width:180px;$disp' class='tbox' id='event_".$id."' name='event[".$id."][email]' value=\"".$value."\" />\n";
$text .= "</td>
</tr>"; </tr>";
return $text; return $text;
} }
function update() { function update() {
global $sql, $pref, $tp, $eArrayStorage; global $sql, $pref, $tp, $eArrayStorage;
foreach ($_POST['event'] as $key => $value) { foreach ($_POST['event'] as $key => $value)
if ($this -> update_event($key)) { {
if ($this -> update_event($key))
{
$active = TRUE; $active = TRUE;
} }
} }
if ($active)
{
$pref['notify'] = TRUE;
}
else
{
$pref['notify'] = FALSE;
}
save_prefs();
$s_prefs = $tp -> toDB($this -> notify_prefs); $s_prefs = $tp -> toDB($this -> notify_prefs);
$s_prefs = $eArrayStorage -> WriteArray($s_prefs); $s_prefs = $eArrayStorage -> WriteArray($s_prefs);
$sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'"); if($sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'")!==FALSE)
if ($active) { {
$pref['notify'] = TRUE; return TRUE;
} else {
$pref['notify'] = FALSE;
} }
save_prefs(); else
{
return FALSE;
}
} }
function update_event($id) { 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']; $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; return TRUE;
} else { } else {
return FALSE; return FALSE;
@@ -183,5 +213,26 @@ class notify_config {
} }
require_once('footer.php'); require_once('footer.php');
function headerjs()
{
$js = "
<script type='text/javascript'>
function mail_field(val,id)
{
if(val == 'email')
{
document.getElementById(id).style.display ='';
}
else
{
document.getElementById(id).style.display ='none';
}
}
</script>";
return $js;
}
?> ?>

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/notify_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/notify_class.php,v $
| $Revision: 1.2 $ | $Revision: 1.3 $
| $Date: 2007-03-22 21:26:14 $ | $Date: 2008-04-26 14:34:17 $
| $Author: e107steved $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -23,41 +23,51 @@ class notify {
var $notify_prefs; var $notify_prefs;
function notify() { function notify()
{
global $sysprefs, $e_event, $eArrayStorage; global $sysprefs, $e_event, $eArrayStorage;
$this -> notify_prefs = $sysprefs -> get('notify_prefs'); $this -> notify_prefs = $sysprefs -> get('notify_prefs');
$this -> notify_prefs = $eArrayStorage -> ReadArray($this -> notify_prefs); $this -> notify_prefs = $eArrayStorage -> ReadArray($this -> notify_prefs);
foreach ($this -> notify_prefs['event'] as $id => $status) { foreach ($this -> notify_prefs['event'] as $id => $status)
if ($status['type'] != 'off') { {
if ($status['class'] != 255)
{
$e_event -> register($id, 'notify_'.$id); $e_event -> register($id, 'notify_'.$id);
} }
} }
if(defined("e_LANGUAGE") && is_readable(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php')) { include_lan(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');
}
} }
function send($id, $subject, $message) { function send($id, $subject, $message) {
global $sql,$tp; global $sql,$tp;
e107_require_once(e_HANDLER.'mail.php'); e107_require_once(e_HANDLER.'mail.php');
$subject = SITENAME.': '.$subject; $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)); 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"); $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 if ($this -> notify_prefs['event'][$id]['class'] == '253')
} else { {
$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)); 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)); sendemail($this -> notify_prefs['event'][$id]['email'], $tp->toEmail($subject), $tp->toEmail($message));
} }
} }