XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
newblocks.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
15class LegacyNewblocksObject extends XoopsSimpleObject
16{
17 public $mModule = null;
18
23 public $mGroup = [];
24
25 public $mBmodule = [];
26
27 public $mColumn = null;
28
29 public $mCachetime = null;
30
31 public function LegacyNewblocksObject()
32 {
33 self::__construct();
34 }
35
36 public function __construct()
37 {
38 static $initVars;
39 if (isset($initVars)) {
40 $this->mVars = $initVars;
41 return;
42 }
43 $this->initVar('bid', XOBJ_DTYPE_INT, '0', true);
44 $this->initVar('mid', XOBJ_DTYPE_INT, '0', true);
45 $this->initVar('func_num', XOBJ_DTYPE_INT, '0', true);
46 $this->initVar('options', XOBJ_DTYPE_STRING, '', true, 191);
47 $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 150);
48 $this->initVar('title', XOBJ_DTYPE_STRING, '', true, 191);
49 $this->initVar('content', XOBJ_DTYPE_TEXT, '', true);
50 $this->initVar('side', XOBJ_DTYPE_INT, '0', true);
51 $this->initVar('weight', XOBJ_DTYPE_INT, '0', true);
52 $this->initVar('visible', XOBJ_DTYPE_BOOL, '0', true);
53 $this->initVar('block_type', XOBJ_DTYPE_STRING, '', true, 1);
54 $this->initVar('c_type', XOBJ_DTYPE_STRING, '', true, 1);
55 $this->initVar('isactive', XOBJ_DTYPE_BOOL, '0', true);
56 $this->initVar('dirname', XOBJ_DTYPE_STRING, '', true, 50);
57 $this->initVar('func_file', XOBJ_DTYPE_STRING, '', true, 50);
58 $this->initVar('show_func', XOBJ_DTYPE_STRING, '', true, 50);
59 $this->initVar('edit_func', XOBJ_DTYPE_STRING, '', true, 50);
60 $this->initVar('template', XOBJ_DTYPE_STRING, '', true, 50);
61 $this->initVar('bcachetime', XOBJ_DTYPE_INT, '0', true);
62 $this->initVar('last_modified', XOBJ_DTYPE_INT, time(), true);
63 $initVars = $this->mVars;
64 }
65
66 public function loadModule()
67 {
68 $handler =& xoops_gethandler('module');
69 $this->mModule =& $handler->get($this->get('mid'));
70 }
71
77 public function loadGroup()
78 {
79 $handler =& xoops_gethandler('groupperm');
80 $criteria =new CriteriaCompo();
81 $criteria->add(new Criteria('gperm_modid', 1));
82 $criteria->add(new Criteria('gperm_itemid', $this->get('bid')));
83 $criteria->add(new Criteria('gperm_name', 'block_read'));
84
85 $gpermArr =& $handler->getObjects($criteria);
86
87 $handler =& xoops_gethandler('group');
88 foreach ($gpermArr as $gperm) {
89 $this->mGroup[] =& $handler->get($gperm->get('gperm_groupid'));
90 }
91 }
92
93 public function loadBmodule()
94 {
95 $handler =& xoops_getmodulehandler('block_module_link', 'legacy');
96 $criteria =new Criteria('block_id', $this->get('bid'));
97
98 $this->mBmodule =& $handler->getObjects($criteria);
99 }
100
101 public function loadColumn()
102 {
103 $handler =& xoops_getmodulehandler('columnside', 'legacy');
104 $this->mColumn =& $handler->get($this->get('side'));
105 }
106
107 public function loadCachetime()
108 {
109 $handler =& xoops_gethandler('cachetime');
110 $this->mCachetime =& $handler->get($this->get('bcachetime'));
111 }
112}
113
115{
116 public $mTable = 'newblocks';
117 public $mPrimary = 'bid';
118 public $mClass = 'LegacyNewblocksObject';
119
120 public function delete(&$obj, $force = false)
121 {
122 if (parent::delete($obj, $force)) {
123 //
124 // Delete related data from block_module_link.
125 //
126 $handler =& xoops_getmodulehandler('block_module_link', 'legacy');
127 $handler->deleteAll(new Criteria('block_id'), $obj->get('bid'));
128
129 //
130 // Delete related permissions from groupperm.
131 //
132 $handler =& xoops_gethandler('groupperm');
133
134 $criteria =new CriteriaCompo();
135 $criteria->add(new Criteria('gperm_modid', 1));
136 $criteria->add(new Criteria('gperm_itemid', $obj->get('bid')));
137 $criteria->add(new Criteria('gperm_name', 'block_read'));
138
139 $handler->deleteAll($criteria);
140
141 return true;
142 } else {
143 return false;
144 }
145 }
146}