/** * Posts a topic to the board remotely * * @access public * @param string $api_key Authentication Key * @param string $api_module Module * @param string $member_field Member field to check (valid: "id", "email", "username", "displayname") * @param string $member_key Member key to check for * @param integer $forum_id Forum id to post in * @param string $topic_title Topic title * @param string $topic_description Topic description * @param string $post_content Posted content * @return string xml */ public function postTopic($api_key, $api_module, $member_field, $member_key, $forum_id, $topic_title, $topic_description, $post_content) { //----------------------------------------- // INIT //----------------------------------------- $api_key = IPSText::md5Clean($api_key); $api_module = IPSText::parseCleanValue($api_module); $member_field = IPSText::parseCleanValue($member_field); $member_key = IPSText::parseCleanValue($member_key); $topic_title = IPSText::parseCleanValue($topic_title); $topic_description = IPSText::parseCleanValue($topic_description); $forum_id = intval($forum_id); $UNCLEANED_post_content = $post_content; //----------------------------------------- // Authenticate //----------------------------------------- if ($this->__authenticate($api_key, $api_module, 'postTopic') !== FALSE) { //----------------------------------------- // Add log //----------------------------------------- if (ipsRegistry::$settings['xmlrpc_log_type'] != 'failed') { $this->registry->DB()->insert('api_log', array('api_log_key' => $api_key, 'api_log_ip' => $_SERVER['REMOTE_ADDR'], 'api_log_date' => time(), 'api_log_query' => $this->classApiServer->raw_request, 'api_log_allowed' => 1)); } //----------------------------------------- // Member field... //----------------------------------------- $member = IPSMember::load($member_key, 'all', $member_field); //----------------------------------------- // Got a member? //----------------------------------------- if (!$member['member_id']) { $this->classApiServer->apiSendError('10', "IP.Board could not locate a member using {$member_key} / {$member_field}"); } //----------------------------------------- // Get some classes //----------------------------------------- require_once IPSLib::getAppDir('forums') . '/app_class_forums.php'; $appClass = new app_class_forums($this->registry); require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php'; $_postClass = new classPost($this->registry); //----------------------------------------- // Set the data //----------------------------------------- $_postClass->setIsPreview(false); $_postClass->setForumData($this->registry->getClass('class_forums')->forum_by_id[$forum_id]); $_postClass->setForumID($forum_id); $_postClass->setPostContent($UNCLEANED_post_content); $_postClass->setAuthor($member['member_id']); $_postClass->setPublished(true); $_postClass->setSettings(array('enableSignature' => 1, 'enableEmoticons' => 1, 'post_htmlstatus' => 0, 'enableTracker' => 0)); $_postClass->setTopicTitle($topic_title); $_postClass->setTopicDescription($topic_description); /** * And post it... */ try { if ($_postClass->addTopic() === FALSE) { $this->classApiServer->apiSendError('10', "IP.Board could not add the topic"); } } catch (Exception $error) { $this->classApiServer->apiSendError('10', "IP.Board post class exception: " . $error->getMessage()); } $this->classApiServer->apiSendReply(array('result' => 'success', 'topic_id' => $_postClass->getTopicData('tid'))); exit; } }