/** * @depends test_newUser */ public function test_getIPs($User) { $ips = $User->getIPs(); $this->assertEquals(0, count($ips)); $User->recordLogin("8.8.8.8"); $ips = $User->getIPs(); $this->assertEquals(1, count($ips)); $Forums = new Forums(); $Category = new Category(); $Forum = new Forum(); $Thread = new Thread(); $Post = new Post(); $Category->title = "Test category"; $Category->commit(); $Forum->name = "Test forum"; $Forum->setCategory($Category)->commit(); $Thread->title = "Test thread"; $Thread->setForum($Forum)->setAuthor($User)->commit(); $Post->ip = "8.8.8.8"; $Post->text = "Test post text"; $Post->setThread($Thread)->setAuthor($User)->commit(); $ips = $User->getIPs(); $this->assertEquals(2, count($ips)); }
/** * Get an SQL query used to exclude forums from timeline lookup * @since Version 3.9.1 * @param \Railpage\Users\User $User * @return string */ private function getFilteredForums() { $timer = Debug::GetTimer(); if (!isset($this->User->Guest) || !$this->User->Guest instanceof User) { return ""; } $mckey = sprintf("forum.post.filter.user:%d", $this->User->Guest->id); if ($forum_post_filter = $this->Redis->fetch($mckey)) { return $forum_post_filter; } $Forums = new Forums(); $Index = new Index(); $acl = $Forums->setUser($this->User->Guest)->getACL(); $allowed_forums = array(); foreach ($Index->forums() as $row) { $Forum = new Forum($row['forum_id']); if ($Forum->setUser($this->User->Guest)->isAllowed(Forums::AUTH_READ)) { $allowed_forums[] = $Forum->id; } } $forum_filter = "AND p.forum_id IN (" . implode(",", $allowed_forums) . ")"; if (count($allowed_forums) === 0) { $this->Redis->save($mckey, "", strtotime("+1 week")); return ""; } $forum_post_filter = "AND id NOT IN (SELECT l.id AS log_id\r\n FROM log_general AS l \r\n LEFT JOIN nuke_bbposts AS p ON p.post_id = l.value\r\n WHERE l.key = 'post_id' \r\n " . $forum_filter . ")"; $this->Redis->save($mckey, $forum_post_filter, strtotime("+1 week")); Debug::LogEvent(__METHOD__, $timer); return $forum_post_filter; }
/** * @depends testAddIdea */ public function test_createThread($idea_id) { $Idea = new Idea($idea_id); $Category = new ForumCategory(); $Category->title = "Ideas"; $Category->commit(); $Forum = new Forum(); $Forum->setCategory($Category); $Forum->name = "Ideas forum"; $Forum->commit(); $Thread = new Thread(); $Thread->title = $Idea->title; $Thread->setForum($Forum)->setAuthor($Idea->Author)->commit(); $Post = new Post(); $Post->text = $Idea->description; $Post->ip = "8.8.8.8"; $Post->setAuthor($Idea->Author)->setThread($Thread)->commit(); $this->assertFalse(!filter_var($Post->id, FILTER_VALIDATE_INT)); return $Thread->id; }
/** * @depends testAddCategory */ public function testBreakForum_validate_name($cat_id) { $Category = new Category($cat_id); $this->setExpectedException("Exception", "No forum name has been set"); $Forum = new Forum(); $Forum->category = $Category; $Forum->commit(); }