function &getPostsByLimit($limit = 1, $start = 0, $criteria = null, $isnew = false) { if ($isnew) { $sql = 'SELECT p.* ' . ' FROM ' . $this->db->prefix('bb_posts') . ' AS p'; } else { $sql = 'SELECT p.*, t.* ' . ' FROM ' . $this->db->prefix('bb_posts') . ' AS p' . ' LEFT JOIN ' . $this->db->prefix('bb_posts_text') . " AS t ON t.post_id = p.post_id"; } if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { $sql .= " " . $criteria->renderWhere(); if ($criteria->getSort() != "") { $sql .= " ORDER BY " . $criteria->getSort() . " " . $criteria->getOrder(); } } $result = $this->db->query($sql, intval($limit), intval($start)); if (!$result) { newbb_message("NewbbTopicHandler::getAllPosts error:" . $sql); return null; } $ret = array(); while ($myrow = $this->db->fetchArray($result)) { $post =& $this->create(false); $post->assignVars($myrow); $ret[$myrow['post_id']] = $post; unset($post); } return $ret; }
function &getForumsByCat($cat = 0) { $sql = "SELECT * FROM " . $this->db->prefix('bb_forums'); if ($cat != 0) { $sql .= " WHERE cat_id=" . intval($cat); } $sql .= " ORDER BY forum_order, forum_id=parent_forum"; if (!($result = $this->db->query($sql))) { newbb_message("NewbbForumHandler::getForumsByCat error::" . $sql); return false; } $ret = array(); while ($row = $this->db->fetchArray($result)) { $thisforum = $this->create(false); $thisforum->assignVars($row); $ret[$row['cat_id']][$row['forum_id']] = $thisforum; unset($thisforum); } return $ret; }
redirect_header("viewtopic.php?topic_id=" . $topic_id . "&forum=" . $forum . "", 4, _MD_VOTEONCE); exit; } } } else { // Check if ANONYMOUS user is trying to vote more than once per day. $yesterday = time() - 86400 * $anonwaitdays; $result = $xoopsDB->query("SELECT COUNT(*) FROM " . $xoopsDB->prefix('bb_votedata') . " WHERE topic_id={$topic_id} AND ratinguser=0 AND ratinghostname = '{$ip}' AND ratingtimestamp > {$yesterday}"); list($anonvotecount) = $xoopsDB->fetchRow($result); if ($anonvotecount >= 1) { redirect_header("viewtopic.php?topic_id=" . $topic_id . "&forum=" . $forum . "", 4, _MD_VOTEONCE); exit; } } } else { redirect_header("viewtopic.php?topic_id=" . $topic_id . "&forum=" . $forum . "", 4, _MD_NOVOTERATE); exit; } // All is well. Add to Line Item Rate to DB. $newid = $xoopsDB->genId($xoopsDB->prefix('bb_votedata') . "_ratingid_seq"); $datetime = time(); $sql = sprintf("INSERT INTO %s (ratingid, topic_id, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (%u, %u, %u, %u, '%s', %u)", $xoopsDB->prefix('bb_votedata'), $newid, $topic_id, $ratinguser, $rating, $ip, $datetime); if (!($result = $xoopsDB->queryF($sql))) { newbb_message($sql); } // All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. newbb_updaterating($topic_id); $ratemessage = _MD_VOTEAPPRE . "<br />" . sprintf(_MD_THANKYOU, $xoopsConfig['sitename']); redirect_header("viewtopic.php?topic_id=" . $topic_id . "&forum=" . $forum . "", 4, $ratemessage); exit; include 'footer.php';
$poll->setVar("end_time", time() + 86400 * 10); } if (!empty($_POST["notify"]) && $end_time > time()) { // if notify, set mail status to "not mailed" $poll->setVar("mail_status", POLL_NOTMAILED); } else { // if not notify, set mail status to already "mailed" $poll->setVar("mail_status", POLL_MAILED); } if (!empty($_POST["reset"])) { // reset all logs XoopsPollLog::deleteByPollId($poll->getVar("poll_id")); XoopsPollOption::resetCountByPollId($poll->getVar("poll_id")); } if (!$poll->store()) { newbb_message($poll->getHtmlErrors()); exit; } $poll->updateCount(); include_once XOOPS_ROOT_PATH . '/class/template.php'; xoops_template_clear_module_cache($xoopsModule->getVar('mid')); redirect_header("viewtopic.php?topic_id={$topic_id}", 1, _MD_POLL_DBUPDATED); //exit(); } if ($op == "log") { //include XOOPS_ROOT_PATH."/header.php"; echo "<h4>" . _MD_POLL_POLLCONF . "</h4>"; echo "<br />View Log<br /> Sorry, not yet. ;-)"; //include XOOPS_ROOT_PATH."/footer.php"; //exit(); }
function b_newbb_author_show($options) { global $xoopsConfig; global $newbbConfig, $access_forums; $db =& Database::getInstance(); $myts =& MyTextSanitizer::getInstance(); $block = array(); $i = 0; $type = "topic"; $order = "count"; $extra_criteria = ""; $time_criteria = null; if (!empty($options[2])) { $time_criteria = time() - newbb_getSinceTime($options[2]); $extra_criteria = " AND topic_time>" . $time_criteria; } switch ($options[0]) { case 'topic': break; case 'digest': $extra_criteria = " AND topic_digest=1"; if ($time_criteria) { $extra_criteria .= " AND digest_time>" . $time_criteria; } break; case 'sticky': $extra_criteria .= " AND topic_sticky=1"; break; case 'post': default: $type = "post"; if ($time_criteria) { $extra_criteria = " AND post_time>" . $time_criteria; } break; } $forum_handler =& xoops_getmodulehandler('forum', 'newbb'); $module_handler =& xoops_gethandler('module'); $newbb = $module_handler->getByDirname('newbb'); if (!isset($newbbConfig)) { $config_handler =& xoops_gethandler('config'); $newbbConfig =& $config_handler->getConfigsByCat(0, $newbb->getVar('mid')); } if (!isset($access_forums)) { $access_forums = $forum_handler->getForums(0, 'access'); // get all accessible forums } if (!empty($options[5])) { $allowedforums = array_slice($options, 5); // get allowed forums $allowed_forums = array_intersect($allowedforums, array_keys($access_forums)); } else { $allowed_forums = array_keys($access_forums); } if ($type == "topic") { $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count FROM ' . $db->prefix('bb_topics') . ' WHERE topic_poster>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC'; } else { $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count FROM ' . $db->prefix('bb_posts') . ' WHERE uid>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC'; } $result = $db->query($query, $options[1], 0); if (!$result) { newbb_message("newbb block query error: " . $query); return false; } $author = array(); while ($row = $db->fetchArray($result)) { $author[$row["author"]]["count"] = $row["count"]; } if (count($author) < 1) { return false; } $author_name =& newbb_getUnameFromIds(array_keys($author), $newbbConfig['show_realname']); foreach (array_keys($author) as $uid) { $author[$uid]["name"] = $myts->htmlSpecialChars($author_name[$uid]); } $block['authors'] =& $author; $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; $block['indexNav'] = intval($options[4]); return $block; }
if (empty($dimention[1])) { $height = 31; } else { $height = $dimention[1] > 400 ? 400 : $dimention[1]; } $rss->image_width = $width; $rss->image_height = $height; $rss->max_items = $xoopsModuleConfig['rss_maxitems']; $rss->max_item_description = $xoopsModuleConfig['rss_maxdescription']; $forum_criteria = ' AND t.forum_id IN (' . implode(',', $valid_forums) . ')'; unset($valid_forums); $approve_criteria = ' AND t.approved = 1 AND p.approved = 1'; $query = 'SELECT' . ' f.forum_id, f.forum_name, f.allow_subject_prefix,' . ' t.topic_id, t.topic_title, t.topic_subject,' . ' p.post_id, p.post_time, p.subject, p.uid, p.poster_name, p.post_karma, p.require_reply, p.dohtml, p.dosmiley, p.doxcode,' . ' pt.post_text' . ' FROM ' . $xoopsDB->prefix('bb_posts') . ' AS p' . ' LEFT JOIN ' . $xoopsDB->prefix('bb_topics') . ' AS t ON t.topic_last_post_id=p.post_id' . ' LEFT JOIN ' . $xoopsDB->prefix('bb_posts_text') . ' AS pt ON pt.post_id=p.post_id' . ' LEFT JOIN ' . $xoopsDB->prefix('bb_forums') . ' AS f ON f.forum_id=p.forum_id' . ' WHERE 1=1 ' . $forum_criteria . $approve_criteria . ' ORDER BY p.post_time DESC'; $limit = intval($xoopsModuleConfig['rss_maxitems'] * 1.5); if (!($result = $xoopsDB->query($query, $limit))) { newbb_message("query for rss builder error: " . $query); return $xmlrss_handler->get($rss); } $rows = array(); while ($row = $xoopsDB->fetchArray($result)) { $users[$row['uid']] = 1; $rows[] = $row; } if (count($rows) < 1) { return $xmlrss_handler->get($rss); } $users =& newbb_getUnameFromIds(array_keys($users), $xoopsModuleConfig['show_realname']); foreach ($rows as $topic) { if ($xoopsModuleConfig['enable_karma'] && $topic['post_karma'] > 0) { continue; }
function delete(&$category) { global $xoopsModule; $forum_handler =& xoops_getmodulehandler('forum', 'newbb'); $forums =& $forum_handler->getForumsByCat($category->getVar('cat_id')); if (count($forums[$category->getVar('cat_id')]) > 0) { foreach ($forums[$category->getVar('cat_id')] as $fid => $forum) { $forum_handler->delete($forum); } } $sql = "DELETE FROM " . $category->table . " WHERE cat_id=" . $category->getVar('cat_id') . ""; if ($result = $this->db->query($sql)) { // Delete group permissions return $this->deletePermission($category); /* $gperm_handler = &xoops_gethandler('groupperm'); $criteria = new CriteriaCompo(new Criteria('gperm_modid', intval($xoopsModule->getVar('mid')))); $criteria->add(new Criteria('gperm_name', 'forum_cat_access')); $criteria->add(new Criteria('gperm_itemid', $category->getVar('cat_id'))); return $gperm_handler->deleteAll($criteria); */ } else { newbb_message("delete category error: " . $sql); return false; } }
function &setTemplate($perms) { $file_perm = XOOPS_CACHE_PATH . "/newbb_perm_template.php"; if (!($fp = fopen($file_perm, "w"))) { newbb_message("the template file can not be created: " . $file_perm); return false; } $file_content = "<?php\n"; $file_content .= "\treturn \$perms = '" . serialize($perms) . "';\n"; $file_content .= "?>"; fputs($fp, $file_content); fclose($fp); return true; }