From dc13895c1adb30a4946ad4d999dbcd135ad537a2 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 26 Mar 2014 15:28:37 -0700 Subject: [PATCH] Issue #547 - Upgrade legacy PM template during processing. --- e107_plugins/pm/pm.php | 22 ++++++++++++++++++++ e107_plugins/pm/pm_class.php | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/e107_plugins/pm/pm.php b/e107_plugins/pm/pm.php index d5d8f06dd..631d1be38 100755 --- a/e107_plugins/pm/pm.php +++ b/e107_plugins/pm/pm.php @@ -131,6 +131,8 @@ class pm_extended extends private_message $sc = e107::getScBatch('pm',TRUE); $sc->setVars($pm_info); + $PM_SEND_PM = $this->updateTemplate($PM_SEND_PM); + $text = "
". e107::getParser()->parseTemplate($PM_SEND_PM, TRUE, $sc). @@ -161,6 +163,12 @@ class pm_extended extends private_message $sc = e107::getScBatch('pm',TRUE); $sc->pmNextPrev = array('start' => $start, 'total' => $pmlist['total_messages']); + + $PM_INBOX_HEADER = $this->updateTemplate($PM_INBOX_HEADER); + $PM_INBOX_TABLE = $this->updateTemplate($PM_INBOX_TABLE); + $PM_INBOX_EMPTY = $this->updateTemplate($PM_INBOX_EMPTY); + $PM_INBOX_FOOTER = $this->updateTemplate($PM_INBOX_FOOTER); + $txt = ""; $txt .= $tp->parseTemplate($PM_INBOX_HEADER, true, $sc); @@ -203,6 +211,11 @@ class pm_extended extends private_message $sc = e107::getScBatch('pm',TRUE); $sc->pmNextPrev = array('start' => $start, 'total' => $pmlist['total_messages']); + $PM_OUTBOX_HEADER = $this->updateTemplate($PM_OUTBOX_HEADER); + $PM_OUTBOX_TABLE = $this->updateTemplate($PM_OUTBOX_TABLE); + $PM_OUTBOX_EMPTY = $this->updateTemplate($PM_OUTBOX_EMPTY); + $PM_OUTBOX_FOOTER = $this->updateTemplate($PM_OUTBOX_FOOTER); + $txt = ""; $txt .= $tp->parseTemplate($PM_OUTBOX_HEADER, true, $sc); @@ -259,6 +272,9 @@ class pm_extended extends private_message $this->pm_mark_read($pmid, $pm_info); } + + $PM_SHOW = $this->updateTemplate($PM_SHOW); + $txt = e107::getParser()->parseTemplate($PM_SHOW, true, $sc); $ns->tablerender(LAN_PM, $txt); @@ -295,6 +311,12 @@ class pm_extended extends private_message $sc = e107::getScBatch('pm',TRUE); $sc->pmBlocks = $pmBlocks; + $PM_BLOCKED_HEADER = $this->updateTemplate($PM_BLOCKED_HEADER); + $PM_BLOCKED_TABLE = $this->updateTemplate($PM_BLOCKED_TABLE); + $PM_BLOCKED_EMPTY = $this->updateTemplate($PM_BLOCKED_EMPTY); + $PM_BLOCKED_FOOTER = $this->updateTemplate($PM_BLOCKED_FOOTER); + + $txt = ""; $txt .= $tp->parseTemplate($PM_BLOCKED_HEADER, true, $sc); if($pmTotalBlocked = count($pmBlocks)) diff --git a/e107_plugins/pm/pm_class.php b/e107_plugins/pm/pm_class.php index 604e3dcc4..8fc96fa7c 100755 --- a/e107_plugins/pm/pm_class.php +++ b/e107_plugins/pm/pm_class.php @@ -707,4 +707,44 @@ class private_message fclose($res); } } + + + + function updateTemplate($template) + { + $array = array( + 'FORM_TOUSER' => 'PM_FORM_TOUSER', + 'FORM_TOCLASS' => 'PM_FORM_TOCLASS', + 'FORM_SUBJECT' => 'PM_FORM_SUBJECT', + 'FORM_MESSAGE ' => 'PM_FORM_MESSAGE ', + 'EMOTES' => 'PM_EMOTES', + 'ATTACHMENT' => 'PM_ATTACHMENT', + 'RECEIPT' => 'PM_RECEIPT', + 'INBOX_TOTAL' => 'PM_INBOX_TOTAL', + 'INBOX_UNREAD' => 'PM_INBOX_UNREAD', + 'INBOX_FILLED' => 'PM_INBOX_FILLED', + 'OUTBOX_TOTAL' => 'PM_OUTBOX_TOTAL', + 'OUTBOX_UNREAD' => 'PM_OUTBOX_UNREAD', + 'OUTBOX_FILLED' => 'PM_OUTBOX_FILLED', + + + 'SEND_PM_LINK' => 'PM_SEND_PM_LINK', + 'NEWPM_ANIMATE' => 'PM_NEWPM_ANIMATE', + + 'BLOCKED_SENDERS_MANAGE' => 'PM_BLOCKED_SENDERS_MANAGE', + + + 'DELETE_BLOCKED_SELECTED' => 'DELETE_BLOCKED_SELECTED' + ); + + + foreach($array as $old => $new) + { + $template = str_replace("{".$old."}", "{".$new."}", $template); + } + + return $template; + + } + } \ No newline at end of file