mirror of
https://github.com/e107inc/e107.git
synced 2025-08-12 09:34:54 +02:00
PM next update - admin logging, more reformatting
This commit is contained in:
@@ -6,7 +6,7 @@ define('ADLAN_PM_3', "PM settings not found, default values set");
|
||||
define('ADLAN_PM_4', "Options Updated");
|
||||
define('ADLAN_PM_5', "Limit for selected userclass already exists");
|
||||
define('ADLAN_PM_6', "Limit successfully added");
|
||||
define('ADLAN_PM_7', "Limit not added - unknown error");
|
||||
define('ADLAN_PM_7', "Limit not added/updated - unknown error");
|
||||
define('ADLAN_PM_8', "Limit status updated");
|
||||
define('ADLAN_PM_9', " - Limit successfully removed");
|
||||
define('ADLAN_PM_10', " - Limit not removed - unknown error");
|
||||
@@ -45,19 +45,44 @@ define('ADLAN_PM_42', "Update Limits");
|
||||
define('ADLAN_PM_43', "Add New Limit");
|
||||
define('ADLAN_PM_44', "seconds");
|
||||
define('ADLAN_PM_45', "Limit PM By: ");
|
||||
define('ADLAN_PM_46', "PM Conversion");
|
||||
define('ADLAN_PM_47', "You do not appear to have any old messages from previous versions, it is safe to uninstall the old plugin");
|
||||
define('ADLAN_PM_48', "You have {OLDCOUNT} messages from the older version, please decide what you would like to do with these messages<br /><br />If converting messages, any message successfully converted will be removed from old system.");
|
||||
define('ADLAN_PM_49', "Convert to new PM");
|
||||
define('ADLAN_PM_50', "Discard old messages");
|
||||
define('ADLAN_PM_51', "PM #{PMNUM} not converted");
|
||||
define('ADLAN_PM_52', "messages converted");
|
||||
define('ADLAN_PM_53', "No records found to convert.");
|
||||
|
||||
//define('ADLAN_PM_46', "PM Conversion");
|
||||
//define('ADLAN_PM_47', "You do not appear to have any old messages from previous versions, it is safe to uninstall the old plugin");
|
||||
//define('ADLAN_PM_48', "You have {OLDCOUNT} messages from the older version, please decide what you would like to do with these messages<br /><br />If converting messages, any message successfully converted will be removed from old system.");
|
||||
//define('ADLAN_PM_49', "Convert to new PM");
|
||||
//define('ADLAN_PM_50', "Discard old messages");
|
||||
//define('ADLAN_PM_51', "PM #{PMNUM} not converted");
|
||||
//define('ADLAN_PM_52', "messages converted");
|
||||
//define('ADLAN_PM_53', "No records found to convert.");
|
||||
|
||||
define('ADLAN_PM_54', "Main settings");
|
||||
define('ADLAN_PM_55', "Limits");
|
||||
define('ADLAN_PM_56', "Conversion");
|
||||
//define('ADLAN_PM_56', "Conversion");
|
||||
|
||||
define('ADLAN_PM_57', "This plugin is a fully featured Private Messaging system.");
|
||||
define('ADLAN_PM_58', "Private Messenger");
|
||||
|
||||
define('ADLAN_PM_59', 'Maintenance');
|
||||
define('ADLAN_PM_60', 'PM Maintenance');
|
||||
define('ADLAN_PM_61', 'Execute');
|
||||
define('ADLAN_PM_62', 'These options remove transactions concerned with deleted users from the PM database tables');
|
||||
define('ADLAN_PM_63', 'Messages sent');
|
||||
define('ADLAN_PM_64', 'Messages received');
|
||||
define('ADLAN_PM_65', 'User blocks');
|
||||
define('ADLAN_PM_66', 'No maintenance tasks specified');
|
||||
define('ADLAN_PM_67', 'PM DB maintenance started');
|
||||
define('ADLAN_PM_68', '--COUNT-- blocks to deleted users removed');
|
||||
define('ADLAN_PM_69', '--COUNT-- blocks from deleted users removed');
|
||||
define('ADLAN_PM_70', 'Database error --NUM--: --TEXT-- removing user blocks');
|
||||
define('ADLAN_PM_71', 'Time-expired messages');
|
||||
define('ADLAN_PM_72', 'No PM timeouts set');
|
||||
define('ADLAN_PM_73', '--COUNT-- time-expired PMs deleted');
|
||||
define('ADLAN_PM_74', 'Removed --COUNT-- messages sent by deleted users');
|
||||
define('ADLAN_PM_75', 'Removed --COUNT-- messages received by deleted users');
|
||||
define('ADLAN_PM_76', 'No changes made - nothing logged');
|
||||
define('ADLAN_PM_77', '(Empty all fields and Update to delete a limit)');
|
||||
define('ADLAN_PM_78', '');
|
||||
define('ADLAN_PM_79', '');
|
||||
define('ADLAN_PM_80', '');
|
||||
|
||||
?>
|
||||
|
@@ -1,9 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Id: plugin.xml,v 1.12 2009-10-20 03:49:22 e107coders Exp $ -->
|
||||
<!-- $Id: plugin.xml,v 1.13 2009-12-11 22:33:15 e107steved Exp $ -->
|
||||
<e107Plugin name="ADLAN_PM" version="3.0" compatibility="0.8" installRequired="true">
|
||||
<author name="e107 Inc." email="mcfly@e107.org" />
|
||||
<description>ADLAN_PM_57</description>
|
||||
<category>users</category>
|
||||
<languageFiles>
|
||||
<file type='log' path='languages/--LAN--_log.php' />
|
||||
</languageFiles>
|
||||
<adminLinks>
|
||||
<link url='pm_conf.php' description='ADLAN_PM_2' icon='images/pvt_message_32.png' iconSmall='images/pvt_message_16.png' primary='true' >ADLAN_PM_2</link>
|
||||
</adminLinks>
|
||||
|
@@ -9,8 +9,8 @@
|
||||
*
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_class.php,v $
|
||||
* $Revision: 1.9 $
|
||||
* $Date: 2009-12-10 20:40:38 $
|
||||
* $Revision: 1.10 $
|
||||
* $Date: 2009-12-11 22:33:15 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
@@ -142,6 +142,16 @@ class private_message
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete a PM from a user's inbox/outbox.
|
||||
* PM is only actually deleted from DB once both sender and recipient have marked it as deleted
|
||||
* When physically deleted, any attachments are deleted as well
|
||||
*
|
||||
* @param integer $pmid - ID of the PM
|
||||
* @return boolean|string - FALSE if PM not found, or other DB error. String if successful
|
||||
*/
|
||||
function del($pmid)
|
||||
{
|
||||
global $sql;
|
||||
@@ -193,8 +203,11 @@ class private_message
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function pm_send_notify($uid, $pminfo, $pmid, $attach_count = 0)
|
||||
{
|
||||
require_once(e_HANDLER.'mail.php');
|
||||
|
@@ -6,20 +6,31 @@
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
* PM Plugin - administration
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_conf.php,v $
|
||||
* $Revision: 1.7 $
|
||||
* $Date: 2009-12-10 20:40:38 $
|
||||
* $Revision: 1.8 $
|
||||
* $Date: 2009-12-11 22:33:15 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
TODO:
|
||||
1. Limits page needs some lines round the table
|
||||
2. Limits page - test
|
||||
3. Maintenance page - to be tested
|
||||
4. Check operation of user dropdown bit
|
||||
5. User option to enable/disable email notification of PMs
|
||||
6. Cron-triggered bulk send.
|
||||
7. Is it right that limits are saved in $pref, not $pm_prefs? If not, import routine/change
|
||||
8. Put prefs into plugin.xml?
|
||||
*/
|
||||
|
||||
|
||||
$retrieve_prefs[] = 'pm_prefs';
|
||||
$eplug_admin = TRUE;
|
||||
require_once('../../class2.php');
|
||||
require_once(e_PLUGIN.'pm/pm_class.php');
|
||||
require_once(e_HANDLER.'userclass_class.php');
|
||||
require_once(e_HANDLER.'form_handler.php');
|
||||
|
||||
if (!e107::isInstalled('pm') || !getperms('P'))
|
||||
{
|
||||
@@ -27,6 +38,12 @@ if (!e107::isInstalled('pm') || !getperms('P'))
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(e_PLUGIN.'pm/pm_class.php');
|
||||
require_once(e_HANDLER.'userclass_class.php');
|
||||
require_once(e_HANDLER.'form_handler.php');
|
||||
require_once (e_HANDLER.'message_handler.php');
|
||||
$emessage = &eMessage :: getInstance();
|
||||
|
||||
$action = e_QUERY;
|
||||
|
||||
require_once(e_ADMIN.'auth.php');
|
||||
@@ -44,7 +61,8 @@ if(!is_array($pm_prefs))
|
||||
require_once(e_PLUGIN.'pm/pm_default.php');
|
||||
$pm_prefs = pm_set_default_prefs(); // Use the default settings
|
||||
$sysprefs->setArray('pm_prefs');
|
||||
$message = ADLAN_PM_3;
|
||||
$emessage->add(ADLAN_PM_3, E_MESSAGE_INFO);
|
||||
$e107->admin_log->log_event('PM_ADM_01', '');
|
||||
}
|
||||
|
||||
|
||||
@@ -54,30 +72,90 @@ if(!is_array($pm_prefs))
|
||||
|
||||
if (isset($_POST['update_prefs']))
|
||||
{
|
||||
foreach($_POST['option'] as $k => $v)
|
||||
$temp = array();
|
||||
foreach($_POST as $k => $v)
|
||||
{
|
||||
$pm_prefs[$k] = $v;
|
||||
if (strpos($k, 'pm_option-') === 0)
|
||||
{
|
||||
$k = str_replace('pm_option-','',$k);
|
||||
$temp[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($e107->admin_log->logArrayDiffs($temp, $pm_prefs, 'PM_ADM_02'))
|
||||
{
|
||||
$sysprefs->setArray('pm_prefs');
|
||||
$emessage->add(ADLAN_PM_4, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$emessage->add(ADLAN_PM_76, E_MESSAGE_INFO);
|
||||
}
|
||||
$sysprefs->setArray('pm_prefs');
|
||||
$message = ADLAN_PM_4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Mantenance options
|
||||
if (isset($_POST['pm_maint_execute']))
|
||||
{
|
||||
$maintOpts = array();
|
||||
$emessage->add('Starting maintenance', E_MESSAGE_INFO);
|
||||
if (vartrue($_POST['pm_maint_sent']))
|
||||
{
|
||||
$maintOpts['sent'] = 1;
|
||||
}
|
||||
if (vartrue($_POST['pm_maint_rec']))
|
||||
{
|
||||
$maintOpts['rec'] = 1;
|
||||
}
|
||||
if (vartrue($_POST['pm_maint_blocked']))
|
||||
{
|
||||
$maintOpts['blocked'] = 1;
|
||||
}
|
||||
if (vartrue($_POST['pm_maint_expired']))
|
||||
{
|
||||
$maintOpts['expired'] = 1;
|
||||
}
|
||||
$result = doMaint($maintOpts, $pm_prefs);
|
||||
if (is_array($result))
|
||||
{
|
||||
foreach ($result as $k => $ma)
|
||||
{
|
||||
foreach ($ma as $m)
|
||||
{
|
||||
$emessage->add($m, $k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($_POST['addlimit']))
|
||||
{
|
||||
if($sql->db_Select('generic','gen_id',"gen_type = 'pm_limit' AND gen_datestamp = {$_POST['newlimit_class']}"))
|
||||
$id = intval($_POST['newlimit_class']);
|
||||
if($sql->db_Select('generic','gen_id',"gen_type = 'pm_limit' AND gen_datestamp = ".$id))
|
||||
{
|
||||
$message = ADLAN_PM_5;
|
||||
$emessage->add(ADLAN_PM_5, E_MESSAGE_INFO); // 'Limit for selected user class already exists'
|
||||
}
|
||||
else
|
||||
{
|
||||
if($sql->db_Insert('generic',"0, 'pm_limit', '{$_POST['newlimit_class']}', '{$_POST['new_inbox_count']}', '{$_POST['new_outbox_count']}', '{$_POST['new_inbox_size']}', '{$_POST['new_outbox_size']}'"))
|
||||
$limArray = array( // Strange field names because we use the 'generic' table. But at least it documents the correlation
|
||||
'gen_type' => 'pm_limit',
|
||||
'gen_datestamp' => intval($_POST['newlimit_class']),
|
||||
'gen_user_id' => intval($_POST['new_inbox_count']),
|
||||
'gen_ip' => intval($_POST['new_outbox_count']),
|
||||
'gen_intdata' => intval($_POST['new_inbox_size']),
|
||||
'gen_chardata' => intval($_POST['new_outbox_size'])
|
||||
);
|
||||
if($sql->db_Insert('generic', $limArray))
|
||||
{
|
||||
$message = ADLAN_PM_6;
|
||||
$e107->admin_log->logArrayAll('PM_ADM_05', $limArray);
|
||||
$emessage->add(ADLAN_PM_6, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = ADLAN_PM_7;
|
||||
$e107->admin_log->log_event('PM_ADM_08', '');
|
||||
$emessage->add(ADLAN_PM_7, E_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,136 +166,166 @@ if(isset($_POST['updatelimits']))
|
||||
{
|
||||
$pref['pm_limits'] = $_POST['pm_limits'];
|
||||
save_prefs();
|
||||
$message .= ADLAN_PM_8."<br />";
|
||||
$emessage->add(ADLAN_PM_8, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
foreach(array_keys($_POST['inbox_count']) as $id)
|
||||
{
|
||||
if($_POST['inbox_count'][$id] == "" && $_POST['outbox_count'][$id] == "" && $_POST['inbox_size'][$id] == "" && $_POST['outbox_size'][$id] == "")
|
||||
$id = intval($id);
|
||||
if($_POST['inbox_count'][$id] == '' && $_POST['outbox_count'][$id] == '' && $_POST['inbox_size'][$id] == '' && $_POST['outbox_size'][$id] == '')
|
||||
{
|
||||
//All entries empty - Remove record
|
||||
if($sql->db_Delete('generic',"gen_id = {$id}"))
|
||||
if($sql->db_Delete('generic','gen_id = '.$id))
|
||||
{
|
||||
$message .= $id.ADLAN_PM_9."<br />";
|
||||
$e107->admin_log->log_event('PM_ADM_07', 'ID: '.$id);
|
||||
$emessage->add($id.ADLAN_PM_9, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$message .= $id.ADLAN_PM_10."<br />";
|
||||
$e107->admin_log->log_event('PM_ADM_10', '');
|
||||
$emessage->add($id.ADLAN_PM_10, E_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql->db_Update('generic',"gen_user_id = '{$_POST['inbox_count'][$id]}', gen_ip = '{$_POST['outbox_count'][$id]}', gen_intdata = '{$_POST['inbox_size'][$id]}', gen_chardata = '{$_POST['outbox_size'][$id]}' WHERE gen_id = {$id}");
|
||||
$message .= $id.ADLAN_PM_11."<br />";
|
||||
$limArray = array( // Strange field names because we use the 'generic' table. But at least it documents the correlation
|
||||
'gen_user_id' => intval($_POST['inbox_count'][$id]),
|
||||
'gen_ip' => intval($_POST['outbox_count'][$id]),
|
||||
'gen_intdata' => intval($_POST['inbox_size'][$id]),
|
||||
'gen_chardata' => intval($_POST['outbox_size'][$id])
|
||||
);
|
||||
if ($sql->db_Update('generic',array('data' => $limArray, 'WHERE' => 'gen_id = '.$id)))
|
||||
{
|
||||
$e107->admin_log->logArrayAll('PM_ADM_06', $limArray);
|
||||
$emessage->add($id.ADLAN_PM_11, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$e107->admin_log->log_event('PM_ADM_09', '');
|
||||
$emessage->add($id.ADLAN_PM_7, E_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($message))
|
||||
|
||||
if ($emessage->hasMessage())
|
||||
{
|
||||
$ns->tablerender('', $message);
|
||||
$e107->ns->tablerender(ADLAN_PM_58, $emessage->render());
|
||||
}
|
||||
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case 'main' :
|
||||
$ns->tablerender(ADLAN_PM_12, show_options());
|
||||
$ns->tablerender(ADLAN_PM_12, show_options($pm_prefs));
|
||||
break;
|
||||
case 'limits' :
|
||||
$ns->tablerender(ADLAN_PM_14, show_limits());
|
||||
$ns->tablerender(ADLAN_PM_15, add_limit());
|
||||
break;
|
||||
case 'maint' :
|
||||
$ns->tablerender(ADLAN_PM_60, show_maint($pm_prefs));
|
||||
break;
|
||||
}
|
||||
|
||||
require_once(e_ADMIN.'footer.php');
|
||||
|
||||
function yes_no($fname)
|
||||
|
||||
|
||||
|
||||
function yes_no($fname, $curval = '')
|
||||
{
|
||||
global $pm_prefs;
|
||||
$ret =
|
||||
form::form_radio("option[{$fname}]", "1", ($pm_prefs[$fname] ? "1" : "0"), "", "").LAN_YES." ".
|
||||
form::form_radio("option[{$fname}]", "0", ($pm_prefs[$fname] ? "0" : "1"), "", "").LAN_NO;
|
||||
form::form_radio($fname, '1', ($curval ? '1' : '0'), '', '').LAN_YES.' '.
|
||||
form::form_radio($fname, '0', ($curval ? '0' : '1'), '', '').LAN_NO;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function show_options()
|
||||
function show_options($pm_prefs)
|
||||
{
|
||||
global $pm_prefs;
|
||||
$txt = "
|
||||
<fieldset id='plugin-pm-prefs'>
|
||||
<form method='post' action='".e_SELF."'>
|
||||
<table class='fborder' style='width:95%'>
|
||||
<table cellpadding='0' cellspacing='0' class='adminedit'>
|
||||
<colgroup span='2'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_16."</td>
|
||||
<td class='forumheader3' style='width:25%'>".form::form_text('option[title]', 20, $pm_prefs['title'], 50)."</td>
|
||||
<td>".ADLAN_PM_16."</td>
|
||||
<td>".form::form_text('pm_option-title', 20, $pm_prefs['title'], 50)."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_17."</td>
|
||||
<td class='forumheader3' style='width:25%'>".yes_no('animate')."</td>
|
||||
<td>".ADLAN_PM_17."</td>
|
||||
<td>".yes_no('pm_option-animate', $pm_prefs['animate'])."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_18."</td>
|
||||
<td class='forumheader3' style='width:25%'>".yes_no('dropdown')."</td>
|
||||
<td>".ADLAN_PM_18."</td>
|
||||
<td>".yes_no('pm_option-dropdown', $pm_prefs['dropdown'])."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_19."</td>
|
||||
<td class='forumheader3' style='width:25%'>".form::form_text('option[read_timeout]', 5, $pm_prefs['read_timeout'], 5)."</td>
|
||||
<td>".ADLAN_PM_19."</td>
|
||||
<td>".form::form_text('pm_option-read_timeout', 5, $pm_prefs['read_timeout'], 5)."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_20."</td>
|
||||
<td class='forumheader3' style='width:25%'>".form::form_text('option[unread_timeout]', 5, $pm_prefs['unread_timeout'], 5)."</td>
|
||||
<td>".ADLAN_PM_20."</td>
|
||||
<td>".form::form_text('pm_option-unread_timeout', 5, $pm_prefs['unread_timeout'], 5)."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_21."</td>
|
||||
<td class='forumheader3' style='width:25%'>".yes_no('popup')."</td>
|
||||
<td>".ADLAN_PM_21."</td>
|
||||
<td>".yes_no('pm_option-popup', $pm_prefs['popup'])."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_22."</td>
|
||||
<td class='forumheader3' style='width:25%'>".form::form_text('option[popup_delay]', 5, $pm_prefs['popup_delay'], 5)." ".ADLAN_PM_44."</td>
|
||||
<td>".ADLAN_PM_22."</td>
|
||||
<td>".form::form_text('pm_option-popup_delay', 5, $pm_prefs['popup_delay'], 5)." ".ADLAN_PM_44."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_23."</td>
|
||||
<td class='forumheader3' style='width:25%'>".r_userclass('option[pm_class]', $pm_prefs['pm_class'], 'off', 'member,admin,classes')."</td>
|
||||
<td>".ADLAN_PM_23."</td>
|
||||
<td>".r_userclass('pm_option-pm_class', $pm_prefs['pm_class'], 'off', 'member,admin,classes')."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_24."</td>
|
||||
<td class='forumheader3' style='width:25%'>".form::form_text('option[perpage]', 5, $pm_prefs['perpage'], 5)."</td>
|
||||
<td>".ADLAN_PM_24."</td>
|
||||
<td>".form::form_text('pm_option-perpage', 5, $pm_prefs['perpage'], 5)."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_25."</td>
|
||||
<td class='forumheader3' style='width:25%'>".r_userclass('option[notify_class]', $pm_prefs['notify_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
<td>".ADLAN_PM_25."</td>
|
||||
<td>".r_userclass('pm_option-notify_class', $pm_prefs['notify_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_26."</td>
|
||||
<td class='forumheader3' style='width:25%'>".r_userclass('option[receipt_class]', $pm_prefs['receipt_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
<td>".ADLAN_PM_26."</td>
|
||||
<td>".r_userclass('pm_option-receipt_class', $pm_prefs['receipt_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_27."</td>
|
||||
<td class='forumheader3' style='width:25%'>".r_userclass('option[attach_class]', $pm_prefs['attach_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
<td>".ADLAN_PM_27."</td>
|
||||
<td>".r_userclass('pm_option-attach_class', $pm_prefs['attach_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_28."</td>
|
||||
<td class='forumheader3' style='width:25%'>".form::form_text('option[attach_size]', 8, $pm_prefs['attach_size'], 8)." kB</td>
|
||||
<td>".ADLAN_PM_28."</td>
|
||||
<td>".form::form_text('pm_option-attach_size-', 8, $pm_prefs['attach_size'], 8)." kB</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_29."</td>
|
||||
<td class='forumheader3' style='width:25%'>".r_userclass('option[sendall_class]', $pm_prefs['sendall_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
<td>".ADLAN_PM_29."</td>
|
||||
<td>".r_userclass('pm_option-sendall_class', $pm_prefs['sendall_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_30."</td>
|
||||
<td class='forumheader3' style='width:25%'>".r_userclass('option[multi_class]', $pm_prefs['multi_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
<td>".ADLAN_PM_30."</td>
|
||||
<td>".r_userclass('pm_option-multi_class', $pm_prefs['multi_class'], 'off', 'nobody,member,admin,classes')."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:75%'>".ADLAN_PM_31."</td>
|
||||
<td class='forumheader3' style='width:25%'>".yes_no('allow_userclass')."</td>
|
||||
<td>".ADLAN_PM_31."</td>
|
||||
<td>".yes_no('pm_option-allow_userclass', $pm_prefs['allow_userclass'])."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader' colspan='2' style='text-align:center'><input type='submit' class='button' name='update_prefs' value='".ADLAN_PM_32."' /></td>
|
||||
<td colspan='2' style='text-align:center'><input type='submit' class='button' name='update_prefs' value='".ADLAN_PM_32."' /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
";
|
||||
return $txt;
|
||||
}
|
||||
@@ -229,11 +337,10 @@ function show_options()
|
||||
function show_limits()
|
||||
{
|
||||
global $sql, $pref;
|
||||
if($sql->db_Select('userclass_classes','userclass_id, userclass_name'))
|
||||
{
|
||||
$classList = $sql->db_getList();
|
||||
}
|
||||
if($sql->db_Select("generic", "gen_id as limit_id, gen_datestamp as limit_classnum, gen_user_id as inbox_count, gen_ip as outbox_count, gen_intdata as inbox_size, gen_chardata as outbox_size", "gen_type = 'pm_limit'"))
|
||||
|
||||
if (!isset($pref['pm_limits'])) { $pref['pm_limits'] = 0; }
|
||||
|
||||
if($sql->db_Select('generic', "gen_id as limit_id, gen_datestamp as limit_classnum, gen_user_id as inbox_count, gen_ip as outbox_count, gen_intdata as inbox_size, gen_chardata as outbox_size", "gen_type = 'pm_limit'"))
|
||||
{
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
@@ -241,10 +348,17 @@ function show_limits()
|
||||
}
|
||||
}
|
||||
$txt = "
|
||||
<form method='post' action='".e_SELF."?".e_QUERY."'>
|
||||
<table class='fborder' style='width:95%'>
|
||||
<fieldset id='plugin-pm-showlimits'>
|
||||
<form method='post' action='".e_SELF."'>
|
||||
<table cellpadding='0' cellspacing='0' class='adminedit'>
|
||||
<colgroup span='3'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
<col class='col-control' />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan='3' class='forumheader3' style='text-align:left'>".ADLAN_PM_45."
|
||||
<td colspan='3' style='text-align:left'>".ADLAN_PM_45."
|
||||
<select name='pm_limits' class='tbox'>
|
||||
";
|
||||
$sel = ($pref['pm_limits'] == 0 ? "selected='selected'" : "");
|
||||
@@ -258,60 +372,66 @@ function show_limits()
|
||||
|
||||
$txt .= "</select>\n";
|
||||
|
||||
$txt .= "
|
||||
$txt .= ' '.ADLAN_PM_77."
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='fcaption'>".ADLAN_PM_36."</td>
|
||||
<td class='fcaption'>".ADLAN_PM_37."</td>
|
||||
<td class='fcaption'>".ADLAN_PM_38."</td>
|
||||
<th>".ADLAN_PM_36."</th>
|
||||
<th>".ADLAN_PM_37."</th>
|
||||
<th>".ADLAN_PM_38."</th>
|
||||
</tr>
|
||||
";
|
||||
|
||||
if (isset($limitList)) {
|
||||
if (isset($limitList))
|
||||
{
|
||||
foreach($limitList as $row)
|
||||
{
|
||||
$txt .= "
|
||||
<tr>
|
||||
<td class='forumheader3'>".r_userclass_name($row['limit_classnum'])."</td>
|
||||
<td class='forumheader3'>
|
||||
<td>".r_userclass_name($row['limit_classnum'])."</td>
|
||||
<td>
|
||||
".ADLAN_PM_39."<input type='text' class='tbox' size='5' name='inbox_count[{$row['limit_id']}]' value='{$row['inbox_count']}' />
|
||||
".ADLAN_PM_40."<input type='text' class='tbox' size='5' name='outbox_count[{$row['limit_id']}]' value='{$row['outbox_count']}' />
|
||||
</td>
|
||||
<td class='forumheader3'>
|
||||
<td>
|
||||
".ADLAN_PM_39."<input type='text' class='tbox' size='5' name='inbox_size[{$row['limit_id']}]' value='{$row['inbox_size']}' />
|
||||
".ADLAN_PM_40."<input type='text' class='tbox' size='5' name='outbox_size[{$row['limit_id']}]' value='{$row['outbox_size']}' />
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$txt .= "
|
||||
<tr>
|
||||
<td class='forumheader3' colspan='3' style='text-align: center'>".ADLAN_PM_41."</td>
|
||||
<td colspan='3' style='text-align: center'>".ADLAN_PM_41."</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
$txt .= "
|
||||
<tr>
|
||||
<td class='forumheader' colspan='3' style='text-align:center'>
|
||||
<td colspan='3' style='text-align:center'>
|
||||
<input type='submit' class='button' name='updatelimits' value='".ADLAN_PM_42."' />
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
|
||||
$txt .= "</table></form>";
|
||||
$txt .= '
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>';
|
||||
return $txt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function add_limit()
|
||||
{
|
||||
global $sql, $pref;
|
||||
if($sql->db_Select('userclass_classes','userclass_id, userclass_name'))
|
||||
{
|
||||
$classList = $sql->db_getList();
|
||||
}
|
||||
if($sql->db_Select("generic", "gen_id as limit_id, gen_datestamp as limit_classnum, gen_user_id as inbox_count, gen_ip as outbox_count, gen_intdata as inbox_size, gen_chardata as outbox_size", "gen_type = 'pm_limit'"))
|
||||
{
|
||||
while($row = $sql->db_Fetch())
|
||||
@@ -320,50 +440,275 @@ function add_limit()
|
||||
}
|
||||
}
|
||||
$txt = "
|
||||
<fieldset id='plugin-pm-addlimit'>
|
||||
<form method='post' action='".e_SELF."?".e_QUERY."'>
|
||||
<table class='fborder' style='width:95%'>
|
||||
<table cellpadding='0' cellspacing='0' class='adminedit'>
|
||||
<colgroup span='3'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
<col class='col-control' />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class='fcaption'>".ADLAN_PM_36."</td>
|
||||
<td class='fcaption'>".ADLAN_PM_37."</td>
|
||||
<td class='fcaption'>".ADLAN_PM_38."</td>
|
||||
<th>".ADLAN_PM_36."</th>
|
||||
<th>".ADLAN_PM_37."</th>
|
||||
<th>".ADLAN_PM_38."</th>
|
||||
</tr>
|
||||
";
|
||||
|
||||
$txt .= "
|
||||
<tr>
|
||||
<td class='forumheader3'>".r_userclass("newlimit_class", 0, "off", "guest,member,admin,classes,language")."</td>
|
||||
<td class='forumheader3'>
|
||||
<td>".r_userclass("newlimit_class", 0, "off", "guest,member,admin,classes,language")."</td>
|
||||
<td>
|
||||
".ADLAN_PM_39."<input type='text' class='tbox' size='5' name='new_inbox_count' value='' />
|
||||
".ADLAN_PM_40."<input type='text' class='tbox' size='5' name='new_outbox_count' value='' />
|
||||
</td>
|
||||
<td class='forumheader3'>
|
||||
<td>
|
||||
".ADLAN_PM_39."<input type='text' class='tbox' size='5' name='new_inbox_size' value='' />
|
||||
".ADLAN_PM_40."<input type='text' class='tbox' size='5' name='new_outbox_size' value='' />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader' colspan='3' style='text-align:center'>
|
||||
<td colspan='3' style='text-align:center'>
|
||||
<input type='submit' class='button' name='addlimit' value='".ADLAN_PM_43."' />
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
|
||||
$txt .= "</table></form>";
|
||||
$txt .= '
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>';
|
||||
return $txt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function show_maint($pmPrefs)
|
||||
{
|
||||
$txt = "
|
||||
<fieldset id='plugin-pm-maint'>
|
||||
<legend>".ADLAN_PM_62."</legend>
|
||||
<form method='post' action='".e_SELF."?maint'>
|
||||
<table cellpadding='0' cellspacing='0' class='adminedit'>
|
||||
<colgroup span='2'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>".ADLAN_PM_63."</td>
|
||||
<td>".yes_no('pm_maint_sent', '0')."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".ADLAN_PM_64."</td>
|
||||
<td>".yes_no('pm_maint_rec', '0')."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".ADLAN_PM_65."</td>
|
||||
<td>".yes_no('pm_maint_blocked', '0')."</td>
|
||||
</tr>";
|
||||
|
||||
if ($pmPrefs['read_timeout'] || $pmPrefs['unread_timeout'])
|
||||
{
|
||||
$txt .= "
|
||||
<tr>
|
||||
<td>".ADLAN_PM_71."</td>
|
||||
<td>".yes_no('pm_maint_expired', '0')."</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
$txt .= "
|
||||
<tr>
|
||||
<td colspan='2' style='text-align:center'><input type='submit' class='button' name='pm_maint_execute' value='".ADLAN_PM_61."' /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
";
|
||||
return $txt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Turn the array produced by doMaint for message display into an array of log strings.
|
||||
* Data is sorted into time stamp order
|
||||
*
|
||||
* @param array $results - array of arrays as returned from doMaint()
|
||||
* @param array|boolean $extra - optional additional information which is sorted into the main result according to keys - so use low numbers
|
||||
* to make the entry appear at the beginning, and text strings to add to the end.
|
||||
*/
|
||||
function makeLogEntry($results, $extra = FALSE)
|
||||
{
|
||||
$logPrefixes = array(E_MESSAGE_SUCCESS => 'Pass - ', E_MESSAGE_ERROR => 'Fail - ', E_MESSAGE_INFO => 'Info - ', E_MESSAGE_DEBUG => 'Debug - ');
|
||||
$res = array();
|
||||
foreach ($results as $k => $ma)
|
||||
{
|
||||
foreach ($ma as $ts => $m)
|
||||
{
|
||||
$res[$ts] = $logPrefixes[$k].$m;
|
||||
}
|
||||
}
|
||||
if (is_array($extra))
|
||||
{
|
||||
$res = array_merge($res, $extra);
|
||||
}
|
||||
ksort($res); // Sort in ascending order of timestamp
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Do PM DB maintenance
|
||||
* @param array $opts of tasks key = sent|rec|blocked|expired (one or more present). ATM value not used
|
||||
* @return array where key is message type (E_MESSAGE_SUCCESS|E_MESSAGE_ERROR|E_MESSAGE_INFO etc), data is array of messages of that type (key = timestamp)
|
||||
*/
|
||||
function doMaint($opts, $pmPrefs)
|
||||
{
|
||||
if (!count($opts))
|
||||
{
|
||||
return array(E_MESSAGE_ERROR => array(ADLAN_PM_66));
|
||||
}
|
||||
|
||||
$results = array(E_MESSAGE_INFO => array(ADLAN_PM_67));
|
||||
$logResults = array();
|
||||
$e107 = e107::getInstance();
|
||||
$e107->admin_log->log_event('PM_ADM_04', implode(', ',array_keys($opts)));
|
||||
$pmHandler = new private_message();
|
||||
$db2 = new db(); // Will usually need a second DB object to avoid over load
|
||||
$start = 0; // Use to ensure we get different log times
|
||||
|
||||
if (isset($opts['sent'])) // Want pm_from = deleted user and pm_read_del = 1
|
||||
{
|
||||
$cnt = 0;
|
||||
if ($res = $db2->db_Select_gen("SELECT pm.pm_id FROM `#private_msg` AS pm LEFT JOIN `#user` AS u ON pm.`pm_from` = `#user`.`user_id`
|
||||
WHERE (pm.`pm_read_del = 1) AND `#user`.`user_id` IS NULL"))
|
||||
{
|
||||
while ($row = $db2->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
if ($pmHandler->del($row['pm_id']) !== FALSE)
|
||||
{
|
||||
$cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$start = time();
|
||||
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $cnt, ADLAN_PM_74);
|
||||
}
|
||||
if (isset($opts['rec'])) // Want pm_to = deleted user and pm_sent_del = 1
|
||||
{
|
||||
$cnt = 0;
|
||||
if ($res = $db2->db_Select_gen("SELECT pm.pm_id FROM `#private_msg` AS pm LEFT JOIN `#user` AS u ON pm.`pm_to` = `#user`.`user_id`
|
||||
WHERE (pm.`pm_sent_del = 1) AND `#user`.`user_id` IS NULL"))
|
||||
{
|
||||
while ($row = $db2->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
if ($pmHandler->del($row['pm_id']) !== FALSE)
|
||||
{
|
||||
$cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$start = max($start + 1, $time);
|
||||
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $cnt, ADLAN_PM_75);
|
||||
}
|
||||
|
||||
|
||||
if (isset($opts['blocked']))
|
||||
{
|
||||
if ($res = $e107->sql->db_Select_gen("DELETE `#private_msg_block` FROM `#private_msg_block` LEFT JOIN `#user` ON `#private_msg_block`.`pm_block_from` = `#user`.`user_id`
|
||||
WHERE `#user`.`user_id` IS NULL"))
|
||||
{
|
||||
$start = max($start + 1, $time);
|
||||
$results[E_MESSAGE_ERROR][$start] = str_replace(array('--NUM--', '--TEXT--'), array($this->sql->getLastErrorNum, $this->sql->getLastErrorText), ADLAN_PM_70);
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = max($start + 1, $time);
|
||||
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $res, ADLAN_PM_69);
|
||||
}
|
||||
if ($res = $e107->sql->db_Select_gen("DELETE `#private_msg_block` FROM `#private_msg_block` LEFT JOIN `#user` ON `#private_msg_block`.`pm_block_to` = `#user`.`user_id`
|
||||
WHERE `#user`.`user_id` IS NULL"))
|
||||
{
|
||||
$start = max($start + 1, $time);
|
||||
$results[E_MESSAGE_ERROR][$start] = str_replace(array('--NUM--', '--TEXT--'), array($this->sql->getLastErrorNum, $this->sql->getLastErrorText), ADLAN_PM_70);
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = max($start + 1, $time);
|
||||
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $res, ADLAN_PM_68);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($opts['expired']))
|
||||
{
|
||||
$del_qry = array();
|
||||
$read_timeout = intval($pmPrefs['read_timeout']);
|
||||
$unread_timeout = intval($pmPrefs['unread_timeout']);
|
||||
if($read_timeout > 0)
|
||||
{
|
||||
$timeout = time()-($read_timeout * 86400);
|
||||
$del_qry[] = "(pm_sent < {$timeout} AND pm_read > 0)";
|
||||
}
|
||||
if($unread_timeout > 0)
|
||||
{
|
||||
$timeout = time()-($unread_timeout * 86400);
|
||||
$del_qry[] = "(pm_sent < {$timeout} AND pm_read = 0)";
|
||||
}
|
||||
if(count($del_qry) > 0)
|
||||
{
|
||||
$qry = implode(' OR ', $del_qry);
|
||||
$cnt = 0;
|
||||
if($db2->db_Select('private_msg', 'pm_id', $qry))
|
||||
{
|
||||
while ($row = $db2->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
if ($pmHandler->del($row['pm_id']) !== FALSE)
|
||||
{
|
||||
$cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$start = max($start + 1, $time);
|
||||
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $cnt, ADLAN_PM_73);
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = max($start + 1, $time);
|
||||
$results[E_MESSAGE_ERROR][$start] = ADLAN_PM_72;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$e107->admin_log->logArrayAll('PM_ADM_03',makeLogEntry($results));
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function show_menu($action)
|
||||
{
|
||||
global $sql;
|
||||
if ($action == "") { $action = "main"; }
|
||||
if ($action == '') { $action = 'main'; }
|
||||
|
||||
$var['main']['text'] = ADLAN_PM_54;
|
||||
$var['main']['link'] = e_SELF;
|
||||
|
||||
$var['limits']['text'] = ADLAN_PM_55;
|
||||
$var['limits']['link'] = e_SELF."?limits";
|
||||
$var['limits']['link'] = e_SELF.'?limits';
|
||||
|
||||
$var['maint']['text'] = ADLAN_PM_59;
|
||||
$var['maint']['link'] = e_SELF.'?maint';
|
||||
|
||||
show_admin_menu(ADLAN_PM_12, $action, $var);
|
||||
}
|
||||
|
||||
function pm_conf_adminmenu() {
|
||||
|
||||
function pm_conf_adminmenu()
|
||||
{
|
||||
global $action;
|
||||
show_menu($action);
|
||||
}
|
||||
|
Reference in New Issue
Block a user