mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Another attack on globals and notices
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
* e107 Shortcode handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $
|
||||
* $Revision: 1.39 $
|
||||
* $Date: 2009-12-12 16:40:41 $
|
||||
* $Author: secretr $
|
||||
* $Revision: 1.40 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@@ -523,7 +523,7 @@ class e_shortcode
|
||||
$ret = eval($scCode);
|
||||
}
|
||||
|
||||
if($ret != '' || is_numeric($ret))
|
||||
if(isset($ret) && ($ret != '' || is_numeric($ret)))
|
||||
{
|
||||
//if $sc_mode exists, we need it to parse $sc_style
|
||||
if($sc_mode)
|
||||
@@ -544,9 +544,9 @@ class e_shortcode
|
||||
}
|
||||
if (E107_DBG_SC)
|
||||
{
|
||||
$sql->db_Mark_Time("(SC $code Done)");
|
||||
$sql->db_Mark_Time("(SC {$code} Done)");
|
||||
}
|
||||
return $ret;
|
||||
return isset($ret) ? $ret : '';
|
||||
}
|
||||
|
||||
function parse_scbatch($fname, $type = 'file')
|
||||
|
@@ -9,8 +9,8 @@
|
||||
* Shortcodes for event calendar
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/calendar_shortcodes.php,v $
|
||||
* $Revision: 1.15 $
|
||||
* $Date: 2009-11-22 10:11:28 $
|
||||
* $Revision: 1.16 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*
|
||||
*/
|
||||
@@ -20,15 +20,12 @@ TODO:
|
||||
1. Could make date/month arrays 1-based instead of 0-based - might simplify maths
|
||||
2. Good way of reading categories
|
||||
|
||||
2. EC_EVENT_EVENT_DATE_TIME uses global template variable
|
||||
3. EC_NEXT_EVENT_GAP uses global $cal_totev - use $numEvents
|
||||
4. Have 'currentMonth' flag (means 'current day' if $ds == 'one') ?
|
||||
5. Check whether $prop should be calculated better
|
||||
4. Finish the conversion!
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
//require_once(e_HANDLER.'shortcode_handler.php'); // Should only be temporary?
|
||||
|
||||
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
|
||||
register_shortcode('event_calendar_shortcodes', true);
|
||||
initShortcodeClass('event_calendar_shortcodes');
|
||||
@@ -836,7 +833,6 @@ class event_calendar_shortcodes
|
||||
}
|
||||
|
||||
|
||||
// TODO: Resolve global
|
||||
public function sc_ec_event_event_date_time()
|
||||
{
|
||||
$et = 0;
|
||||
|
@@ -6,19 +6,23 @@
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
* PM plugin - main user interface
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm.php,v $
|
||||
* $Revision: 1.14 $
|
||||
* $Date: 2009-12-16 20:23:32 $
|
||||
* $Revision: 1.15 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
/*
|
||||
TODO:
|
||||
4. Check 'to' field - can sometimes be text
|
||||
|
||||
*/
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: pm.php,v 1.15 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
|
||||
$retrieve_prefs[] = 'pm_prefs';
|
||||
require_once('../../class2.php');
|
||||
@@ -32,7 +36,7 @@ if (!e107::isInstalled('pm'))
|
||||
|
||||
|
||||
|
||||
if($_POST['keyword'])
|
||||
if(vartrue($_POST['keyword']))
|
||||
{
|
||||
pm_user_lookup();
|
||||
}
|
||||
@@ -71,10 +75,8 @@ if(!isset($pm_prefs['pm_class']) || !check_class($pm_prefs['pm_class']))
|
||||
}
|
||||
|
||||
setScVar('pm_handler_shortcodes','pmPrefs', $pm_prefs);
|
||||
|
||||
|
||||
|
||||
|
||||
$pmManager = new pmbox_manager($pm_prefs);
|
||||
setScVar('pm_handler_shortcodes','pmManager', &$pmManager);
|
||||
|
||||
|
||||
|
||||
@@ -84,9 +86,7 @@ setScVar('pm_handler_shortcodes','pmPrefs', $pm_prefs);
|
||||
|
||||
class pm_extended extends private_message
|
||||
{
|
||||
protected $e107;
|
||||
protected $pmPrefs;
|
||||
|
||||
protected $pmManager = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -94,10 +94,10 @@ class pm_extended extends private_message
|
||||
* @param array $prefs - pref settings for PM plugin
|
||||
* @return none
|
||||
*/
|
||||
public function __construct($prefs)
|
||||
public function __construct($prefs, $manager)
|
||||
{
|
||||
$this->e107 = e107::getInstance();
|
||||
$this->pmPrefs = $prefs;
|
||||
$this->pmManager = $manager;
|
||||
parent::__construct($prefs);
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,8 @@ class pm_extended extends private_message
|
||||
*/
|
||||
function show_send($to_uid)
|
||||
{
|
||||
$pm_outbox = pm_getInfo('outbox');
|
||||
$pm_info = array();
|
||||
$pm_outbox = $this->pmManager->pm_getInfo('outbox');
|
||||
if (is_array($to_uid))
|
||||
{
|
||||
$pm_info = $to_uid; // We've been passed a 'reply to' PM
|
||||
@@ -125,7 +126,7 @@ class pm_extended extends private_message
|
||||
$pm_info['from_name'] = $row['user_name'];
|
||||
}
|
||||
}
|
||||
echo "Show_send: {$to_uid} from {$pm_info['from_name']} is happening<br />";
|
||||
//echo "Show_send: {$to_uid} from {$pm_info['from_name']} is happening<br />";
|
||||
|
||||
if($pm_outbox['outbox']['filled'] >= 100)
|
||||
{
|
||||
@@ -465,7 +466,7 @@ function pm_user_lookup()
|
||||
|
||||
|
||||
//$pm =& new private_message;
|
||||
$pm = new pm_extended($pm_prefs);
|
||||
$pm = new pm_extended($pm_prefs, &$pmManager);
|
||||
|
||||
$message = '';
|
||||
$pmSource = '';
|
||||
|
@@ -6,63 +6,114 @@
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
* PM plugin - base class API
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_class.php,v $
|
||||
* $Revision: 1.10 $
|
||||
* $Date: 2009-12-11 22:33:15 $
|
||||
* $Revision: 1.11 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: pm_class.php,v 1.11 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
class private_message
|
||||
{
|
||||
protected $e107;
|
||||
protected $pmPrefs;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $prefs - pref settings for PM plugin
|
||||
* @return none
|
||||
*/
|
||||
public function __construct($prefs)
|
||||
{
|
||||
$this->e107 = e107::getInstance();
|
||||
$this->pmPrefs = $prefs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Mark a PM as read
|
||||
* If flag set, send read receipt to sender
|
||||
*
|
||||
* @param int $pm_id - ID of PM
|
||||
* @param array $pm_info - PM details
|
||||
*
|
||||
* @return none
|
||||
*
|
||||
* @todo - 'read_delete' pref doesn't exist - remove code? Or support?
|
||||
*/
|
||||
function pm_mark_read($pm_id, $pm_info)
|
||||
{
|
||||
$now = time();
|
||||
global $pm_prefs, $sql;
|
||||
if($pm_prefs['read_delete'])
|
||||
if($this->pmPrefs['read_delete'])
|
||||
{
|
||||
$this->del($pm_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql->db_Select_gen("UPDATE #private_msg SET pm_read = {$now} WHERE pm_id=".intval($pm_id));
|
||||
if(strpos($pm_info['pm_option'], "+rr") !== FALSE)
|
||||
$this->e107->sql->db_Select_gen("UPDATE `#private_msg` SET `pm_read` = {$now} WHERE `pm_id`=".intval($pm_id));
|
||||
if(strpos($pm_info['pm_option'], '+rr') !== FALSE)
|
||||
{
|
||||
$this->pm_send_receipt($pm_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get an existing PM
|
||||
*
|
||||
* @param int $pmid - ID of PM in DB
|
||||
*
|
||||
* @return boolean|array - FALSE on error, array of PM info on success
|
||||
*/
|
||||
function pm_get($pmid)
|
||||
{
|
||||
global $sql;
|
||||
$qry = "
|
||||
SELECT pm.*, ut.user_image AS sent_image, ut.user_name AS sent_name, uf.user_image AS from_image, uf.user_name AS from_name, uf.user_email as from_email, ut.user_email as to_email FROM #private_msg AS pm
|
||||
LEFT JOIN #user AS ut ON ut.user_id = pm.pm_to
|
||||
LEFT JOIN #user AS uf ON uf.user_id = pm.pm_from
|
||||
WHERE pm.pm_id='".intval($pmid)."'
|
||||
";
|
||||
if ($sql->db_Select_gen($qry))
|
||||
if ($this->e107->sql->db_Select_gen($qry))
|
||||
{
|
||||
$row = $sql->db_Fetch();
|
||||
$row = $this->e107->sql->db_Fetch();
|
||||
return $row;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// Send a PM
|
||||
/*
|
||||
* Send a PM
|
||||
*
|
||||
* @param array $vars - PM information
|
||||
*
|
||||
* @return string - text detailing result
|
||||
*
|
||||
* @todo Convert DB calls to use arrays
|
||||
*/
|
||||
function add($vars)
|
||||
{
|
||||
global $pm_prefs, $tp, $sql;
|
||||
$vars['options'] = "";
|
||||
$vars['options'] = '';
|
||||
$pmsize = 0;
|
||||
$attachlist = "";
|
||||
$pm_options = "";
|
||||
if(isset($vars['receipt']) && $vars['receipt']) {$pm_options .= "+rr+"; }
|
||||
$attachlist = '';
|
||||
$pm_options = '';
|
||||
if(isset($vars['receipt']) && $vars['receipt']) {$pm_options .= '+rr+'; }
|
||||
if(isset($vars['uploaded']))
|
||||
{
|
||||
foreach($vars['uploaded'] as $u)
|
||||
@@ -77,12 +128,12 @@ class private_message
|
||||
}
|
||||
$pmsize += strlen($vars['pm_message']);
|
||||
|
||||
$pm_subject = trim($tp->toDB($vars['pm_subject']));
|
||||
$pm_message = trim($tp->toDB($vars['pm_message']));
|
||||
$pm_subject = trim($this->e107->tp->toDB($vars['pm_subject']));
|
||||
$pm_message = trim($this->e107->tp->toDB($vars['pm_message']));
|
||||
|
||||
if (!$pm_subject && !$pm_message && !$attachlist)
|
||||
{ // Error - no subject, no message body and no uploaded files
|
||||
return LAN_PM_65;
|
||||
return LAN_PM_65;
|
||||
}
|
||||
|
||||
$sendtime = time();
|
||||
@@ -90,8 +141,8 @@ class private_message
|
||||
{
|
||||
if(isset($vars['to_userclass']))
|
||||
{
|
||||
require_once(e_HANDLER."userclass_class.php");
|
||||
$toclass = r_userclass_name($vars['pm_userclass']);
|
||||
require_once(e_HANDLER.'userclass_class.php');
|
||||
$toclass = e107::getUserClass()->uc_get_classname($vars['pm_userclass']);
|
||||
$tolist = $this->get_users_inclass($vars['pm_userclass']);
|
||||
$ret .= LAN_PM_38.": {$vars['to_userclass']}<br />";
|
||||
$class = TRUE;
|
||||
@@ -104,7 +155,7 @@ class private_message
|
||||
foreach($tolist as $u)
|
||||
{
|
||||
set_time_limit(30);
|
||||
if($pmid = $sql->db_Insert("private_msg", "0, '".intval($vars['from_id'])."', '".$tp -> toDB($u['user_id'])."', '".intval($sendtime)."', '0', '{$pm_subject}', '{$pm_message}', '1', '0', '".$tp -> toDB($attachlist)."', '".$tp -> toDB($pm_options)."', '".intval($pmsize)."'"))
|
||||
if($pmid = $this->e107->sql->db_Insert('private_msg', "0, '".intval($vars['from_id'])."', '".$tp -> toDB($u['user_id'])."', '".intval($sendtime)."', '0', '{$pm_subject}', '{$pm_message}', '1', '0', '".$tp -> toDB($attachlist)."', '".$tp -> toDB($pm_options)."', '".intval($pmsize)."'"))
|
||||
{
|
||||
if($class == FALSE)
|
||||
{
|
||||
@@ -121,7 +172,7 @@ class private_message
|
||||
$ret .= LAN_PM_39.": {$u['user_name']} <br />";
|
||||
}
|
||||
}
|
||||
if(!$pmid = $sql->db_Insert("private_msg", "0, '".intval($vars['from_id'])."', '".$tp -> toDB($toclass)."', '".intval($sendtime)."', '1', '{$pm_subject}', '{$pm_message}', '0', '1', '".$tp -> toDB($attachlist)."', '".$tp -> toDB($pm_options)."', '".intval($pmsize)."'"))
|
||||
if(!$pmid = $this->e107->sql->db_Insert('private_msg', "0, '".intval($vars['from_id'])."', '".$tp -> toDB($toclass)."', '".intval($sendtime)."', '1', '{$pm_subject}', '{$pm_message}', '0', '1', '".$tp -> toDB($attachlist)."', '".$tp -> toDB($pm_options)."', '".intval($pmsize)."'"))
|
||||
{
|
||||
$ret .= LAN_PM_41."<br />";
|
||||
}
|
||||
@@ -129,7 +180,7 @@ class private_message
|
||||
}
|
||||
else
|
||||
{
|
||||
if($pmid = $sql->db_Insert("private_msg", "0, '".intval($vars['from_id'])."', '".$tp -> toDB($vars['to_info']['user_id'])."', '".intval($sendtime)."', '0', '{$pm_subject}', '{$pm_message}', '0', '0', '".$tp -> toDB($attachlist)."', '".$tp -> toDB($pm_options)."', '".intval($pmsize)."'"))
|
||||
if($pmid = $this->e107->sql->db_Insert('private_msg', "0, '".intval($vars['from_id'])."', '".$tp -> toDB($vars['to_info']['user_id'])."', '".intval($sendtime)."', '0', '{$pm_subject}', '{$pm_message}', '0', '0', '".$tp -> toDB($attachlist)."', '".$tp -> toDB($pm_options)."', '".intval($pmsize)."'"))
|
||||
{
|
||||
if(check_class($pm_prefs['notify_class'], $vars['to_info']['user_class']))
|
||||
{
|
||||
@@ -154,12 +205,11 @@ class private_message
|
||||
*/
|
||||
function del($pmid)
|
||||
{
|
||||
global $sql;
|
||||
$pmid = (int)$pmid;
|
||||
$ret = '';
|
||||
$del_pm = FALSE;
|
||||
$newvals = '';
|
||||
if($sql->db_Select('private_msg', '*', 'pm_id = '.$pmid.' AND (pm_from = '.USERID.' OR pm_to = '.USERID.')'))
|
||||
if($this->e107->sql->db_Select('private_msg', '*', 'pm_id = '.$pmid.' AND (pm_from = '.USERID.' OR pm_to = '.USERID.')'))
|
||||
{
|
||||
$row = $sql->db_Fetch();
|
||||
if($row['pm_to'] == USERID)
|
||||
@@ -186,7 +236,6 @@ class private_message
|
||||
$a = trim($a);
|
||||
if ($a)
|
||||
{
|
||||
// $filename = getcwd()."/attachments/{$a}";
|
||||
$filename = e_PLUGIN.'pm/attachments/'.$a;
|
||||
if (unlink($filename)) $aCount[0]++; else $aCount[1]++;
|
||||
}
|
||||
@@ -195,11 +244,11 @@ class private_message
|
||||
{
|
||||
$ret .= str_replace(array('--GOOD--', '--FAIL--'), $aCount, LAN_PM_71).'<br />';
|
||||
}
|
||||
$sql->db_Delete('private_msg', 'pm_id = '.$pmid);
|
||||
$this->e107->sql->db_Delete('private_msg', 'pm_id = '.$pmid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql->db_Update('private_msg', $newvals.' WHERE pm_id = '.$pmid);
|
||||
$this->e107->sql->db_Update('private_msg', $newvals.' WHERE pm_id = '.$pmid);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
@@ -208,50 +257,67 @@ class private_message
|
||||
|
||||
|
||||
|
||||
function pm_send_notify($uid, $pminfo, $pmid, $attach_count = 0)
|
||||
/*
|
||||
* Send an email to notify of a PM
|
||||
*
|
||||
* @param int $uid - not used
|
||||
* @param array $pmInfo - PM details
|
||||
* @param int $pmid - ID of PM in database
|
||||
* @param int $attach_count - number of attachments
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function pm_send_notify($uid, $pmInfo, $pmid, $attach_count = 0)
|
||||
{
|
||||
require_once(e_HANDLER.'mail.php');
|
||||
global $PLUGINS_DIRECTORY;
|
||||
$subject = LAN_PM_100.SITENAME;
|
||||
$pmlink = SITEURL.$PLUGINS_DIRECTORY."pm/pm.php?show.{$pmid}";
|
||||
$pmlink = SITEURLBASE.e_PLUGIN_ABS.'pm/pm.php?show.'.$pmid;
|
||||
$txt = LAN_PM_101.SITENAME."\n\n";
|
||||
$txt .= LAN_PM_102.USERNAME."\n";
|
||||
$txt .= LAN_PM_103.$pminfo['pm_subject']."\n";
|
||||
$txt .= LAN_PM_103.$pmInfo['pm_subject']."\n";
|
||||
if($attach_count > 0)
|
||||
{
|
||||
$txt .= LAN_PM_104.$attach_count."\n";
|
||||
}
|
||||
$txt .= LAN_PM_105."\n".$pmlink."\n";
|
||||
sendemail($pminfo['to_info']['user_email'], $subject, $txt, $pminfo['to_info']['user_name']);
|
||||
sendemail($pmInfo['to_info']['user_email'], $subject, $txt, $pmInfo['to_info']['user_name']);
|
||||
}
|
||||
|
||||
function pm_send_receipt($pminfo)
|
||||
|
||||
/*
|
||||
* Send PM read receipt
|
||||
*
|
||||
* @param array $pmInfo - PM details
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function pm_send_receipt($pmInfo)
|
||||
{
|
||||
require_once(e_HANDLER."mail.php");
|
||||
global $PLUGINS_DIRECTORY;
|
||||
$subject = LAN_PM_106.$pminfo['sent_name'];
|
||||
$pmlink = SITEURL.$PLUGINS_DIRECTORY."pm/pm.php?show.{$pminfo['pm_id']}";
|
||||
$txt = str_replace("{UNAME}", $pminfo['sent_name'], LAN_PM_107).date('l F dS Y h:i:s A')."\n\n";
|
||||
$txt .= LAN_PM_108.date('l F dS Y h:i:s A', $pminfo['pm_sent'])."\n";
|
||||
$txt .= LAN_PM_103.$pminfo['pm_subject']."\n";
|
||||
require_once(e_HANDLER.'mail.php');
|
||||
$subject = LAN_PM_106.$pmInfo['sent_name'];
|
||||
$pmlink = SITEURLBASE.e_PLUGIN_ABS."pm/pm.php?show.{$pmInfo['pm_id']}";
|
||||
$txt = str_replace("{UNAME}", $pmInfo['sent_name'], LAN_PM_107).date('l F dS Y h:i:s A')."\n\n";
|
||||
$txt .= LAN_PM_108.date('l F dS Y h:i:s A', $pmInfo['pm_sent'])."\n";
|
||||
$txt .= LAN_PM_103.$pmInfo['pm_subject']."\n";
|
||||
$txt .= LAN_PM_105."\n".$pmlink."\n";
|
||||
sendemail($pminfo['from_email'], $subject, $txt, $pminfo['from_name']);
|
||||
sendemail($pminfo['from_email'], $subject, $txt, $pmInfo['from_name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get list of users blocked from sending to a specific user ID.
|
||||
*
|
||||
* @param integer $to - user ID
|
||||
*
|
||||
* @return array of blocked users as user IDs
|
||||
*/
|
||||
function block_get($to = USERID)
|
||||
{
|
||||
global $sql;
|
||||
$ret = array();
|
||||
$to = intval($to); // Precautionary
|
||||
if ($sql->db_Select('private_msg_block', 'pm_block_from', 'pm_block_to = '.$to))
|
||||
if ($this->e107->sql->db_Select('private_msg_block', 'pm_block_from', 'pm_block_to = '.$to))
|
||||
{
|
||||
while($row = $sql->db_Fetch(MYSQL_ASSOC))
|
||||
while($row = $this->e107->sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$ret[] = $row['pm_block_from'];
|
||||
}
|
||||
@@ -262,17 +328,18 @@ class private_message
|
||||
|
||||
/**
|
||||
* Get list of users blocked from sending to a specific user ID.
|
||||
*
|
||||
* @param integer $to - user ID
|
||||
*
|
||||
* @return array of blocked users, including specific user info
|
||||
*/
|
||||
function block_get_user($to = USERID)
|
||||
{
|
||||
global $sql, $tp;
|
||||
$ret = array();
|
||||
$to = intval($to); // Precautionary
|
||||
if ($sql->db_Select_gen('SELECT pm.*, u.user_name FROM `#private_msg_block` AS pm LEFT JOIN `#user` AS u ON `pm`.`pm_block_from` = `u`.`user_id` WHERE pm_block_to = '.$to))
|
||||
if ($this->e107->sql->db_Select_gen('SELECT pm.*, u.user_name FROM `#private_msg_block` AS pm LEFT JOIN `#user` AS u ON `pm`.`pm_block_from` = `u`.`user_id` WHERE pm_block_to = '.$to))
|
||||
{
|
||||
while($row = $sql->db_Fetch(MYSQL_ASSOC))
|
||||
while($row = $this->e107->sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$ret[] = $row;
|
||||
}
|
||||
@@ -280,20 +347,31 @@ class private_message
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a user block
|
||||
*
|
||||
* @param int $from - sender to block
|
||||
* @param int $to - user doing the blocking
|
||||
*
|
||||
* @return string result message
|
||||
*
|
||||
* @todo change db access to use arrays
|
||||
*/
|
||||
function block_add($from, $to = USERID)
|
||||
{
|
||||
global $sql, $tp;
|
||||
if($sql->db_Select("user", "user_name, user_perms", "user_id = '".intval($from)."'"))
|
||||
$from = intval($from);
|
||||
if($this->e107->sql->db_Select('user', 'user_name, user_perms', 'user_id = '.$from))
|
||||
{
|
||||
$uinfo = $sql->db_Fetch();
|
||||
if (($uinfo['user_perms'] == '0') || ($uinfo['user_perms'] == '0.'))
|
||||
{ // Don't allow block of main admin
|
||||
return LAN_PM_64;
|
||||
}
|
||||
$uinfo = $this->e107->sql->db_Fetch();
|
||||
if (($uinfo['user_perms'] == '0') || ($uinfo['user_perms'] == '0.'))
|
||||
{ // Don't allow block of main admin
|
||||
return LAN_PM_64;
|
||||
}
|
||||
|
||||
if(!$sql->db_Count("private_msg_block", "(*)", "WHERE pm_block_from = '".intval($from)."' AND pm_block_to = '".$tp -> toDB($to)."'"))
|
||||
if(!$this->e107->sql->db_Count('private_msg_block', '(*)', 'WHERE pm_block_from = '.$from." AND pm_block_to = '".$this->e107->tp->toDB($to)."'"))
|
||||
{
|
||||
if($sql->db_Insert("private_msg_block", "0, '".intval($from)."', '".$tp -> toDB($to)."', '".time()."', '0'"))
|
||||
if($this->e107->sql->db_Insert('private_msg_block', "0, '".$from."', '".$this->e107->tp -> toDB($to)."', '".time()."', '0'"))
|
||||
{
|
||||
return str_replace('{UNAME}', $uinfo['user_name'], LAN_PM_47);
|
||||
}
|
||||
@@ -313,17 +391,26 @@ class private_message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete user block
|
||||
*
|
||||
* @param int $from - sender to block
|
||||
* @param int $to - user doing the blocking
|
||||
*
|
||||
* @return string result message
|
||||
*/
|
||||
function block_del($from, $to = USERID)
|
||||
{
|
||||
global $sql;
|
||||
$from = intval($from);
|
||||
if($sql->db_Select('user', 'user_name', 'user_id = '.$from))
|
||||
if($this->e107->sql->db_Select('user', 'user_name', 'user_id = '.$from))
|
||||
{
|
||||
$uinfo = $sql->db_Fetch();
|
||||
if($sql->db_Select('private_msg_block', 'pm_block_id', 'pm_block_from = '.$from.' AND pm_block_to = '.intval($to)))
|
||||
$uinfo = $this->e107->sql->db_Fetch();
|
||||
if($this->e107->sql->db_Select('private_msg_block', 'pm_block_id', 'pm_block_from = '.$from.' AND pm_block_to = '.intval($to)))
|
||||
{
|
||||
$row = $sql->db_Fetch();
|
||||
if($sql->db_Delete('private_msg_block', 'pm_block_id = '.intval($row['pm_block_id'])))
|
||||
$row = $this->e107->sql->db_Fetch();
|
||||
if($this->e107->sql->db_Delete('private_msg_block', 'pm_block_id = '.intval($row['pm_block_id'])))
|
||||
{
|
||||
return str_replace('{UNAME}', $uinfo['user_name'], LAN_PM_44);
|
||||
}
|
||||
@@ -343,89 +430,142 @@ class private_message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get user ID matching a name
|
||||
*
|
||||
* @param string var - name to match
|
||||
*
|
||||
* @return boolean|array - FALSE if no match, array of user info if found
|
||||
*/
|
||||
function pm_getuid($var)
|
||||
{
|
||||
global $sql, $tp;
|
||||
$var = trim($var);
|
||||
if($sql->db_Select("user", "user_id, user_name, user_class, user_email", "user_name LIKE '".$sql -> escape(trim($var), TRUE)."'"))
|
||||
if($this->e107->sql->db_Select('user', 'user_id, user_name, user_class, user_email', "user_name LIKE '".$this->e107->sql -> escape(trim($var), TRUE)."'"))
|
||||
{
|
||||
$row = $sql->db_Fetch();
|
||||
$row = $this->e107->sql->db_Fetch();
|
||||
return $row;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get list of users in class
|
||||
*
|
||||
* @param int $class - class ID
|
||||
*
|
||||
* @return boolean|array - FALSE on error/none found, else array of user information arrays
|
||||
*/
|
||||
function get_users_inclass($class)
|
||||
{
|
||||
global $sql, $tp;
|
||||
if($class == e_UC_MEMBER)
|
||||
{
|
||||
$qry = "SELECT user_id, user_name, user_email, user_class FROM #user WHERE 1";
|
||||
$qry = "SELECT user_id, user_name, user_email, user_class FROM `#user` WHERE 1";
|
||||
}
|
||||
elseif($class == e_UC_ADMIN)
|
||||
{
|
||||
$qry = "SELECT user_id, user_name, user_email, user_class FROM #user WHERE user_admin = 1";
|
||||
$qry = "SELECT user_id, user_name, user_email, user_class FROM `#user` WHERE user_admin = 1";
|
||||
}
|
||||
elseif($class)
|
||||
{
|
||||
$regex = "(^|,)(".$tp -> toDB($class).")(,|$)";
|
||||
$qry = "SELECT user_id, user_name, user_email, user_class FROM #user WHERE user_class REGEXP '{$regex}'";
|
||||
$regex = "(^|,)(".$this->e107->tp->toDB($class).")(,|$)";
|
||||
$qry = "SELECT user_id, user_name, user_email, user_class FROM `#user` WHERE user_class REGEXP '{$regex}'";
|
||||
}
|
||||
if($sql->db_Select_gen($qry))
|
||||
if($this->e107->sql->db_Select_gen($qry))
|
||||
{
|
||||
$ret = $sql->db_getList();
|
||||
$ret = $this->e107->sql->db_getList();
|
||||
return $ret;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get inbox - up to $limit messages from $from
|
||||
*
|
||||
* @param int $uid - user ID
|
||||
* @param int $from - first message
|
||||
* @param int $limit - number of messages
|
||||
*
|
||||
* @return boolean|array - FALSE if none found or error, array of PMs if available
|
||||
*
|
||||
* @todo - use MYSQL_CALC_ROWS
|
||||
*/
|
||||
function pm_get_inbox($uid = USERID, $from = 0, $limit = 10)
|
||||
{
|
||||
global $sql;
|
||||
$ret = "";
|
||||
if($total_messages = $sql->db_Count("private_msg", "(*)", "WHERE pm_to='{$uid}' AND pm_read_del=0"))
|
||||
$ret = array();
|
||||
$uid = intval($uid);
|
||||
$limit = intval($limit);
|
||||
if ($limit < 2) { $limit = 10; }
|
||||
$from = intval($from);
|
||||
if($total_messages = $this->e107->sql->db_Count("private_msg", "(*)", "WHERE pm_to='{$uid}' AND pm_read_del=0"))
|
||||
{
|
||||
$qry = "
|
||||
SELECT pm.*, u.user_image, u.user_name FROM #private_msg AS pm
|
||||
LEFT JOIN #user AS u ON u.user_id = pm.pm_from
|
||||
WHERE pm.pm_to='{$uid}' AND pm.pm_read_del=0
|
||||
ORDER BY pm.pm_sent DESC
|
||||
LIMIT ".intval($from).", ".intval($limit)."
|
||||
LIMIT ".$from.", ".$limit."
|
||||
";
|
||||
if($sql->db_Select_gen($qry))
|
||||
if($this->e107->sql->db_Select_gen($qry))
|
||||
{
|
||||
$ret['messages'] = $sql->db_getList();
|
||||
$ret['messages'] = $this->e107->sql->db_getList();
|
||||
$ret['total_messages'] = $total_messages;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get outbox - up to $limit messages from $from
|
||||
*
|
||||
* @param int $uid - user ID
|
||||
* @param int $from - first message
|
||||
* @param int $limit - number of messages
|
||||
*
|
||||
* @return boolean|array - FALSE if none found or error, array of PMs if available
|
||||
*
|
||||
* @todo - use MYSQL_CALC_ROWS
|
||||
*/
|
||||
function pm_get_outbox($uid = USERID, $from = 0, $limit = 10)
|
||||
{
|
||||
global $sql;
|
||||
if(intval($limit < 1)) { $limit = 10; }
|
||||
if($total_messages = $sql->db_Count("private_msg", "(*)", "WHERE pm_from='{$uid}' AND pm_sent_del=0"))
|
||||
$uid = intval($uid);
|
||||
$limit = intval($limit);
|
||||
if ($limit < 2) { $limit = 10; }
|
||||
$from = intval($from);
|
||||
if($total_messages = $this->e107->sql->db_Count("private_msg", "(*)", "WHERE pm_from='{$uid}' AND pm_sent_del=0"))
|
||||
{
|
||||
$qry = "
|
||||
SELECT pm.*, u.user_image, u.user_name FROM #private_msg AS pm
|
||||
LEFT JOIN #user AS u ON u.user_id = pm.pm_to
|
||||
WHERE pm.pm_from='{$uid}' AND pm.pm_sent_del=0
|
||||
ORDER BY pm.pm_sent DESC
|
||||
LIMIT ".intval($from).", ".intval($limit)."
|
||||
";
|
||||
if($sql->db_Select_gen($qry))
|
||||
LIMIT ".$from.', '.$limit;
|
||||
if($this->e107->sql->db_Select_gen($qry))
|
||||
{
|
||||
$ret['messages'] = $sql->db_getList();
|
||||
$ret['messages'] = $this->e107->sql->db_getList();
|
||||
$ret['total_messages'] = $total_messages;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a file down to the user
|
||||
*
|
||||
* @param int $pmid - PM ID
|
||||
* @param string $filenum - attachment number within the list associated with the PM
|
||||
*
|
||||
* @return none
|
||||
*
|
||||
* @todo Can we use core send routine?
|
||||
*/
|
||||
function send_file($pmid, $filenum)
|
||||
{
|
||||
global $pref;
|
||||
$pm_info = $this->pm_get($pmid);
|
||||
$attachments = explode(chr(0), $pm_info['pm_attachments']);
|
||||
if(!isset($attachments[$filenum]))
|
||||
|
@@ -9,12 +9,21 @@
|
||||
* PM Plugin - administration
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_conf.php,v $
|
||||
* $Revision: 1.10 $
|
||||
* $Date: 2009-12-16 20:23:35 $
|
||||
* $Revision: 1.11 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: pm_conf.php,v 1.11 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
TODO:
|
||||
1. Limits page needs some lines round the table
|
||||
@@ -253,6 +262,7 @@ if ($emessage->hasMessage())
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case 'main' :
|
||||
@@ -374,7 +384,7 @@ function show_options($pm_prefs)
|
||||
|
||||
function show_limits($pm_prefs)
|
||||
{
|
||||
global $sql;
|
||||
$sql = e107::getDb();
|
||||
|
||||
if (!isset($pm_prefs['pm_limits'])) { $pm_prefs['pm_limits'] = 0; }
|
||||
|
||||
@@ -469,7 +479,7 @@ function show_limits($pm_prefs)
|
||||
|
||||
function add_limit($pm_prefs)
|
||||
{
|
||||
global $sql;
|
||||
$sql = e107::getDb();
|
||||
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())
|
||||
@@ -621,7 +631,7 @@ function doMaint($opts, $pmPrefs)
|
||||
$logResults = array();
|
||||
$e107 = e107::getInstance();
|
||||
$e107->admin_log->log_event('PM_ADM_04', implode(', ',array_keys($opts)));
|
||||
$pmHandler = new private_message();
|
||||
$pmHandler = new private_message($pmPrefs);
|
||||
$db2 = new db(); // Will usually need a second DB object to avoid over load
|
||||
$start = 0; // Use to ensure we get different log times
|
||||
|
||||
@@ -799,8 +809,10 @@ function doMaint($opts, $pmPrefs)
|
||||
|
||||
|
||||
|
||||
function show_menu($action)
|
||||
|
||||
function pm_conf_adminmenu()
|
||||
{
|
||||
global $action;
|
||||
if ($action == '') { $action = 'main'; }
|
||||
|
||||
$var['main']['text'] = ADLAN_PM_54;
|
||||
@@ -815,11 +827,4 @@ function show_menu($action)
|
||||
show_admin_menu(ADLAN_PM_12, $action, $var);
|
||||
}
|
||||
|
||||
|
||||
function pm_conf_adminmenu()
|
||||
{
|
||||
global $action;
|
||||
show_menu($action);
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -1,4 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Private messenger plugin - default preferences (used if no stored values)
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_default.php,v $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* default preferences (used if no stored values)
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: pm_default.php,v 1.3 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
function pm_set_default_prefs()
|
||||
|
@@ -6,98 +6,134 @@
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
* Private messenger plugin - utility functions
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_func.php,v $
|
||||
* $Revision: 1.7 $
|
||||
* $Date: 2009-11-18 01:05:53 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.8 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: pm_func.php,v 1.8 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
function pm_getInfo($which = "inbox")
|
||||
|
||||
|
||||
class pmbox_manager
|
||||
{
|
||||
static $pm_info;
|
||||
global $sql, $pref, $pm_prefs;
|
||||
if('clear' == $which)
|
||||
protected $pmPrefs = array();
|
||||
protected $pmDB;
|
||||
|
||||
public function __construct($prefs)
|
||||
{
|
||||
unset($pm_info['inbox']);
|
||||
unset($pm_info['outbox']);
|
||||
return;
|
||||
$this->pmDB = e107::getDb();
|
||||
$this->pmPrefs = $prefs;
|
||||
}
|
||||
|
||||
if('inbox' == $which)
|
||||
{
|
||||
$qry = "SELECT count(pm.pm_id) AS total, SUM(pm.pm_size)/1024 size, SUM(pm.pm_read = 0) as unread FROM #private_msg as pm WHERE pm.pm_to = ".USERID." AND pm.pm_read_del = 0";
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry = "SELECT count(pm.pm_from) AS total, SUM(pm.pm_size)/1024 size, SUM(pm.pm_read = 0) as unread FROM #private_msg as pm WHERE pm.pm_from = ".USERID." AND pm.pm_sent_del = 0";
|
||||
}
|
||||
|
||||
if(!isset($pm_info[$which]['total']))
|
||||
/**
|
||||
* Get the box-related information for inbox or outbox - limits, message count etc
|
||||
* The information read from the DB is cached internally for efficiency
|
||||
*
|
||||
* @param string $which = inbox|outbox|clear
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
function pm_getInfo($which = 'inbox')
|
||||
{
|
||||
$sql->db_Select_gen($qry);
|
||||
$pm_info[$which] = $sql->db_Fetch();
|
||||
if ($which == 'inbox' && ($pm_prefs['animate'] == 1 || $pm_prefs['popup'] == 1))
|
||||
static $pm_info;
|
||||
|
||||
if('clear' == $which)
|
||||
{
|
||||
if($new = $sql->db_Count("private_msg", "(*)", "WHERE pm_sent > '".USERLV."' AND pm_read = 0 AND pm_to = '".USERID."' AND pm_read_del != 1"))
|
||||
{
|
||||
$pm_info['inbox']['new'] = $new;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pm_info['inbox']['new'] = 0;
|
||||
}
|
||||
unset($pm_info['inbox']);
|
||||
unset($pm_info['outbox']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($pm_info[$which]['limit']))
|
||||
{
|
||||
if(varset($pref['pm_limits'],0) > 0)
|
||||
if('inbox' == $which)
|
||||
{
|
||||
if($pref['pm_limits'] == 1)
|
||||
{
|
||||
$qry = "SELECT MAX(gen_user_id) AS inbox_limit, MAX(gen_ip) as outbox_limit FROM #generic WHERE gen_type='pm_limit' AND gen_datestamp IN (".USERCLASS_LIST.")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry = "SELECT MAX(gen_intdata) AS inbox_limit, MAX(gen_chardata) as outbox_limit FROM #generic WHERE gen_type='pm_limit' AND gen_datestamp IN (".USERCLASS_LIST.")";
|
||||
}
|
||||
if($sql->db_Select_gen($qry))
|
||||
{
|
||||
$row = $sql->db_Fetch();
|
||||
$pm_info['inbox']['limit'] = $row['inbox_limit'];
|
||||
$pm_info['outbox']['limit'] = $row['outbox_limit'];
|
||||
}
|
||||
$pm_info['inbox']['limit_val'] = ($pref['pm_limits'] == 1 ? varset($pm_info['inbox']['total'],'') : varset($pm_info['inbox']['size'],''));
|
||||
if(!$pm_info['inbox']['limit'] || !$pm_info['inbox']['limit_val'])
|
||||
{
|
||||
$pm_info['inbox']['filled'] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pm_info['inbox']['filled'] = number_format($pm_info['inbox']['limit_val']/$pm_info['inbox']['limit'] * 100, 2);
|
||||
}
|
||||
$pm_info['outbox']['limit_val'] = ($pref['pm_limits'] == 1 ? varset($pm_info['outbox']['total'],'') : varset($pm_info['outbox']['size'],''));
|
||||
if(!$pm_info['outbox']['limit'] || !$pm_info['outbox']['limit_val'])
|
||||
{
|
||||
$pm_info['outbox']['filled'] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pm_info['outbox']['filled'] = number_format($pm_info['outbox']['limit_val']/$pm_info['outbox']['limit'] * 100, 2);
|
||||
}
|
||||
$qry = "SELECT count(pm.pm_id) AS total, SUM(pm.pm_size)/1024 size, SUM(pm.pm_read = 0) as unread FROM `#private_msg` as pm WHERE pm.pm_to = ".USERID." AND pm.pm_read_del = 0";
|
||||
}
|
||||
else
|
||||
{
|
||||
$pm_info['inbox']['limit'] = "";
|
||||
$pm_info['outbox']['limit'] = "";
|
||||
$pm_info['inbox']['filled'] = "";
|
||||
$pm_info['outbox']['filled'] = "";
|
||||
$qry = "SELECT count(pm.pm_from) AS total, SUM(pm.pm_size)/1024 size, SUM(pm.pm_read = 0) as unread FROM `#private_msg` as pm WHERE pm.pm_from = ".USERID." AND pm.pm_sent_del = 0";
|
||||
}
|
||||
|
||||
if(!isset($pm_info[$which]['total']))
|
||||
{
|
||||
$this->pmDB->db_Select_gen($qry);
|
||||
$pm_info[$which] = $this->pmDB->db_Fetch();
|
||||
if ($which == 'inbox' && ($this->pmPrefs['animate'] == 1 || $this->pmPrefs['popup'] == 1))
|
||||
{
|
||||
if($new = $this->pmDB->db_Count('private_msg', '(*)', "WHERE pm_sent > '".USERLV."' AND pm_read = 0 AND pm_to = '".USERID."' AND pm_read_del != 1"))
|
||||
{
|
||||
$pm_info['inbox']['new'] = $new;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pm_info['inbox']['new'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($pm_info[$which]['limit']))
|
||||
{
|
||||
if(varset($this->pmPrefs['pm_limits'],0) > 0)
|
||||
{
|
||||
if($this->pmPrefs['pm_limits'] == 1)
|
||||
{
|
||||
$qry = "SELECT MAX(gen_user_id) AS inbox_limit, MAX(gen_ip) as outbox_limit FROM `#generic` WHERE gen_type='pm_limit' AND gen_datestamp IN (".USERCLASS_LIST.")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry = "SELECT MAX(gen_intdata) AS inbox_limit, MAX(gen_chardata) as outbox_limit FROM `#generic` WHERE gen_type='pm_limit' AND gen_datestamp IN (".USERCLASS_LIST.")";
|
||||
}
|
||||
if($this->pmDB->db_Select_gen($qry))
|
||||
{
|
||||
$row = $this->pmDB->db_Fetch();
|
||||
$pm_info['inbox']['limit'] = $row['inbox_limit'];
|
||||
$pm_info['outbox']['limit'] = $row['outbox_limit'];
|
||||
}
|
||||
$pm_info['inbox']['limit_val'] = ($this->pmPrefs['pm_limits'] == 1 ? varset($pm_info['inbox']['total'],'') : varset($pm_info['inbox']['size'],''));
|
||||
if(!$pm_info['inbox']['limit'] || !$pm_info['inbox']['limit_val'])
|
||||
{
|
||||
$pm_info['inbox']['filled'] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pm_info['inbox']['filled'] = number_format($pm_info['inbox']['limit_val']/$pm_info['inbox']['limit'] * 100, 2);
|
||||
}
|
||||
$pm_info['outbox']['limit_val'] = ($this->pmPrefs['pm_limits'] == 1 ? varset($pm_info['outbox']['total'],'') : varset($pm_info['outbox']['size'],''));
|
||||
if(!$pm_info['outbox']['limit'] || !$pm_info['outbox']['limit_val'])
|
||||
{
|
||||
$pm_info['outbox']['filled'] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pm_info['outbox']['filled'] = number_format($pm_info['outbox']['limit_val']/$pm_info['outbox']['limit'] * 100, 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$pm_info['inbox']['limit'] = '';
|
||||
$pm_info['outbox']['limit'] = '';
|
||||
$pm_info['inbox']['filled'] = '';
|
||||
$pm_info['outbox']['filled'] = '';
|
||||
}
|
||||
}
|
||||
return $pm_info;
|
||||
}
|
||||
return $pm_info;
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
@@ -6,21 +6,33 @@
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* PM plugin - install/uninstall routines
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_setup.php,v $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2009-11-18 01:49:18 $
|
||||
* $Author: marj_nl_fr $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* install/uninstall routines
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: pm_setup.php,v 1.4 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
class pm_setup
|
||||
{
|
||||
|
||||
function uninstall_post()
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
$sql->db_Delete("core", "e107_name = 'pm_prefs'");
|
||||
$sql->db_Delete("menus", "menu_name = 'private_msg_menu'");
|
||||
$sql->db_Delete('core', "e107_name = 'pm_prefs'");
|
||||
$sql->db_Delete('menus', "menu_name = 'private_msg_menu'");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -6,14 +6,24 @@
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
* PM plugin - shortcodes
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_shortcodes.php,v $
|
||||
* $Revision: 1.16 $
|
||||
* $Date: 2009-12-16 20:23:37 $
|
||||
* $Revision: 1.17 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: pm_shortcodes.php,v 1.17 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
|
||||
// Note: all shortcodes now begin with 'PM', so some changes from previous versions
|
||||
|
||||
|
||||
@@ -78,6 +88,7 @@ class pm_handler_shortcodes
|
||||
public $pmBlocks = array(); // Array of blocked users.
|
||||
public $pmBlocked = array(); // Block info when using 'display blocked' page
|
||||
public $nextPrev = array(); // Variables used by nextprev
|
||||
public $pmManager = NULL; // Pointer to pmbox_manager class instance
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -87,7 +98,7 @@ class pm_handler_shortcodes
|
||||
|
||||
public function sc_pm_form_touser()
|
||||
{
|
||||
if($this->pmInfo['from_name'])
|
||||
if(vartrue($this->pmInfo['from_name']))
|
||||
{
|
||||
return "<input type='hidden' name='pm_to' value='{$this->pmInfo['from_name']}' />{$this->pmInfo['from_name']}";
|
||||
}
|
||||
@@ -107,7 +118,7 @@ class pm_handler_shortcodes
|
||||
|
||||
public function sc_pm_form_toclass()
|
||||
{
|
||||
if($this->pmInfo['from_name'])
|
||||
if(vartrue($this->pmInfo['from_name']))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
@@ -120,7 +131,7 @@ class pm_handler_shortcodes
|
||||
{
|
||||
$args = 'member, '.$args;
|
||||
}
|
||||
$ret .= e107::getUserClass()->uc_dropdown('pm_userclass', '', $args); // TODO: userclass
|
||||
$ret .= e107::getUserClass()->uc_dropdown('pm_userclass', '', $args);
|
||||
if (strpos($ret,'option') === FALSE) $ret = '';
|
||||
}
|
||||
return $ret;
|
||||
@@ -130,7 +141,7 @@ class pm_handler_shortcodes
|
||||
public function sc_pm_form_subject()
|
||||
{
|
||||
$value = '';
|
||||
if($this->pmInfo['pm_subject'])
|
||||
if(vartrue($this->pmInfo['pm_subject']))
|
||||
{
|
||||
$value = $this->pmInfo['pm_subject'];
|
||||
if(substr($value, 0, strlen(LAN_PM_58)) != LAN_PM_58)
|
||||
@@ -145,7 +156,7 @@ class pm_handler_shortcodes
|
||||
public function sc_pm_form_message()
|
||||
{
|
||||
$value = '';
|
||||
if($this->pmInfo['pm_text'])
|
||||
if(vartrue($this->pmInfo['pm_text']))
|
||||
{
|
||||
if(isset($_POST['quote']))
|
||||
{
|
||||
@@ -233,42 +244,42 @@ class pm_handler_shortcodes
|
||||
|
||||
public function sc_pm_inbox_total()
|
||||
{
|
||||
$pm_inbox = pm_getInfo('inbox');
|
||||
$pm_inbox = $this->pmManager->pm_getInfo('inbox');
|
||||
return intval($pm_inbox['inbox']['total']);
|
||||
}
|
||||
|
||||
|
||||
public function sc_pm_inbox_unread()
|
||||
{
|
||||
$pm_inbox = pm_getInfo('inbox');
|
||||
$pm_inbox = $this->pmManager->pm_getInfo('inbox');
|
||||
return intval($pm_inbox['inbox']['unread']);
|
||||
}
|
||||
|
||||
|
||||
public function sc_pm_inbox_filled()
|
||||
{
|
||||
$pm_inbox = pm_getInfo('inbox');
|
||||
$pm_inbox = $this->pmManager->pm_getInfo('inbox');
|
||||
return (intval($pm_inbox['inbox']['filled']) > 0 ? $pm_inbox['inbox']['filled'] : '');
|
||||
}
|
||||
|
||||
|
||||
public function sc_pm_outbox_total()
|
||||
{
|
||||
$pm_outbox = pm_getInfo('outbox');
|
||||
$pm_outbox = $this->pmManager->pm_getInfo('outbox');
|
||||
return intval($pm_outbox['outbox']['total']);
|
||||
}
|
||||
|
||||
|
||||
public function sc_pm_outbox_unread()
|
||||
{
|
||||
$pm_outbox = pm_getInfo('outbox');
|
||||
$pm_outbox = $this->pmManager->pm_getInfo('outbox');
|
||||
return intval($pm_outbox['outbox']['unread']);
|
||||
}
|
||||
|
||||
|
||||
public function sc_pm_outbox_filled()
|
||||
{
|
||||
$pm_outbox = pm_getInfo('outbox');
|
||||
$pm_outbox = $this->pmManager->pm_getInfo('outbox');
|
||||
return (intval($pm_outbox['outbox']['filled']) > 0 ? $pm_outbox['outbox']['filled'] : '');
|
||||
}
|
||||
|
||||
@@ -454,7 +465,7 @@ class pm_handler_shortcodes
|
||||
|
||||
public function sc_pm_send_pm_link()
|
||||
{
|
||||
$pm_outbox = pm_getInfo('outbox');
|
||||
$pm_outbox = $this->pmManager->pm_getInfo('outbox');
|
||||
if($pm_outbox['outbox']['filled'] < 100)
|
||||
{
|
||||
$link = $this->e107->url->getUrl('pm','main',array('f' => 'send'));
|
||||
@@ -468,7 +479,7 @@ class pm_handler_shortcodes
|
||||
{
|
||||
if($this->pmPrefs['animate'])
|
||||
{
|
||||
$pm_inbox = pm_getInfo('inbox');
|
||||
$pm_inbox = $this->pmManager->pm_getInfo('inbox');
|
||||
if($pm_inbox['inbox']['new'] > 0)
|
||||
{
|
||||
return NEWPM_ANIMATION;
|
||||
@@ -478,7 +489,7 @@ class pm_handler_shortcodes
|
||||
}
|
||||
|
||||
|
||||
public function sc_pm_nextprev()
|
||||
public function sc_pm_nextprev($parm = '')
|
||||
{
|
||||
return $this->e107->tp->parseTemplate("{NEXTPREV={$this->pmNextPrev['total']},{$this->pmPrefs['perpage']},{$this->pmNextPrev['start']},".e_SELF."?{$parm}.[FROM]}");
|
||||
}
|
||||
@@ -515,7 +526,7 @@ class pm_handler_shortcodes
|
||||
}
|
||||
|
||||
|
||||
public function sc_pm_blocked_date()
|
||||
public function sc_pm_blocked_date($parm='')
|
||||
{
|
||||
require_once(e_HANDLER.'date_handler.php');
|
||||
return convert::convert_date($this->pmBlocked['pm_block_datestamp'], $parm);
|
||||
|
@@ -9,19 +9,16 @@ CREATE TABLE private_msg (
|
||||
pm_sent_del tinyint(1) unsigned NOT NULL default '0', /* Set when can delete */
|
||||
pm_read_del tinyint(1) unsigned NOT NULL default '0', /* set when can delete */
|
||||
pm_attachments text NOT NULL,
|
||||
pm_option varchar(250) NOT NULL default '',
|
||||
pm_option varchar(250) NOT NULL default '', /* Options associated with PM - '+rr' for read receipt */
|
||||
pm_size int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (pm_id)
|
||||
) 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',
|
||||
pm_block_to int(10) unsigned NOT NULL default '0',
|
||||
pm_block_datestamp int(10) unsigned NOT NULL default '0',
|
||||
pm_block_count int(10) unsigned NOT NULL default '0', /* Not sure what this is for */
|
||||
pm_block_count int(10) unsigned NOT NULL default '0', /* Counts number of blocked PMs */
|
||||
PRIMARY KEY (pm_block_id)
|
||||
) TYPE=MyISAM AUTO_INCREMENT=1 ;
|
||||
|
||||
|
@@ -6,14 +6,23 @@
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
* PM plugin - template file
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_template.php,v $
|
||||
* $Revision: 1.7 $
|
||||
* $Date: 2009-12-16 20:23:37 $
|
||||
* $Revision: 1.8 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: pm_template.php,v 1.8 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
global $sc_style;
|
||||
|
@@ -6,17 +6,26 @@
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
* PM plugin - menu display
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/private_msg_menu.php,v $
|
||||
* $Revision: 1.11 $
|
||||
* $Date: 2009-12-16 20:23:37 $
|
||||
* $Revision: 1.12 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: private_msg_menu.php,v 1.12 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
if (!e107::isInstalled('pm')) { return ''; }
|
||||
global $sysprefs, $pref, $pm_prefs;
|
||||
global $sysprefs, $pm_prefs;
|
||||
if(!isset($pm_prefs['perpage']))
|
||||
{
|
||||
$pm_prefs = $sysprefs->getArray('pm_prefs');
|
||||
@@ -25,7 +34,8 @@ require_once(e_PLUGIN.'pm/pm_func.php');
|
||||
e107::getScParser();
|
||||
require_once(e_PLUGIN.'pm/pm_shortcodes.php');
|
||||
setScVar('pm_handler_shortcodes','pmPrefs', $pm_prefs);
|
||||
pm_getInfo('clear');
|
||||
$pmManager = new pmbox_manager($pm_prefs);
|
||||
setScVar('pm_handler_shortcodes','pmManager', &$pmManager);
|
||||
|
||||
define('PM_INBOX_ICON', "<img src='".e_PLUGIN_ABS."pm/images/mail_get.png' class='icon S16' alt='".LAN_PM_25."' title='".LAN_PM_25."' />");
|
||||
define('PM_OUTBOX_ICON', "<img src='".e_PLUGIN_ABS."pm/images/mail_send.png' class='icon S16' alt='".LAN_PM_26."' title='".LAN_PM_26."' />");
|
||||
@@ -69,23 +79,22 @@ if(!isset($pm_menu_template))
|
||||
|
||||
if(check_class($pm_prefs['pm_class']))
|
||||
{
|
||||
global $tp, $pm_inbox;
|
||||
$pm_inbox = pm_getInfo('inbox');
|
||||
// require_once(e_PLUGIN."pm/pm_shortcodes.php");
|
||||
$tp = e107::getParser();
|
||||
$pm_inbox = $pmManager->pm_getInfo('inbox');
|
||||
$txt = $tp->parseTemplate($pm_menu_template, TRUE);
|
||||
if($pm_inbox['inbox']['new'] > 0 && $pm_prefs['popup'] && strpos(e_SELF, 'pm.php') === FALSE && $_COOKIE['pm-alert'] != 'ON')
|
||||
{
|
||||
$txt .= pm_show_popup();
|
||||
$txt .= pm_show_popup($pm_inbox, $pm_prefs);
|
||||
}
|
||||
$ns->tablerender(LAN_PM, $txt, 'pm');
|
||||
}
|
||||
|
||||
function pm_show_popup()
|
||||
|
||||
function pm_show_popup($pm_inbox, $pm_prefs)
|
||||
{
|
||||
global $pm_inbox, $pm_prefs;
|
||||
$alertdelay = intval($pm_prefs['popup_delay']);
|
||||
if($alertdelay == 0) { $alertdalay = 60; }
|
||||
setcookie("pm-alert", "ON", time()+$alertdelay);
|
||||
setcookie('pm-alert', 'ON', time()+$alertdelay);
|
||||
$popuptext = "
|
||||
<html>
|
||||
<head>
|
||||
@@ -106,8 +115,8 @@ function pm_show_popup()
|
||||
</table>
|
||||
</body>
|
||||
</html> ";
|
||||
$popuptext = str_replace("\n", "", $popuptext);
|
||||
$popuptext = str_replace("\t", "", $popuptext);
|
||||
$popuptext = str_replace("\n", '', $popuptext);
|
||||
$popuptext = str_replace("\t", '', $popuptext);
|
||||
$text .= "
|
||||
<script type='text/javascript'>
|
||||
winl=(screen.width-200)/2;
|
||||
@@ -117,4 +126,5 @@ function pm_show_popup()
|
||||
</script >";
|
||||
return $text;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,10 +1,25 @@
|
||||
/*
|
||||
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id: sendpm.sc,v 1.4 2009-12-17 22:47:20 e107steved Exp $
|
||||
*
|
||||
* PM icon shortcode
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: sendpm.sc,v 1.4 2009-12-17 22:47:20 e107steved Exp $;
|
||||
*/
|
||||
|
||||
include_lan(e_PLUGIN.'pm/languages/'.e_LANGUAGE.'.php');
|
||||
|
||||
global $sysprefs, $pm_prefs;
|
||||
$pm_prefs = $sysprefs->getArray("pm_prefs");
|
||||
if(check_class($pm_prefs['pm_class']))
|
||||
{
|
||||
if(file_exists(THEME."forum/pm.png"))
|
||||
if(file_exists(THEME.'forum/pm.png'))
|
||||
{
|
||||
$img = "<img src='".THEME_ABS."forum/pm.png' alt='".LAN_PM."' title='".LAN_PM."' style='border:0' />";
|
||||
}
|
||||
@@ -16,5 +31,5 @@ if(check_class($pm_prefs['pm_class']))
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
@@ -9,9 +9,9 @@
|
||||
*
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_themes/e107v4a/theme.php,v $
|
||||
* $Revision: 1.8 $
|
||||
* $Date: 2009-11-18 01:06:02 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.9 $
|
||||
* $Date: 2009-12-17 22:47:20 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@@ -238,13 +238,13 @@ define("POST_EXTENDEDSTRING", " ]<br />");
|
||||
|
||||
// [linkstyle]
|
||||
|
||||
define(PRELINK, "");
|
||||
define(POSTLINK, "");
|
||||
define(LINKSTART, "<span><img src='".THEME_ABS."images/bullet2.gif' alt='bullet' /> ");
|
||||
define(LINKSTART_HILITE, "<span style='font-weight:bold'><img src='".THEME_ABS."images/bullet3.png' alt='bullet' /> ");
|
||||
define(LINKEND, "</span><br />");
|
||||
define(LINKDISPLAY, 2);
|
||||
define(LINKALIGN, "left");
|
||||
define('PRELINK', '');
|
||||
define('POSTLINK', '');
|
||||
define('LINKSTART', "<span><img src='".THEME_ABS."images/bullet2.gif' alt='bullet' /> ");
|
||||
define('LINKSTART_HILITE', "<span style='font-weight:bold'><img src='".THEME_ABS."images/bullet3.png' alt='bullet' /> ");
|
||||
define('LINKEND', "</span><br />");
|
||||
define('LINKDISPLAY', 2);
|
||||
define('LINKALIGN', "left");
|
||||
|
||||
|
||||
// [tablestyle]
|
||||
|
Reference in New Issue
Block a user