public function save($args) { $db = Loader::db(); $cnvMessageID = $db->GetOne('select cnvMessageID from btCoreConversationMessage where bID = ?', array($this->bID)); if (!$cnvMessageID) { $message = ConversationMessage::add(false, $args['cnvMessageSubject'], $args['cnvMessageBody']); if (!Loader::helper('validation/antispam')->check($args['cnvMessageBody'], 'conversation_comment')) { $message->flag(ConversationFlagType::getByHandle('spam')); } else { $message->approve(); } $data = array(); $data['cnvMessageID'] = $message->getConversationMessageID(); parent::save($data); // update any conversation blocks on that page to have their conversations reflect that this is a base message block. // we will then use that to group and show replies and messages in the dashboard $b = $this->getBlockObject(); $c = $b->getBlockCollectionObject(); $blocks = $c->getBlocks(); foreach ($blocks as $b) { if ($b->getBlockTypeHandle() == BLOCK_HANDLE_CONVERSATION) { $bi = $b->getController(); $conversation = $bi->getConversationObject(); $conversation->setConversationParentMessageID($message->getConversationMessageID()); } } } }
if (!Loader::helper('validation/token')->validate('add_conversation_message', $_POST['token'])) { $ve->add(t('Invalid conversation post token.')); } if (!$vs->notempty($_POST['cnvMessageBody'])) { $ve->add(t('Your message cannot be empty.')); } if (Loader::helper('validation/numbers')->integer($_POST['cnvMessageParentID']) && $_POST['cnvMessageParentID'] > 0) { $parent = ConversationMessage::getByID($_POST['cnvMessageParentID']); if (!is_object($parent)) { $ve->add(t('Invalid parent message.')); } } if (Config::get('conversation.banned_words') && Loader::helper('validation/banned_words')->hasBannedWords($_POST['cnvMessageBody'])) { $ve->add(t('Banned words detected.')); } if ($ve->has()) { $ax->sendError($ve); } else { $msg = ConversationMessage::add($cn, $cnvMessageSubject, $_POST['cnvMessageBody'], $parent); if (!Loader::helper('validation/antispam')->check($_POST['cnvMessageBody'], 'conversation_comment')) { $msg->flag(ConversationFlagType::getByHandle('spam')); } else { $msg->approve(); } if ($_POST['attachments'] && count($_POST['attachments'])) { foreach ($_POST['attachments'] as $attachmentID) { $msg->attachFile(File::getByID($attachmentID)); } } $ax->sendResult($msg); }