mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
More PM work
This commit is contained in:
@@ -81,8 +81,8 @@ 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_75', 'Removed --COUNT-- messages received by deleted users');
|
||||||
define('ADLAN_PM_76', 'No changes made - nothing logged');
|
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_77', '(Empty all fields and Update to delete a limit)');
|
||||||
define('ADLAN_PM_78', '');
|
define('ADLAN_PM_78', 'Check attachments');
|
||||||
define('ADLAN_PM_79', '');
|
define('ADLAN_PM_79', '--ORPHANS-- unused attachments deleted. --MISSING-- missing attachments noted');
|
||||||
define('ADLAN_PM_80', '');
|
define('ADLAN_PM_80', '');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
* PM Plugin - administration
|
* PM Plugin - administration
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_conf.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_conf.php,v $
|
||||||
* $Revision: 1.8 $
|
* $Revision: 1.9 $
|
||||||
* $Date: 2009-12-11 22:33:15 $
|
* $Date: 2009-12-13 12:32:28 $
|
||||||
* $Author: e107steved $
|
* $Author: e107steved $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -115,6 +115,10 @@ if (isset($_POST['pm_maint_execute']))
|
|||||||
{
|
{
|
||||||
$maintOpts['expired'] = 1;
|
$maintOpts['expired'] = 1;
|
||||||
}
|
}
|
||||||
|
if (vartrue($_POST['pm_maint_attach']))
|
||||||
|
{
|
||||||
|
$maintOpts['attach'] = 1;
|
||||||
|
}
|
||||||
$result = doMaint($maintOpts, $pm_prefs);
|
$result = doMaint($maintOpts, $pm_prefs);
|
||||||
if (is_array($result))
|
if (is_array($result))
|
||||||
{
|
{
|
||||||
@@ -162,9 +166,10 @@ if(isset($_POST['addlimit']))
|
|||||||
|
|
||||||
if(isset($_POST['updatelimits']))
|
if(isset($_POST['updatelimits']))
|
||||||
{
|
{
|
||||||
if($pref['pm_limits'] != $_POST['pm_limits'])
|
$limitVal = intval($_POST['pm_limits']);
|
||||||
|
if($pref['pm_limits'] != $limitVal)
|
||||||
{
|
{
|
||||||
$pref['pm_limits'] = $_POST['pm_limits'];
|
$pref['pm_limits'] = $limitVal;
|
||||||
save_prefs();
|
save_prefs();
|
||||||
$emessage->add(ADLAN_PM_8, E_MESSAGE_SUCCESS);
|
$emessage->add(ADLAN_PM_8, E_MESSAGE_SUCCESS);
|
||||||
}
|
}
|
||||||
@@ -509,7 +514,8 @@ function show_maint($pmPrefs)
|
|||||||
<tr>
|
<tr>
|
||||||
<td>".ADLAN_PM_65."</td>
|
<td>".ADLAN_PM_65."</td>
|
||||||
<td>".yes_no('pm_maint_blocked', '0')."</td>
|
<td>".yes_no('pm_maint_blocked', '0')."</td>
|
||||||
</tr>";
|
</tr>
|
||||||
|
";
|
||||||
|
|
||||||
if ($pmPrefs['read_timeout'] || $pmPrefs['unread_timeout'])
|
if ($pmPrefs['read_timeout'] || $pmPrefs['unread_timeout'])
|
||||||
{
|
{
|
||||||
@@ -521,6 +527,10 @@ function show_maint($pmPrefs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$txt .= "
|
$txt .= "
|
||||||
|
<tr>
|
||||||
|
<td>".ADLAN_PM_78."</td>
|
||||||
|
<td>".yes_no('pm_maint_attach', '0')."</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan='2' style='text-align:center'><input type='submit' class='button' name='pm_maint_execute' value='".ADLAN_PM_61."' /></td>
|
<td colspan='2' style='text-align:center'><input type='submit' class='button' name='pm_maint_execute' value='".ADLAN_PM_61."' /></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -582,6 +592,7 @@ function doMaint($opts, $pmPrefs)
|
|||||||
$db2 = new db(); // Will usually need a second DB object to avoid over load
|
$db2 = new db(); // Will usually need a second DB object to avoid over load
|
||||||
$start = 0; // Use to ensure we get different log times
|
$start = 0; // Use to ensure we get different log times
|
||||||
|
|
||||||
|
|
||||||
if (isset($opts['sent'])) // Want pm_from = deleted user and pm_read_del = 1
|
if (isset($opts['sent'])) // Want pm_from = deleted user and pm_read_del = 1
|
||||||
{
|
{
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
@@ -613,7 +624,7 @@ function doMaint($opts, $pmPrefs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$start = max($start + 1, $time);
|
$start = max($start + 1, time());
|
||||||
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $cnt, ADLAN_PM_75);
|
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $cnt, ADLAN_PM_75);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,27 +634,28 @@ function doMaint($opts, $pmPrefs)
|
|||||||
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`
|
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"))
|
WHERE `#user`.`user_id` IS NULL"))
|
||||||
{
|
{
|
||||||
$start = max($start + 1, $time);
|
$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);
|
$results[E_MESSAGE_ERROR][$start] = str_replace(array('--NUM--', '--TEXT--'), array($this->sql->getLastErrorNum, $this->sql->getLastErrorText), ADLAN_PM_70);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$start = max($start + 1, $time);
|
$start = max($start + 1, time());
|
||||||
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $res, ADLAN_PM_69);
|
$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`
|
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"))
|
WHERE `#user`.`user_id` IS NULL"))
|
||||||
{
|
{
|
||||||
$start = max($start + 1, $time);
|
$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);
|
$results[E_MESSAGE_ERROR][$start] = str_replace(array('--NUM--', '--TEXT--'), array($this->sql->getLastErrorNum, $this->sql->getLastErrorText), ADLAN_PM_70);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$start = max($start + 1, $time);
|
$start = max($start + 1, time());
|
||||||
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $res, ADLAN_PM_68);
|
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $res, ADLAN_PM_68);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($opts['expired']))
|
if (isset($opts['expired']))
|
||||||
{
|
{
|
||||||
$del_qry = array();
|
$del_qry = array();
|
||||||
@@ -673,17 +685,74 @@ function doMaint($opts, $pmPrefs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$start = max($start + 1, $time);
|
$start = max($start + 1, time());
|
||||||
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $cnt, ADLAN_PM_73);
|
$results[E_MESSAGE_SUCCESS][$start] = str_replace('--COUNT--', $cnt, ADLAN_PM_73);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$start = max($start + 1, $time);
|
$start = max($start + 1, time());
|
||||||
$results[E_MESSAGE_ERROR][$start] = ADLAN_PM_72;
|
$results[E_MESSAGE_ERROR][$start] = ADLAN_PM_72;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (isset($opts['attach']))
|
||||||
|
{ // Check for orphaned and missing attachments
|
||||||
|
require_once(e_HANDLER.'file_class.php');
|
||||||
|
$fl = new e_file();
|
||||||
|
$missing = array();
|
||||||
|
$orphans = array();
|
||||||
|
$fileArray = $fl->get_files(e_PLUGIN.'pm/attachments');
|
||||||
|
if ($db2->db_Select('private_msg', 'pm_id, pm_attachments', "pm_attachments != ''"))
|
||||||
|
{
|
||||||
|
while ($row = $db2->db_Fetch(MYSQL_ASSOC))
|
||||||
|
{
|
||||||
|
$attachList = explode(chr(0), $row['pm_attachments']);
|
||||||
|
foreach ($attachList as $a)
|
||||||
|
{
|
||||||
|
$found = FALSE;
|
||||||
|
foreach ($fileArray as $k => $fd)
|
||||||
|
{
|
||||||
|
if ($fd['fname'] == $a)
|
||||||
|
{
|
||||||
|
$found = TRUE;
|
||||||
|
unset($fileArray[$k]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$found)
|
||||||
|
{
|
||||||
|
$missing[] = $row['pm_id'].':'.$a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Any files left in $fileArray now are unused
|
||||||
|
if (count($fileArray))
|
||||||
|
{
|
||||||
|
foreach ($fileArray as $k => $fd)
|
||||||
|
{
|
||||||
|
unlink($fd['path'].$fd['fname']);
|
||||||
|
$orphans[] = $fd['fname'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$attachMessage = str_replace(array('--ORPHANS--', '--MISSING--'), array(count($orphans), count($missing)), ADLAN_PM_79);
|
||||||
|
if (TRUE)
|
||||||
|
{ // Mostly for testing - probably disable this
|
||||||
|
if (count($orphans))
|
||||||
|
{
|
||||||
|
$attachMessage .= '[!br!]Orphans:[!br!]'.implode('[!br!]', $orphans);
|
||||||
|
}
|
||||||
|
if (count($missing))
|
||||||
|
{
|
||||||
|
$attachMessage .= '[!br!]Missing:[!br!]'.implode('[!br!]', $missing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$start = max($start + 1, time());
|
||||||
|
$results[E_MESSAGE_SUCCESS][$start] = $attachMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$e107->admin_log->logArrayAll('PM_ADM_03',makeLogEntry($results));
|
$e107->admin_log->logArrayAll('PM_ADM_03',makeLogEntry($results));
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
@@ -1,24 +1,27 @@
|
|||||||
CREATE TABLE private_msg (
|
CREATE TABLE private_msg (
|
||||||
pm_id int(10) unsigned NOT NULL auto_increment,
|
pm_id int(10) unsigned NOT NULL auto_increment,
|
||||||
pm_from int(10) unsigned NOT NULL default '0',
|
pm_from int(10) unsigned NOT NULL default '0',
|
||||||
pm_to varchar(250) NOT NULL default '',
|
pm_to varchar(250) NOT NULL default '',
|
||||||
pm_sent int(10) unsigned NOT NULL default '0',
|
pm_sent int(10) unsigned NOT NULL default '0', /* Date sent */
|
||||||
pm_read int(10) unsigned NOT NULL default '0',
|
pm_read int(10) unsigned NOT NULL default '0', /* Date read */
|
||||||
pm_subject text NOT NULL,
|
pm_subject text NOT NULL,
|
||||||
pm_text text NOT NULL,
|
pm_text text NOT NULL,
|
||||||
pm_sent_del tinyint(1) unsigned NOT NULL default '0',
|
pm_sent_del tinyint(1) unsigned NOT NULL default '0', /* Set when can delete */
|
||||||
pm_read_del tinyint(1) unsigned NOT NULL default '0',
|
pm_read_del tinyint(1) unsigned NOT NULL default '0', /* set when can delete */
|
||||||
pm_attachments text NOT NULL,
|
pm_attachments text NOT NULL,
|
||||||
pm_option varchar(250) NOT NULL default '',
|
pm_option varchar(250) NOT NULL default '',
|
||||||
pm_size int(10) unsigned NOT NULL default '0',
|
pm_size int(10) unsigned NOT NULL default '0',
|
||||||
PRIMARY KEY (pm_id)
|
PRIMARY KEY (pm_id)
|
||||||
) TYPE=MyISAM AUTO_INCREMENT=1 ;
|
) TYPE=MyISAM AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
CREATE TABLE private_msg_block (
|
|
||||||
pm_block_id int(10) unsigned NOT NULL auto_increment,
|
|
||||||
pm_block_from int(10) unsigned NOT NULL default '0',
|
CREATE TABLE private_msg_block (
|
||||||
pm_block_to int(10) unsigned NOT NULL default '0',
|
pm_block_id int(10) unsigned NOT NULL auto_increment,
|
||||||
pm_block_datestamp int(10) unsigned NOT NULL default '0',
|
pm_block_from int(10) unsigned NOT NULL default '0',
|
||||||
pm_block_count int(10) unsigned NOT NULL default '0',
|
pm_block_to int(10) unsigned NOT NULL default '0',
|
||||||
PRIMARY KEY (pm_block_id)
|
pm_block_datestamp int(10) unsigned NOT NULL default '0',
|
||||||
) TYPE=MyISAM AUTO_INCREMENT=1 ;
|
pm_block_count int(10) unsigned NOT NULL default '0', /* Not sure what this is for */
|
||||||
|
PRIMARY KEY (pm_block_id)
|
||||||
|
) TYPE=MyISAM AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user