|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* |
|
5
|
|
|
* Module: SmartObject |
|
6
|
|
|
* Author: The SmartFactory |
|
7
|
|
|
* Licence: GNU |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
use XoopsModules\Smartobject\ObjectController; |
|
11
|
|
|
|
|
12
|
|
|
require_once __DIR__ . '/header.php'; |
|
13
|
|
|
//require_once SMARTOBJECT_ROOT_PATH . 'class/smartloader.php'; |
|
14
|
|
|
//require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectlink.php'; |
|
15
|
|
|
require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
16
|
|
|
|
|
17
|
|
|
$xoopsTpl = new \XoopsTpl(); |
|
18
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
19
|
|
|
$xoopsConfig['sitename'] = $myts->displayTarea($xoopsConfig['sitename']); |
|
20
|
|
|
|
|
21
|
|
|
xoops_header(false); |
|
22
|
|
|
echo Smartobject\Utility::getCssLink(SMARTOBJECT_URL . 'assets/css/module.css'); |
|
23
|
|
|
echo '</head><body>'; |
|
24
|
|
|
|
|
25
|
|
|
$smartobjectLinkHandler = Smartobject\Helper::getInstance()->getHandler('link', 'smartobject'); |
|
26
|
|
|
$linkObj = $smartobjectLinkHandler->create(); |
|
27
|
|
|
|
|
28
|
|
|
$op = \Xmf\Request::getString('op', '', 'POST'); |
|
29
|
|
|
|
|
30
|
|
|
switch ($op) { |
|
31
|
|
|
case 'sendlink': |
|
32
|
|
|
|
|
33
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
|
34
|
|
|
$controller = new XoopsModules\Smartobject\ObjectController($smartobjectLinkHandler); |
|
35
|
|
|
|
|
36
|
|
|
$linkObj = $controller->storeSmartObject(); |
|
37
|
|
|
if ($linkObj->hasError()) { |
|
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @todo inform user and propose to close the window if a problem occured when saving the link |
|
40
|
|
|
*/ |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
$xoopsMailer = xoops_getMailer(); |
|
44
|
|
|
$xoopsMailer->useMail(); |
|
45
|
|
|
$xoopsMailer->setTemplateDir('language/' . $xoopsConfig['language'] . '/mail_template'); |
|
46
|
|
|
|
|
47
|
|
|
$xoopsMailer->setTemplate('sendlink.tpl'); |
|
48
|
|
|
$xoopsMailer->assign('X_SITENAME', $xoopsConfig['sitename']); |
|
49
|
|
|
$xoopsMailer->assign('TO_NAME', $linkObj->getVar('to_name')); |
|
|
|
|
|
|
50
|
|
|
$xoopsMailer->assign('FROM_NAME', $linkObj->getVar('from_name')); |
|
|
|
|
|
|
51
|
|
|
$xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
|
52
|
|
|
$xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|
53
|
|
|
$xoopsMailer->assign('MESSAGE', $_POST['body']); |
|
54
|
|
|
$xoopsMailer->setToEmails($linkObj->getVar('to_email')); |
|
|
|
|
|
|
55
|
|
|
$xoopsMailer->setFromEmail($linkObj->getVar('from_email')); |
|
|
|
|
|
|
56
|
|
|
$xoopsMailer->setFromName($xoopsConfig['sitename']); |
|
57
|
|
|
$xoopsMailer->setSubject(sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $myts->oopsStripSlashesGPC($xoopsConfig['sitename']))); |
|
58
|
|
|
|
|
59
|
|
|
if (!$xoopsMailer->send(true)) { |
|
60
|
|
|
$xoopsTpl->assign('send_error', sprintf(_CO_SOBJECT_SEND_ERROR, $xoopsConfig['adminmail']) . '<br>' . $xoopsMailer->getErrors(true)); |
|
61
|
|
|
} else { |
|
62
|
|
|
$xoopsTpl->assign('send_success', _CO_SOBJECT_SEND_SUCCESS); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
break; |
|
66
|
|
|
|
|
67
|
|
|
default: |
|
68
|
|
|
if (isset($_GET['mid'])) { |
|
69
|
|
|
$mid = $_GET['mid']; |
|
70
|
|
|
} else { |
|
71
|
|
|
/** |
|
72
|
|
|
* @todo close the window if no mid is passed as GET |
|
73
|
|
|
*/ |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
$hModule = xoops_getHandler('module'); |
|
77
|
|
|
$module = $hModule->get($mid); |
|
78
|
|
|
$linkObj->setVar('mid', $module->getVar('mid')); |
|
79
|
|
|
$linkObj->setVar('mid_name', $module->getVar('name')); |
|
80
|
|
|
|
|
81
|
|
|
if (isset($_GET['link'])) { |
|
82
|
|
|
$link = $_GET['link']; |
|
83
|
|
|
} else { |
|
84
|
|
|
/** |
|
85
|
|
|
* @todo close the window if no link is passed as GET |
|
86
|
|
|
*/ |
|
87
|
|
|
} |
|
88
|
|
|
$linkObj->setVar('link', $link); |
|
89
|
|
|
|
|
90
|
|
|
if (is_object($xoopsUser)) { |
|
91
|
|
|
$linkObj->setVar('from_uid', $xoopsUser->getVar('uid')); |
|
92
|
|
|
$linkObj->setVar('from_name', '' !== $xoopsUser->getVar('name') ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname')); |
|
93
|
|
|
$linkObj->setVar('from_email', $xoopsUser->getVar('email')); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
$linkObj->setVar('subject', sprintf(_CO_SOBJECT_SUBJECT_DEFAULT, $xoopsConfig['sitename'])); |
|
97
|
|
|
$linkObj->setVar('body', sprintf(_CO_SOBJECT_BODY_DEFAULT, $xoopsConfig['sitename'], $link)); |
|
98
|
|
|
$linkObj->setVar('date', time()); |
|
99
|
|
|
$linkObj->hideFieldFromForm(['from_uid', 'to_uid', 'link', 'mid', 'mid_name']); |
|
100
|
|
|
|
|
101
|
|
|
$form = $linkObj->getForm(_CO_SOBJECT_SEND_LINK_FORM, 'sendlink', false, _SEND, 'javascript:window.close();'); |
|
102
|
|
|
|
|
103
|
|
|
$form->assign($xoopsTpl); |
|
104
|
|
|
|
|
105
|
|
|
$xoopsTpl->assign('showform', true); |
|
106
|
|
|
break; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
$xoopsTpl->display('db:smartobject_sendlink.tpl'); |
|
110
|
|
|
|
|
111
|
|
|
xoops_footer(); |
|
112
|
|
|
|
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.