-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathepm.php
More file actions
101 lines (89 loc) · 4.42 KB
/
Copy pathepm.php
File metadata and controls
101 lines (89 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
//if (!defined('e107_INIT')) { exit; } // Isto não funciona, não sei porquê....
//var_dump('e107_INIT');
if (!defined('e107_INIT'))
{
require_once(__DIR__.'/../../class2.php');
}
// INJECTO AQUI O PM DO CORE
/*
$content = file_get_contents(e_PLUGIN.'pm/pm.php');
$order = array('getScBatch(\'pm\', true, \'pm\')',
'case \'inbox\' :
$caption = LAN_PM;',
'case \'outbox\' :
$caption = LAN_PM;',
);
$replace = array(
// Usa o shortcode batch do teu plugin
'getScBatch(\'pm\', \'epm\', \'pm\')',
// INBOX — carrega o template e faz parse do caption
'case \'inbox\' :
$PM_TEMPLATE = e107::getTemplate("pm", "pm", "inbox");
$sc = e107::getScBatch(\'pm\', true, \'pm\');
$sc->wrapper(\'pm\');
$caption = e107::getParser()->parseTemplate(vartrue($PM_TEMPLATE["caption"], LAN_PM), true, $sc);',
// OUTBOX — idem
'case \'outbox\' :
$PM_TEMPLATE = e107::getTemplate("pm", "pm", "outbox");
$sc = e107::getScBatch(\'pm\', true, \'pm\');
$sc->wrapper(\'pm\');
$caption = e107::getParser()->parseTemplate(vartrue($PM_TEMPLATE["caption"], LAN_PM), true, $sc);',
);
$content = str_replace($order, $replace, $content);
eval('?>'.$content.'?><?php');
*/
e107::css('epm', 'epm.css');
e107::lan('epm'); // English_menu.php or {LANGUAGE}_menu.php
$content = file_get_contents(e_PLUGIN.'pm/pm.php');
//vvvv Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
$injectMethod = <<<'PHP'
function epm_caption($type = 'inbox')
{
$PM_TEMPLATE = e107::getTemplate('pm', 'pm', $type);
$tp = e107::getParser();
$sc = e107::getScBatch('pm', 'epm', 'pm');
$sc->wrapper('pm');
$caption_source = vartrue($PM_TEMPLATE['caption'], LAN_PM);
return $tp->parseTemplate($caption_source, true, $sc);
}
PHP;
// Injeta a função DEPOIS do __construct()
$content = preg_replace(
'/(function\s+__construct\s*\(.*?\)\s*{.*?^\s*})/ms',
"$1\n\n".$injectMethod."\n",
$content,
1
);
// ^^^ Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
// Substituir o caption original
$search = array(
'getScBatch(\'pm\', true, \'pm\')',
'$ns->tablerender(LAN_PM, LAN_PM_12);', // Remover se o pull https://github.com/e107inc/e107/pull/5562 seja aprovado
"\$ns->tablerender(LAN_PM, \$this->breadcrumb(\$bread, '#' . \$pmid) . \$txt);", // Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
"\$ns->tablerender(LAN_PM, \$pm->breadcrumb(LAN_PLUGIN_PM_NEW)",// Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
"\$PM_SEND_PM = e107::getTemplate('pm', 'pm', 'send')", // Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
"case 'inbox' :\n\t\t\t\$caption = LAN_PM;",// Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
"case 'outbox' :\n\t\t\t\$caption = LAN_PM;",// Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
"\$txt .= \$tp->parseTemplate(\$PM_INBOX['item'],",
"\$txt .= \$tp->parseTemplate(\$PM_OUTBOX['item'],"
);
$replace = array(
// Usa o shortcode batch do teu plugin
'getScBatch(\'pm\', \'epm\', \'pm\')',
'$msg = e107::getMessage();
$msg->addwarning(LAN_PM_12);
$warning_text = $msg->render();
$ns->tablerender(LAN_PM, $warning_text);',// Remover se o pull https://github.com/e107inc/e107/pull/5562 seja aprovado
"\$ns->tablerender(\$this->epm_caption(\$comeFrom), \$this->breadcrumb(\$bread, '#' . \$pmid) . \$txt);",// Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
"\$ns->tablerender(\$pm->epm_caption('send'), \$pm->breadcrumb(LAN_PLUGIN_PM_NEW)",// Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
"\$PM_SEND_PM = e107::getTemplate('pm', 'pm', 'send')['main']", // Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
"case 'inbox' :\n\t\t\t\$caption = \$pm->epm_caption('inbox');",// Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
"case 'outbox' :\n\t\t\t\$caption = \$pm->epm_caption('outbox');",// Remover se o pull https://github.com/e107inc/e107/pull/5563 seja aprovado
// Para o euser ter acesso aos dados do user da linha da tabela
"\$GLOBALS['euser_vars']['user_id'] = \$rec['pm_from'];\$txt .= \$tp->parseTemplate(\$PM_INBOX['item'],",
"\$GLOBALS['euser_vars']['user_id'] = \$rec['pm_to'];\$txt .= \$tp->parseTemplate(\$PM_OUTBOX['item'],"
);
$content = str_replace($search, $replace, $content);
// Finalmente executar
eval('?>'.$content);