1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Notifications were failing under some circumstance. 'Email address' option now working again.

This commit is contained in:
Cameron
2015-03-07 16:30:46 -08:00
parent 3134d75d00
commit 1e5ab81afe
3 changed files with 76 additions and 47 deletions

View File

@@ -669,10 +669,9 @@ $override = e107::getSingleton('override', true); //TODO - find & replace $overr
$e_userclass = e107::getUserClass(); //TODO - find & replace $e_userclass, $e107->user_class $e_userclass = e107::getUserClass(); //TODO - find & replace $e_userclass, $e107->user_class
if(!empty($pref['notify']))
{ e107::getNotify()->registerEvents();
e107::getNotify()->registerEvents();
}
// //
// O: Start user session // O: Start user session

View File

@@ -36,8 +36,7 @@ $nc = new notify_config;
$uc = new user_class; $uc = new user_class;
$mes = e107::getMessage(); $mes = e107::getMessage();
$uc->fixed_classes['email'] = 'Email Address =>';
$uc->text_class_link['email'] = 'email';
if (isset($_POST['update'])) if (isset($_POST['update']))
{ {
@@ -69,18 +68,14 @@ class notify_config
function __construct() function __construct()
{ {
$ns = e107::getRender();
$tp = e107::getParser();
$pref = e107::getPref(); $pref = e107::getPref();
$sql = e107::getDb();
$this->notify_prefs = e107::getConfig('notify')->getPref(); $this->notify_prefs = e107::getConfig('notify')->getPref();
$this->prefCleanup();
// print_a($this->notify_prefs); $this->prefCleanup();
$this->test();
$recalibrate = FALSE; $recalibrate = FALSE;
// load every e_notify.php file. // load every e_notify.php file.
if($pref['e_notify_list']) if($pref['e_notify_list'])
{ {
@@ -156,7 +151,19 @@ class notify_config
} }
function test()
{
if(!empty($_POST['test']))
{
$id = key( $_POST['test']);
$exampleData = array('id'=>'Test for '.$id, 'data'=>'example data' );
e107::getMessage()->addSuccess('Triggering: '.$id);
e107::getEvent()->trigger($id, $exampleData);
}
}
@@ -389,7 +396,10 @@ class notify_config
{ {
$tp = e107::getParser(); $tp = e107::getParser();
$frm = e107::getForm(); $frm = e107::getForm();
$uc = e107::getUserClass(); $uc = e107::getUserClass();
$uc->fixed_classes['email'] = 'Email Address =>';
$uc->text_class_link['email'] = 'email';
if(defined($description)) if(defined($description))
{ {
@@ -401,7 +411,7 @@ class notify_config
<tr> <tr>
<td title='".$id."'>".$description.": </td> <td title='".$id."'>".$description.": </td>
<td class='form-inline nowrap'> <td class='form-inline nowrap'>
".$uc->uc_dropdown('event['.$id.'][class]', varset($this->notify_prefs['event'][$id]['class'],255), "nobody,main,admin,member,classes,email","onchange=\"mail_field(this.value,'event_".$id."');\" "); ".$uc->uc_dropdown('event['.$id.'][class]', varset($this->notify_prefs['event'][$id]['class'], e_UC_NOBODY), "nobody,main,admin,member,classes,email","onchange=\"mail_field(this.value,'event_".$id."');\" ");
if($this -> notify_prefs['event'][$id]['class'] == 'email') if($this -> notify_prefs['event'][$id]['class'] == 'email')
{ {
@@ -419,6 +429,12 @@ class notify_config
$text .= $frm->hidden("event[".$id."][include]", $include); $text .= $frm->hidden("event[".$id."][include]", $include);
$text .= $frm->hidden("event[".$id."][legacy]", $legacy); // function or method $text .= $frm->hidden("event[".$id."][legacy]", $legacy); // function or method
if($this->notify_prefs['event'][$id]['class'] != e_UC_NOBODY)
{
$text .= $frm->button('test['.$id.']', $id, 'confirm', 'Test');
}
$text .= "</td> $text .= "</td>
</tr>"; </tr>";
return $text; return $text;
@@ -427,41 +443,35 @@ class notify_config
function update() function update()
{ {
global $sql, $pref, $eArrayStorage;
$this->changeList = array(); $this->changeList = array();
$active = false;
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();
// print_a($this->notify_prefs); // print_a($this->notify_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);
if($sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'")!==FALSE) if($sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'")!==FALSE)
*/ */
e107::getConfig()->set('notify',$active)->save(true,true,false);
e107::getConfig('notify')->updatePref($this->notify_prefs); e107::getConfig('notify')->updatePref($this->notify_prefs);
if (e107::getConfig('notify')->save(FALSE)) if (e107::getConfig('notify')->save(FALSE))
{ {
// e107::getAdminLog()->logArrayAll('NOTIFY_01',$this->changeList); // e107::getAdminLog()->logArrayAll('NOTIFY_01',$this->changeList);
return TRUE; return true;
} }
else else
{ {
return FALSE; return false;
} }
} }

View File

@@ -24,6 +24,12 @@ class notify
function __construct() function __construct()
{ {
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php'); include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php');
if(empty($this->notify_prefs))
{
$this->notify_prefs = e107::getConfig('notify')->getPref();
}
} }
@@ -32,9 +38,15 @@ class notify
*/ */
public function registerEvents() public function registerEvents()
{ {
$e_event = e107::getEvent(); $active = e107::getConfig()->get('notify');
$this->notify_prefs = e107::getConfig('notify')->getPref(); if(empty($active))
{
e107::getMessage()->addDebug('Notify is disabled!');
return false;
}
$e_event = e107::getEvent();
if(varset($this->notify_prefs['event'])) if(varset($this->notify_prefs['event']))
{ {
@@ -91,6 +103,7 @@ class notify
/** /**
* Send an email notification following an event. * Send an email notification following an event.
* *
@@ -106,16 +119,7 @@ class notify
*/ */
function send($id, $subject, $message) function send($id, $subject, $message)
{ {
if(E107_DEBUG_LEVEL > 0)
{
$data = array('id'=>$id, 'subject'=>$subject, 'message'=>$message);
e107::getLog()->add('Notify Debug', $data, E_LOG_INFORMATIVE, "NOTIFY_DBG");
return;
}
$e107 = e107::getInstance();
$tp = e107::getParser(); $tp = e107::getParser();
$sql = e107::getDb(); $sql = e107::getDb();
@@ -130,8 +134,8 @@ class notify
$blockOriginator = FALSE; // TODO: set this using a pref $blockOriginator = FALSE; // TODO: set this using a pref
$recipients = array(); $recipients = array();
if ($notifyTarget == 'email') if ($notifyTarget == 'email') // Single email address - that can always go immediately
{ // Single email address - that can always go immediately {
if (!$blockOriginator || ($this->notify_prefs['event'][$id]['email'] != USEREMAIL)) if (!$blockOriginator || ($this->notify_prefs['event'][$id]['email'] != USEREMAIL))
{ {
$recipients[] = array( $recipients[] = array(
@@ -161,7 +165,7 @@ class notify
{ {
$qry .= ' AND `user_id` != '.USERID; $qry .= ' AND `user_id` != '.USERID;
} }
if (FALSE !== ($count = $sql->gen($qry))) if (false !== ($count = $sql->gen($qry)))
{ {
// Now add email addresses to the list // Now add email addresses to the list
while ($row = $sql->fetch(MYSQL_ASSOC)) while ($row = $sql->fetch(MYSQL_ASSOC))
@@ -175,8 +179,19 @@ class notify
} }
} }
} }
} }
if(E107_DEBUG_LEVEL > 0)
{
$data = array('id'=>$id, 'subject'=>$subject, 'recipients'=> $recipients, 'prefs'=>$this->notify_prefs['event'][$id], 'message'=>$message);
e107::getMessage()->addDebug(print_a($data,true));
e107::getLog()->add('Notify Debug', $data, E_LOG_INFORMATIVE, "NOTIFY_DBG");
return;
}
if (count($recipients)) if (count($recipients))
{ {
require_once(e_HANDLER.'mail_manager_class.php'); require_once(e_HANDLER.'mail_manager_class.php');
@@ -196,7 +211,12 @@ class notify
); );
$result = $mailer->sendEmails('NOTIFY_TEMPLATE', $mailData, $recipients); $result = $mailer->sendEmails('NOTIFY_TEMPLATE', $mailData, $recipients);
$e107->admin_log->e_log_event(10,-1,'NOTIFY',$subject,$message,FALSE,LOG_TO_ROLLING); e107::getLog()->e_log_event(10,-1,'NOTIFY',$subject,$message,FALSE,LOG_TO_ROLLING);
}
else
{
$data = array('qry'=>$qry, 'error'=>'No recipients');
e107::getLog()->add('Notify Debug', $data, E_LOG_WARNING_, "NOTIFY_DBG");
} }
} }