|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder; |
|
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
|
|
|
* Modulebuilder module for xoops |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright module for xoops |
|
19
|
|
|
* @license GPL 3.0 or later |
|
20
|
|
|
* @package Modulebuilder |
|
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 Ratings |
|
29
|
|
|
*/ |
|
30
|
|
|
class Ratings extends \XoopsObject |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* Constructor |
|
34
|
|
|
* |
|
35
|
|
|
* @param null |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->initVar('rate_id', XOBJ_DTYPE_INT); |
|
40
|
|
|
$this->initVar('rate_source', XOBJ_DTYPE_INT); |
|
41
|
|
|
$this->initVar('rate_itemid', XOBJ_DTYPE_INT); |
|
42
|
|
|
$this->initVar('rate_value', XOBJ_DTYPE_INT); |
|
43
|
|
|
$this->initVar('rate_uid', XOBJ_DTYPE_INT); |
|
44
|
|
|
$this->initVar('rate_ip', XOBJ_DTYPE_TXTBOX); |
|
45
|
|
|
$this->initVar('rate_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 getNewInsertedIdRatings() |
|
66
|
|
|
{ |
|
67
|
|
|
$newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
68
|
|
|
|
|
69
|
|
|
return $newInsertedId; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get Values |
|
74
|
|
|
* @param null $keys |
|
|
|
|
|
|
75
|
|
|
* @param null $format |
|
|
|
|
|
|
76
|
|
|
* @param null $maxDepth |
|
|
|
|
|
|
77
|
|
|
* @return array |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getValuesRatings($keys = null, $format = null, $maxDepth = null) |
|
80
|
|
|
{ |
|
81
|
|
|
$ret = $this->getValues($keys, $format, $maxDepth); |
|
82
|
|
|
$ret['id'] = $this->getVar('rate_id'); |
|
83
|
|
|
$ret['source'] = $this->getVar('rate_source'); |
|
84
|
|
|
$ret['itemid'] = $this->getVar('rate_itemid'); |
|
85
|
|
|
$ret['value'] = $this->getVar('rate_value'); |
|
86
|
|
|
$ret['uid'] = \XoopsUser::getUnameFromId($this->getVar('rate_uid')); |
|
87
|
|
|
$ret['ip'] = $this->getVar('rate_ip'); |
|
88
|
|
|
$ret['date'] = formatTimestamp($this->getVar('rate_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 toArrayRatings() |
|
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
|
|
|
|