Created
February 14, 2014 15:53
-
-
Save blar/9003470 to your computer and use it in GitHub Desktop.
Tapatalk-API für mein Projekt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Application\Modules\Boards\Controllers; | |
| use Blar\MVC\Controllers\XmlRpcController as BaseXmlRpcController, | |
| Blar\Password, | |
| Blar\Session\SessionManager, | |
| Blar\Network\XmlRpc\XmlRpc, | |
| Blar\Network\Http\HttpRequest, | |
| Blar\Network\Curl, | |
| Blar\Collections\Collection, | |
| Application\Modules\Account\Models\User, | |
| Application\Modules\Boards\Models\Board, | |
| Application\Modules\Boards\Models\BoardSubscribe, | |
| Application\Modules\Boards\Models\Thread, | |
| Application\Modules\Boards\Models\Post, | |
| Application\Modules\Boards\Models\Message, | |
| Application\Modules\Boards\Models\Smiley; | |
| /** | |
| * @link https://tapatalk.com/api/api_home.php | |
| */ | |
| class TapatalkController extends BaseXmlRpcController { | |
| protected $apiKey = ''; | |
| public function getApiKey() { | |
| return $this->apiKey; | |
| } | |
| public function getConfigAction() { | |
| return array( | |
| 'advanced_delete' => (int) false, | |
| 'advanced_online_users' => (int) method_exists($this, 'getOnlineUsersAction'), | |
| 'advanced_search' => (int) method_exists($this, 'searchAction'), | |
| 'alert' => (int) method_exists($this, 'getAlertAction'), | |
| 'announcement' => (int) true, | |
| 'anonymous' => (int) true, | |
| 'anonymous_login' => (int) true, | |
| 'api_level' => (string) 3, | |
| 'avatar' => (int) true, | |
| 'can_subscribe' => false, | |
| 'can_unread' => (int) false, | |
| 'conversation' => (int) false, | |
| 'default_smilies' => (int) false, | |
| 'delete_reason' => (int) false, | |
| 'direct_unsubscribe' => (int) false, | |
| 'emoji_support' => (int) true, | |
| 'first_unread' => (int) false, | |
| 'get_activity' => (int) method_exists($this, 'getActivityAction'), | |
| 'get_forum' => (int) true, | |
| 'get_forum_status' => (int) method_exists($this, 'getForumStatusAction'), | |
| 'get_id_by_url' => (int) method_exists($this, 'getIdByUrlAction'), | |
| 'get_latest_topic' => (int) method_exists($this, 'getLatestTopicAction'), | |
| 'get_participated_forum' => (int) method_exists($this, 'getParticipatedForumAction'), | |
| 'get_smilies' => (int) method_exists($this, 'getSmiliesAction'), | |
| 'get_topic_status' => (int) method_exists($this, 'getTopicStatusAction'), | |
| 'guest_okay' => true, | |
| 'guest_search' => (int) true, | |
| 'guest_whosonline' => (int) true, | |
| 'ignore_user' => (int) method_exists($this, 'ignoreUserAction'), | |
| 'inappreg' => (int) false, | |
| 'inappsignin' => (int) false, | |
| 'inbox_stat' => (int) true, | |
| 'is_open' => true, | |
| 'm_approve' => (int) false, | |
| 'm_delete' => (int) false, | |
| 'm_report' => (int) false, | |
| 'mark_forum' => (int) method_exists($this, 'markAllAsReadAction'), | |
| 'mark_pm_unread' => (int) method_exists($this, 'markPmUnreadAction'), | |
| 'mark_read' => (int) method_exists($this, 'markAllAsReadAction'), | |
| 'mark_topic_read' => (int) method_exists($this, 'markTopicRead'), | |
| 'mass_subscribe' => (int) false, | |
| 'min_search_length' => 3, | |
| 'multi_quote' => (int) true, | |
| 'pm_load' => (int) false, | |
| 'push_type' => implode(',', array('ann', 'conv', 'pm', 'sub', 'like', 'thank', 'quote', 'newtopic', 'tag')), | |
| 'report_pm' => (int) method_exists($this, 'reportPmAction'), | |
| 'report_post' => (int) method_exists($this, 'reportPostAction'), | |
| 'search_user' => (int) method_exists($this, 'searchUserAction'), | |
| 'searchid' => (int) false, | |
| 'sign_in' => (int) true, | |
| 'subscribe_forum' => (int) method_exists($this, 'subscribeForumAction'), | |
| 'subscribe_load' => (int) false, | |
| 'support_md5' => (int) false, | |
| 'support_sha1' => (int) false, | |
| 'sys_version' => date('Y-m-d'), | |
| 'user_id' => (int) false, | |
| 'user_recommended' => (int) method_exists($this, 'getRecommendedUserAction'), | |
| 'version' => 'dev', | |
| ); | |
| } | |
| public function getForumAction($returnDescription = false, Board $board = NULL) { | |
| $attributes = array(); | |
| if($board) { | |
| $attributes['parentId'] = $board->getId(); | |
| } | |
| $user = $this->getLogin(); | |
| return $this->getRepository(Board::class)->findByAttributes($attributes)->getIterator()->map(function($board) use($user) { | |
| return array( | |
| 'forum_id' => $board->getId(), | |
| 'forum_name' => XmlRpc::encodeBase64($board->getTitle()), | |
| 'description' => XmlRpc::encodeBase64($board->getDescription()), | |
| 'parent_id' => $board->getParentBoard() ? $board->getParentBoard()->getId() : -1, | |
| 'logo_url' => $board->getLogo(), | |
| 'new_post' => false, | |
| 'is_protected' => $board->isProtected(), | |
| 'is_subscribed' => $board->isSubscribedByUser($user), | |
| 'can_subscribe' => true, | |
| 'sub_only' => false, | |
| 'child' => $board->getChildBoards() | |
| ); | |
| }); | |
| } | |
| public function getParticipatedForumAction() { | |
| return array( | |
| 'total_forums_num' => 0, | |
| 'forums' => array() | |
| ); | |
| } | |
| public function markAllAsReadAction(Board $board) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function loginForumAction(Board $board, $password) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Access denied') | |
| ); | |
| } | |
| public function getIdByUrlAction($url) { | |
| return array( | |
| 'forum_id' => NULL, | |
| 'topic_id' => NULL, | |
| 'post_id' => NULL | |
| ); | |
| } | |
| public function getBoardStatAction() { | |
| return array( | |
| 'total_threads' => count($this->getRepository(Thread::class)->findAll()), | |
| 'total_posts' => count($this->getRepository(Post::class)->findAll()), | |
| 'total_members' => count($this->getRepository(User::class)->findAll()), | |
| 'active_members' => NULL, | |
| 'total_online' => NULL, | |
| 'guest_online' => NULL | |
| ); | |
| } | |
| public function getForumStatusAction($ids) { | |
| return array( | |
| 'forums' => $this->getRepository(Board::class)->findByAttributes($ids)->getIterator()->map(function($board) { | |
| return array( | |
| 'forum_id' => $board->getId(), | |
| 'forum_name' => XmlRpc::encodeBase64($board->getTitle()), | |
| 'logo_url' => $board->getLogo(), | |
| 'is_protected' => $board->isProtected(), | |
| 'new_post' => false | |
| ); | |
| }) | |
| ); | |
| } | |
| public function getSmiliesAction() { | |
| $smilies = $this->getRepository(Smiley::class)->findAll(); | |
| $smilies = $smilies->getIterator()->map(function($smiley) { | |
| return array( | |
| 'code' => XmlRpc::encodeBase64($smiley->getCode()), | |
| 'url' => $smiley->getUrl(), | |
| 'title' => XmlRpc::encodeBase64($smiley->getTitle()), | |
| 'category' => $smiley->getCategory() | |
| ); | |
| }); | |
| return $smilies->partition(function(&$smiley) { | |
| $category = $smiley['category']; | |
| unset($smiley['category']); | |
| return $category; | |
| }); | |
| } | |
| public function markTopicReadAction() { | |
| } | |
| public function getTopicStatusAction() { | |
| } | |
| public function newTopicAction() { | |
| } | |
| public function getTopicAction(Board $board, $start = NULL, $length = NULL, $mode = NULL) { | |
| $result = array( | |
| 'forum_id' => $board->getId(), | |
| 'forum_name' => $board->getTitle(), | |
| 'can_post' => true, | |
| 'unread_sticky_count' => 4, | |
| 'unread_announce_count' => 4, | |
| 'can_subscribe' => true, | |
| 'is_subscribed' => false | |
| ); | |
| switch($mode) { | |
| case 'TOP': | |
| $result['topics'] = $this->getTopTopicAction($board); | |
| break; | |
| case 'ANN': | |
| $result['topics'] = $this->getAnnTopicAction($board); | |
| break; | |
| default: | |
| $result['topics'] = $this->getDefaultTopicAction($board); | |
| break; | |
| } | |
| $result['total_topic_num'] = count($result['topics']); | |
| return $result; | |
| } | |
| public function getTopTopicAction(Board $board) { | |
| return $this->getDefaultTopicAction($board); | |
| return array(); | |
| } | |
| public function getAnnTopicAction(Board $board) { | |
| return $this->getDefaultTopicAction($board); | |
| return array(); | |
| } | |
| public function getDefaultTopicAction(Board $board) { | |
| return $board->getThreads()->getIterator()->map(function($thread) use($board) { | |
| return array( | |
| 'forum_id' => $board->getId(), | |
| 'topic_id' => $thread->getId(), | |
| 'topic_title' => XmlRpc::encodeBase64($thread->getTitle()), | |
| 'topic_author_id' => $thread->getUser()->getId(), | |
| 'topic_author_name' => XmlRpc::encodeBase64($thread->getUser()->getName()), | |
| 'is_subscribed' => false, | |
| 'can_subscribe' => true, | |
| 'is_closed' => false, | |
| 'icon_url' => $thread->getUser()->getAvatar(), | |
| 'last_reply_time' => new \DateTime(), | |
| 'reply_number' => count($thread->getPosts()), | |
| 'new_post' => false, | |
| # 'view_number' => 1337, | |
| # 'short_content' => $thread->getPreview() | |
| ); | |
| }); | |
| } | |
| public function getUnreadTopicAction($first = NULL, $last = NULL, $search = NULL, $filters = array()) { | |
| } | |
| public function getParticipatedTopicAction($userName, $first = NULL, $last = NULL, $search = NULL, User $user = NULL) { | |
| } | |
| public function getLatestTopicAction($first = NULL, $last = NULL, $search = NULL, $filters = array()) { | |
| $result = array( | |
| 'result' => true, | |
| 'topics' => $this->getRepository(Thread::class)->findAll()->setOrder('modified', 'DESC')->getIterator()->map(function($thread) { | |
| return array( | |
| 'forum_id' => $thread->getBoard()->getId(), | |
| 'forum_name' => XmlRpc::encodeBase64($thread->getBoard()->getTitle()), | |
| 'topic_id' => $thread->getId(), | |
| 'topic_title' => XmlRpc::encodeBase64($thread->getTitle()), | |
| 'post_author_id' => $thread->getUser()->getId(), | |
| 'post_author_name' => XmlRpc::encodeBase64($thread->getUser()->getName()), | |
| 'icon_url' => $thread->getUser()->getAvatar(), | |
| 'is_subscribed' => false, | |
| 'can_subscribe' => true, | |
| 'is_closed' => false, | |
| ); | |
| }) | |
| ); | |
| $result['total_topic_num'] = count($result['topics']); | |
| return $result; | |
| } | |
| public function getThreadAction(Thread $thread, $start = NULL, $length = NULL, $returnHtml = true) { | |
| $board = $thread->getBoard(); | |
| $result = array( | |
| 'forum_id' => $board->getId(), | |
| 'forum_name' => XmlRpc::encodeBase64($board->getTitle()), | |
| 'topic_id' => $thread->getId(), | |
| 'topic_title' => XmlRpc::encodeBase64($thread->getTitle()), | |
| 'total_post_num' => 0 | |
| ); | |
| $result['breadcrumb'] = array( | |
| array( | |
| 'forum_id' => $board->getId(), | |
| 'forum_name' => XmlRpc::encodeBase64($board->getTitle()), | |
| 'sub_only' => false | |
| ) | |
| ); | |
| $result['posts'] = $thread->getPosts()->getIterator()->map(function($post) { | |
| return array( | |
| 'post_id' => $post->getId(), | |
| 'post_title' => XmlRpc::encodeBase64(''), | |
| 'post_content' => XmlRpc::encodeBase64($post->getContent()), | |
| 'post_author_id' => '1', | |
| 'post_author_name' => XmlRpc::encodeBase64('foo'), | |
| 'icon_url' => $thread->getUser()->getAvatar(), | |
| 'post_time' => new \DateTime() | |
| ); | |
| }); | |
| $result['total_post_num'] = count($result['posts']); | |
| return $result; | |
| } | |
| public function loginAction($userName, $password, $anonymous = false) { | |
| $user = $this->getRepository(User::class)->findOneByAttributes(array( | |
| 'name' => $userName | |
| )); | |
| if(!$user) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => 'Unknown User' | |
| ); | |
| } | |
| if(!Password::verify($password, $user->getPassword())) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => 'Invalid Password' | |
| ); | |
| } | |
| if(Password::needsRehash($user->getPassword())) { | |
| $hash = Password::hash($password); | |
| $user->setPassword($hash); | |
| $this->getRepository(User::class)->persist($user); | |
| } | |
| SessionManager::startSession(); | |
| $_SESSION['User']['id'] = $user->getId(); | |
| return array( | |
| 'can_moderate' => false, | |
| 'can_pm' => true, | |
| 'can_profile' => true, | |
| 'can_search' => true, | |
| 'can_send_pm' => true, | |
| 'can_upload_avatar' => true, | |
| 'can_whosonline' => true, | |
| 'email' => XmlRpc::encodeBase64($user->getEmail()), | |
| 'icon_url' => $thread->getUser()->getAvatar(), | |
| 'ignored_uids' => '', | |
| 'max_attachment' => 4, | |
| 'max_jpg_size' => 2 ^ 22, | |
| 'max_png_size' => 2 ^ 22, | |
| 'post_count' => count($this->getRepository(Post::class)->findByAttributes(array( | |
| 'userId' => $user->getId() | |
| ))), | |
| 'result' => true, | |
| 'status' => 0, | |
| 'user_id' => $user->getId(), | |
| 'user_type' => XmlRpc::encodeBase64('normal'), | |
| 'usergroup_id' => array('Registered'), | |
| 'username' => XmlRpc::encodeBase64($user->getName()), | |
| ); | |
| } | |
| public function getInboxStatsAction() { | |
| return array( | |
| 'inbox_unread_count' => 23, | |
| 'subscribed_topic_unread_count' => 42 | |
| ); | |
| } | |
| public function reportPostAction(Post $post, $reason) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function replyPostAction(Board $board, Thread $thread, $title, $content, $attachments = array(), $group = NULL, $returnHtml = false) { | |
| $post = new Post(); | |
| $post->setContent($content); | |
| $post->setThreadId($thread->getId()); | |
| $this->getRepository(Post::class)->persist($post); | |
| return array( | |
| 'result' => true, | |
| 'post_id' => $post->getId() | |
| ); | |
| } | |
| public function getQuotePostAction(Post $post) { | |
| return array( | |
| 'post_id' => $post->getId(), | |
| 'post_title' => XmlRpc::encodeBase64($post->getTitle()), | |
| 'post_content' => XmlRpc::encodeBase64($post->getContent()) | |
| ); | |
| } | |
| public function getRawPostAction(Post $post) { | |
| return array( | |
| 'post_id' => $post->getId(), | |
| 'post_title' => XmlRpc::encodeBase64($post->getTitle()), | |
| 'post_content' => XmlRpc::encodeBase64($post->getContent()) | |
| ); | |
| } | |
| public function saveRawPostAction(Post $post, $title, $content, $returnHtml = false) { | |
| } | |
| public function logoutUserAction() { | |
| SessionManager::destroySession(); | |
| return array( | |
| 'result' => true, | |
| 'result_text' => XmlRpc::encodeBase64('') | |
| ); | |
| } | |
| public function getOnlineUsersAction($page = 0, $perPage = 12, $id = NULL, $area = NULL) { | |
| $result = array( | |
| 'guest_count' => 0, | |
| 'list' => $this->getRepository(User::class)->findAll()->getIterator()->map(function($user) { | |
| return array( | |
| 'user_id' => $user->getId(), | |
| 'username' => XmlRpc::encodeBase64($user->getName()), | |
| 'icon_url' => $user->getAvatar(), | |
| 'user_name' => XmlRpc::encodeBase64($user->getName()), | |
| # 'display_text' => XmlRpc::encodeBase64('Message'), | |
| ); | |
| }) | |
| ); | |
| $result['member_count'] = count($result['list']); | |
| return $result; | |
| } | |
| public function getUserInfoAction($userName, User $user) { | |
| return array( | |
| 'user_id' => $user->getId(), | |
| 'username' => XmlRpc::encodeBase64($user->getName()), | |
| 'post_count' => count($this->getRepository(Post::class)->findByAttributes(array('userId' => $user->getId()))), | |
| 'reg_time' => $user->getCreated(), | |
| 'accept_pm' => true, | |
| 'icon_url' => $user->getAvatar(), | |
| ); | |
| } | |
| public function getUserTopicAction($userName, User $user) { | |
| return $this->getRepository(Thread::class)->findByAttributes(array('userId' => $user->getId()))->setOrder('created', 'DESC')->setLimit(50)->getIterator()->map(function($thread) { | |
| return array( | |
| 'forum_id' => $thread->getBoard()->getId(), | |
| 'forum_name' => XmlRpc::encodeBase64($thread->getBoard()->getTitle()), | |
| 'topic_id' => $thread->getId(), | |
| 'topic_title' => XmlRpc::encodeBase64($thread->getTitle()), | |
| 'reply_number' => $thread->countPosts(), | |
| 'new_post' => false, | |
| 'view_number' => NULL | |
| ); | |
| }); | |
| } | |
| public function getSubscribedForumAction() { | |
| $subscribes = $this->getRepository(BoardSubscribe::class)->findByAttributes(array( | |
| 'userId' => 1 | |
| )); | |
| $result = array(); | |
| $result['forums'] = $subscribes->getIterator()->map(function($subscribe) { | |
| $board = $this->getRepository(Board::class)->findOneByPrimary($subscribe->getBoardId()); | |
| return array( | |
| 'forum_id' => $board->getId(), | |
| 'forum_name' => XmlRpc::encodeBase64($board->getTitle()), | |
| 'is_protected' => false, | |
| 'new_post' => false | |
| ); | |
| }); | |
| $result['total_forums_num'] = count($result['forums']); | |
| return $result; | |
| } | |
| public function subscribeForumAction(Board $board) { | |
| $subscribe = new BoardSubscribe(); | |
| $subscribe->setBoard($board); | |
| $subscribe->setUserId(1); | |
| $this->getEntityManager()->persist($subscribe); | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function unsubscribeForumAction(Board $board) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function getSubscribedTopicAction() { | |
| $threads = $this->getRepository(Thread::class)->findAll(); | |
| $result = array(); | |
| $result['topics'] = $threads->getIterator()->map(function($thread) { | |
| return array( | |
| 'forum_id' => $thread->getBoard()->getId(), | |
| 'forum_name' => XmlRpc::encodeBase64($thread->getBoard()->getTitle()), | |
| 'topic_id' => $thread->getId(), | |
| 'topic_title' => XmlRpc::encodeBase64($thread->getTitle()), | |
| 'is_protected' => false, | |
| 'new_post' => false | |
| ); | |
| }); | |
| $result['total_topic_num'] = count($result['topics']); | |
| return $result; | |
| } | |
| public function subscribeTopicAction(Thread $thread) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function unsubscribeTopicAction(Thread $thread) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function reportPmActionAction($message, $reason) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function createMessageAction($receivers, $subject, $content, $action = 0, $message = NULL) { | |
| $message = new Message(); | |
| $message->setSubject($subject); | |
| $message->setContent($content); | |
| $status = $this->getEntityManager()->persist($message); | |
| if(!$status) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not saved') | |
| ); | |
| } | |
| return array( | |
| 'result' => true, | |
| 'msg_id' => $message->getId() | |
| ); | |
| } | |
| public function getBoxInfoAction() { | |
| return array( | |
| 'result' => true, | |
| 'message_room_count' => 1024, | |
| 'list' => array( | |
| array( | |
| 'box_id' => 1, | |
| 'box_name' => XmlRpc::encodeBase64('Posteingang1'), | |
| 'msg_count' => 1, | |
| 'box_type' => 'INBOX' | |
| ), | |
| array( | |
| 'box_id' => 2, | |
| 'box_name' => XmlRpc::encodeBase64('Postausgang2'), | |
| 'msg_count' => 1, | |
| 'unread_count' => 1, | |
| 'box_type' => 'SENT' | |
| ), | |
| array( | |
| 'box_id' => 3, | |
| 'box_name' => XmlRpc::encodeBase64('Entwürfe'), | |
| 'msg_count' => 1, | |
| 'unread_count' => 1 | |
| ) | |
| ) | |
| ); | |
| } | |
| public function getBoxAction($box) { | |
| $result = array( | |
| 'result' => true | |
| ); | |
| $messages = $this->getRepository(Message::class)->findAll(); | |
| $result['list'] = $messages->getIterator()->map(function($message) { | |
| $sender = $message->getSender(); | |
| return array( | |
| 'msg_id' => $message->getId(), | |
| 'msg_state' => 1, | |
| 'msg_from_id' => $sender ? $sender->getId() : NULL, | |
| 'msg_from' => $sender ? XmlRpc::encodeBase64($sender->getName()) : NULL, | |
| 'msg_subject' => XmlRpc::encodeBase64($message->getSubject()), | |
| 'short_content' => XmlRpc::encodeBase64($message->getContent()), | |
| 'is_online' => true, | |
| 'msg_to' => array( | |
| array( | |
| 'user_id' => 1, | |
| 'username' => XmlRpc::encodeBase64('Blar1') | |
| ) | |
| ) | |
| ); | |
| }); | |
| $result['total_message_count'] = count($result['list']); | |
| $result['total_unread_count'] = count($result['list']); | |
| return $result; | |
| } | |
| public function getMessageAction(Message $message, $box, $returnHtml = false) { | |
| $sender = $message->getSender(); | |
| $result = array( | |
| 'result' => true, | |
| 'msg_from' => $sender ? XmlRpc::encodeBase64($sender->getName()) : NULL, | |
| 'msg_subject' => $message->getSubject(), | |
| 'text_body' => $message->getContent(), | |
| 'msg_to' => array( | |
| array( | |
| 'user_id' => 1, | |
| 'username' => XmlRpc::encodeBase64('Blar2') | |
| ) | |
| ) | |
| ); | |
| return $result; | |
| } | |
| public function getQuotePmAction(Message $message) { | |
| return array( | |
| 'result' => true, | |
| 'msg_id' => $message->getId(), | |
| 'msg_subject' => $message->getSubject(), | |
| 'text_body' => $message->getContent() | |
| ); | |
| } | |
| public function deleteMessageAction(Message $message, $box) { | |
| $this->getEntityManager()->remove($message); | |
| return array( | |
| 'result' => true | |
| ); | |
| } | |
| public function markPmUnreadAction(Message $message) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function signInAction($token, $code, $email = NULL, $username = NULL, $password = NULL) { | |
| $curl = new Curl(); | |
| $request = new HttpRequest(); | |
| $request->setMethod('POST'); | |
| $request->setUrl('http://directory.tapatalk.com/au_reg_verify.php'); | |
| $request->setBody(array( | |
| 'token' => $token, | |
| 'code' => $code, | |
| 'key' => $this->getApiKey() | |
| )); | |
| $response = $curl->sendRequest($request); | |
| error_log(print_r($response, true)); | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| $user = $this->getRepository(User::class)->findOneByPrimary(1); | |
| return array( | |
| 'result' => true, | |
| 'register' => false, | |
| # 'status' => 0, | |
| 'user_id' => $user->getId(), | |
| 'username' => XmlRpc::encodeBase64($user->getName()), | |
| 'usergroup_id' => array(), | |
| 'email' => XmlRpc::encodeBase64($user->getEmail()), | |
| 'icon_url' => XmlRpc::encodeBase64(''), | |
| 'post_count' => rand(23, 42), | |
| 'user_type' => XmlRpc::encodeBase64('normal'), | |
| 'can_pm' => true, | |
| 'can_send_pm' => true, | |
| 'can_moderate' => false, | |
| 'can_search' => true, | |
| 'can_whosonline' => true, | |
| 'can_profile' => true, | |
| 'can_upload_avatar' => true | |
| ); | |
| } | |
| public function forgetPasswordAction($userName, $token = NULL, $code = NULL) { | |
| return array( | |
| 'result' => true, | |
| 'verified' => true | |
| ); | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function updatePasswordAction() { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function updateEmailAction($password, $email) { | |
| $user = $this->getLogin(); | |
| if(!Password::verify($password, $user->getPassword())) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Invalid password') | |
| ); | |
| } | |
| $user->setEmail($email); | |
| $status = $this->getEntityManager()->persist($user); | |
| if(!$status) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Invalid password') | |
| ); | |
| } | |
| return array( | |
| 'result' => true, | |
| ); | |
| } | |
| public function registerAction($userName, $password, $email, $token = NULL, $code = NULL) { | |
| $user = new User(); | |
| $user->setName($userName); | |
| $user->setEmail($email); | |
| $user->setPassword(Password::hash($password)); | |
| $status = $this->getEntityManager()->persist($user); | |
| if(!$status) { | |
| return array( | |
| 'result' => false | |
| ); | |
| } | |
| return array( | |
| 'result' => true | |
| ); | |
| } | |
| public function searchTopicAction($query, $start = NULL, $last = NULL, $id = NULL) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function searchPostAction($query, $start, $last = NULL, $id = NULL) { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function searchAction() { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| public function getAlertAction($page = 0, $perPage = 12) { | |
| /* | |
| $alerts[] = array( | |
| 'user_id' => 1, | |
| 'username' => XmlRpc::encodeBase64('System'), | |
| 'message' => XmlRpc::encodeBase64('Hello World'), | |
| 'timestamp' => time(), | |
| 'content_type' => 'post', | |
| 'content_id' => 1, | |
| 'topic_id' => 1, | |
| 'unread' => true, | |
| ); | |
| */ | |
| $alerts = array(); | |
| return array( | |
| 'total' => count($alerts), | |
| 'items' => $alerts | |
| ); | |
| } | |
| /** | |
| * Was auch immer diese Methode macht, es ist nicht dokumentiert! | |
| */ | |
| public function prefetchAccountAction() { | |
| return array( | |
| 'result' => false, | |
| 'result_text' => XmlRpc::encodeBase64('Not implemented') | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment