1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-27 01:40:22 +02:00

Code formatting and cleanup.

This commit is contained in:
Cameron
2017-04-12 17:23:03 -07:00
parent 544ff80f98
commit 1d4aa96be6

View File

@@ -68,7 +68,10 @@ else
$qs = explode('.', e_QUERY); $qs = explode('.', e_QUERY);
$action = varset($qs[0], 'inbox'); $action = varset($qs[0], 'inbox');
if (!$action) $action = 'inbox'; if(!$action)
{
$action = 'inbox';
}
if(!empty($_GET['mode'])) if(!empty($_GET['mode']))
{ {
@@ -108,14 +111,15 @@ if(!isset($pm_prefs['pm_class']) || !check_class($pm_prefs['pm_class']))
//setScVar('pm_handler_shortcodes','pmPrefs', $pm_prefs); //setScVar('pm_handler_shortcodes','pmPrefs', $pm_prefs);
$pmManager = new pmbox_manager($pm_prefs); $pmManager = new pmbox_manager($pm_prefs);
//setScVar('pm_handler_shortcodes','pmManager', &$pmManager); //setScVar('pm_handler_shortcodes','pmManager', &$pmManager);
class pm_extended extends private_message class pm_extended extends private_message
{ {
protected $pmManager = NULL;
protected $pmManager = null;
/** /**
* Constructor * Constructor
@@ -130,7 +134,6 @@ class pm_extended extends private_message
} }
/** /**
* Show the 'Send to' form * Show the 'Send to' form
* @param array|int $to_uid - a PM block of message to reply to, or UID of user to send to * @param array|int $to_uid - a PM block of message to reply to, or UID of user to send to
@@ -149,7 +152,6 @@ class pm_extended extends private_message
} }
if(!empty($to_uid)) if(!empty($to_uid))
{ {
@@ -169,20 +171,29 @@ class pm_extended extends private_message
{ {
return "<div class='alert alert-danger'>" . LAN_PM_115 . "</div>"; return "<div class='alert alert-danger'>" . LAN_PM_115 . "</div>";
} }
} }
//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) if($pm_outbox['outbox']['filled'] >= 100)
{ {
return str_replace('{PERCENT}', $pm_outbox['outbox']['filled'], LAN_PM_13); return str_replace('{PERCENT}', $pm_outbox['outbox']['filled'], LAN_PM_13);
} }
// $tpl_file = THEME.'pm_template.php'; // $tpl_file = THEME.'pm_template.php';
// include_once(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php'); // include_once(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php');
if(THEME_LEGACY){
if(THEME_LEGACY === true)
{
include_once(THEME . 'pm_template.php'); include_once(THEME . 'pm_template.php');
$PM_SEND_PM = $this->updateTemplate($PM_SEND_PM); $PM_SEND_PM = $this->updateTemplate($PM_SEND_PM);
} }
if (!$PM_SEND_PM){$PM_SEND_PM = e107::getTemplate('pm', 'pm', 'send');}
if(empty($PM_SEND_PM))
{
$PM_SEND_PM = e107::getTemplate('pm', 'pm', 'send');
}
$enc = (check_class($this->pmPrefs['attach_class']) ? "enctype='multipart/form-data'" : ''); $enc = (check_class($this->pmPrefs['attach_class']) ? "enctype='multipart/form-data'" : '');
// setScVar('pm_handler_shortcodes','pmInfo', $pm_info); // setScVar('pm_handler_shortcodes','pmInfo', $pm_info);
@@ -193,10 +204,11 @@ class pm_extended extends private_message
// $PM_SEND_PM = $this->updateTemplate($PM_SEND_PM); // $PM_SEND_PM = $this->updateTemplate($PM_SEND_PM);
$text = "<form {$enc} method='post' action='".e_SELF."' id='dataform'> $text = "<form {$enc} method='post' action='" . e_REQUEST_SELF . "' id='dataform'>
<div><input type='hidden' name='numsent' value='{$pm_outbox['outbox']['total']}' />" . <div><input type='hidden' name='numsent' value='{$pm_outbox['outbox']['total']}' />" .
e107::getParser()->parseTemplate($PM_SEND_PM, TRUE, $sc). e107::getParser()->parseTemplate($PM_SEND_PM, true, $sc) .
'</div></form>'; '</div></form>';
return $text; return $text;
} }
@@ -214,16 +226,22 @@ class pm_extended extends private_message
// $tpl_file = THEME.'pm_template.php'; // $tpl_file = THEME.'pm_template.php';
// include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php'); // include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php');
if(THEME_LEGACY){ if(THEME_LEGACY === true)
{
include_once(THEME . 'pm_template.php'); include_once(THEME . 'pm_template.php');
// Is updateTemplate really necessary for v2.x templates? // Is updateTemplate really necessary for v2.x templates?
$PM_INBOX = array();
$PM_INBOX['start'] = $this->updateTemplate($PM_INBOX_HEADER); $PM_INBOX['start'] = $this->updateTemplate($PM_INBOX_HEADER);
$PM_INBOX['item'] = $this->updateTemplate($PM_INBOX_TABLE); $PM_INBOX['item'] = $this->updateTemplate($PM_INBOX_TABLE);
$PM_INBOX['empty'] = $this->updateTemplate($PM_INBOX_EMPTY); $PM_INBOX['empty'] = $this->updateTemplate($PM_INBOX_EMPTY);
$PM_INBOX['end'] = $this->updateTemplate($PM_INBOX_FOOTER); $PM_INBOX['end'] = $this->updateTemplate($PM_INBOX_FOOTER);
} }
if (!$PM_INBOX){$PM_INBOX = e107::getTemplate('pm', 'pm', 'inbox');}
if(empty($PM_INBOX))
{
$PM_INBOX = e107::getTemplate('pm', 'pm', 'inbox');
}
$pm_blocks = $this->block_get(); $pm_blocks = $this->block_get();
$pmlist = $this->pm_get_inbox(USERID, $start, $this->pmPrefs['perpage']); $pmlist = $this->pm_get_inbox(USERID, $start, $this->pmPrefs['perpage']);
@@ -248,7 +266,10 @@ class pm_extended extends private_message
{ {
foreach($pmlist['messages'] as $rec) foreach($pmlist['messages'] as $rec)
{ {
if(trim($rec['pm_subject']) == '') { $rec['pm_subject'] = '['.LAN_PM_61.']'; } if(trim($rec['pm_subject']) == '')
{
$rec['pm_subject'] = '[' . LAN_PM_61 . ']';
}
$sc->setVars($rec); $sc->setVars($rec);
$txt .= $tp->parseTemplate($PM_INBOX['item'], true, $sc); $txt .= $tp->parseTemplate($PM_INBOX['item'], true, $sc);
} }
@@ -278,16 +299,22 @@ class pm_extended extends private_message
// $tpl_file = THEME.'pm_template.php'; // $tpl_file = THEME.'pm_template.php';
// include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php'); // include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php');
if(THEME_LEGACY){ if(THEME_LEGACY === true)
{
include_once(THEME . 'pm_template.php'); include_once(THEME . 'pm_template.php');
// Is updateTemplate really necessary for v2.x templates? // Is updateTemplate really necessary for v2.x templates?
$PM_OUTBOX = array();
$PM_OUTBOX['start'] = $this->updateTemplate($PM_OUTBOX_HEADER); $PM_OUTBOX['start'] = $this->updateTemplate($PM_OUTBOX_HEADER);
$PM_OUTBOX['item'] = $this->updateTemplate($PM_OUTBOX_TABLE); $PM_OUTBOX['item'] = $this->updateTemplate($PM_OUTBOX_TABLE);
$PM_OUTBOX['empty'] = $this->updateTemplate($PM_OUTBOX_EMPTY); $PM_OUTBOX['empty'] = $this->updateTemplate($PM_OUTBOX_EMPTY);
$PM_OUTBOX['end'] = $this->updateTemplate($PM_OUTBOX_FOOTER); $PM_OUTBOX['end'] = $this->updateTemplate($PM_OUTBOX_FOOTER);
} }
if (!$PM_OUTBOX){$PM_OUTBOX = e107::getTemplate('pm', 'pm', 'outbox');}
if(empty($PM_OUTBOX))
{
$PM_OUTBOX = e107::getTemplate('pm', 'pm', 'outbox');
}
$pmlist = $this->pm_get_outbox(USERID, $start, $this->pmPrefs['perpage']); $pmlist = $this->pm_get_outbox(USERID, $start, $this->pmPrefs['perpage']);
// setScVar('pm_handler_shortcodes', 'pmNextPrev', array('start' => $start, 'total' => $pmlist['total_messages'])); // setScVar('pm_handler_shortcodes', 'pmNextPrev', array('start' => $start, 'total' => $pmlist['total_messages']));
@@ -303,13 +330,17 @@ class pm_extended extends private_message
$PM_OUTBOX_EMPTY = $this->updateTemplate($PM_OUTBOX['empty']); $PM_OUTBOX_EMPTY = $this->updateTemplate($PM_OUTBOX['empty']);
$PM_OUTBOX_FOOTER = $this->updateTemplate($PM_OUTBOX['end']); $PM_OUTBOX_FOOTER = $this->updateTemplate($PM_OUTBOX['end']);
*/ */
$txt = "<form method='post' action='".e_SELF."?".e_QUERY."'>"; $txt = "<form method='post' action='" . e_REQUEST_SELF . "?" . e_QUERY . "'>";
$txt .= $tp->parseTemplate($PM_OUTBOX['start'], true, $sc); $txt .= $tp->parseTemplate($PM_OUTBOX['start'], true, $sc);
if($pmlist['total_messages']) if($pmlist['total_messages'])
{ {
foreach($pmlist['messages'] as $rec) foreach($pmlist['messages'] as $rec)
{ {
if(trim($rec['pm_subject']) == '') { $rec['pm_subject'] = '['.LAN_PM_61.']'; } if(trim($rec['pm_subject']) == '')
{
$rec['pm_subject'] = '[' . LAN_PM_61 . ']';
}
// setScVar('pm_handler_shortcodes','pmInfo', $rec); // setScVar('pm_handler_shortcodes','pmInfo', $rec);
$sc->setVars($rec); $sc->setVars($rec);
$txt .= $tp->parseTemplate($PM_OUTBOX['item'], true, $sc); $txt .= $tp->parseTemplate($PM_OUTBOX['item'], true, $sc);
@@ -321,6 +352,7 @@ class pm_extended extends private_message
} }
$txt .= $tp->parseTemplate($PM_OUTBOX['end'], true, $sc); $txt .= $tp->parseTemplate($PM_OUTBOX['end'], true, $sc);
$txt .= '</form>'; $txt .= '</form>';
return $txt; return $txt;
} }
@@ -338,11 +370,17 @@ class pm_extended extends private_message
// $tpl_file = THEME.'pm_template.php'; // $tpl_file = THEME.'pm_template.php';
// include_once(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php'); // include_once(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php');
if(THEME_LEGACY){ if(THEME_LEGACY === true)
{
$PM_SHOW = null;
include_once(THEME . 'pm_template.php'); include_once(THEME . 'pm_template.php');
$PM_SHOW = $this->updateTemplate($PM_SHOW); $PM_SHOW = $this->updateTemplate($PM_SHOW);
} }
if (!$PM_SHOW){$PM_SHOW = e107::getTemplate('pm', 'pm', 'show');}
if(empty($PM_SHOW))
{
$PM_SHOW = e107::getTemplate('pm', 'pm', 'show');
}
$pm_info = $this->pm_get($pmid); $pm_info = $this->pm_get($pmid);
@@ -353,8 +391,7 @@ class pm_extended extends private_message
if($pm_info['pm_to'] != USERID && $pm_info['pm_from'] != USERID) if($pm_info['pm_to'] != USERID && $pm_info['pm_from'] != USERID)
{ {
$ns->tablerender(LAN_PM, LAN_PM_60); $ns->tablerender(LAN_PM, LAN_PM_60);
return; return null;
} }
if($pm_info['pm_read'] == 0 && $pm_info['pm_to'] == USERID) if($pm_info['pm_read'] == 0 && $pm_info['pm_to'] == USERID)
@@ -383,7 +420,10 @@ class pm_extended extends private_message
if(!$comeFrom) if(!$comeFrom)
{ {
if ($pm_info['pm_from'] == USERID) { $comeFrom = 'outbox'; } if($pm_info['pm_from'] == USERID)
{
$comeFrom = 'outbox';
}
} }
// Need to show inbox or outbox from start // Need to show inbox or outbox from start
@@ -391,13 +431,21 @@ class pm_extended extends private_message
{ // Show Outbox { // Show Outbox
$caption = ''; $caption = '';
if(!deftrue('BOOTSTRAP')){ $caption .= LAN_PM." - ".LAN_PLUGIN_PM_OUTBOX; } if(!deftrue('BOOTSTRAP'))
{
$caption .= LAN_PM . " - " . LAN_PLUGIN_PM_OUTBOX;
}
$ns->tablerender($caption, $this->show_outbox(), 'PM'); $ns->tablerender($caption, $this->show_outbox(), 'PM');
} }
else else
{ // Show Inbox { // Show Inbox
$caption = ''; $caption = '';
if(!deftrue('BOOTSTRAP')){ $caption .= LAN_PM." - ".LAN_PLUGIN_PM_INBOX; } if(!deftrue('BOOTSTRAP'))
{
$caption .= LAN_PM . " - " . LAN_PLUGIN_PM_INBOX;
}
$ns->tablerender($caption, $this->show_inbox(), 'PM'); $ns->tablerender($caption, $this->show_inbox(), 'PM');
} }
} }
@@ -414,20 +462,26 @@ class pm_extended extends private_message
$tp = e107::getParser(); $tp = e107::getParser();
// $tpl_file = THEME.'pm_template.php'; // $tpl_file = THEME.'pm_template.php';
// include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php'); // include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php');
if(THEME_LEGACY){ if(THEME_LEGACY === true)
{
include_once(THEME . 'pm_template.php'); include_once(THEME . 'pm_template.php');
// Is updateTemplate really necessary for v2.x templates? // Is updateTemplate really necessary for v2.x templates?
$PM_BLOCKED = array();
$PM_BLOCKED['start'] = $this->updateTemplate($PM_BLOCKED_HEADER); $PM_BLOCKED['start'] = $this->updateTemplate($PM_BLOCKED_HEADER);
$PM_BLOCKED['item'] = $this->updateTemplate($PM_BLOCKED_TABLE); $PM_BLOCKED['item'] = $this->updateTemplate($PM_BLOCKED_TABLE);
$PM_BLOCKED['empty'] = $this->updateTemplate($PM_BLOCKED_EMPTY); $PM_BLOCKED['empty'] = $this->updateTemplate($PM_BLOCKED_EMPTY);
$PM_BLOCKED['end'] = $this->updateTemplate($PM_BLOCKED_FOOTER); $PM_BLOCKED['end'] = $this->updateTemplate($PM_BLOCKED_FOOTER);
} }
if (!$PM_BLOCKED){$PM_BLOCKED = e107::getTemplate('pm', 'pm', 'blocked');}
if(empty($PM_BLOCKED))
{
$PM_BLOCKED = e107::getTemplate('pm', 'pm', 'blocked');
}
$pmBlocks = $this->block_get_user(); // TODO - handle pagination, maybe (is it likely to be necessary?) $pmBlocks = $this->block_get_user(); // TODO - handle pagination, maybe (is it likely to be necessary?)
$sc = e107::getScBatch('pm',TRUE, 'pm'); $sc = e107::getScBatch('pm', true, 'pm');
$sc->pmBlocks = $pmBlocks; $sc->pmBlocks = $pmBlocks;
$sc->wrapper('pm'); $sc->wrapper('pm');
@@ -439,8 +493,9 @@ class pm_extended extends private_message
$PM_BLOCKED_FOOTER = $this->updateTemplate($PM_BLOCKED['end']); $PM_BLOCKED_FOOTER = $this->updateTemplate($PM_BLOCKED['end']);
*/ */
$txt = "<form method='post' action='".e_SELF."?".e_QUERY."'>"; $txt = "<form method='post' action='" . e_REQUEST_SELF . "?" . e_QUERY . "'>";
$txt .= $tp->parseTemplate($PM_BLOCKED['start'], true, $sc); $txt .= $tp->parseTemplate($PM_BLOCKED['start'], true, $sc);
if($pmTotalBlocked = count($pmBlocks)) if($pmTotalBlocked = count($pmBlocks))
{ {
foreach($pmBlocks as $pmBlocked) foreach($pmBlocks as $pmBlocked)
@@ -456,6 +511,7 @@ class pm_extended extends private_message
} }
$txt .= $tp->parseTemplate($PM_BLOCKED['end'], true, $sc); $txt .= $tp->parseTemplate($PM_BLOCKED['end'], true, $sc);
$txt .= '</form>'; $txt .= '</form>';
return $txt; return $txt;
} }
@@ -621,12 +677,11 @@ class pm_extended extends private_message
{ {
$randnum = rand(1000, 9999); $randnum = rand(1000, 9999);
$type = 'attachment+' . $randnum . '_'; $type = 'attachment+' . $randnum . '_';
return e107::getFile()->getUploaded("attachments", $type, array('max_file_count' => 3)); return e107::getFile()->getUploaded("attachments", $type, array('max_file_count' => 3));
} }
function breadcrumb($type = '', $other) function breadcrumb($type = '', $other)
{ {
if(!deftrue('BOOTSTRAP')) if(!deftrue('BOOTSTRAP'))
@@ -658,9 +713,6 @@ class pm_extended extends private_message
} }
/** /**
* Look up users matching a keyword, output a list of those found * Look up users matching a keyword, output a list of those found
* Direct echo * Direct echo
@@ -687,8 +739,6 @@ function pm_user_lookup()
} }
//$pm =& new private_message; //$pm =& new private_message;
$pm = new pm_extended($pm_prefs, $pmManager); $pm = new pm_extended($pm_prefs, $pmManager);
@@ -704,7 +754,6 @@ elseif (isset($qs[2]))
} }
//Auto-delete message, if timeout set in admin //Auto-delete message, if timeout set in admin
$del_qry = array(); $del_qry = array();
$read_timeout = intval($pm_prefs['read_timeout']); $read_timeout = intval($pm_prefs['read_timeout']);
@@ -727,7 +776,7 @@ if(count($del_qry) > 0)
$delList = $sql->db_getList(); $delList = $sql->db_getList();
foreach($delList as $p) foreach($delList as $p)
{ {
$pm->del($p['pm_id'], TRUE); $pm->del($p['pm_id'], true);
} }
} }
} }
@@ -838,6 +887,7 @@ switch ($action)
case 'reply' : case 'reply' :
$pmid = $pm_proc_id; $pmid = $pm_proc_id;
if($pm_info = $pm->pm_get($pmid)) if($pm_info = $pm->pm_get($pmid))
{ {
if($pm_info['pm_to'] != USERID) if($pm_info['pm_to'] != USERID)
@@ -857,14 +907,23 @@ switch ($action)
case 'inbox' : case 'inbox' :
$caption = LAN_PM; $caption = LAN_PM;
if(!deftrue('BOOTSTRAP')){ $caption .= ' - '.LAN_PLUGIN_PM_INBOX; }
if(THEME_LEGACY === true)
{
$caption .= ' - ' . LAN_PLUGIN_PM_INBOX;
}
$ns->tablerender($caption, $pm->breadcrumb(LAN_PLUGIN_PM_INBOX) . $mes->render() . $pm->show_inbox($pm_proc_id), 'PM'); $ns->tablerender($caption, $pm->breadcrumb(LAN_PLUGIN_PM_INBOX) . $mes->render() . $pm->show_inbox($pm_proc_id), 'PM');
break; break;
case 'outbox' : case 'outbox' :
$caption = LAN_PM; $caption = LAN_PM;
if(!deftrue('BOOTSTRAP')){ $caption .= ' - '.LAN_PLUGIN_PM_OUTBOX; }
if(THEME_LEGACY === true)
{
$caption .= ' - ' . LAN_PLUGIN_PM_OUTBOX;
}
$ns->tablerender($caption, $pm->breadcrumb(LAN_PLUGIN_PM_OUTBOX) . $mes->render() . $pm->show_outbox($pm_proc_id), 'PM'); $ns->tablerender($caption, $pm->breadcrumb(LAN_PLUGIN_PM_OUTBOX) . $mes->render() . $pm->show_outbox($pm_proc_id), 'PM');
break; break;
@@ -875,7 +934,12 @@ switch ($action)
case 'blocked' : case 'blocked' :
$caption = LAN_PM; $caption = LAN_PM;
if(!deftrue('BOOTSTRAP')){ $caption .= ' - '.LAN_PM_66; }
if(THEME_LEGACY === true)
{
$caption .= ' - ' . LAN_PM_66;
}
$ns->tablerender($caption, $pm->breadcrumb('blocked') . $mes->render() . $pm->showBlocked($pm_proc_id), 'PM'); $ns->tablerender($caption, $pm->breadcrumb('blocked') . $mes->render() . $pm->showBlocked($pm_proc_id), 'PM');
break; break;
} }