XOOPS Cube Legacy base repository
修訂 | 8037be6a45736884c2ae624bde90c300242024b2 (tree) |
---|---|
時間 | 2011-11-16 22:02:10 |
作者 | nbuy <nbuy@704c...> |
Commiter | nbuy |
revise for speedup
git-svn-id: https://xoopscube.svn.sourceforge.net/svnroot/xoopscube/Package_Legacy/trunk@1050 704cf05f-ae62-4b0e-a484-234ee0250e75
@@ -172,34 +172,23 @@ class XoopsBlock extends XoopsObject | ||
172 | 172 | if ( $this->getVar('block_type', 'N') != 'C' ) { |
173 | 173 | // get block display function |
174 | 174 | $show_func = $this->getVar('show_func', 'N'); |
175 | - if ( !$show_func ) { | |
176 | - return $ret; | |
177 | - } | |
175 | + if ( !$show_func ) return $ret; | |
178 | 176 | // must get lang files b4 execution of the function |
179 | 177 | if ( file_exists($path = XOOPS_ROOT_PATH.'/modules/'.($dirname = $this->getVar('dirname', 'N')).'/blocks/'.$this->getVar('func_file', 'N')) ) { |
180 | 178 | $root=&XCube_Root::getSingleton(); |
181 | 179 | $root->mLanguageManager->loadBlockMessageCatalog($dirname); |
182 | 180 | |
183 | 181 | require_once $path; |
184 | - $options = explode('|', $this->getVar('options', 'N')); | |
185 | 182 | if ( function_exists($show_func) ) { |
186 | 183 | // execute the function |
187 | - $block = $show_func($options); | |
188 | - if ( !$block ) { | |
189 | - return $ret; | |
190 | - } | |
191 | - } else { | |
192 | - return $ret; | |
193 | - } | |
194 | - } else { | |
195 | - return $ret; | |
196 | - } | |
184 | + $block = $show_func(explode('|', $this->getVar('options', 'N'))); | |
185 | + if ( !$block ) return $ret; | |
186 | + } else return $ret; | |
187 | + } else return $ret; | |
197 | 188 | } else { |
198 | 189 | // it is a custom block, so just return the contents |
199 | 190 | $block['content'] = $this->getContent('S',$this->getVar('c_type', 'N')); |
200 | - if (empty($block['content'])) { | |
201 | - return $ret; | |
202 | - } | |
191 | + if (empty($block['content'])) return $ret; | |
203 | 192 | } |
204 | 193 | return $block; |
205 | 194 | } |
@@ -251,9 +240,9 @@ class XoopsBlock extends XoopsObject | ||
251 | 240 | if (!$edit_func) { |
252 | 241 | return false; |
253 | 242 | } |
254 | - if (file_exists($path = XOOPS_ROOT_PATH.'/modules/'.$this->getVar('dirname', 'N').'/blocks/'.$this->getVar('func_file', 'N'))) { | |
243 | + if (file_exists($path = XOOPS_ROOT_PATH.'/modules/'.($dirname=$this->getVar('dirname', 'N')).'/blocks/'.$this->getVar('func_file', 'N'))) { | |
255 | 244 | $root =& XCube_Root::getSingleton(); |
256 | - $root->mLanguageManager->loadBlockMessageCatalog($this->getVar('dirname')); | |
245 | + $root->mLanguageManager->loadBlockMessageCatalog($dirname); | |
257 | 246 | |
258 | 247 | include_once $path; |
259 | 248 | $options = explode('|', $this->getVar('options', 'N')); |
@@ -144,7 +144,7 @@ class XoopsConfigItem extends XoopsObject | ||
144 | 144 | */ |
145 | 145 | function &getConfValueForOutput() |
146 | 146 | { |
147 | - switch ($this->getVar('conf_valuetype', 'N')) { | |
147 | + switch ($this->getVar('conf_valuetype')) { | |
148 | 148 | case 'int': |
149 | 149 | $ret = (int)$this->getVar('conf_value', 'N'); |
150 | 150 | return $ret; |
@@ -343,11 +343,12 @@ class XoopsConfigItemHandler extends XoopsObjectHandler | ||
343 | 343 | $ret = false; |
344 | 344 | $id = (int)$id; |
345 | 345 | if ($id > 0) { |
346 | - $sql = 'SELECT * FROM '.$this->db->prefix('config').' WHERE conf_id='.$id; | |
347 | - if ($result = $this->db->query($sql)) { | |
348 | - $numrows = $this->db->getRowsNum($result); | |
346 | + $db = &$this->db; | |
347 | + $sql = 'SELECT * FROM '.$db->prefix('config').' WHERE conf_id='.$id; | |
348 | + if ($result = $db->query($sql)) { | |
349 | + $numrows = $db->getRowsNum($result); | |
349 | 350 | if ($numrows == 1) { |
350 | - $myrow = $this->db->fetchArray($result); | |
351 | + $myrow = $db->fetchArray($result); | |
351 | 352 | $config =new XoopsConfigItem(); |
352 | 353 | $config->assignVars($myrow); |
353 | 354 | $ret =& $config; |
@@ -377,17 +378,18 @@ class XoopsConfigItemHandler extends XoopsObjectHandler | ||
377 | 378 | foreach ($config->cleanVars as $k => $v) { |
378 | 379 | ${$k} = $v; |
379 | 380 | } |
381 | + $db = &$this->db; | |
380 | 382 | if ($config->isNew()) { |
381 | - $conf_id = $this->db->genId('config_conf_id_seq'); | |
382 | - $sql = sprintf("INSERT INTO %s (conf_id, conf_modid, conf_catid, conf_name, conf_title, conf_value, conf_desc, conf_formtype, conf_valuetype, conf_order) VALUES (%u, %u, %u, %s, %s, %s, %s, %s, %s, %u)", $this->db->prefix('config'), $conf_id, $conf_modid, $conf_catid, $this->db->quoteString($conf_name), $this->db->quoteString($conf_title), $this->db->quoteString($conf_value), $this->db->quoteString($conf_desc), $this->db->quoteString($conf_formtype), $this->db->quoteString($conf_valuetype), $conf_order); | |
383 | + $conf_id = $db->genId('config_conf_id_seq'); | |
384 | + $sql = sprintf('INSERT INTO %s (conf_id, conf_modid, conf_catid, conf_name, conf_title, conf_value, conf_desc, conf_formtype, conf_valuetype, conf_order) VALUES (%u, %u, %u, %s, %s, %s, %s, %s, %s, %u)', $db->prefix('config'), $conf_id, $conf_modid, $conf_catid, $db->quoteString($conf_name), $db->quoteString($conf_title), $db->quoteString($conf_value), $db->quoteString($conf_desc), $db->quoteString($conf_formtype), $db->quoteString($conf_valuetype), $conf_order); | |
383 | 385 | } else { |
384 | - $sql = sprintf("UPDATE %s SET conf_modid = %u, conf_catid = %u, conf_name = %s, conf_title = %s, conf_value = %s, conf_desc = %s, conf_formtype = %s, conf_valuetype = %s, conf_order = %u WHERE conf_id = %u", $this->db->prefix('config'), $conf_modid, $conf_catid, $this->db->quoteString($conf_name), $this->db->quoteString($conf_title), $this->db->quoteString($conf_value), $this->db->quoteString($conf_desc), $this->db->quoteString($conf_formtype), $this->db->quoteString($conf_valuetype), $conf_order, $conf_id); | |
386 | + $sql = sprintf('UPDATE %s SET conf_modid = %u, conf_catid = %u, conf_name = %s, conf_title = %s, conf_value = %s, conf_desc = %s, conf_formtype = %s, conf_valuetype = %s, conf_order = %u WHERE conf_id = %u', $db->prefix('config'), $conf_modid, $conf_catid, $db->quoteString($conf_name), $db->quoteString($conf_title), $db->quoteString($conf_value), $db->quoteString($conf_desc), $db->quoteString($conf_formtype), $db->quoteString($conf_valuetype), $conf_order, $conf_id); | |
385 | 387 | } |
386 | - if (!$result = $this->db->query($sql)) { | |
388 | + if (!$result = $db->query($sql)) { | |
387 | 389 | return false; |
388 | 390 | } |
389 | 391 | if (empty($conf_id)) { |
390 | - $conf_id = $this->db->getInsertId(); | |
392 | + $conf_id = $db->getInsertId(); | |
391 | 393 | } |
392 | 394 | $config->assignVar('conf_id', $conf_id); |
393 | 395 | return true; |
@@ -404,7 +406,7 @@ class XoopsConfigItemHandler extends XoopsObjectHandler | ||
404 | 406 | if (strtolower(get_class($config)) != 'xoopsconfigitem') { |
405 | 407 | return false; |
406 | 408 | } |
407 | - $sql = sprintf("DELETE FROM %s WHERE conf_id = %u", $this->db->prefix('config'), $config->getVar('conf_id')); | |
409 | + $sql = sprintf('DELETE FROM %s WHERE conf_id = %u', $this->db->prefix('config'), $config->getVar('conf_id')); | |
408 | 410 | if (!$result = $this->db->query($sql)) { |
409 | 411 | return false; |
410 | 412 | } |
@@ -456,15 +458,16 @@ class XoopsConfigItemHandler extends XoopsObjectHandler | ||
456 | 458 | function getCount($criteria = null) |
457 | 459 | { |
458 | 460 | $limit = $start = 0; |
459 | - $sql = 'SELECT * FROM '.$this->db->prefix('config'); | |
461 | + $db = &$this->db; | |
462 | + $sql = 'SELECT * FROM '.$db->prefix('config'); | |
460 | 463 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
461 | 464 | $sql .= ' '.$criteria->renderWhere(); |
462 | 465 | } |
463 | - $result =& $this->db->query($sql); | |
466 | + $result = $db->query($sql); | |
464 | 467 | if (!$result) { |
465 | 468 | return false; |
466 | 469 | } |
467 | - list($count) = $this->db->fetchRow($result); | |
470 | + list($count) = $db->fetchRow($result); | |
468 | 471 | return $count; |
469 | 472 | } |
470 | 473 | } |
@@ -180,9 +180,9 @@ class XoopsConfigOptionHandler extends XoopsObjectHandler | ||
180 | 180 | } |
181 | 181 | if ($confoption->isNew()) { |
182 | 182 | $confop_id = $this->db->genId('configoption_confop_id_seq'); |
183 | - $sql = sprintf("INSERT INTO %s (confop_id, confop_name, confop_value, conf_id) VALUES (%u, %s, %s, %u)", $this->db->prefix('configoption'), $confop_id, $this->db->quoteString($confop_name), $this->db->quoteString($confop_value), $conf_id); | |
183 | + $sql = sprintf('INSERT INTO %s (confop_id, confop_name, confop_value, conf_id) VALUES (%u, %s, %s, %u)', $this->db->prefix('configoption'), $confop_id, $this->db->quoteString($confop_name), $this->db->quoteString($confop_value), $conf_id); | |
184 | 184 | } else { |
185 | - $sql = sprintf("UPDATE %s SET confop_name = %s, confop_value = %s WHERE confop_id = %u", $this->db->prefix('configoption'), $this->db->quoteString($confop_name), $this->db->quoteString($confop_value), $confop_id); | |
185 | + $sql = sprintf('UPDATE %s SET confop_name = %s, confop_value = %s WHERE confop_id = %u', $this->db->prefix('configoption'), $this->db->quoteString($confop_name), $this->db->quoteString($confop_value), $confop_id); | |
186 | 186 | } |
187 | 187 | if (!$result = $this->db->query($sql)) { |
188 | 188 | return false; |
@@ -205,7 +205,7 @@ class XoopsConfigOptionHandler extends XoopsObjectHandler | ||
205 | 205 | if (strtolower(get_class($confoption)) != 'xoopsconfigoption') { |
206 | 206 | return false; |
207 | 207 | } |
208 | - $sql = sprintf("DELETE FROM %s WHERE confop_id = %u", $this->db->prefix('configoption'), $confoption->getVar('confop_id')); | |
208 | + $sql = sprintf('DELETE FROM %s WHERE confop_id = %u', $this->db->prefix('configoption'), $confoption->getVar('confop_id', 'n')); | |
209 | 209 | if (!$result = $this->db->query($sql)) { |
210 | 210 | return false; |
211 | 211 | } |
@@ -104,12 +104,13 @@ class XoopsGroupHandler extends XoopsObjectHandler | ||
104 | 104 | { |
105 | 105 | $ret = false; |
106 | 106 | if ((int)$id > 0) { |
107 | - $sql = 'SELECT * FROM '.$this->db->prefix('groups').' WHERE groupid='.$id; | |
108 | - if ($result = $this->db->query($sql)) { | |
109 | - $numrows = $this->db->getRowsNum($result); | |
107 | + $db = &$this->db; | |
108 | + $sql = 'SELECT * FROM '.$db->prefix('groups').' WHERE groupid='.$id; | |
109 | + if ($result = $db->query($sql)) { | |
110 | + $numrows = $db->getRowsNum($result); | |
110 | 111 | if ($numrows == 1) { |
111 | 112 | $group = new XoopsGroup(); |
112 | - $group->assignVars($this->db->fetchArray($result)); | |
113 | + $group->assignVars($db->fetchArray($result)); | |
113 | 114 | $ret =& $group; |
114 | 115 | } |
115 | 116 | } |
@@ -137,18 +138,15 @@ class XoopsGroupHandler extends XoopsObjectHandler | ||
137 | 138 | foreach ($group->cleanVars as $k => $v) { |
138 | 139 | ${$k} = $v; |
139 | 140 | } |
141 | + $db = &$this->db; | |
140 | 142 | if ($group->isNew()) { |
141 | - $groupid = $this->db->genId('group_groupid_seq'); | |
142 | - $sql = sprintf("INSERT INTO %s (groupid, name, description, group_type) VALUES (%u, %s, %s, %s)", $this->db->prefix('groups'), $groupid, $this->db->quoteString($name), $this->db->quoteString($description), $this->db->quoteString($group_type)); | |
143 | + $groupid = $db->genId('group_groupid_seq'); | |
144 | + $sql = sprintf('INSERT INTO %s (groupid, name, description, group_type) VALUES (%u, %s, %s, %s)', $db->prefix('groups'), $groupid, $db->quoteString($name), $db->quoteString($description), $db->quoteString($group_type)); | |
143 | 145 | } else { |
144 | - $sql = sprintf("UPDATE %s SET name = %s, description = %s, group_type = %s WHERE groupid = %u", $this->db->prefix('groups'), $this->db->quoteString($name), $this->db->quoteString($description), $this->db->quoteString($group_type), $groupid); | |
145 | - } | |
146 | - if (!$result = $this->db->query($sql)) { | |
147 | - return false; | |
148 | - } | |
149 | - if (empty($groupid)) { | |
150 | - $groupid = $this->db->getInsertId(); | |
146 | + $sql = sprintf("UPDATE %s SET name = %s, description = %s, group_type = %s WHERE groupid = %u", $db->prefix('groups'), $db->quoteString($name), $db->quoteString($description), $db->quoteString($group_type), $groupid); | |
151 | 147 | } |
148 | + if (!$result = $db->query($sql)) return false; | |
149 | + if (empty($groupid)) $groupid = $db->getInsertId(); | |
152 | 150 | $group->assignVar('groupid', $groupid); |
153 | 151 | return true; |
154 | 152 | } |
@@ -161,10 +159,8 @@ class XoopsGroupHandler extends XoopsObjectHandler | ||
161 | 159 | */ |
162 | 160 | function delete(&$group) |
163 | 161 | { |
164 | - if (strtolower(get_class($group)) != 'xoopsgroup') { | |
165 | - return false; | |
166 | - } | |
167 | - $sql = sprintf("DELETE FROM %s WHERE groupid = %u", $this->db->prefix('groups'), $group->getVar('groupid')); | |
162 | + if (strtolower(get_class($group)) != 'xoopsgroup') return false; | |
163 | + $sql = sprintf('DELETE FROM %s WHERE groupid = %u', $this->db->prefix('groups'), $group->getVar('groupid')); | |
168 | 164 | if (!$result = $this->db->query($sql)) { |
169 | 165 | return false; |
170 | 166 | } |
@@ -182,17 +178,18 @@ class XoopsGroupHandler extends XoopsObjectHandler | ||
182 | 178 | { |
183 | 179 | $ret = array(); |
184 | 180 | $limit = $start = 0; |
185 | - $sql = 'SELECT * FROM '.$this->db->prefix('groups'); | |
181 | + $db = &$this->db; | |
182 | + $sql = 'SELECT * FROM '.$db->prefix('groups'); | |
186 | 183 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
187 | 184 | $sql .= ' '.$criteria->renderWhere(); |
188 | 185 | $limit = $criteria->getLimit(); |
189 | 186 | $start = $criteria->getStart(); |
190 | 187 | } |
191 | - $result = $this->db->query($sql, $limit, $start); | |
188 | + $result = $db->query($sql, $limit, $start); | |
192 | 189 | if (!$result) { |
193 | 190 | return $ret; |
194 | 191 | } |
195 | - while ($myrow = $this->db->fetchArray($result)) { | |
192 | + while ($myrow = $db->fetchArray($result)) { | |
196 | 193 | $group =new XoopsGroup(); |
197 | 194 | $group->assignVars($myrow); |
198 | 195 | if (!$id_as_key) { |
@@ -265,12 +262,13 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
265 | 262 | { |
266 | 263 | $ret = false; |
267 | 264 | if ((int)$id > 0) { |
268 | - $sql = 'SELECT * FROM '.$this->db->prefix('groups_users_link').' WHERE linkid='.$id; | |
269 | - if ($result = $this->db->query($sql)) { | |
270 | - $numrows = $this->db->getRowsNum($result); | |
265 | + $db = &$this->db; | |
266 | + $sql = 'SELECT * FROM '.$db->prefix('groups_users_link').' WHERE linkid='.$id; | |
267 | + if ($result = $db->query($sql)) { | |
268 | + $numrows = $db->getRowsNum($result); | |
271 | 269 | if ($numrows == 1) { |
272 | 270 | $mship =new XoopsMembership(); |
273 | - $mship->assignVars($this->db->fetchArray($result)); | |
271 | + $mship->assignVars($db->fetchArray($result)); | |
274 | 272 | $ret =& $mship; |
275 | 273 | } |
276 | 274 | } |
@@ -298,18 +296,15 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
298 | 296 | foreach ($mship->cleanVars as $k => $v) { |
299 | 297 | ${$k} = $v; |
300 | 298 | } |
299 | + $db = &$this->db; | |
301 | 300 | if ($mship->isNew()) { |
302 | - $linkid = $this->db->genId('groups_users_link_linkid_seq'); | |
303 | - $sql = sprintf("INSERT INTO %s (linkid, groupid, uid) VALUES (%u, %u, %u)", $this->db->prefix('groups_users_link'), $linkid, $groupid, $uid); | |
301 | + $linkid = $db->genId('groups_users_link_linkid_seq'); | |
302 | + $sql = sprintf("INSERT INTO %s (linkid, groupid, uid) VALUES (%u, %u, %u)", $db->prefix('groups_users_link'), $linkid, $groupid, $uid); | |
304 | 303 | } else { |
305 | - $sql = sprintf("UPDATE %s SET groupid = %u, uid = %u WHERE linkid = %u", $this->db->prefix('groups_users_link'), $groupid, $uid, $linkid); | |
306 | - } | |
307 | - if (!$result = $this->db->query($sql)) { | |
308 | - return false; | |
309 | - } | |
310 | - if (empty($linkid)) { | |
311 | - $linkid = $this->db->getInsertId(); | |
304 | + $sql = sprintf("UPDATE %s SET groupid = %u, uid = %u WHERE linkid = %u", $db->prefix('groups_users_link'), $groupid, $uid, $linkid); | |
312 | 305 | } |
306 | + if (!$result = $db->query($sql)) return false; | |
307 | + if (empty($linkid)) $linkid = $this->db->getInsertId(); | |
313 | 308 | $mship->assignVar('linkid', $linkid); |
314 | 309 | return true; |
315 | 310 | } |
@@ -325,10 +320,8 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
325 | 320 | if (strtolower(get_class($mship)) != 'xoopsmembership') { |
326 | 321 | return false; |
327 | 322 | } |
328 | - $sql = sprintf("DELETE FROM %s WHERE linkid = %u", $this->db->prefix('groups_users_link'), $groupm->getVar('linkid')); | |
329 | - if (!$result = $this->db->query($sql)) { | |
330 | - return false; | |
331 | - } | |
323 | + $sql = sprintf('DELETE FROM %s WHERE linkid = %u', $this->db->prefix('groups_users_link'), $groupm->getVar('linkid')); | |
324 | + if (!$result = $this->db->query($sql)) return false; | |
332 | 325 | return true; |
333 | 326 | } |
334 | 327 |
@@ -343,17 +336,18 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
343 | 336 | { |
344 | 337 | $ret = array(); |
345 | 338 | $limit = $start = 0; |
346 | - $sql = 'SELECT * FROM '.$this->db->prefix('groups_users_link'); | |
339 | + $db = &$this->db; | |
340 | + $sql = 'SELECT * FROM '.$db->prefix('groups_users_link'); | |
347 | 341 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
348 | 342 | $sql .= ' '.$criteria->renderWhere(); |
349 | 343 | $limit = $criteria->getLimit(); |
350 | 344 | $start = $criteria->getStart(); |
351 | 345 | } |
352 | - $result = $this->db->query($sql, $limit, $start); | |
346 | + $result = $db->query($sql, $limit, $start); | |
353 | 347 | if (!$result) { |
354 | 348 | return $ret; |
355 | 349 | } |
356 | - while ($myrow = $this->db->fetchArray($result)) { | |
350 | + while ($myrow = $db->fetchArray($result)) { | |
357 | 351 | $mship = new XoopsMembership(); |
358 | 352 | $mship->assignVars($myrow); |
359 | 353 | if (!$id_as_key) { |
@@ -374,15 +368,16 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
374 | 368 | */ |
375 | 369 | function getCount($criteria = null) |
376 | 370 | { |
377 | - $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('groups_users_link'); | |
371 | + $db = &$this->db; | |
372 | + $sql = 'SELECT COUNT(*) FROM '.$db->prefix('groups_users_link'); | |
378 | 373 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
379 | 374 | $sql .= ' '.$criteria->renderWhere(); |
380 | 375 | } |
381 | - $result = $this->db->query($sql); | |
376 | + $result = $db->query($sql); | |
382 | 377 | if (!$result) { |
383 | 378 | return 0; |
384 | 379 | } |
385 | - list($count) = $this->db->fetchRow($result); | |
380 | + list($count) = $db->fetchRow($result); | |
386 | 381 | return $count; |
387 | 382 | } |
388 | 383 |
@@ -398,9 +393,7 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
398 | 393 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
399 | 394 | $sql .= ' '.$criteria->renderWhere(); |
400 | 395 | } |
401 | - if (!$result = $this->db->query($sql)) { | |
402 | - return false; | |
403 | - } | |
396 | + if (!$result = $this->db->query($sql)) return false; | |
404 | 397 | return true; |
405 | 398 | } |
406 | 399 |
@@ -415,13 +408,12 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
415 | 408 | function &getGroupsByUser($uid) |
416 | 409 | { |
417 | 410 | $ret = array(); |
418 | - $sql = 'SELECT groupid FROM '.$this->db->prefix('groups_users_link').' WHERE uid='.(int)$uid; | |
419 | - $result = $this->db->query($sql); | |
420 | - if (!$result) { | |
421 | - return $ret; | |
422 | - } | |
423 | - while ($myrow = $this->db->fetchArray($result)) { | |
424 | - $ret[] = $myrow['groupid']; | |
411 | + $db = &$this->db; | |
412 | + $sql = 'SELECT groupid FROM '.$db->prefix('groups_users_link').' WHERE uid='.(int)$uid; | |
413 | + $result = $db->query($sql); | |
414 | + if (!$result) return $ret; | |
415 | + while (list($groupid) = $db->fetchRow($result)) { | |
416 | + $ret[] = $groupid; | |
425 | 417 | } |
426 | 418 | return $ret; |
427 | 419 | } |
@@ -439,14 +431,13 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
439 | 431 | function &getUsersByGroup($groupid, $limit=0, $start=0) |
440 | 432 | { |
441 | 433 | $ret = array(); |
442 | - $sql = 'SELECT uid FROM ' . $this->db->prefix('groups_users_link') . ' WHERE groupid='.(int)$groupid; | |
434 | + $db = &$this->db; | |
435 | + $sql = 'SELECT uid FROM ' . $db->prefix('groups_users_link') . ' WHERE groupid='.(int)$groupid; | |
443 | 436 | |
444 | - $result = $this->db->query($sql, $limit, $start); | |
445 | - if (!$result) { | |
446 | - return $ret; | |
447 | - } | |
448 | - while ($myrow = $this->db->fetchArray($result)) { | |
449 | - $ret[] = $myrow['uid']; | |
437 | + $result = $db->query($sql, $limit, $start); | |
438 | + if (!$result) return $ret; | |
439 | + while (list($uid) = $db->fetchRow($result)) { | |
440 | + $ret[] = $uid; | |
450 | 441 | } |
451 | 442 | return $ret; |
452 | 443 | } |
@@ -459,8 +450,9 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
459 | 450 | $ret = array(); |
460 | 451 | |
461 | 452 | $groupid = (int)$groupid; |
462 | - $usersTable = $this->db->prefix('users'); | |
463 | - $linkTable = $this->db->prefix('groups_users_link'); | |
453 | + $db = &$this->db; | |
454 | + $usersTable = $db->prefix('users'); | |
455 | + $linkTable = $db->prefix('groups_users_link'); | |
464 | 456 | |
465 | 457 | $sql = "SELECT u.uid FROM ${usersTable} u LEFT JOIN ${linkTable} g ON u.uid=g.uid," . |
466 | 458 | "${usersTable} u2 LEFT JOIN ${linkTable} g2 ON u2.uid=g2.uid AND g2.groupid=${groupid} " . |
@@ -468,12 +460,10 @@ class XoopsMembershipHandler extends XoopsObjectHandler | ||
468 | 460 | "AND (g2.groupid = ${groupid} OR g2.groupid IS NULL) " . |
469 | 461 | "AND u.uid = u2.uid AND g2.uid IS NULL GROUP BY u.uid"; |
470 | 462 | |
471 | - $result = $this->db->query($sql, $limit, $start); | |
472 | - if (!$result) { | |
473 | - return $ret; | |
474 | - } | |
475 | - while ($myrow = $this->db->fetchArray($result)) { | |
476 | - $ret[] = $myrow['uid']; | |
463 | + $result = $db->query($sql, $limit, $start); | |
464 | + if (!$result) return $ret; | |
465 | + while (list($uid) = $db->fetchRow($result)) { | |
466 | + $ret[] = $uid; | |
477 | 467 | } |
478 | 468 | return $ret; |
479 | 469 | } |
@@ -165,12 +165,13 @@ class XoopsGroupPermHandler extends XoopsObjectHandler | ||
165 | 165 | { |
166 | 166 | $ret = false; |
167 | 167 | if ((int)$id > 0) { |
168 | - $sql = sprintf("SELECT * FROM %s WHERE gperm_id = %u", $this->db->prefix('group_permission'), $id); | |
169 | - if ($result = $this->db->query($sql)) { | |
170 | - $numrows = $this->db->getRowsNum($result); | |
168 | + $db = &$this->db; | |
169 | + $sql = sprintf('SELECT * FROM %s WHERE gperm_id = %u', $db->prefix('group_permission'), $id); | |
170 | + if ($result = $db->query($sql)) { | |
171 | + $numrows = $db->getRowsNum($result); | |
171 | 172 | if ( $numrows == 1 ) { |
172 | 173 | $perm =new XoopsGroupPerm(); |
173 | - $perm->assignVars($this->db->fetchArray($result)); | |
174 | + $perm->assignVars($db->fetchArray($result)); | |
174 | 175 | $ret =& $perm; |
175 | 176 | } |
176 | 177 | } |
@@ -200,18 +201,15 @@ class XoopsGroupPermHandler extends XoopsObjectHandler | ||
200 | 201 | foreach ($perm->cleanVars as $k => $v) { |
201 | 202 | ${$k} = $v; |
202 | 203 | } |
204 | + $db = &$this->db; | |
203 | 205 | if ($perm->isNew()) { |
204 | - $gperm_id = $this->db->genId('group_permission_gperm_id_seq'); | |
205 | - $sql = sprintf("INSERT INTO %s (gperm_id, gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, %u, %u, %s)", $this->db->prefix('group_permission'), $gperm_id, $gperm_groupid, $gperm_itemid, $gperm_modid, $this->db->quoteString($gperm_name)); | |
206 | + $gperm_id = $db->genId('group_permission_gperm_id_seq'); | |
207 | + $sql = sprintf('INSERT INTO %s (gperm_id, gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, %u, %u, %s)', $db->prefix('group_permission'), $gperm_id, $gperm_groupid, $gperm_itemid, $gperm_modid, $db->quoteString($gperm_name)); | |
206 | 208 | } else { |
207 | - $sql = sprintf("UPDATE %s SET gperm_groupid = %u, gperm_itemid = %u, gperm_modid = %u WHERE gperm_id = %u", $this->db->prefix('group_permission'), $gperm_groupid, $gperm_itemid, $gperm_modid, $gperm_id); | |
208 | - } | |
209 | - if (!$result = $this->db->query($sql)) { | |
210 | - return false; | |
211 | - } | |
212 | - if (empty($gperm_id)) { | |
213 | - $gperm_id = $this->db->getInsertId(); | |
209 | + $sql = sprintf('UPDATE %s SET gperm_groupid = %u, gperm_itemid = %u, gperm_modid = %u WHERE gperm_id = %u', $db->prefix('group_permission'), $gperm_groupid, $gperm_itemid, $gperm_modid, $gperm_id); | |
214 | 210 | } |
211 | + if (!$result = $db->query($sql)) return false; | |
212 | + if (empty($gperm_id)) $gperm_id = $this->db->getInsertId(); | |
215 | 213 | $perm->assignVar('gperm_id', $gperm_id); |
216 | 214 | return true; |
217 | 215 | } |
@@ -247,17 +245,18 @@ class XoopsGroupPermHandler extends XoopsObjectHandler | ||
247 | 245 | { |
248 | 246 | $ret = array(); |
249 | 247 | $limit = $start = 0; |
250 | - $sql = 'SELECT * FROM '.$this->db->prefix('group_permission'); | |
248 | + $db = &$this->db; | |
249 | + $sql = 'SELECT * FROM '.$db->prefix('group_permission'); | |
251 | 250 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
252 | 251 | $sql .= ' '.$criteria->renderWhere(); |
253 | 252 | $limit = $criteria->getLimit(); |
254 | 253 | $start = $criteria->getStart(); |
255 | 254 | } |
256 | - $result = $this->db->query($sql, $limit, $start); | |
255 | + $result = $db->query($sql, $limit, $start); | |
257 | 256 | if (!$result) { |
258 | 257 | return $ret; |
259 | 258 | } |
260 | - while ($myrow = $this->db->fetchArray($result)) { | |
259 | + while ($myrow = $db->fetchArray($result)) { | |
261 | 260 | $perm =new XoopsGroupPerm(); |
262 | 261 | $perm->assignVars($myrow); |
263 | 262 | if (!$id_as_key) { |
@@ -279,15 +278,16 @@ class XoopsGroupPermHandler extends XoopsObjectHandler | ||
279 | 278 | */ |
280 | 279 | function getCount($criteria = null) |
281 | 280 | { |
282 | - $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('group_permission'); | |
281 | + $db = &$this->db; | |
282 | + $sql = 'SELECT COUNT(*) FROM '.$db->prefix('group_permission'); | |
283 | 283 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
284 | 284 | $sql .= ' '.$criteria->renderWhere(); |
285 | 285 | } |
286 | - $result = $this->db->query($sql); | |
286 | + $result = $db->query($sql); | |
287 | 287 | if (!$result) { |
288 | 288 | return 0; |
289 | 289 | } |
290 | - list($count) = $this->db->fetchRow($result); | |
290 | + list($count) = $db->fetchRow($result); | |
291 | 291 | return $count; |
292 | 292 | } |
293 | 293 |
@@ -151,11 +151,10 @@ class XoopsUser extends XoopsObject | ||
151 | 151 | $member_handler =& xoops_gethandler('member'); |
152 | 152 | $user =& $member_handler->getUser($userid); |
153 | 153 | if (is_object($user)) { |
154 | - $ts =& MyTextSanitizer::getInstance(); | |
155 | 154 | if ( $usereal ) { |
156 | - return $ts->htmlSpecialChars($user->getVar('name')); | |
155 | + return $user->getVar('name'); | |
157 | 156 | } else { |
158 | - return $ts->htmlSpecialChars($user->getVar('uname')); | |
157 | + return $user->getVar('uname'); | |
159 | 158 | } |
160 | 159 | } |
161 | 160 | } |
@@ -270,7 +269,7 @@ class XoopsUser extends XoopsObject | ||
270 | 269 | { |
271 | 270 | if (!isset($this->_isOnline)) { |
272 | 271 | $onlinehandler =& xoops_gethandler('online'); |
273 | - $this->_isOnline = ($onlinehandler->getCount(new Criteria('online_uid', $this->getVar('uid'))) > 0) ? true : false; | |
272 | + $this->_isOnline = ($onlinehandler->getCount(new Criteria('online_uid', $this->getVar('uid', 'N'))) > 0) ? true : false; | |
274 | 273 | } |
275 | 274 | return $this->_isOnline; |
276 | 275 | } |
@@ -288,7 +287,7 @@ class XoopsUser extends XoopsObject | ||
288 | 287 | */ |
289 | 288 | function uid() |
290 | 289 | { |
291 | - return $this->getVar("uid"); | |
290 | + return $this->getVar('uid'); | |
292 | 291 | } |
293 | 292 | |
294 | 293 | /** |