From: <tr...@us...> - 2011-10-08 18:30:43
|
Revision: 7813 http://xoops.svn.sourceforge.net/xoops/?rev=7813&view=rev Author: trabis Date: 2011-10-08 18:30:34 +0000 (Sat, 08 Oct 2011) Log Message: ----------- More updated kernel classes Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/member.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/module.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/notification.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/online.php XoopsCore/branches/2.6.x/2.6.0/htdocs/misc.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/pm/class/message.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/blocksadmin/main.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/blocks/system_blocks.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/member.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/member.php 2011-10-08 13:56:08 UTC (rev 7812) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/member.php 2011-10-08 18:30:34 UTC (rev 7813) @@ -59,8 +59,10 @@ /** * Constructor + * + * @param XoopsDatabase|null $db */ - public function __construct($db) + public function __construct($db = null) { $this->_gHandler = new XoopsGroupHandler($db); $this->_uHandler = new XoopsUserHandler($db); @@ -383,10 +385,10 @@ * * @param string $fieldName name of the field to update * @param string $fieldValue updated value for the field - * @param object $criteria {@link CriteriaElement} object + * @param CriteriaElement|null $criteria {@link CriteriaElement} object * @return bool TRUE if success or unchanged, FALSE on failure */ - public function updateUsersByField($fieldName, $fieldValue, $criteria = null) + public function updateUsersByField($fieldName, $fieldValue, CriteriaElement $criteria = null) { return $this->_uHandler->updateAll($fieldName, $fieldValue, $criteria); } @@ -410,7 +412,7 @@ * Get a list of users belonging to certain groups and matching criteria * Temporary solution * - * @param int $groups IDs of groups + * @param array $groups IDs of groups * @param CriteriaElement|null $criteria {@link CriteriaElement} object * @param bool $asobject return the users as objects? * @param bool $id_as_key use the UID as key for the array if $asobject is TRUE @@ -463,7 +465,7 @@ * Get count of users belonging to certain groups and matching criteria * Temporary solution * - * @param int $groups IDs of groups + * @param array $groups IDs of groups * @param CriteriaElement|null $criteria * @return int count of users */ Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/module.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/module.php 2011-10-08 13:56:08 UTC (rev 7812) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/module.php 2011-10-08 18:30:34 UTC (rev 7813) @@ -26,25 +26,25 @@ class XoopsModule extends XoopsObject { /** - * * @var string */ - var $modinfo; + public $modinfo; + /** * * @var string */ - var $adminmenu; + public $adminmenu; /** * * @var array */ - var $_msg; + private $_msg; /** * Constructor */ - function __construct() + public function __construct() { $this->initVar('mid', XOBJ_DTYPE_INT, null, false); $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, true, 150); @@ -68,9 +68,9 @@ * @param string $dirname Directory Name * @param boolean $verbose */ - function loadInfoAsVar($dirname, $verbose = true) + public function loadInfoAsVar($dirname, $verbose = true) { - $dirname = basename($dirname); + $dirname = basename($dirname); if (!isset($this->modinfo)) { $this->loadInfo($dirname, $verbose); } @@ -99,7 +99,7 @@ * @param string $str message to add * @access public */ - function setMessage($str) + public function setMessage($str) { $this->_msg[] = trim($str); } @@ -110,7 +110,7 @@ * @return array an array of messages * @access public */ - function getMessages() + public function getMessages() { return $this->_msg; } @@ -122,7 +122,7 @@ * @param mix $value * @return bool **/ - function setInfo($name, $value) + public function setInfo($name, $value) { if (empty($name)) { $this->modinfo = $value; @@ -139,7 +139,7 @@ * @return array |string Array of module information. * If {@link $name} is set, returns a single module information item as string. */ - function getInfo($name = null) + public function getInfo($name = null) { if (!isset($this->modinfo)) { $this->loadInfo($this->getVar('dirname')); @@ -159,7 +159,7 @@ * * @return string FALSE on fail */ - function mainLink() + public function mainLink() { if ($this->getVar('hasmain') == 1) { $ret = '<a href="' . XOOPS_URL . '/modules/' . $this->getVar('dirname') . '/">' . $this->getVar('name') . '</a>'; @@ -173,7 +173,7 @@ * * @return string */ - function subLink() + public function subLink() { $ret = array(); if ($this->getInfo('sub') && is_array($this->getInfo('sub'))) { @@ -189,7 +189,7 @@ /** * Load the admin menu for the module */ - function loadAdminMenu() + public function loadAdminMenu() { if ($this->getInfo('adminmenu') && $this->getInfo('adminmenu') != '' && file_exists(XOOPS_ROOT_PATH . '/modules/' . $this->getVar('dirname') . '/' . $this->getInfo('adminmenu'))) { $adminmenu = array(); @@ -203,7 +203,7 @@ * * @return string */ - function getAdminMenu() + public function getAdminMenu() { if (!isset($this->adminmenu)) { $this->loadAdminMenu(); @@ -216,8 +216,9 @@ * * @param string $dirname Module directory * @param bool $verbose Give an error on fail? + * @return bool */ - function loadInfo($dirname, $verbose = true) + public function loadInfo($dirname, $verbose = true) { $dirname = basename($dirname); global $xoopsConfig; @@ -248,7 +249,7 @@ * @param integer $userid * @return mixed Search result. */ - function search($term = '', $andor = 'AND', $limit = 0, $offset = 0, $userid = 0) + public function search($term = '', $andor = 'AND', $limit = 0, $offset = 0, $userid = 0) { if ($this->getVar('hassearch') != 1) { return false; @@ -263,125 +264,143 @@ return false; } if (function_exists($search['func'])) { - $func = $search['func']; + $func = (string)$search['func']; return $func($term, $andor, $limit, $offset, $userid); } return false; } /** - * Returns Class Base Variable mid + * @param string $format + * @return mixed */ - function id($format = 'N') + public function id($format = 'n') { return $this->getVar('mid', $format); } /** - * Returns Class Base Variable mid + * @param string $format + * @return mixed */ - function mid($format = '') + public function mid($format = '') { return $this->getVar('mid', $format); } /** - * Returns Class Base Variable name + * @param string $format + * @return mixed */ - function name($format = '') + public function name($format = '') { return $this->getVar('name', $format); } /** - * Returns Class Base Variable version + * @param string $format + * @return mixed */ - function version($format = '') + public function version($format = '') { return $this->getVar('version', $format); } /** - * Returns Class Base Variable last_update + * @param string $format + * @return mixed */ - function last_update($format = '') + public function last_update($format = '') { return $this->getVar('last_update', $format); } /** - * Returns Class Base Variable weight + * @param string $format + * @return mixed */ - function weight($format = '') + public function weight($format = '') { return $this->getVar('weight', $format); } /** - * Returns Class Base Variable isactive + * @param string $format + * @return mixed */ - function isactive($format = '') + public function isactive($format = '') { return $this->getVar('isactive', $format); } /** - * Returns Class Base Variable dirname + * @param string $format + * @return mixed */ - function dirname($format = '') + public function dirname($format = '') { return $this->getVar('dirname', $format); } /** - * Returns Class Base Variable hasmain + * @param string $format + * @return mixed */ - function hasmain($format = '') + public function hasmain($format = '') { return $this->getVar('hasmain', $format); } /** - * Returns Class Base Variable hasadmin + * @param string $format + * @return mixed */ - function hasadmin($format = '') + public function hasadmin($format = '') { return $this->getVar('hasadmin', $format); } /** - * Returns Class Base Variable hassearch + * @param string $format + * @return mixed */ - function hassearch($format = '') + public function hassearch($format = '') { return $this->getVar('hassearch', $format); } /** - * Returns Class Base Variable hasconfig + * @param string $format + * @return mixed */ - function hasconfig($format = '') + public function hasconfig($format = '') { return $this->getVar('hasconfig', $format); } /** - * Returns Class Base Variable hascomments + * @param string $format + * @return mixed */ - function hascomments($format = '') + public function hascomments($format = '') { return $this->getVar('hascomments', $format); } /** - * Returns Class Base Variable hasnotification + * @param string $format + * @return mixed */ - function hasnotification($format = '') + public function hasnotification($format = '') { return $this->getVar('hasnotification', $format); } - function getByDirName($dirname) + /** + * @param $dirname + * @return XoopsModule + */ + public function getByDirName($dirname) { $modhandler = xoops_gethandler('module'); $inst = $modhandler->getByDirname($dirname); @@ -399,7 +418,7 @@ * @author Kazumi Ono <on...@xo...> * @copyright (c) 2000-2003 The Xoops Project - www.xoops.org */ -class XoopsModuleHandler extends XoopsObjectHandler +class XoopsModuleHandler extends XoopsPersistableObjectHandler { /** * holds an array of cached module references, indexed by module id @@ -407,7 +426,7 @@ * @var array * @access private */ - var $_cachedModule_mid = array(); + private $_cachedModule_mid = array(); /** * holds an array of cached module references, indexed by module dirname @@ -415,55 +434,43 @@ * @var array * @access private */ - var $_cachedModule_dirname = array(); + private $_cachedModule_dirname = array(); /** - * Create a new {@link XoopsModule} object + * Constructor * - * @param boolean $isNew Flag the new object as "new" - * @return object + * @param XoopsDatabase|null $db {@link XoopsDatabase} */ - function create($isNew = true) + public function __construct(XoopsDatabase $db = null) { - $module = new XoopsModule(); - if ($isNew) { - $module->setNew(); - } - return $module; + parent::__construct($db, 'modules', 'XoopsModule', 'mid', 'dirname'); } /** * Load a module from the database * * @param int $id ID of the module - * @return object FALSE on fail + * @return XoopsModule|false on fail */ function get($id) { static $_cachedModule_dirname; static $_cachedModule_mid; $id = intval($id); - $module = false; if ($id > 0) { if (!empty($_cachedModule_mid[$id])) { return $_cachedModule_mid[$id]; } else { - $sql = 'SELECT * FROM ' . $this->db->prefix('modules') . ' WHERE mid = ' . $id; - if (!$result = $this->db->query($sql)) { - return $module; + $module = parent::get($id); + if (!is_object($module)) { + return false; } - $numrows = $this->db->getRowsNum($result); - if ($numrows == 1) { - $module = new XoopsModule(); - $myrow = $this->db->fetchArray($result); - $module->assignVars($myrow); - $_cachedModule_mid[$id] = &$module; - $_cachedModule_dirname[$module->getVar('dirname')] = &$module; - return $module; - } + $_cachedModule_mid[$id] = $module; + $_cachedModule_dirname[$module->getVar('dirname')] = $module; + return $module; } } - return $module; + return false; } /** @@ -472,31 +479,24 @@ * @param string $dirname * @return object FALSE on fail */ - function getByDirname($dirname) + public function getByDirname($dirname) { - $dirname = basename($dirname); - //could not we check for spaces instead?? - if (strpos(strtolower($dirname), ' union ')) { - return false; - } + $dirname = basename(trim($dirname)); static $_cachedModule_mid; static $_cachedModule_dirname; if (!empty($_cachedModule_dirname[$dirname])) { return $_cachedModule_dirname[$dirname]; } else { - $module = false; - $sql = "SELECT * FROM " . $this->db->prefix('modules') . " WHERE dirname = '" . trim($dirname) . "'"; - if (!$result = $this->db->query($sql)) { - return $module; + $myts = MyTextSanitizer::getInstance(); + $criteria = new Criteria('dirname', $myts->addSlashes($dirname)); + $modules = $this->getObjects($criteria); + if (count($modules) == 1 && is_object($modules[0])) { + $module = $modules[0]; + } else { + return false; } - $numrows = $this->db->getRowsNum($result); - if ($numrows == 1) { - $module = new XoopsModule(); - $myrow = $this->db->fetchArray($result); - $module->assignVars($myrow); - $_cachedModule_dirname[$dirname] = $module; - $_cachedModule_mid[$module->getVar('mid')] = $module; - } + $_cachedModule_dirname[$dirname] = $module; + $_cachedModule_mid[$module->getVar('mid')] = $module; return $module; } } @@ -504,40 +504,18 @@ /** * Write a module to the database * - * @param object $ &$module reference to a {@link XoopsModule} + * @param XoopsModule &$module reference to a {@link XoopsModule} * @return bool */ - function insert(&$module) + public function insert(XoopsModule &$module) { - /** - * - * @TODO : Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($module, 'xoopsmodule')) { + if (!parent::insert($module)) { return false; } - if (!$module->isDirty()) { - return true; - } - if (!$module->cleanVars()) { - return false; - } - foreach ($module->cleanVars as $k => $v) { - ${$k} = $v; - } - if ($module->isNew()) { - $mid = $this->db->genId('modules_mid_seq'); - $sql = sprintf("INSERT INTO %s (mid, name, version, last_update, weight, isactive, dirname, hasmain, hasadmin, hassearch, hasconfig, hascomments, hasnotification) VALUES (%u, %s, %u, %u, %u, %u, %s, %u, %u, %u, %u, %u, %u)", $this->db->prefix('modules'), $mid, $this->db->quoteString($name), $version, time(), $weight, 1, $this->db->quoteString($dirname), $hasmain, $hasadmin, $hassearch, $hasconfig, $hascomments, $hasnotification); - } else { - $sql = sprintf("UPDATE %s SET name = %s, dirname = %s, version = %u, last_update = %u, weight = %u, isactive = %u, hasmain = %u, hasadmin = %u, hassearch = %u, hasconfig = %u, hascomments = %u, hasnotification = %u WHERE mid = %u", $this->db->prefix('modules'), $this->db->quoteString($name), $this->db->quoteString($dirname), $version, time(), $weight, $isactive, $hasmain, $hasadmin, $hassearch, $hasconfig, $hascomments, $hasnotification, $mid); - } - if (!$result = $this->db->query($sql)) { - return false; - } - if (empty($mid)) { - $mid = $this->db->getInsertId(); - } - $module->assignVar('mid', $mid); + + $dirname = $module->getvar('dirname'); + $mid = $module->getvar('mid'); + if (!empty($this->_cachedModule_dirname[$dirname])) { unset($this->_cachedModule_dirname[$dirname]); } @@ -550,22 +528,15 @@ /** * Delete a module from the database * - * @param object $ &$module + * @param XoopsModule &$module * @return bool */ - function delete(&$module) + public function delete(XoopsModule &$module) { - /** - * - * @TODO : Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($module, 'xoopsmodule')) { + if (!parent::delete($module)) { return false; } - $sql = sprintf("DELETE FROM %s WHERE mid = %u", $this->db->prefix('modules'), $module->getVar('mid')); - if (!$result = $this->db->query($sql)) { - return false; - } + // delete admin permissions assigned for this module $sql = sprintf("DELETE FROM %s WHERE gperm_name = 'module_admin' AND gperm_itemid = %u", $this->db->prefix('group_permission'), $module->getVar('mid')); $this->db->query($sql); @@ -612,11 +583,11 @@ /** * Load some modules * - * @param object $criteria {@link CriteriaElement} + * @param CriteriaElement|null $criteria {@link CriteriaElement} * @param boolean $id_as_key Use the ID as key into the array * @return array */ - function getObjects($criteria = null, $id_as_key = false) + public function getObjects(CriteriaElement $criteria = null, $id_as_key = false) { $ret = array(); $limit = $start = 0; @@ -645,35 +616,17 @@ } /** - * Count some modules - * - * @param object $criteria {@link CriteriaElement} - * @return int - */ - function getCount($criteria = null) - { - $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('modules'); - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { - $sql .= ' ' . $criteria->renderWhere(); - } - if (!$result = $this->db->query($sql)) { - return 0; - } - list ($count) = $this->db->fetchRow($result); - return $count; - } - - /** * returns an array of module names * - * @param bool $criteria + * @param CriteriaElement|null $criteria * @param boolean $dirname_as_key if true, array keys will be module directory names * if false, array keys will be module id * @return array */ - function getList($criteria = null, $dirname_as_key = false) + function getList(CriteriaElement $criteria = null, $dirname_as_key = false) { $ret = array(); + //TODO we could use getAll to save memory(trabis) $modules = $this->getObjects($criteria, true); foreach (array_keys($modules) as $i) { if (!$dirname_as_key) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/notification.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/notification.php 2011-10-08 13:56:08 UTC (rev 7812) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/notification.php 2011-10-08 18:30:34 UTC (rev 7813) @@ -29,17 +29,16 @@ * @package kernel * @subpackage notification * - * @author Michael van Dam <mv...@ca...> - * @copyright copyright (c) 2000-2003 XOOPS.org + * @author Michael van Dam <mv...@ca...> + * @copyright copyright (c) 2000-2003 XOOPS.org */ class XoopsNotification extends XoopsObject { /** * Constructor **/ - function XoopsNotification() + public function __construct() { - $this->XoopsObject(); $this->initVar('not_id', XOBJ_DTYPE_INT, NULL, false); $this->initVar('not_modid', XOBJ_DTYPE_INT, NULL, false); $this->initVar('not_category', XOBJ_DTYPE_TXTBOX, null, false, 30); @@ -58,65 +57,73 @@ /** - * Returns Class Base Variable not_id + * @param string $format + * @return mixed */ - function id($format = 'N') + public function id($format = 'n') { return $this->getVar('not_id', $format); } /** - * Returns Class Base Variable not_id + * @param string $format + * @return mixed */ - function not_id($format = '') + public function not_id($format = '') { return $this->getVar('not_id', $format); } /** - * Returns Class Base Variable not_modid + * @param string $format + * @return mixed */ - function not_modid($format = '') + public function not_modid($format = '') { return $this->getVar('not_modid', $format); } /** - * Returns Class Base Variable mid + * @param string $format + * @return mixed */ - function not_category($format = '') + public function not_category($format = '') { return $this->getVar('not_category', $format); } /** - * Returns Class Base Variable not_itemid + * @param string $format + * @return mixed */ - function not_itemid($format = '') + public function not_itemid($format = '') { return $this->getVar('not_itemid', $format); } /** - * Returns Class Base Variable not_event + * @param string $format + * @return mixed */ - function not_event($format = '') + public function not_event($format = '') { return $this->getVar('not_event', $format); } /** - * Returns Class Base Variable not_uid + * @param string $format + * @return mixed */ - function not_uid($format = '') + public function not_uid($format = '') { return $this->getVar('not_uid', $format); } /** - * Returns Class Base Variable not_mode + * @param string $format + * @return mixed */ - function not_mode($format = '') + public function not_mode($format = '') { return $this->getVar('not_mode', $format); } @@ -129,11 +136,16 @@ * @param string $subject Subject line for notification message * @param array $tags Array of substitutions for template variables * - * @return bool true if success, false if error + * @return bool true if success, false if error **/ - function notifyUser($template_dir, $template, $subject, $tags) + public function notifyUser($template_dir, $template, $subject, $tags) { - // Check the user's notification preference. + /** + * @var $member_handler XoopsMemberHandler + * @var $config_handler XoopsConfigHandler + */ + + // Check the user's notification preference. $member_handler = xoops_gethandler('member'); $user = $member_handler->getUser($this->getVar('not_uid')); if (!is_object($user)) { @@ -144,24 +156,24 @@ $xoopsMailer = xoops_getMailer(); include_once $GLOBALS['xoops']->path('include/notification_constants.php'); switch ($method) { - case XOOPS_NOTIFICATION_METHOD_PM: - $xoopsMailer->usePM(); - $config_handler = xoops_gethandler('config'); - $xoopsMailerConfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER); - $xoopsMailer->setFromUser($member_handler->getUser($xoopsMailerConfig['fromuid'])); - foreach ($tags as $k => $v) { - $xoopsMailer->assign($k, $v); - } - break; - case XOOPS_NOTIFICATION_METHOD_EMAIL: - $xoopsMailer->useMail(); - foreach ($tags as $k => $v) { - $xoopsMailer->assign($k, preg_replace("/&/i", '&', $v)); - } - break; - default: - return true; // report error in user's profile?? - break; + case XOOPS_NOTIFICATION_METHOD_PM: + $xoopsMailer->usePM(); + $config_handler = xoops_gethandler('config'); + $xoopsMailerConfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER); + $xoopsMailer->setFromUser($member_handler->getUser($xoopsMailerConfig['fromuid'])); + foreach ($tags as $k => $v) { + $xoopsMailer->assign($k, $v); + } + break; + case XOOPS_NOTIFICATION_METHOD_EMAIL: + $xoopsMailer->useMail(); + foreach ($tags as $k => $v) { + $xoopsMailer->assign($k, preg_replace("/&/i", '&', $v)); + } + break; + default: + return true; // report error in user's profile?? + break; } // Set up the mailer @@ -204,124 +216,29 @@ * @package kernel * @subpackage notification * - * @author Michael van Dam <mv...@ca...> - * @copyright copyright (c) 2000-2003 XOOPS.org + * @author Michael van Dam <mv...@ca...> + * @copyright copyright (c) 2000-2003 XOOPS.org */ -class XoopsNotificationHandler extends XoopsObjectHandler +class XoopsNotificationHandler extends XoopsPersistableObjectHandler { /** - * Create a {@link XoopsNotification} + * Constructor * - * @param bool $isNew Flag the object as "new"? - * - * @return object + * @param XoopsDatabase|null $db {@link XoopsDatabase} */ - function create($isNew = true) + public function __construct(XoopsDatabase $db = null) { - $notification = new XoopsNotification(); - if ($isNew) { - $notification->setNew(); - } - return $notification; + parent::__construct($db, 'xoopsnotifications', 'XoopsNotification', 'not_id', 'not_itemid'); } /** - * Retrieve a {@link XoopsNotification} - * - * @param int $id ID - * - * @return object {@link XoopsNotification}, FALSE on fail - **/ - function get($id) - { - $notification = false; - $id = intval($id); - if ($id > 0) { - $sql = 'SELECT * FROM ' . $this->db->prefix('xoopsnotifications') . ' WHERE not_id=' . $id; - if (!$result = $this->db->query($sql)) { - return $notification; - } - $numrows = $this->db->getRowsNum($result); - if ($numrows == 1) { - $notification = new XoopsNotification(); - $notification->assignVars($this->db->fetchArray($result)); - } - } - return $notification; - } - - /** - * Write a notification(subscription) to database - * - * @param object &$notification - * - * @return bool - **/ - function insert(&$notification) - { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($notification, 'xoopsnotification')) { - return false; - } - if (!$notification->isDirty()) { - return true; - } - if (!$notification->cleanVars()) { - return false; - } - foreach ($notification->cleanVars as $k => $v) { - ${$k} = $v; - } - if ($notification->isNew()) { - $not_id = $this->db->genId('xoopsnotifications_not_id_seq'); - $sql = sprintf("INSERT INTO %s (not_id, not_modid, not_itemid, not_category, not_uid, not_event, not_mode) VALUES (%u, %u, %u, %s, %u, %s, %u)", $this->db->prefix('xoopsnotifications'), $not_id, $not_modid, $not_itemid, $this->db->quoteString($not_category), $not_uid, $this->db->quoteString($not_event), $not_mode); - } else { - $sql = sprintf("UPDATE %s SET not_modid = %u, not_itemid = %u, not_category = %s, not_uid = %u, not_event = %s, not_mode = %u WHERE not_id = %u", $this->db->prefix('xoopsnotifications'), $not_modid, $not_itemid, $this->db->quoteString($not_category), $not_uid, $this->db->quoteString($not_event), $not_mode, $not_id); - } - if (!$result = $this->db->query($sql)) { - return false; - } - if (empty($not_id)) { - $not_id = $this->db->getInsertId(); - } - $notification->assignVar('not_id', $not_id); - return true; - } - - /** - * Delete a {@link XoopsNotification} from the database - * - * @param object &$notification - * - * @return bool - **/ - function delete(&$notification) - { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($notification, 'xoopsnotification')) { - return false; - } - - $sql = sprintf("DELETE FROM %s WHERE not_id = %u", $this->db->prefix('xoopsnotifications'), $notification->getVar('not_id')); - if (!$result = $this->db->query($sql)) { - return false; - } - return true; - } - - /** * Get some {@link XoopsNotification}s * - * @param object $criteria + * @param CriteriaElement|null $criteria * @param bool $id_as_key Use IDs as keys into the array? - * * @return array Array of {@link XoopsNotification} objects - **/ - function getObjects($criteria = null, $id_as_key = false) + */ + public function getObjects(CriteriaElement $criteria = null, $id_as_key = false) { $ret = array(); $limit = $start = 0; @@ -350,50 +267,19 @@ return $ret; } - // TODO: Need this?? /** - * Count Notifications + * @todo rename this + * Also, should we have get by module, get by category, etc...?? * - * @param object $criteria {@link CriteriaElement} - * - * @return int Count - **/ - function getCount($criteria = null) + * @param int $module_id + * @param string $category + * @param int $item_id + * @param string $event + * @param int $user_id + * @return array|bool + */ + public function getNotification($module_id, $category, $item_id, $event, $user_id) { - $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('xoopsnotifications'); - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { - $sql .= ' ' . $criteria->renderWhere(); - } - if (!$result = $this->db->query($sql)) { - return 0; - } - list ($count) = $this->db->fetchRow($result); - return $count; - } - - /** - * Delete multiple notifications - * - * @param object $criteria {@link CriteriaElement} - * - * @return bool - **/ - function deleteAll($criteria = null) - { - $sql = 'DELETE FROM ' . $this->db->prefix('xoopsnotifications'); - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { - $sql .= ' ' . $criteria->renderWhere(); - } - if (!$result = $this->db->query($sql)) { - return false; - } - return true; - } - - // TODO: rename this... - // Also, should we have get by module, get by category, etc...?? - function getNotification($module_id, $category, $item_id, $event, $user_id) - { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('not_modid', intval($module_id))); $criteria->add(new Criteria('not_category', mysql_real_escape_string($category))); @@ -417,9 +303,9 @@ * @param string $event Event * @param int $module_id ID of module (default current module) * @param int $user_id ID of user (default current user) - * return int 0 if not subscribe; non-zero if subscribed + * @return int 0 if not subscribe; non-zero if subscribed */ - function isSubscribed($category, $item_id, $event, $module_id, $user_id) + public function isSubscribed($category, $item_id, $event, $module_id, $user_id) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('not_modid', intval($module_id))); @@ -431,12 +317,13 @@ } - // TODO: how about a function to subscribe a whole group of users??? - // e.g. if we want to add all moderators to be notified of subscription - // of new threads... /** * Subscribe for notification for an event(s) * + * @todo: how about a function to subscribe a whole group of users??? + * e.g. if we want to add all moderators to be notified of subscription + * of new threads... + * * @param string $category category of notification * @param int $item_id ID of the item * @param mixed $events event string or array of events @@ -444,8 +331,9 @@ * (e.g. once_only) (default to current user preference) * @param int $module_id ID of the module (default to current module) * @param int $user_id ID of the user (default to current user) - **/ - function subscribe($category, $item_id, $events, $mode = null, $module_id = null, $user_id = null) + * @return bool + */ + public function subscribe($category, $item_id, $events, $mode = null, $module_id = null, $user_id = null) { if (!isset($user_id)) { global $xoopsUser; @@ -485,31 +373,39 @@ $this->insert($notification); } } + return true; } - // TODO: this will be to provide a list of everything a particular - // user has subscribed to... e.g. for on the 'Profile' page, similar - // to how we see the various posts etc. that the user has made. - // We may also want to have a function where we can specify module id + /** * Get a list of notifications by user ID * - * @param int $user_id ID of the user + * @todo this will be to provide a list of everything a particular + * user has subscribed to... e.g. for on the 'Profile' page, similar + * to how we see the various posts etc. that the user has made. + * We may also want to have a function where we can specify module id * + * @param int $user_id ID of the user * @return array Array of {@link XoopsNotification} objects **/ - function getByUser($user_id) + public function getByUser($user_id) { $criteria = new Criteria('not_uid', $user_id); return $this->getObjects($criteria, true); } - // TODO: rename this?? /** * Get a list of notification events for the current item/mod/user * - **/ - function getSubscribedEvents($category, $item_id, $module_id, $user_id) + * @todo rename this? + * + * @param string $category + * @param int $item_id + * @param int $module_id + * @param int $user_id + * @return array + */ + public function getSubscribedEvents($category, $item_id, $module_id, $user_id) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('not_modid', intval($module_id))); @@ -526,17 +422,18 @@ return $ret; } - // TODO: is this a useful function?? (Copied from comment_handler) /** * Retrieve items by their ID * + * @todo is this a useful function?? (Copied from comment_handler) + * * @param int $module_id Module ID * @param int $item_id Item ID * @param string $order Sort order - * + * @param int $status * @return array Array of {@link XoopsNotification} objects - **/ - function getByItemId($module_id, $item_id, $order = null, $status = null) + */ + public function getByItemId($module_id, $item_id, $order = null, $status = null) { $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); $criteria->add(new Criteria('com_itemid', intval($item_id))); @@ -552,22 +449,23 @@ /** * Send notifications to users * + * @todo(?) - pass in an event LIST. This will help to avoid + * problem of sending people multiple emails for similar events. + * BUT, then we need an array of mail templates, etc... Unless + * mail templates can include logic in the future, then we can + * tailor the mail so it makes sense for any of the possible + * (or combination of) events. + * * @param string $category notification category * @param int $item_id ID of the item - * @param string $event notification event + * @param string $events notification event * @param array $extra_tags array of substitutions for template to be * merged with the one from function.. * @param array $user_list only notify the selected users * @param int $module_id ID of the module * @param int $omit_user_id ID of the user to omit from notifications. (default to current user). set to 0 for all users to receive notification. - **/ - // TODO:(?) - pass in an event LIST. This will help to avoid - // problem of sending people multiple emails for similar events. - // BUT, then we need an array of mail templates, etc... Unless - // mail templates can include logic in the future, then we can - // tailor the mail so it makes sense for any of the possible - // (or combination of) events. - function triggerEvents($category, $item_id, $events, $extra_tags = array(), $user_list = array(), $module_id = null, $omit_user_id = null) + */ + public function triggerEvents($category, $item_id, $events, $extra_tags = array(), $user_list = array(), $module_id = null, $omit_user_id = null) { if (!is_array($events)) { $events = array($events); @@ -578,8 +476,6 @@ } /** - * Enter description here... - * * @param int $category * @param int $item_id * @param int $event @@ -587,15 +483,18 @@ * @param array $user_list * @param int $module_id * @param int $omit_user_id - * @return unknown + * @return bool */ - function triggerEvent($category, $item_id, $event, $extra_tags = array(), $user_list = array(), $module_id = null, $omit_user_id = null) + public function triggerEvent($category, $item_id, $event, $extra_tags = array(), $user_list = array(), $module_id = null, $omit_user_id = null) { + /** + * @var $config_handler XoopsConfigHandler + */ if (!isset($module_id)) { global $xoopsModule; $module = $xoopsModule; - $module_id =! empty($xoopsModule) ? $xoopsModule->getVar('mid') : 0; + $module_id = !empty($xoopsModule) ? $xoopsModule->getVar('mid') : 0; } else { $module_handler = xoops_gethandler('module'); $module = $module_handler->get($module_id); @@ -640,7 +539,7 @@ } $notifications = $this->getObjects($criteria); if (empty($notifications)) { - return; + return false; } // Add some tag substitutions here @@ -653,7 +552,7 @@ if (file_exists($tags_file)) { include_once $tags_file; if (!empty($not_config['tags_func'])) { - $tags_func = $not_config['tags_func']; + $tags_func = (string)$not_config['tags_func']; if (function_exists($tags_func)) { $tags = $tags_func($category, intval($item_id), $event); } @@ -661,12 +560,12 @@ } } // RMV-NEW - if (! empty($not_config['lookup_file'])) { + if (!empty($not_config['lookup_file'])) { $lookup_file = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname') . '/' . $not_config['lookup_file']); if (file_exists($lookup_file)) { include_once $lookup_file; if (!empty($not_config['lookup_func'])) { - $lookup_func = $not_config['lookup_func']; + $lookup_func = (string)$not_config['lookup_func']; if (function_exists($lookup_func)) { $item_info = $lookup_func($category, intval($item_id)); } @@ -674,9 +573,10 @@ } } } - $tags['X_ITEM_NAME'] = ! empty($item_info['name']) ? $item_info['name'] : '[' . _NOT_ITEMNAMENOTAVAILABLE . ']'; - $tags['X_ITEM_URL'] = ! empty($item_info['url']) ? $item_info['url'] : '[' . _NOT_ITEMURLNOTAVAILABLE . ']'; - $tags['X_ITEM_TYPE'] = ! empty($category_info['item_name']) ? $category_info['title'] : '[' . _NOT_ITEMTYPENOTAVAILABLE . ']'; + $tags['X_ITEM_NAME'] = !empty($item_info['name']) ? $item_info['name'] : '[' . _NOT_ITEMNAMENOTAVAILABLE . ']'; + $tags['X_ITEM_URL'] = !empty($item_info['url']) ? $item_info['url'] : '[' . _NOT_ITEMURLNOTAVAILABLE . ']'; + $tags['X_ITEM_TYPE'] = !empty($category_info['item_name']) ? $category_info['title'] + : '[' . _NOT_ITEMTYPENOTAVAILABLE . ']'; $tags['X_MODULE'] = $module->getVar('name'); $tags['X_MODULE_URL'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/'; $tags['X_NOTIFY_CATEGORY'] = $category; @@ -687,6 +587,7 @@ $subject = $event_info['mail_subject']; foreach ($notifications as $notification) { + /* @var $notification XoopsNotification */ if (empty($omit_user_id) || $notification->getVar('not_uid') != $omit_user_id) { // user-specific tags //$tags['X_UNSUBSCRIBE_URL'] = 'TODO'; @@ -696,6 +597,7 @@ $notification->notifyUser($template_dir, $template, $subject, $tags); } } + return true; } /** @@ -704,16 +606,17 @@ * @param int $user_id ID of the user * @return bool **/ - function unsubscribeByUser($user_id) + public function unsubscribeByUser($user_id) { $criteria = new Criteria('not_uid', intval($user_id)); return $this->deleteAll($criteria); } - // TODO: allow these to use current module, etc... /** * Unsubscribe notifications for an event(s). * + * @todo allow these to use current module, etc... + * * @param string $category category of the events * @param int $item_id ID of the item * @param mixed $events event string or array of events @@ -721,8 +624,8 @@ * @param int $user_id UID of the user (default current user) * * @return bool - **/ - function unsubscribe($category, $item_id, $events, $module_id = null, $user_id = null) + */ + public function unsubscribe($category, $item_id, $events, $module_id = null, $user_id = null) { if (!isset($user_id)) { global $xoopsUser; @@ -752,16 +655,15 @@ return $this->deleteAll($criteria); } - // TODO: When 'update' a module, may need to switch around some - // notification classes/IDs... or delete the ones that no longer - // exist. /** * Delete all notifications for a particular module * + * @todo When 'update' a module, may need to switch around some + * * @param int $module_id ID of the module * @return bool **/ - function unsubscribeByModule($module_id) + public function unsubscribeByModule($module_id) { $criteria = new Criteria('not_modid', intval($module_id)); return $this->deleteAll($criteria); @@ -776,7 +678,7 @@ * * @return bool **/ - function unsubscribeByItem($module_id, $category, $item_id) + public function unsubscribeByItem($module_id, $category, $item_id) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('not_modid', intval($module_id))); @@ -793,7 +695,7 @@ * * @param int $user_id ID of the user being logged in **/ - function doLoginMaintenance($user_id) + public function doLoginMaintenance($user_id) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('not_uid', intval($user_id))); @@ -801,6 +703,7 @@ $notifications = $this->getObjects($criteria, true); foreach ($notifications as $n) { + /* @var $n XoopsNotification*/ $n->setVar('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT); $this->insert($n); } @@ -809,13 +712,13 @@ /** * Update * - * @param object &$notification {@link XoopsNotification} object + * @param XoopsNotification &$notification {@link XoopsNotification} object * @param string $field_name Name of the field * @param mixed $field_value Value to write * * @return bool **/ - function updateByField(&$notification, $field_name, $field_value) + public function updateByField(XoopsNotification &$notification, $field_name, $field_value) { $notification->unsetNew(); $notification->setVar($field_name, $field_value); @@ -823,4 +726,5 @@ } } + ?> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php 2011-10-08 13:56:08 UTC (rev 7812) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php 2011-10-08 18:30:34 UTC (rev 7813) @@ -292,7 +292,9 @@ if (isset($this->vars[$key])) { if (is_object($this->vars[$key]) && is_a($this->vars[$key], 'XoopsObject')) { if ($maxDepth) { - $vars[$key] = $this->vars[$key]->getValues(null, $format, $maxDepth - 1); + /* @var $obj XoopsObject */ + $obj = $this->vars[$key]; + $vars[$key] = $obj->getValues(null, $format, $maxDepth - 1); } } else { $vars[$key] = $this->getVar($key, $format); @@ -637,6 +639,7 @@ */ public function xoopsClone() { + /* @var $clone XoopsObject */ $class = get_class($this); $clone = null; $clone = new $class(); @@ -719,7 +722,7 @@ /** * called from child classes only * - * @param object $db reference to the {@link XoopsDatabase} object + * @param XoopsDatabase $db reference to the {@link XoopsDatabase} object * @access protected */ function __construct($db) @@ -945,6 +948,7 @@ */ function create($isNew = true) { + /* @var $obj XoopsObject */ $obj = new $this->className(); if ($isNew === true) { $obj->setNew(); @@ -1006,6 +1010,7 @@ */ function insert(XoopsObject $object, $force = true) { + /* @var $handler XoopsModelWrite */ $handler = $this->loadHandler('write'); return $handler->insert($object, $force); } @@ -1019,6 +1024,7 @@ */ function delete(XoopsObject $object, $force = false) { + /* @var $handler XoopsModelWrite */ $handler = $this->loadHandler('write'); return $handler->delete($object, $force); } @@ -1033,6 +1039,7 @@ */ function deleteAll(CriteriaElement $criteria = null, $force = true, $asObject = false) { + /* @var $handler XoopsModelWrite */ $handler = $this->loadHandler('write'); return $handler->deleteAll($criteria, $force, $asObject); } @@ -1048,6 +1055,7 @@ */ function updateAll($fieldname, $fieldvalue, CriteriaElement $criteria = null, $force = false) { + /* @var $handler XoopsModelWrite */ $handler = $this->loadHandler('write'); return $handler->updateAll($fieldname, $fieldvalue, $criteria, $force); } @@ -1071,6 +1079,7 @@ */ function getObjects(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true) { + /* @var $handler XoopsModelRead */ $handler = $this->loadHandler('read'); $ret = $handler->getObjects($criteria, $id_as_key, $as_object); return $ret; @@ -1087,6 +1096,7 @@ */ function getAll(CriteriaElement $criteria = null, $fields = null, $asObject = true, $id_as_key = true) { + /* @var $handler XoopsModelRead */ $handler = $this->loadHandler('read'); $ret = $handler->getAll($criteria, $fields, $asObject, $id_as_key); return $ret; @@ -1102,6 +1112,7 @@ */ function getList(CriteriaElement $criteria = null, $limit = 0, $start = 0) { + /* @var $handler XoopsModelRead */ $handler = $this->loadHandler('read'); $ret = $handler->getList($criteria, $limit, $start); return $ret; @@ -1115,31 +1126,13 @@ */ function getIds(CriteriaElement $criteria = null) { + /* @var $handler XoopsModelRead */ $handler = $this->loadHandler('read'); $ret = $handler->getIds($criteria); return $ret; } /** - * get a limited list of objects matching a condition - * - * {@link CriteriaCompo} - * - * @param int $limit Max number of objects to fetch - * @param int $start Which record to start at - * @param CriteriaElement|null $criteria {@link CriteriaElement} to match - * @param array $fields variables to fetch - * @param bool $asObject flag indicating as object, otherwise as array - * @return array of objects {@link XoopsObject} - */ - function getByLimit($limit = 0, $start = 0, CriteriaElement $criteria = null, $fields = null, $asObject = true) - { - $handler = $this->loadHandler('read'); - $ret = $handler->getByLimit($limit, $start, $criteria, $fields, $asObject); - return $ret; - } - - /** * *#@- */ @@ -1155,6 +1148,7 @@ */ function getCount(CriteriaElement $criteria = null) { + /* @var $handler XoopsModelStats */ $handler = $this->loadHandler('stats'); return $handler->getCount($criteria); } @@ -1167,6 +1161,7 @@ */ function getCounts(CriteriaElement $criteria = null) { + /* @var $handler XoopsModelStats*/ $handler = $this->loadHandler('stats'); return $handler->getCounts($criteria); } @@ -1191,6 +1186,7 @@ */ function getByLink(CriteriaElement $criteria = null, $fields = null, $asObject = true, $field_link = null, $field_object = null) { + /* @var $handler XoopsModelJoint */ $handler = $this->loadHandler('joint'); $ret = $handler->getByLink($criteria, $fields, $asObject, $field_link, $field_object); return $ret; @@ -1204,6 +1200,7 @@ */ function getCountByLink(CriteriaElement $criteria = null) { + /* @var $handler XoopsModelJoint */ $handler = $this->loadHandler('joint'); $ret = $handler->getCountByLink($criteria); return $ret; @@ -1217,6 +1214,7 @@ */ function getCountsByLink(CriteriaElement $criteria = null) { + /* @var $handler XoopsModelJoint */ $handler = $this->loadHandler('joint'); $ret = $handler->getCountsByLink($criteria); return $ret; @@ -1231,6 +1229,7 @@ */ function updateByLink($data, CriteriaElement $criteria = null) { + /* @var $handler XoopsModelJoint */ $handler = $this->loadHandler('joint'); $ret = $handler->updateByLink($data, $criteria); return $ret; @@ -1244,6 +1243,7 @@ */ function deleteByLink(CriteriaElement $criteria = null) { + /* @var $handler XoopsModelJoint */ $handler = $this->loadHandler('joint'); $ret = $handler->deleteByLink($criteria); return $ret; @@ -1267,6 +1267,7 @@ */ function cleanOrphan($table_link = '', $field_link = '', $field_object = '') { + /* @var $handler XoopsModelSync */ $handler = $this->loadHandler('sync'); $ret = $handler->cleanOrphan($table_link, $field_link, $field_object); return $ret; Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/online.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/online.php 2011-10-08 13:56:08 UTC (rev 7812) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/online.php 2011-10-08 18:30:34 UTC (rev 7813) @@ -19,45 +19,104 @@ defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** - * A handler for "Who is Online?" information + * Online object * - * @package kernel + * @author trabis <lus...@gm...> + * @copyright copyright (c) 2000 XOOPS.org * - * @author Kazumi Ono <on...@xo...> - * @copyright copyright (c) 2000-2003 XOOPS.org + * @package kernel */ -class XoopsOnlineHandler +class XoopsOnline extends XoopsObject { /** - * Database connection - * - * @var object - * @access private + * Constructor */ - var $db; + function __construct() + { + $this->initVar('online_uid', XOBJ_DTYPE_INT, null, false); + $this->initVar('online_uname', XOBJ_DTYPE_TXTBOX, null, true); + $this->initVar('online_updated', XOBJ_DTYPE_INT, null, true); + $this->initVar('online_module', XOBJ_DTYPE_INT, null, true); + $this->initVar('online_ip', XOBJ_DTYPE_TXTBOX, null, true); + } /** + * @param string $format + * @return mixed + */ + public function online_uid($format = 'n') + { + return $this->getVar('online_uid', $format); + } + + /** + * @param string $format + * @return mixed + */ + public function online_uname($format = '') + { + return $this->getVar('online_uname', $format); + } + + /** + * @param string $format + * @return mixed + */ + public function online_updated($format = '') + { + return $this->getVar('online_updated', $format); + } + + /** + * @param string $format + * @return mixed + */ + public function online_module($format = '') + { + return $this->getVar('online_module', $format); + } + + /** + * @param string $format + * @return mixed + */ + public function online_ip($format = '') + { + return $this->getVar('online_ip', $format); + } + +} +/** + * A handler for "Who is Online?" information + * + * @package kernel + * + * @author Kazumi Ono <on...@xo...> + * @copyright copyright (c) 2000-2003 XOOPS.org + */ +class XoopsOnlineHandler extends XoopsPersistableObjectHandler +{ + /** * Constructor * - * @param object &$db {@link XoopsHandlerFactory} + * @param XoopsDatabase|null $db {@link XoopsDatabase} */ - function XoopsOnlineHandler(&$db) + public function __construct(XoopsDatabase $db = null) { - $this->db = $db; + parent::__construct($db, 'online', 'XoopsOnline', 'online_uid', 'online_uname'); } /** * Write online information to the database * - * @param int $uid UID of the active user - * @param string $uname Username - * @param string $timestamp - * @param string $module Current module - * @param string $ip User's IP adress - * - * @return bool TRUE on success + * @param int $uid UID of the active user + * @param string $uname Username + * @param string $time + * @param string $module Current module + * @param string $ip User's IP adress + * @return bool TRUE on success */ - function write($uid, $uname, $time, $module, $ip) + public function write($uid, $uname, $time, $module, $ip) { $uid = intval($uid); if ($uid > 0) { @@ -83,14 +142,13 @@ /** * Delete online information for a user * - * @param int $uid UID - * - * @return bool TRUE on success + * @param int $uid UID + * @return bool TRUE on success */ - function destroy($uid) + public function destroy($uid) { - $sql = sprintf("DELETE FROM %s WHERE online_uid = %u", $this->db->prefix('online'), $uid); - if (!$result = $this->db->queryF($sql)) { + $criteria = new Criteria('online_uid', intval($uid)); + if (!$this->deleteAll($criteria)) { return false; } return true; @@ -101,57 +159,18 @@ * * Delete all online information that has not been updated for a certain time * - * @param int $expire Expiration time in seconds + * @param int $expire Expiration time in seconds + * @return bool */ - function gc($expire) + public function gc($expire) { - $sql = sprintf("DELETE FROM %s WHERE online_updated < %u", $this->db->prefix('online'), time() - intval($expire)); - $this->db->queryF($sql); - } - - /** - * Get an array of online information - * - * @param object $criteria {@link CriteriaElement} - * @return array Array of associative arrays of online information - */ - function getAll($criteria = null) - { - $ret = array(); - $limit = $start = 0; - $sql = 'SELECT * FROM ' . $this->db->prefix('online'); - if (is_object($criteria) && is_subclass_of($criteria, 'criteriaelement')) { - $sql .= ' ' . $criteria->renderWhere(); - $limit = $criteria->getLimit(); - $start = $criteria->getStart(); - } - $result = $this->db->query($sql, $limit, $start); - if (!$result) { + $criteria = new CriteriaCompo('online_updated', time() - intval($expire), '<'); + if (!$this->deleteAll($criteria)) { return false; } - while ($myrow = $this->db->fetchArray($result)) { - $ret[] = $myrow; - unset($myrow); - } - return $ret; + return true; } - /** - * Count the number of online users - * - * @param object $criteria {@link CriteriaElement} - */ - function getCount($criteria = null) - { - $sql = 'SELEC... [truncated message content] |