public static function setWatching(GWF_ForumThread $thread, $cut) { $tid = $thread->getID(); # Insert current spectator // GDO::table(__CLASS__); $row = new self(array('fowa_sess' => GWF_Session::getSessID(), 'fowa_time' => time(), 'fowa_tid' => $tid)); if (false === $row->replace()) { return false; } # Delete old $cut = time() - $cut; if (false === $row->deleteWhere("fowa_time<{$cut}")) { return false; } # Set new amount if (false === $thread->saveVar('thread_watchers', $row->countRows("fowa_tid={$tid}"))) { return false; } return true; }
private function onMerge(GWF_ForumThread $first, GWF_ForumThread $last) { // Delete thread if (false === $last->delete()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // Sum counters if (false === $first->saveVar('thread_postcount', $first->getPostCount() + $last->getPostCount())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $first->saveVar('thread_viewcount', $first->getVar('thread_viewcount') + $last->getVar('thread_viewcount'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $first->saveVar('thread_thanks', $first->getVar('thread_thanks') + $last->getVar('thread_thanks'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $first->saveVar('thread_votes_up', $first->getVar('thread_votes_up') + $last->getVar('thread_votes_up'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $first->saveVar('thread_votes_down', $first->getVar('thread_votes_down') + $last->getVar('thread_votes_down'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // -1 thread if (false === $first->getBoard()->adjustCounters(-1, 0)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // change threadid's $t1id = $first->getID(); $t2id = $last->getID(); if (false === GDO::table('GWF_ForumPost')->update("post_tid={$t1id}", "post_tid={$t2id}")) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // Done return $this->module->message('msg_merged'); }