Returns a formatted conversation message body string, based on configuration options supplied.

@param \Concrete\Core\Conversation\Conversation $cnv
@param string $cnvMessageBody
@param array $config

@return string
485680
public function formatConversationMessageBody($cnv, $cnvMessageBody, $config = array())
    {
        /** @var  \Concrete\Core\Html\Service\Html $htmlHelper */
        $htmlHelper = Core::make('helper/html');
        $cnvMessageBody = $htmlHelper->noFollowHref($cnvMessageBody);
        if (isset($config['htmlawed'])) {
            $default = array('safe' => 1, 'elements' => 'p, br, strong, em, strike, a');
            $conf = array_merge($default, (array) $config['htmlawed']);
            $result = htmLawed($cnvMessageBody, $conf);
        } else {
            $result = $cnvMessageBody;
        }
        if (isset($config['mention']) && $config['mention'] !== false) {
            $users = $cnv->getConversationMessageUsers();
            $needle = array();
            $haystack = array();
            foreach ($users as $user) {
                $needle[] = "@" . $user->getUserName();
                $haystack[] = "<a href='" . $user->getUserPublicProfileURL() . "'>'@" . $user->getUserName() . "</a>";
            }

            $result = str_ireplace($needle, $haystack, $result);
        }

        // Replace any potential XSS
        $result = $this->removeJavascriptLinks($result);
        return $result;
    }
921664
function Transport(config, transport) {
  transport = transport || {};

  /** @namespace Transport */
  const base = {
    logger: config.logger,
    name: 'base'
  };

  /**
   * runs the setup needed for the transport to work
   */
  base.setup = function(callback) {
    transport.ran_setup = true;

    callback = _.defaultTo(callback, _.noop);
    callback();
  };

  /**
   * validates the inbound request of data
   * 
   * @param {Object} req - the inbound request from express
   * @returns {Boolean} isValid
   */
  base.validate = function(req) {
    let isValid = !!req;

    return isValid;
  };

  /** 
   * Parses the body into individual inbound messages
   *
   * @param {Object} body
   * @returns {inboundMessage[]} inboundMessages
   */
  base.parse = function(body, callback) {
    callback(_.castArray(body));
  };

  /** 
   * returns the conversation the inbound message is part of
   * 
   * @param {InboundMessage} inboundMessage
   * @param {Array} convos - array of conversation objects
   * @returns {Object|false} convo - the conversation or false if none is found
   */
  base.findConversation = function(inboundMessage, convos) {
    base.logger.debug('Looking for conversation...');
    if (!_.has(inboundMessage.headers, 'references'))
      return false;

    let messageIds = inboundMessage.headers['references'].split(' ');

    base.logger.debug('Looking in message references...');

    let conversationId = messageIds[0].match(new RegExp("<conversation-id_(.*)>"));

    if (!_.isArray(conversationId))
      return false;

    conversationId = conversationId[1];

    base.logger.debug('ID found: '+conversationId);

    let convo = _.find(convos, function(convo) {
      return convo.id === conversationId;
    });

    if (_.isUndefined(convo)) {
      return false;
    }

    base.logger.debug('Conversation found');

    return convo;
  };

  /** 
   * Sends email out
   *
   * @param {InboundMessage} inboundMessage
   * @param {OutboundMessage} outboundMessage
   * @param {function} callback
   */
  base.send = function(inboundMessage, outboundMessage, callback) {
    callback(null, true);
  };

  /**
   * defaults all the required keys on the inbound message
   *
   * @param {InboundMessage} inboundMessage
   */
  base.defaultInboundMessage = function(inboundMessage) {
    return _.defaultsDeep(inboundMessage, {
      event: '',
      to: {
        email: config.inbound_address,
        name: ''
      },
      from: '',
      subject: '',
      text: '',
      html: '',
      recipients: [],
      cc: [],
      bcc: [],
      headers: {},
      attachments: [],
      _raw: {}
    });
  };

  /**
   * defaults all the required keys on the outbound message
   *
   * @param {OutboundMessage} outboundMessage
   */
  base.defaultOutboundMessage = function(outboundMessage) {
    let html = minify(outboundMessage.html || outboundMessage.body || '');
    let text = outboundMessage.text || htmlToText(html, config.htmlToTextOpts).replace(/{{/g, ' {{');
    delete outboundMessage['body'];

    return _.defaultsDeep(outboundMessage, {
      subject: '',
      html:  html,
      text: text,
      headers: {},
      recipients: [],
      cc: [],
      bcc: [],
      from: {
        name: config.name,
        email: config.sending_address
      },
      reply_to: {
        name: config.name,
        email: config.inbound_address
      },
      substitution_data: {},
      attachments: [],
      inline_images: []
    });
  };

  /** 
   * returns the message id or a default auto generated one
   * 
   * @param {InboundMessage} inboundMessage
   * @returns {string} messageId
   */
  base.defaultMessageId = function(inboundMessage) {
    return _.at(inboundMessage, 'headers[message-id]')[0] || `${uniqid()}@${config.sending_address.split('@')[1]}`;
  };


  return _.defaults(transport, base);
}
1344078
public function getConversationMessageById($conversationId)
    {
        if ($this->conversation->checkUserExist($this->userId, $conversationId)) {
            $channel = $this->getChannelName($conversationId, 'chat_room');

            return $this->conversation->getConversationMessageById($conversationId, $this->userId, $channel);
        }

        abort(404);
    }
1309784
public static function getDbo($config = array(), $cname = '')
	{
		// empty instance of db
		$db = App::get('db');

		// make sure we have a group object
		if (!$group = Group::getInstance(\Request::getString('cn', $cname)))
		{
			return $db;
		}

		// make sure we are a super group
		if (!$group->isSuperGroup())
		{
			return $db;
		}

		// load super group db config if not passed in
		if (empty($config))
		{
			// build path to config file
			$uploadPath = \Component::params( 'com_groups' )->get('uploadpath');
			$configPath = PATH_APP . DS . trim($uploadPath, DS) . DS . $group->get('gidNumber') . DS . 'config' . DS . 'db.php';

			// make sure file exists
			if (!file_exists($configPath))
			{
				return $db;
			}

			// include config
			$config = include $configPath;
		}

		// return instance of db
		return \Hubzero\Database\Driver::getInstance($config);
	}
627185
private function loadConversations(string $uri, ConversationRequest $conversationRequest): PagedCollection
    {
        /** @var HalPagedResources $conversationResources */
        $conversationResources = $this->restClient->getResources(Conversation::class, 'conversations', $uri);
        $conversations = $conversationResources->map(function (HalResource $customerResource) use ($conversationRequest) {
            return $this->hydrateConversationWithSubEntities($customerResource, $conversationRequest);
        });

        return new PagedCollection(
            $conversations,
            $conversationResources->getPageMetadata(),
            $conversationResources->getLinks(),
            function (string $uri) use ($conversationRequest) {
                return $this->loadConversations($uri, $conversationRequest);
            }
        );
    }
1181793
protected function _renderMessage($message, $config)
    {
        $config = new AnConfig($config);

        $config->append(array(
            'type' => 'info',
        ));

        $message = ''
        .'<div class="alert alert-block alert-'.$config->type.'">'
        .'<a class="close" data-dismiss="alert" href="#">&times;</a>'
        .$message
        .'</div>';

        return $message;
    }
1263382
protected function parseCsv($filename, ConfigurationInterface $config)
    {
        $length = $config->getLength();
        $delimiter = $config->getDelimiter();
        $enclosure = $config->getEnclosureChar();
        $escape = $config->getEscapeChar();
        $result = [];

        if (($handle = fopen($filename, 'r')) !== false) {
            while (($row = fgetcsv($handle, $length, $delimiter, $enclosure, $escape)) !== false) {
                $temp = [];

                if (empty($this->attributes)) {
                    if ($config->isFirstLineAsAttributes()) {
                        $this->attributes = $row;
                    } else {
                        $cRow = count($row);
                        for ($i = 0; $i < $cRow; ++$i) {
                            $attrName = 'attribute '.$i;
                            $this->attributes[] = $attrName;
                            $temp[$attrName] = trim($row[$i]);
                        }
                        $result[] = $temp;
                    }
                } else {
                    $cRow = count($row);
                    for ($i = 0; $i < $cRow; ++$i) {
                        $attrName = $this->attributes[$i];
                        $temp[$attrName] = trim($row[$i]);
                    }
                    $result[] = $temp;
                }
            }
            fclose($handle);
        }

        return $result;
    }
179645
function(messageContent) {
                /**
                 * + MessageChangeStateVO       {object}
                 *    - messageId               {long}
                 *    - participantId           {long}
                 *    - conversationId          {long}
                 */

                var MessageChangeState = {
                    messageId: messageContent.messageId,
                    senderId: messageContent.participantId,
                    threadId: messageContent.conversationId
                };

                return MessageChangeState;
            }
588515
public static function getMessage($mailer, ConfigObject $config = null)
    {
        // Do it this way to avoid merging into the original mailer config
        $mailerConfig = Mailer::getConfig()->get($mailer)->toArray();
        $mailerConfig = new ConfigObject($mailerConfig);
        if ($config) {
            $mailerConfig->mergeWith($config);
        }
        $lib = self::getLibrary($mailer);

        /** @var MailerInterface $libInstance */
        $libInstance = self::factory($lib, MailerInterface::class);

        $instance = $libInstance::getMessage($mailerConfig);
        if (!self::isInstanceOf($instance, MessageInterface::class)) {
            throw new MailerException(MailerException::MESSAGE_INTERFACE);
        }

        return $instance;
    }
601114
public function streamCsv(array $data = [], $status = 200, array $config = []): SymfonyResponse
    {
        $filename = $config['filename'] ?? 'export';

        $collection = $this->convertToCsvable($data, $config);

        return Response::stream(function () use ($collection) {
            $collection->streamCsv();
        }, $status, [
            'Content-Type' => 'text/csv',
            'Content-Disposition' => 'attachment; filename="'.$filename.'.csv"',
        ]);
    }
270882
protected function getCommandConfig(Config $config, $command)
    {
        $string = '';
        if (isset($config[$command])) {
            /** @var Config $config */
            $config = $config[$command];
            if ($config->count() > 0) {
                $config = $config->toArray();
                /** @var array $config */
                $string .= $this->commands[$command] . PHP_EOL . '{' . PHP_EOL . "\t";
                $string .= $this->getValuesString($config, true);
                $string .= PHP_EOL . '}' . PHP_EOL;
            }
        }
        return $string;
    }
977600
public function format_message_text($cm, $post) {
        $context = \context_module::instance($cm->id);
        $message = file_rewrite_pluginfile_urls(
            $post->message,
            'pluginfile.php',
            $context->id,
            'mod_forum',
            'post',
            $post->id,
            [
                'includetoken' => true,
            ]);
        $options = new \stdClass();
        $options->para = true;
        $options->context = $context;
        return format_text($message, $post->messageformat, $options);
    }
1251894
private function sendMessage($groupConversationId, array $data)
    {
        $conversation = $this->find($groupConversationId);

        $created = $conversation->messages()
            ->create([
                'text'    => $data['text'],
                'user_id' => $data['user_id'],
            ]);

        if ($created) {
            if (array_key_exists('file', $data)) {
                foreach ($data['file'] as $file) {
                    $fileName = Carbon::now()->format('YmdHis').'-'.$file->getClientOriginalName();
                    $path = str_finish('', '/').$fileName;
                    $content = File::get($file->getRealPath());
                    $result = $this->manager->saveFile($path, $content);

                    if ($result === true) {
                        $conversation->files()->create([
                            'message_id' => $created->id,
                            'name'       => $fileName,
                            'user_id'    => $data['user_id'],
                        ]);
                    }
                }
            }

            $data['files'] = $conversation->messages()->find($created->id)->files()->get();

            broadcast(new NewGroupConversationMessage($data['text'], $data['channel'], $data['files']));

            return true;
        }

        return false;
    }
225204
private function hydrateConversationWithSubEntities(
        HalResource $conversationResource,
        ConversationRequest $conversationRequest
    ): Conversation {
        $conversationLoader = new ConversationLoader($this->restClient, $conversationResource, $conversationRequest->getLinks());
        $conversationLoader->load();

        return $conversationResource->getEntity();
    }
372222
public function lock_message($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'entity' => null
        ));

        if (!($config->entity instanceof ModelEntityInterface)) {
            throw new \UnexpectedValueException('$config->entity should be a ModelEntityInterface instance');
        }

        $entity = $config->entity;
        $message = '';

        if($entity->isLockable() && $entity->isLocked())
        {
            $user = $entity->getLocker();
            $date = $this->getObject('date', array('date' => $entity->locked_on));

            $message = $this->getObject('translator')->translate(
                'Locked by {name} {date}', array('name' => $user->getName(), 'date' => $date->humanize())
            );
        }

        return $message;
    }
676236
protected static function createMessage(string $to, string $subject, string $from = 'default'): Swift_Message
    {
        $fromName = $from === 'default' ? self::$config['from']['default'] : $from;
        $from     = self::$config['from'][$fromName];

        return (new Swift_Message())
            ->setContentType('text/html')
            ->setSubject($subject)
            ->setFrom([$from['address'] => $from['name']])
            ->setTo($to)
            ;
    }
486478
function (message, config, cb) {
        if(typeof config === 'function') {
            cb = config;
            config = {};
        }
        var stdin = config.stdin || process.stdin,
            stdout = config.stdout || process.stdout,
            prompt = config.prompt || '\u203A';
        stdout.write('  ' + message + '\n  ' + prompt + ' ');
        stdin.resume();
        stdin.setEncoding('utf8');
        stdin.on('data', function (text) {
            text = text.trim().replace(/\r\n|\n/, '');
            cb(text);
        });
    }