function vote($uid, $vote_ip, $point) { $mod_config = $this->categoryObj->getOverriddenModConfig(); $db =& Database::getInstance(); // branch users and guests if ($uid) { $useridentity4select = "uid={$uid}"; } else { $useridentity4select = "vote_ip='" . mysql_real_escape_string($vote_ip) . "' AND uid=0 AND vote_time>" . (time() - @$mod_config['guest_vote_interval']); } // delete previous vote $sql = "DELETE FROM " . $db->prefix($this->mydirname . "_content_votes") . " WHERE content_id={$this->id} AND ({$useridentity4select})"; if (!($result = $db->queryF($sql))) { die(_MD_PICO_ERR_SQL . __LINE__); } // insert this vote $sql = "INSERT INTO " . $db->prefix($this->mydirname . "_content_votes") . " (content_id,vote_point,vote_time,vote_ip,uid) VALUES ({$this->id},{$point},UNIX_TIMESTAMP(),'" . mysql_real_escape_string($vote_ip) . "',{$uid})"; if (!$db->queryF($sql)) { die(_MD_PICO_ERR_SQL . __LINE__); } require_once dirname(dirname(__FILE__)) . '/include/transact_functions.php'; pico_sync_content_votes($this->mydirname, $this->id); }
function pico_sync_all($mydirname) { $db =& Database::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($mydirname); $config_handler =& xoops_gethandler('config'); $configs = $config_handler->getConfigList($module->mid()); // sync contents <- content_votes $result = $db->query("SELECT content_id FROM " . $db->prefix($mydirname . "_contents")); while (list($content_id) = $db->fetchRow($result)) { pico_sync_content_votes($mydirname, intval($content_id)); } // sync tags pico_sync_tags($mydirname); // d3forum comment integration if (!empty($configs['comment_dirname']) && $configs['comment_forum_id'] > 0) { $target_module =& $module_handler->getByDirname($configs['comment_dirname']); if (is_object($target_module)) { $target_dirname = $target_module->getVar('dirname'); $forum_id = intval($configs['comment_forum_id']); $result = $db->query("SELECT topic_external_link_id,COUNT(*) FROM " . $db->prefix($target_dirname . "_topics") . " WHERE topic_external_link_id>0 AND forum_id={$forum_id} AND ! topic_invisible GROUP BY topic_external_link_id"); while (list($content_id, $comments_count) = $db->fetchRow($result)) { $db->queryF("UPDATE " . $db->prefix($mydirname . "_contents") . " SET comments_count={$comments_count} WHERE content_id={$content_id}"); } } } // fix null and '' confusion $db->queryF("UPDATE " . $db->prefix($mydirname . "_categories") . " SET cat_vpath=null WHERE cat_vpath=''"); $db->queryF("UPDATE " . $db->prefix($mydirname . "_contents") . " SET vpath=null WHERE vpath=''"); // serialize_type conversion from PHP built-in serialize() to var_export() pico_convert_serialized_data($mydirname); // sync category's tree pico_sync_cattree($mydirname); // sync content_ef_sortables pico_sync_content_ef_sortables($mydirname); }