|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Xnewsletter; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* **************************************************************************** |
|
7
|
|
|
* - A Project by Developers TEAM For Xoops - ( https://xoops.org ) |
|
8
|
|
|
* **************************************************************************** |
|
9
|
|
|
* XNEWSLETTER - MODULE FOR XOOPS |
|
10
|
|
|
* Copyright (c) 2007 - 2012 |
|
11
|
|
|
* Goffy ( wedega.com ) |
|
12
|
|
|
* |
|
13
|
|
|
* You may not change or alter any portion of this comment or credits |
|
14
|
|
|
* of supporting developers from this source code or any supporting |
|
15
|
|
|
* source code which is considered copyrighted (c) material of the |
|
16
|
|
|
* original comment or credit authors. |
|
17
|
|
|
* |
|
18
|
|
|
* This program is distributed in the hope that it will be useful, |
|
19
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21
|
|
|
* GNU General Public License for more details. |
|
22
|
|
|
* --------------------------------------------------------------------------- |
|
23
|
|
|
* @copyright Goffy ( wedega.com ) |
|
24
|
|
|
* @license GNU General Public License 2.0 |
|
25
|
|
|
* @package xnewsletter |
|
26
|
|
|
* @author Goffy ( [email protected] ) |
|
27
|
|
|
* |
|
28
|
|
|
* **************************************************************************** |
|
29
|
|
|
*/ |
|
30
|
|
|
|
|
31
|
|
|
//use XoopsModules\Xnewsletter; |
|
32
|
|
|
|
|
33
|
|
|
require_once dirname(__DIR__) . '/include/common.php'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Class Attachment |
|
37
|
|
|
*/ |
|
38
|
|
|
class Attachment extends \XoopsObject |
|
39
|
|
|
{ |
|
40
|
|
|
public $helper = null; |
|
41
|
|
|
public $db; |
|
42
|
|
|
|
|
43
|
|
|
//Constructor |
|
44
|
|
|
|
|
45
|
|
View Code Duplication |
public function __construct() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->helper = Helper::getInstance(); |
|
48
|
|
|
$this->db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
49
|
|
|
$this->initVar('attachment_id', XOBJ_DTYPE_INT, null, false); |
|
50
|
|
|
$this->initVar('attachment_letter_id', XOBJ_DTYPE_INT, null, false); |
|
51
|
|
|
$this->initVar('attachment_name', XOBJ_DTYPE_TXTBOX, null, false, 200); |
|
52
|
|
|
$this->initVar('attachment_type', XOBJ_DTYPE_TXTBOX, null, false, 100); |
|
53
|
|
|
$this->initVar('attachment_submitter', XOBJ_DTYPE_INT, null, false); |
|
54
|
|
|
$this->initVar('attachment_created', XOBJ_DTYPE_INT, time(), false); |
|
55
|
|
|
$this->initVar('attachment_size', XOBJ_DTYPE_INT, 0, false); |
|
56
|
|
|
$this->initVar('attachment_mode', XOBJ_DTYPE_INT, _XNEWSLETTER_ATTACHMENTS_MODE_ASATTACHMENT, false); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param bool $action |
|
61
|
|
|
* |
|
62
|
|
|
* @return \XoopsThemeForm |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getForm($action = false) |
|
65
|
|
|
{ |
|
66
|
|
|
global $xoopsDB; |
|
67
|
|
|
|
|
68
|
|
|
if (false === $action) { |
|
69
|
|
|
$action = $_SERVER['REQUEST_URI']; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
$title = $this->isNew() ? sprintf(_AM_XNEWSLETTER_ATTACHMENT_ADD) : sprintf(_AM_XNEWSLETTER_ATTACHMENT_EDIT); |
|
73
|
|
|
|
|
74
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
75
|
|
|
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
76
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
|
77
|
|
|
|
|
78
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_XNEWSLETTER_ATTACHMENT_NAME, $this->getVar('attachment_name'))); |
|
79
|
|
|
|
|
80
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_XNEWSLETTER_ATTACHMENT_SIZE, "<span title='" . $this->getVar('attachment_size') . " B'>" . xnewsletter_bytesToSize1024($this->getVar('attachment_size')) . '</span>')); |
|
81
|
|
|
|
|
82
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_XNEWSLETTER_ATTACHMENT_TYPE, $this->getVar('attachment_type'))); |
|
83
|
|
|
|
|
84
|
|
|
// attachment_mode |
|
85
|
|
|
$mode_select = new \XoopsFormRadio(_AM_XNEWSLETTER_ATTACHMENT_MODE, 'attachment_mode', $this->getVar('attachment_mode')); |
|
86
|
|
|
$mode_select->addOption(_XNEWSLETTER_ATTACHMENTS_MODE_ASATTACHMENT, _AM_XNEWSLETTER_ATTACHMENT_MODE_ASATTACHMENT); |
|
87
|
|
|
$mode_select->addOption(_XNEWSLETTER_ATTACHMENTS_MODE_ASLINK, _AM_XNEWSLETTER_ATTACHMENT_MODE_ASLINK); |
|
88
|
|
|
//$mode_select->addOption(_XNEWSLETTER_ATTACHMENTS_MODE_AUTO, _AM_XNEWSLETTER_ATTACHMENT_MODE_AUTO); // for future features |
|
89
|
|
|
$form->addElement($mode_select); |
|
90
|
|
|
|
|
91
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_XNEWSLETTER_SUBMITTER, $GLOBALS['xoopsUser']->uname())); |
|
92
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_XNEWSLETTER_CREATED, formatTimestamp($time, 's'))); |
|
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save_attachment')); |
|
95
|
|
|
$form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
96
|
|
|
|
|
97
|
|
|
return $form; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Get Values |
|
102
|
|
|
* @param null $keys |
|
103
|
|
|
* @param string|null $format |
|
104
|
|
|
* @param int|null $maxDepth |
|
105
|
|
|
* @return array |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getValuesAttachment($keys = null, $format = null, $maxDepth = null) |
|
108
|
|
|
{ |
|
109
|
|
|
$ret['id'] = $this->getVar('attachment_id'); |
|
110
|
|
|
$ret['letter_id'] = $this->getVar('attachment_letter_id'); |
|
111
|
|
|
$ret['name'] = $this->getVar('attachment_name'); |
|
112
|
|
|
$ret['type'] = $this->getVar('attachment_type'); |
|
113
|
|
|
$ret['size'] = $this->getVar('attachment_size'); |
|
114
|
|
|
$ret['mode'] = $this->getVar('attachment_mode'); |
|
115
|
|
|
$ret['created'] = formatTimestamp($this->getVar('attachment_created'), 's'); |
|
116
|
|
|
$ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('attachment_submitter')); |
|
117
|
|
|
return $ret; |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.