/** * get authors or translators of a book * @param int $type ($type = 0 for author, $type = 1 for translator) * @return Engine_Db_Table_Rowset of User_Model_User */ public function getAuthors($type = Book_Plugin_Constants::AUTHOR) { if (empty($this->author_ids) && empty($this->author_names)) { $bookAuthorTable = new Book_Model_DbTable_BookAuthor(); $select = $bookAuthorTable->select(array('author_id', 'author_name')); $select->where('book_id = ?', $this->getIdentity()); $select->where('type = ?', $type); $authorIds = array(); $authorNames = array(); foreach ($bookAuthorTable->fetchAll($select) as $row) { if (!empty($row->author_id)) { array_push($authorIds, $row->author_id); } else { if (!empty($row->author_name)) { array_push($authorNames, $row->author_name); } } } } else { $authorIds = explode(',', $this->author_ids); $authorNames = explode(',', $this->author_names); } $authors = array(); if (!empty($authorIds)) { $authors = Engine_Api::_()->user()->getUserMulti($authorIds); } if (!empty($authorNames)) { foreach ($authorNames as $authorName) { array_push($authors, $authorName); } } return $authors; }