1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +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).
|
| $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,"<div style='text-align:center'>".$message."</div>");
}
$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 .= "<tr>
<td colspan='2' class='forumheader'>".$config_category."</td>
</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);
}
}
@@ -134,47 +144,67 @@ class notify_config {
}
function render_event($id, $description) {
global $rs, $tp;
$text .= "<tr>
<td class='forumheader3' style='width: 30%'>
".$description.":
</td>
<td class='forumheader3' style='width: 70%; white-space: nowrap'>
<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."
<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')."
<input type='radio' name='event[".$id."][type]' value='email' ".($this -> 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)."
</td>
global $rs, $tp, $uc;
$text .= "
<tr>
<td class='forumheader3' style='width: 40%'>".$description.": </td>
<td class='forumheader3' style='width: 60%; 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."');\" ");
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 .= "<input type='text' style='width:180px;$disp' class='tbox' id='event_".$id."' name='event[".$id."][email]' value=\"".$value."\" />\n";
$text .= "</td>
</tr>";
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 = "
<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).
|
| $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));
}
}