1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Publisher; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
You may not change or alter any portion of this comment or credits |
7
|
|
|
of supporting developers from this source code or any supporting source code |
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Publisher module for xoops |
17
|
|
|
* |
18
|
|
|
* @copyright module for xoops |
19
|
|
|
* @license GPL 3.0 or later |
20
|
|
|
* @package Publisher |
21
|
|
|
* @since 1.0 |
22
|
|
|
* @min_xoops 2.5.10 |
23
|
|
|
* @author XOOPS Development Team |
24
|
|
|
*/ |
25
|
|
|
\defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class Object Vote |
29
|
|
|
*/ |
30
|
|
|
class Vote extends \XoopsObject |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* Constructor |
34
|
|
|
* |
35
|
|
|
* @param null |
36
|
|
|
*/ |
37
|
|
|
public function __construct() |
38
|
|
|
{ |
39
|
|
|
$this->initVar('ratingid', XOBJ_DTYPE_INT); |
40
|
|
|
$this->initVar('source', XOBJ_DTYPE_INT); |
41
|
|
|
$this->initVar('itemid', XOBJ_DTYPE_INT); |
42
|
|
|
$this->initVar('rate', XOBJ_DTYPE_INT); |
43
|
|
|
$this->initVar('uid', XOBJ_DTYPE_INT); |
44
|
|
|
$this->initVar('ip', XOBJ_DTYPE_TXTBOX); |
45
|
|
|
$this->initVar('date', XOBJ_DTYPE_INT); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @static function &getInstance |
50
|
|
|
* |
51
|
|
|
* @param null |
52
|
|
|
*/ |
53
|
|
|
public static function getInstance() |
54
|
|
|
{ |
55
|
|
|
static $instance = false; |
56
|
|
|
if (!$instance) { |
57
|
|
|
$instance = new self(); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* The new inserted $Id |
63
|
|
|
* @return int inserted id |
64
|
|
|
*/ |
65
|
|
|
public function getNewInsertedIdVote() |
66
|
|
|
{ |
67
|
|
|
$newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
68
|
|
|
|
69
|
|
|
return $newInsertedId; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get Values |
74
|
|
|
* @param array|null $keys |
75
|
|
|
* @param string|null $format |
76
|
|
|
* @param int|null $maxDepth |
77
|
|
|
* @return array |
78
|
|
|
*/ |
79
|
|
|
public function getValuesVote($keys = null, $format = null, $maxDepth = null) |
80
|
|
|
{ |
81
|
|
|
$ret = $this->getValues($keys, $format, $maxDepth); |
82
|
|
|
$ret['ratingid'] = $this->getVar('ratingid'); |
83
|
|
|
$ret['source'] = $this->getVar('source'); |
84
|
|
|
$ret['itemid'] = $this->getVar('itemid'); |
85
|
|
|
$ret['value'] = $this->getVar('rate'); |
86
|
|
|
$ret['uid'] = \XoopsUser::getUnameFromId($this->getVar('rate_uid')); |
87
|
|
|
$ret['ip'] = $this->getVar('rate_ip'); |
88
|
|
|
$ret['date'] = \formatTimestamp($this->getVar('date'), 's'); |
89
|
|
|
|
90
|
|
|
return $ret; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Returns an array representation of the object |
95
|
|
|
* |
96
|
|
|
* @return array |
97
|
|
|
*/ |
98
|
|
|
public function toArrayVote() |
99
|
|
|
{ |
100
|
|
|
$ret = []; |
101
|
|
|
$vars = $this->getVars(); |
102
|
|
|
foreach (\array_keys($vars) as $var) { |
103
|
|
|
$ret[$var] = $this->getVar('"{$var}"'); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
return $ret; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|