|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace XoopsModules\Adslight; |
|
6
|
|
|
|
|
7
|
|
|
/* |
|
8
|
|
|
You may not change or alter any portion of this comment or credits |
|
9
|
|
|
of supporting developers from this source code or any supporting source code |
|
10
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
11
|
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Module: Adslight |
|
19
|
|
|
* |
|
20
|
|
|
* @category Module |
|
21
|
|
|
* @package adslight |
|
22
|
|
|
* @author XOOPS Development Team <https://xoops.org> |
|
23
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
24
|
|
|
* @license GPL 2.0 or later |
|
25
|
|
|
* @link https://xoops.org/ |
|
26
|
|
|
* @since 1.0.0 |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
use XoopsModules\Adslight\{ |
|
30
|
|
|
Helper |
|
|
|
|
|
|
31
|
|
|
}; |
|
32
|
|
|
use Xmf\Module\Helper\Permission; |
|
33
|
|
|
|
|
34
|
|
|
//$permHelper = new \Xmf\Module\Helper\Permission(); |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Class Uservotedata |
|
38
|
|
|
*/ |
|
39
|
|
|
class Uservotedata extends \XoopsObject |
|
40
|
|
|
{ |
|
41
|
|
|
public $helper; |
|
42
|
|
|
public $permHelper; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Constructor |
|
46
|
|
|
* |
|
47
|
|
|
* @param null |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct() |
|
50
|
|
|
{ |
|
51
|
|
|
parent::__construct(); |
|
52
|
|
|
/** @var Helper $helper */ |
|
53
|
|
|
$this->helper = Helper::getInstance(); |
|
54
|
|
|
$this->permHelper = new Permission(); |
|
55
|
|
|
$this->initVar('ratingid', \XOBJ_DTYPE_INT); |
|
56
|
|
|
$this->initVar('usid', \XOBJ_DTYPE_INT); |
|
57
|
|
|
$this->initVar('ratinguser', \XOBJ_DTYPE_INT); |
|
58
|
|
|
$this->initVar('rating', \XOBJ_DTYPE_INT); |
|
59
|
|
|
$this->initVar('ratinghostname', \XOBJ_DTYPE_TXTBOX); |
|
60
|
|
|
$this->initVar('date_created', \XOBJ_DTYPE_INT); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Get form |
|
65
|
|
|
* |
|
66
|
|
|
* @return \XoopsModules\Adslight\Form\UservotesForm |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getForm(): Form\UservotesForm |
|
69
|
|
|
{ |
|
70
|
|
|
return new Form\UservotesForm($this); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return array|null |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getGroupsRead(): ?array |
|
77
|
|
|
{ |
|
78
|
|
|
//$permHelper = new \Xmf\Module\Helper\Permission(); |
|
79
|
|
|
return $this->permHelper->getGroupsForItem( |
|
80
|
|
|
'sbcolumns_read', |
|
81
|
|
|
$this->getVar('ratingid') |
|
82
|
|
|
); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return array|null |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getGroupsSubmit(): ?array |
|
89
|
|
|
{ |
|
90
|
|
|
//$permHelper = new \Xmf\Module\Helper\Permission(); |
|
91
|
|
|
return $this->permHelper->getGroupsForItem( |
|
92
|
|
|
'sbcolumns_submit', |
|
93
|
|
|
$this->getVar('ratingid') |
|
94
|
|
|
); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return array|null |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getGroupsModeration(): ?array |
|
101
|
|
|
{ |
|
102
|
|
|
//$permHelper = new \Xmf\Module\Helper\Permission(); |
|
103
|
|
|
return $this->permHelper->getGroupsForItem( |
|
104
|
|
|
'sbcolumns_moderation', |
|
105
|
|
|
$this->getVar('ratingid') |
|
106
|
|
|
); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: