/** * @depends test_createThread * @depends testAddIdea */ public function test_setIdeaThread($thread_id, $idea_id) { $Thread = new Thread($thread_id); $Idea = new Idea($idea_id); $this->assertNull($Idea->getForumThread()); $Idea->setForumThread($Thread); $this->assertInstanceOf("Railpage\\Forums\\Thread", $Idea->getForumThread()); }
/** * Get ideas by user * @since Version 3.9.1 * @return array * @param int $page Page number * @param int $itemsPerPage Number of results to return */ public function getIdeasByUser($page = 1, $itemsPerPage = 25) { if (!$this->User instanceof User) { throw new Exception("You must set a valid user before you can find ideas created by a user"); } $query = "SELECT SQL_CALC_FOUND_ROWS id, title, date FROM idea_ideas WHERE author = ? ORDER BY date DESC LIMIT ?, ?"; $params = array($this->User->id, ($page - 1) * $itemsPerPage, $itemsPerPage); $return = array("total" => 0, "page" => $page, "perpage" => $itemsPerPage, "ideas" => array()); if ($result = $this->db->fetchAll($query, $params)) { $return['total'] = $this->db_readonly->fetchOne("SELECT FOUND_ROWS() AS total"); foreach ($result as $row) { $Idea = new Idea($row['id']); $return['ideas'][] = $Idea->getArray(); } } return $return; }