1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Xoopspoll; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
XOOPS - PHP Content Management System |
7
|
|
|
Copyright (c) 2000-2020 XOOPS.org |
8
|
|
|
<https://xoops.org> |
9
|
|
|
This program is free software; you can redistribute it and/or modify |
10
|
|
|
it under the terms of the GNU General Public License as published by |
11
|
|
|
the Free Software Foundation; either version 2 of the License, or |
12
|
|
|
(at your option) any later version. |
13
|
|
|
|
14
|
|
|
You may not change or alter any portion of this comment or credits |
15
|
|
|
of supporting developers from this source code or any supporting |
16
|
|
|
source code which is considered copyrighted (c) material of the |
17
|
|
|
original comment or credit authors. |
18
|
|
|
|
19
|
|
|
This program is distributed in the hope that it will be useful, |
20
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
|
|
|
GNU General Public License for more details. |
23
|
|
|
|
24
|
|
|
You should have received a copy of the GNU General Public License |
25
|
|
|
along with this program; if not, write to the Free Software |
26
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Log class for the XoopsPoll Module |
31
|
|
|
* |
32
|
|
|
* @copyright :: {@link https://xoops.org/ XOOPS Project} |
33
|
|
|
* @license :: {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
34
|
|
|
* @package :: xoopspoll |
35
|
|
|
* @subpackage:: class |
36
|
|
|
* @since :: 1.40 |
37
|
|
|
* @author :: {@link http://www.myweb.ne.jp/ Kazumi Ono (AKA onokazu)} |
38
|
|
|
**/ |
39
|
|
|
|
40
|
|
|
use XoopsModules\Xoopspoll; |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Log() class definition for Log Objects |
46
|
|
|
* @author:: zyspec <[email protected]> |
47
|
|
|
* @uses :: xoops_getModuleHandler poll module handler for class use |
48
|
|
|
*/ |
49
|
|
|
class Log extends \XoopsObject |
50
|
|
|
{ |
51
|
|
|
// class Log extends \XoopsObject { |
52
|
|
|
// var $db; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Constructor |
56
|
|
|
* @param null $id |
|
|
|
|
57
|
|
|
*/ |
58
|
|
|
public function __construct($id = null) |
59
|
|
|
{ |
60
|
|
|
parent::__construct(); |
61
|
|
|
$this->initVar('log_id', \XOBJ_DTYPE_INT, 0); |
62
|
|
|
$this->initVar('poll_id', \XOBJ_DTYPE_INT, null, true); |
63
|
|
|
$this->initVar('option_id', \XOBJ_DTYPE_INT, null, true); |
64
|
|
|
$this->initVar('ip', \XOBJ_DTYPE_OTHER, null); |
65
|
|
|
$this->initVar('user_id', \XOBJ_DTYPE_INT, 0); |
66
|
|
|
$this->initVar('time', \XOBJ_DTYPE_INT, null); |
67
|
|
|
if (!empty($id) && \is_array($id)) { |
68
|
|
|
$this->assignVars($id); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param null $id |
|
|
|
|
74
|
|
|
*/ |
75
|
|
|
public function Log($id = null) |
76
|
|
|
{ |
77
|
|
|
$this->__construct($id); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* The following method is provided for backward compatibility with newbb |
82
|
|
|
* @param int $pid |
83
|
|
|
* @return mixed |
84
|
|
|
* @deprecated since Xoopspoll 1.40, please use LogHandler & Log |
85
|
|
|
*/ |
86
|
|
|
public static function deleteByPollId($pid) |
87
|
|
|
{ |
88
|
|
|
$trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); |
89
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated since Xoopspoll 1.40, please use Log and LogHandler methods instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}"); |
90
|
|
|
$slogHandler = self::getStaticLogHandler(); |
91
|
|
|
$criteria = new \Criteria('poll_id', (int)$pid, '='); |
92
|
|
|
|
93
|
|
|
return $slogHandler->deleteAll($criteria); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param $opt_id |
98
|
|
|
* @return mixed |
99
|
|
|
*/ |
100
|
|
|
public static function deleteByOptionId($opt_id) |
101
|
|
|
{ |
102
|
|
|
$trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); |
103
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated since Xoopspoll 1.40, please use Log and LogHandler methods instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}"); |
104
|
|
|
|
105
|
|
|
$slogHandler = self::getStaticLogHandler(); |
106
|
|
|
$criteria = new \Criteria('option_id', (int)$opt_id, '='); |
107
|
|
|
|
108
|
|
|
return $slogHandler->deleteAll($criteria); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param $pid |
113
|
|
|
* @param $ip |
114
|
|
|
* @param $uid |
115
|
|
|
* @return mixed |
116
|
|
|
*/ |
117
|
|
|
public static function hasVoted($pid, $ip, $uid) |
118
|
|
|
{ |
119
|
|
|
$trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); |
120
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated since Xoopspoll 1.40, please use Log and LogHandler methods instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}"); |
121
|
|
|
|
122
|
|
|
$slogHandler = self::getStaticLogHandler(); |
123
|
|
|
|
124
|
|
|
return $slogHandler->hasVoted($pid, $ip, $uid); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return bool |
129
|
|
|
*/ |
130
|
|
|
private static function getStaticLogHandler() |
131
|
|
|
{ |
132
|
|
|
static $log_h; |
133
|
|
|
$trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); |
134
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated since Xoopspoll 1.40, please use Log and LogHandler methods instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}"); |
135
|
|
|
|
136
|
|
|
if (!isset($log_h)) { |
137
|
|
|
$log_h = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
return $log_h; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/**#@-*/ |
144
|
|
|
} |
145
|
|
|
|