/** * Posts a topic reply * * @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 $topic_id Topic id to post in * @param string $post_content Posted content * @return string xml */ public function postReply($api_key, $api_module, $member_field, $member_key, $topic_id, $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_id = intval($topic_id); $UNCLEANED_post_content = $post_content; //----------------------------------------- // Authenticate //----------------------------------------- if ($this->__authenticate($api_key, $api_module, 'postReply') !== 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); //----------------------------------------- // Need the topic... //----------------------------------------- $topic = $this->registry->DB()->buildAndFetch(array('select' => '*', 'from' => 'topics', 'where' => 'tid=' . $topic_id)); //----------------------------------------- // Set the data //----------------------------------------- $_postClass->setIsPreview(false); $_postClass->setForumData($this->registry->getClass('class_forums')->forum_by_id[$topic['forum_id']]); $_postClass->setForumID($topic['forum_id']); $_postClass->setTopicID($topic_id); $_postClass->setTopicData($topic); $_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)); /** * And post it... */ try { if ($_postClass->addReply() === FALSE) { //print $_postClass->_postErrors; $this->classApiServer->apiSendError('10', "IP.Board could not add the reply " . $_postClass->_postErrors); } } catch (Exception $error) { $this->classApiServer->apiSendError('10', "IP.Board post class exception: " . $error->getMessage()); } $this->classApiServer->apiSendReply(array('result' => 'success')); exit; } }