/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return array Array of stdcommand, stdhtml, stdout, and stderr responses */ function run($options, $parameters, &$occle_fs) { if (array_key_exists('h', $options) || array_key_exists('help', $options)) { return array('', do_command_help('send_chatmessage', array('h'), array(true, true)), '', ''); } else { if (!array_key_exists(0, $parameters)) { return array('', '', '', do_lang('MISSING_PARAM', '1', 'send_chatmessage')); } if (!array_key_exists(1, $parameters)) { return array('', '', '', do_lang('MISSING_PARAM', '2', 'send_chatmessage')); } require_code('chat'); if (is_numeric($parameters[0])) { $chatroom = $parameters[0]; } elseif ($parameters[0] == 'first-watched') { $_chatroom = get_value('occle_watched_chatroom'); $chatroom = is_null($_chatroom) ? $GLOBALS['SITE_DB']->query_value_null_ok('chat_rooms', 'id', NULL, 'ORDER BY id') : intval($_chatroom); } else { $chatroom = get_chatroom_id($parameters[0]); } if (is_null($chatroom)) { return array('', '', '', do_lang('MISSING_RESOURCE')); } chat_post_message($chatroom, $parameters[1], get_option('chat_default_post_font'), get_option('chat_default_post_colour')); return array('', '', do_lang('SUCCESS'), ''); } }
/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return array Array of stdcommand, stdhtml, stdout, and stderr responses */ function run($options, $parameters, &$occle_fs) { if (array_key_exists('h', $options) || array_key_exists('help', $options)) { return array('', do_command_help('watch_chatroom', array('h', 'u'), array(true)), '', ''); } else { require_code('chat'); if (array_key_exists('u', $options) || array_key_exists('unwatch', $options)) { delete_value('occle_watched_chatroom'); $_chatroom = do_lang('SUCCESS'); } elseif (array_key_exists(0, $parameters)) { if (is_numeric($parameters[0])) { $chatroom = $parameters[0]; } else { $chatroom = get_chatroom_id($parameters[0]); } if (is_null($chatroom)) { return array('', '', '', do_lang('MISSING_RESOURCE')); } set_value('occle_watched_chatroom', $chatroom); $_chatroom = get_chatroom_name($chatroom); } else { $_chatroom = get_chatroom_name(intval(get_value('occle_watched_chatroom')), true); if (is_null($_chatroom)) { return array('', '', '', do_lang('MISSING_RESOURCE')); } } return array('', '', $_chatroom, ''); } }
/** * Parse invitation chat code tag. * * @param string Comma-separated list of members to invite * @param string The room name * @param SHORT_TEXT The username of who made this chatcode * @param string The text we are using * @param ID_TEXT The zone the chat module is in * @return array A pair: whether the message was deleted, and the new text of the message */ function _deal_with_chatcode_invite($pm_user, $pm_message, $username, $text, $zone) { $pm_message_deleted = false; // This deals with the [invite="user"]room[/invite] tag $quoted_users = explode(',', $pm_user); foreach ($quoted_users as $quoted_user) { $real_member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($quoted_user) == get_member() && !is_guest($GLOBALS['FORUM_DRIVER']->get_member_from_username($quoted_user)) && !is_null($GLOBALS['FORUM_DRIVER']->get_member_from_username($quoted_user)) || $username == $GLOBALS['FORUM_DRIVER']->get_username(get_member()); if ($real_member) { $room_id = get_chatroom_id(chat_convert_html_entities($pm_message), true); if (!is_null($room_id)) { // Display the invite $invite_code = do_template('CHAT_INVITE', array('_GUID' => '493ac2dcabc763fe03e7eee072dd9629', 'USERNAME' => $username, 'ROOM' => chat_convert_html_entities($pm_message), 'LINK' => hyperlink(build_url(array('page' => 'chat', 'type' => 'room', 'room_id' => strval($room_id)), $zone), do_lang_tempcode('CHAT_INVITE_TEXT_REPLY')))); $text = preg_replace('#\\[invite="([^&]*)"\\]([^\\[]*)\\[/invite\\]#', $invite_code->evaluate(), $text, 1); } } if (!$real_member || is_null($room_id)) { // Replace the invite with nothingness $text = preg_replace('#\\[invite="([^&]*)"\\]([^\\[]*)\\[/invite\\]#', '', $text, 1); if (is_null($text) || $text == '') { $pm_message_deleted = true; } } } return array('pm_message_deleted' => $pm_message_deleted, 'text' => $text); }