mirror of
https://github.com/e107inc/e107.git
synced 2025-07-25 17:01:43 +02:00
Notifications cleanup
This commit is contained in:
@@ -1286,9 +1286,15 @@ class admin_newspost
|
||||
if ($sql->count('news','(*)',"news_id={$del_id}"))
|
||||
{
|
||||
e107::getEvent()->trigger("newsdel", $del_id);
|
||||
|
||||
if(e107::getEvent()->trigger("admin_news_delete", $del_id)) // Allow trigger to halt process if it returns true.
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if($sql->delete("news", "news_id={$del_id}"))
|
||||
{
|
||||
e107::getEvent()->trigger("admin_news_delete", $del_id);
|
||||
e107::getEvent()->trigger("admin_news_deleted", $del_id);
|
||||
e107::getLog()->add('NEWS_01',$del_id,E_LOG_INFORMATIVE,'');
|
||||
$this->show_message(NWSLAN_31." #".$del_id." ".NWSLAN_32, E_MESSAGE_SUCCESS);
|
||||
$this->clear_cache();
|
||||
@@ -1564,7 +1570,7 @@ class admin_newspost
|
||||
$this->clear_cache();
|
||||
|
||||
e107::getEvent()->trigger("newscatpost", array_merge($inserta['data'], $rwinserta['data'])); // @deprecated
|
||||
e107::getEvent()->trigger("admin_news_category_create", array_merge($inserta['data'], $rwinserta['data']));
|
||||
e107::getEvent()->trigger("admin_news_category_created", array_merge($inserta['data'], $rwinserta['data']));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1674,7 +1680,7 @@ class admin_newspost
|
||||
|
||||
|
||||
e107::getEvent()->trigger("newscatupd", array_merge($updatea['data'], $inserta['data'])); // @deprecated
|
||||
e107::getEvent()->trigger("admin_news_category_update", array_merge($updatea['data'], $inserta['data']));
|
||||
e107::getEvent()->trigger("admin_news_category_updated", array_merge($updatea['data'], $inserta['data']));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -69,15 +69,16 @@ class notify_config
|
||||
|
||||
function __construct()
|
||||
{
|
||||
global $sysprefs, $eArrayStorage;
|
||||
$ns = e107::getRender();
|
||||
$tp = e107::getParser();
|
||||
$pref = e107::getPref();
|
||||
$sql = e107::getDb();
|
||||
$ns = e107::getRender();
|
||||
$tp = e107::getParser();
|
||||
$pref = e107::getPref();
|
||||
$sql = e107::getDb();
|
||||
|
||||
// $this -> notify_prefs = $sysprefs -> get('notify_prefs');
|
||||
// $this -> notify_prefs = $eArrayStorage -> ReadArray($this -> notify_prefs);
|
||||
$this->notify_prefs = e107::getConfig('notify')->getPref();
|
||||
|
||||
$this->prefCleanup();
|
||||
|
||||
// print_a($this->notify_prefs);
|
||||
|
||||
$recalibrate = FALSE;
|
||||
// load every e_notify.php file.
|
||||
@@ -131,13 +132,33 @@ class notify_config
|
||||
|
||||
if ($recalibrate)
|
||||
{
|
||||
$s_prefs = $tp -> toDB($this -> notify_prefs);
|
||||
$s_prefs = $eArrayStorage -> WriteArray($s_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'");
|
||||
}
|
||||
}
|
||||
|
||||
function prefCleanup()
|
||||
{
|
||||
$oldPrefs = e107::getEvent()->oldCoreList();
|
||||
$curData = $this->notify_prefs['event'];
|
||||
|
||||
foreach($curData as $k=>$v)
|
||||
{
|
||||
if(isset($oldPrefs[$k]))
|
||||
{
|
||||
$newKey = $oldPrefs[$k];
|
||||
$this->notify_prefs['event'][$newKey] = $v;
|
||||
unset($this->notify_prefs['event'][$k]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function config()
|
||||
{
|
||||
@@ -146,8 +167,74 @@ class notify_config
|
||||
$frm = e107::getForm();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
// <div>".NT_LAN_2.":</div>
|
||||
|
||||
$events = e107::getEvent()->coreList();
|
||||
$tab = array();
|
||||
|
||||
foreach($events as $k=>$cat)
|
||||
{
|
||||
$text = " <table class='table adminform'>
|
||||
<colgroup>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>";
|
||||
|
||||
foreach($cat as $c=>$ev)
|
||||
{
|
||||
$text .= $this -> render_event($c, $ev);
|
||||
}
|
||||
$text .= "</table>";
|
||||
|
||||
$caption = str_replace("_menu","",ucfirst($k))." Events"; //TODO LAN
|
||||
|
||||
$tab[] = array('caption'=>$caption, 'text' => $text);
|
||||
}
|
||||
|
||||
if(!empty($this->notify_prefs['plugins']))
|
||||
{
|
||||
|
||||
foreach ($this->notify_prefs['plugins'] as $plugin_id => $plugin_settings)
|
||||
{
|
||||
if(is_readable(e_PLUGIN.$plugin_id.'/e_notify.php'))
|
||||
{
|
||||
$config_category = $this->pluginConfig[$plugin_id]['category'];
|
||||
$legacy = $this->pluginConfig[$plugin_id]['legacy'];
|
||||
|
||||
$text = "<table class='table adminform'>
|
||||
<colgroup>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>";
|
||||
;
|
||||
|
||||
foreach ($this->pluginConfig[$plugin_id]['events'] as $event_id => $event_text)
|
||||
{
|
||||
$text .= $this->render_event($event_id, $event_text, $plugin_id, $legacy);
|
||||
}
|
||||
|
||||
$text .= "</table>\n";
|
||||
|
||||
$tab[] = array('caption'=> $config_category, 'text'=> $text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$text2 = $frm->open('scanform', 'post', e_SELF); // <form action='".e_SELF."?results' method='post' id='scanform'>
|
||||
$text2 .= $frm->tabs($tab);
|
||||
$text2 .= "<div class='buttons-bar center'>". $frm->admin_button('update', LAN_UPDATE,'update') . "</div>";
|
||||
$text2 .= $frm->close();
|
||||
|
||||
|
||||
$ns -> tablerender(NT_LAN_1, $mes->render() . $text2);
|
||||
|
||||
|
||||
return;
|
||||
|
||||
|
||||
// <div>".NT_LAN_2.":</div>
|
||||
/*
|
||||
$text = "
|
||||
|
||||
<form action='".e_SELF."?results' method='post' id='scanform'>
|
||||
@@ -182,6 +269,7 @@ class notify_config
|
||||
$text .= $this -> render_event('userveri', NU_LAN_3);
|
||||
$text .= $this -> render_event('login', NU_LAN_4);
|
||||
$text .= $this -> render_event('logout', NU_LAN_5);
|
||||
$text .= $this -> render_event('user_xup_', NU_LAN_5);
|
||||
|
||||
$text .= "</table></fieldset>
|
||||
<fieldset id='core-notify-2'>
|
||||
@@ -292,18 +380,26 @@ class notify_config
|
||||
";
|
||||
|
||||
$ns -> tablerender(NT_LAN_1, $mes->render() . $text);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
function render_event($id, $description, $include='', $legacy = 0)
|
||||
{
|
||||
global $uc; // $rs
|
||||
$tp = e107::getParser();
|
||||
$frm = e107::getForm();
|
||||
$uc = e107::getUserClass();
|
||||
|
||||
if(defined($description))
|
||||
{
|
||||
$description = constant($description);
|
||||
}
|
||||
|
||||
|
||||
$text = "
|
||||
<tr>
|
||||
<td >".$description.": </td>
|
||||
<td title='".$id."'>".$description.": </td>
|
||||
<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."');\" ");
|
||||
|
||||
@@ -333,6 +429,7 @@ class notify_config
|
||||
{
|
||||
global $sql, $pref, $eArrayStorage;
|
||||
$this->changeList = array();
|
||||
|
||||
foreach ($_POST['event'] as $key => $value)
|
||||
{
|
||||
if ($this -> update_event($key))
|
||||
@@ -348,7 +445,7 @@ class notify_config
|
||||
{
|
||||
$pref['notify'] = FALSE;
|
||||
}
|
||||
save_prefs();
|
||||
// save_prefs();
|
||||
|
||||
// print_a($this->notify_prefs);
|
||||
/*
|
||||
|
@@ -516,8 +516,8 @@ class users_admin_ui extends e_admin_ui
|
||||
$sysuser->setData($row)->save();
|
||||
|
||||
e107::getLog()->add('USET_10', str_replace(array('--UID--', '--NAME--', '--EMAIL--'), array($sysuser->getId(), $sysuser->getName(), $sysuser->getValue('email')), USRLAN_166), E_LOG_INFORMATIVE);
|
||||
$e_event->trigger('userfull', $row); //BC
|
||||
e107::getEvent()->trigger('admin_user_activate', $row);
|
||||
e107::getEvent()->trigger('userfull', $row); //BC
|
||||
e107::getEvent()->trigger('admin_user_activated', $row);
|
||||
|
||||
$mes->addSuccess(USRLAN_86." (#".$sysuser->getId()." : ".$sysuser->getName().' - '.$sysuser->getValue('email').")");
|
||||
|
||||
@@ -1246,7 +1246,7 @@ class users_admin_ui extends e_admin_ui
|
||||
$userMethods->addNonDefaulted($user_data);
|
||||
validatorClass::addFieldTypes($userMethods->userVettingInfo, $allData);
|
||||
|
||||
$userid = $sql->db_Insert('user', $allData);
|
||||
$userid = $sql->insert('user', $allData);
|
||||
if ($userid)
|
||||
{
|
||||
$sysuser = e107::getSystemUser(false, false);
|
||||
@@ -1258,9 +1258,9 @@ class users_admin_ui extends e_admin_ui
|
||||
e107::getLog()->add('USET_02',"UName: {$user_data['user_name']}; Email: {$user_data['user_email']}", E_LOG_INFORMATIVE);
|
||||
|
||||
// Add to user audit trail
|
||||
$admin_log->user_audit(USER_AUDIT_ADD_ADMIN, $user_data, 0, $user_data['user_loginname']);
|
||||
$e_event->trigger('userfull', $user_data);
|
||||
e107::getEvent()->trigger('admin_user_create', $user_data);
|
||||
e107::getLog()->user_audit(USER_AUDIT_ADD_ADMIN, $user_data, 0, $user_data['user_loginname']);
|
||||
e107::getEvent()->trigger('userfull', $user_data);
|
||||
e107::getEvent()->trigger('admin_user_created', $user_data);
|
||||
|
||||
// send everything available for user data - bit sparse compared with user-generated signup
|
||||
if(isset($_POST['sendconfemail']))
|
||||
|
@@ -2,12 +2,10 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2015 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
@@ -17,6 +15,73 @@ class e107_event
|
||||
{
|
||||
var $functions = array();
|
||||
var $includes = array();
|
||||
|
||||
protected $coreEvents = array( // used by e_notify admin area.
|
||||
|
||||
'session' => array(
|
||||
|
||||
'user_signup_submitted' => NU_LAN_2,
|
||||
'user_signup_activated' => NU_LAN_3,
|
||||
'login' => NU_LAN_4,
|
||||
'logout' => NU_LAN_5,
|
||||
'user_xup_login' => 'User social login',
|
||||
'user_xup_signup' => 'User social signup',
|
||||
'user_ban_flood' => NS_LAN_2,
|
||||
'user_ban_failed_login' => 'IP banned for multiple failed login attempts'
|
||||
|
||||
),
|
||||
|
||||
'administrators' => array(
|
||||
'admin_password_update' => "Administrator updates their password",
|
||||
'admin_user_created' => 'Administrator creates a new user',
|
||||
'admin_user_activated' => "Administrator activates a new user"
|
||||
|
||||
),
|
||||
|
||||
'news' => array(
|
||||
|
||||
'admin_news_created' => NN_LAN_3,
|
||||
'admin_news_updated' => NN_LAN_4,
|
||||
'admin_news_deleted' => NN_LAN_5,
|
||||
'user_news_submit' => NN_LAN_2,
|
||||
),
|
||||
|
||||
'mail' => array(
|
||||
|
||||
'maildone' => NM_LAN_2,
|
||||
),
|
||||
|
||||
'file' => array(
|
||||
|
||||
// 'fileupload' => NF_LAN_2,
|
||||
'user_file_upload' => NF_LAN_2,
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
protected $oldCoreEvents = array(
|
||||
|
||||
'usersup' => 'user_signup_submitted',
|
||||
'userveri' => 'user_signup_activated',
|
||||
'flood' => 'user_ban_flood',
|
||||
'subnews' => 'user_news_submit',
|
||||
'fileupload' => 'user_file_upload',
|
||||
'newspost' => 'admin_news_created',
|
||||
'newsupd' => 'admin_news_updated',
|
||||
'newsdel' => 'admin_news_deleted'
|
||||
);
|
||||
|
||||
|
||||
function coreList()
|
||||
{
|
||||
return $this->coreEvents;
|
||||
}
|
||||
|
||||
function oldCoreList()
|
||||
{
|
||||
return $this->oldCoreEvents;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register event
|
||||
@@ -43,8 +108,9 @@ class e107_event
|
||||
|
||||
function debug()
|
||||
{
|
||||
|
||||
echo "<h3>Event Functions</h3>";
|
||||
print_a($this->functions);
|
||||
echo "<h3>Event Includes</h3>";
|
||||
print_a($this->includes);
|
||||
|
||||
}
|
||||
@@ -111,8 +177,10 @@ class e107_event
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
e107::getLog()->add('Event Trigger failed',array('name'=>$eventname,'location'=>$location,'function'=>$evt_func),E_LOG_WARNING,'EVENT_01');
|
||||
else
|
||||
{
|
||||
e107::getLog()->add('Event Trigger failed',array('name'=>$eventname,'location'=>$location,'function'=>$evt_func), E_LOG_WARNING,'EVENT_01');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -171,6 +171,7 @@ class news {
|
||||
$data['data']['news_id'] = $news['news_id'];
|
||||
|
||||
e107::getEvent()->trigger('newsupd', $data['data']);
|
||||
e107::getEvent()->trigger('admin_news_updated', $data['data']);
|
||||
$message = LAN_UPDATED;
|
||||
$emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS, $smessages);
|
||||
e107::getCache()->clear('news.php');
|
||||
@@ -220,6 +221,7 @@ class news {
|
||||
//moved down - prevent wrong mysql_insert_id
|
||||
e107::getAdminLog()->logArrayAll('NEWS_08', $logData);
|
||||
e107::getEvent()->trigger('newspost', $data['data']);
|
||||
e107::getEvent()->trigger('admin_news_created', $data['data']);
|
||||
|
||||
//XXX - triggerHook after trigger?
|
||||
$evdata = array('method'=>'create', 'table'=>'news', 'id'=>$data['data']['news_id'], 'plugin'=>'news', 'function'=>'submit_item');
|
||||
|
@@ -23,7 +23,9 @@ class notify
|
||||
|
||||
function notify()
|
||||
{
|
||||
global $e_event;
|
||||
// global $e_event;
|
||||
|
||||
$e_event = e107::getEvent();
|
||||
|
||||
$this->notify_prefs = e107::getConfig('notify')->getPref();
|
||||
|
||||
@@ -31,7 +33,9 @@ class notify
|
||||
{
|
||||
foreach ($this->notify_prefs['event'] as $id => $status)
|
||||
{
|
||||
if ($status['class'] != 255)
|
||||
$include = null;
|
||||
|
||||
if ($status['class'] != e_UC_NOBODY) // 255;
|
||||
{
|
||||
if(varset($status['include'])) // Plugin
|
||||
{
|
||||
@@ -50,7 +54,14 @@ class notify
|
||||
}
|
||||
else // core
|
||||
{
|
||||
$e_event->register($id, 'notify_'.$id);
|
||||
if(function_exists('notify_'.$id)) // as found below.
|
||||
{
|
||||
$e_event->register($id, 'notify_'.$id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$e_event->register($id, array('notify', 'generic')); // use generic notification.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +70,19 @@ class notify
|
||||
}
|
||||
|
||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_notify.php');
|
||||
// e107::getEvent()->debug();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generic Notification method when none defined.
|
||||
*/
|
||||
function generic($data,$id)
|
||||
{
|
||||
$message = print_a($data,true);
|
||||
$this->send($id, 'Event Triggered: '.$id, $message);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +102,15 @@ class notify
|
||||
*/
|
||||
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();
|
||||
$sql = e107::getDb();
|
||||
@@ -153,7 +186,6 @@ class notify
|
||||
'mail_subject' => $subject,
|
||||
'mail_sender_email' => e107::getPref('siteadminemail'),
|
||||
'mail_sender_name' => e107::getPref('siteadmin'),
|
||||
// 'mail_send_style' => 'textonly',
|
||||
'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
|
||||
'mail_body' => $message,
|
||||
'template' => 'notify'
|
||||
@@ -205,6 +237,7 @@ function notify_userveri($data)
|
||||
$nt->send('userveri', NT_LAN_UV_1, $msgtext);
|
||||
}
|
||||
|
||||
|
||||
function notify_login($data)
|
||||
{
|
||||
global $nt;
|
||||
|
@@ -1047,7 +1047,7 @@ class e_user_provider
|
||||
$userdata = $user->getData();
|
||||
$userdata['provider'] = $this->getProvider();
|
||||
|
||||
e107::getEvent()->trigger('userveri', $userdata); // Trigger New verified user.
|
||||
// e107::getEvent()->trigger('userveri', $userdata); // Trigger New verified user.
|
||||
|
||||
e107::getEvent()->trigger('user_xup_signup', $userdata);
|
||||
|
||||
|
@@ -352,6 +352,7 @@ if (e_QUERY)
|
||||
$admin_log->user_audit(USER_AUDIT_EMAILACK,$row);
|
||||
|
||||
e107::getEvent()->trigger('userveri', $row); // Legacy event
|
||||
e107::getEvent()->trigger('user_signup_activated', $row);
|
||||
e107::getEvent()->trigger('userfull', $row); // 'New' event
|
||||
|
||||
if (varset($pref['autologinpostsignup']))
|
||||
@@ -682,7 +683,6 @@ if (isset($_POST['register']) && intval($pref['user_reg']) === 1)
|
||||
}
|
||||
|
||||
e107::getEvent()->trigger('usersup', $_POST); // Old trigger - send everything in the template, including extended fields.
|
||||
// FIXME - undocummented feature - userpartial trigger (better trigger name?)
|
||||
e107::getEvent()->trigger('userpartial', array_merge($allData['data'],$eufVals['data'])); // New trigger - send everything in the template, including extended fields.
|
||||
|
||||
require_once(HEADERF);
|
||||
|
@@ -119,6 +119,7 @@ if (isset($_POST['submitnews_submit']) && $_POST['submitnews_title'] && $_POST['
|
||||
|
||||
$edata_sn = array("user" => $submitnews_user, "email" => $submitnews_email, "itemtitle" => $submitnews_title, "catid" => intval($_POST['cat_id']), "item" => $submitnews_item, "image" => $submitnews_file, "ip" => $ip);
|
||||
$e_event->trigger("subnews", $edata_sn);
|
||||
e107::getEvent()->trigger("user_news_submit", $edata_sn);
|
||||
|
||||
$mes = e107::getMessage();
|
||||
$mes->addSuccess(LAN_134);
|
||||
|
Reference in New Issue
Block a user