1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Extgallery; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* ExtGallery Class Manager |
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
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
14
|
|
|
* |
15
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
16
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
17
|
|
|
* @author Zoullou (http://www.zoullou.net) |
18
|
|
|
* @package ExtGallery |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use XoopsModules\Extgallery; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class Extgallery\QuotaHandler |
25
|
|
|
*/ |
26
|
|
|
class QuotaHandler extends Extgallery\PersistableObjectHandler |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Extgallery\QuotaHandler constructor. |
30
|
|
|
* @param \XoopsDatabase|null $db |
31
|
|
|
*/ |
32
|
|
|
public function __construct(\XoopsDatabase $db = null) |
33
|
|
|
{ |
34
|
|
|
parent::__construct($db, 'extgallery_quota', 'Extgallery\Quota', 'quota_id'); |
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param $data |
39
|
|
|
* |
40
|
|
|
* @return bool |
41
|
|
|
*/ |
42
|
|
|
public function createQuota($data) |
43
|
|
|
{ |
44
|
|
|
$quota = $this->create(); |
45
|
|
|
$quota->setVars($data); |
46
|
|
|
|
47
|
|
|
return $this->insert($quota, true); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return bool |
52
|
|
|
*/ |
53
|
|
|
public function deleteQuota() |
54
|
|
|
{ |
55
|
|
|
$criteria = new \Criteria('quota_name', 'private'); |
56
|
|
|
|
57
|
|
|
return $this->deleteAll($criteria); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param $groupid |
62
|
|
|
* @param $quotaName |
63
|
|
|
* |
64
|
|
|
* @return \XoopsObject |
65
|
|
|
*/ |
66
|
|
|
public function getQuota($groupid, $quotaName) |
67
|
|
|
{ |
68
|
|
|
$criteria = new \CriteriaCompo(); |
69
|
|
|
$criteria->add(new \Criteria('groupid', $groupid)); |
70
|
|
|
$criteria->add(new \Criteria('quota_name', $quotaName)); |
71
|
|
|
$ret = $this->getObjects($criteria); |
72
|
|
|
if (empty($ret)) { |
73
|
|
|
return $this->create(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
return $ret[0]; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|