' . t('Have questions? Please contact Chatroll Support at @support-display-url.', array('@support-url' => 'http://chatroll.com/help/support?r=drupal-module', '@support-display-url' => 'http://chatroll.com/help/support')) . '
'; break; } return $output; } /** * Implements of hook_perm(). */ function chatroll_permission() { // Array of valid permissions for Chatroll module: // This permission is used to generate the ismod SSO param return array( 'moderate chatroll' => array( 'title' => t('Moderate chatroll'), 'description' => t('Moderate chatroll'), ), ); } /** * Implements hook_block_info(). */ function chatroll_block_info() { // Define two Blocks, to make it easy to embed the same chatroll in // different formats: sidebar and content body // e.g. user can choose to embed a chat on the sidebar, and/or // create a dedicated chat page // Users looking to embed additional chats will need the MultiBlock // module (http://drupal.org/project/multiblock) // or integrate using PHP snippets inside node content // Cache PER USER, since Single Sign On (SSO) parameters will vary // for each user return array( 'chatroll_sidebar' => array('info' => t('Chatroll: Sidebar'), 'cache' => DRUPAL_CACHE_PER_USER), 'chatroll_content' => array('info' => t('Chatroll: Content'), 'cache' => DRUPAL_CACHE_PER_USER), ); } /** * Implements hook_block_configure(). */ function chatroll_block_configure($delta = '') { // Note: We allow different embed HTML config for each block, for different size/color/format $form['chatroll_shortcode_' . $delta] = array( '#type' => 'textfield', '#size' => 80, '#maxlength' => 200, '#title' => t('Chatroll Shortcode'), '#default_value' => variable_get('chatroll_shortcode_' . $delta, ''), '#description' => t("Copy and paste your Chatroll Shortcode here. Your Shortcode can be found on your Chatroll's Settings -> Widget -> Install page on !chatroll-domain", array('@chatroll-url' => 'http://chatroll.com', '!chatroll-domain' => 'chatroll.com')), '#required' => TRUE, ); $form['chatroll_width_' . $delta] = array( '#type' => 'textfield', '#title' => t('Width'), '#default_value' => variable_get('chatroll_width_' . $delta, '100%'), '#size' => 5, '#maxlength' => 5, '#description' => t('Set the width of your Chatroll'), '#required' => TRUE, ); $form['chatroll_height_' . $delta] = array( '#type' => 'textfield', '#title' => t('Height'), '#default_value' => variable_get('chatroll_height_' . $delta, '300'), '#size' => 5, '#maxlength' => 5, '#description' => t("Set the height of your Chatroll."), '#required' => TRUE, ); return $form; } /** * Implements of hook_block_save() */ function chatroll_block_save($delta = '', $edit = array()) { variable_set('chatroll_shortcode_' . $delta, $edit['chatroll_shortcode_' . $delta]); variable_set('chatroll_width_' . $delta, $edit['chatroll_width_' . $delta]); variable_set('chatroll_height_' . $delta, $edit['chatroll_height_' . $delta]); } /** * Implementation of hook_block_view() */ function chatroll_block_view($delta = '') { $block = array(); $block['content'] = chatroll_render_block($delta); return $block; } /** * Implementation of hook_theme() */ function chatroll_theme() { return array( 'chatroll_iframe' => array( 'arguments' => array( 'attributes' => NULL, ), ), ); } /** * Render Chatroll IFrame theme hook * * Renders Chatroll IFrame HTML. * * @param $attributes * IFrame attributes, including the src URL to the hosted Chatroll instance */ function theme_chatroll_iframe($attributes = array()) { return ''; } /** * Render Chatroll Block * * Renders Chatroll based on the block configuration values. * * @param $delta * Integer identifier of the specific Chatroll block. */ function chatroll_render_block($delta) { module_load_include('inc', 'chatroll', 'chatroll.drupal'); $chatroll = new Chatroll(); $chatroll->width= check_plain(variable_get('chatroll_width_' . $delta, '')); $chatroll->height = check_plain(variable_get('chatroll_height_' . $delta, '')); // Shortcode syntax is validated within Chatroll class, does not need check_plain(). return $chatroll->renderChatrollHtmlFromShortcode(variable_get('chatroll_shortcode_' . $delta, '')); }