You are here

mylivechat.module in My Live Chat 6

Same filename and directory in other branches
  1. 7 mylivechat.module

File

mylivechat.module
View source
<?php

// $Id$
require_once drupal_get_path('module', 'mylivechat') . '/mylivechat.php';

/*
 * @file
 * Drupal Module: mylivechat
 */
function mylivechat_menu() {
  $items['admin/settings/mylivechat'] = array(
    'title' => 'MyLiveChat',
    'description' => 'Integrate MyLiveChat software with your website.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'mylivechat_admin_settings_form',
    ),
    'access arguments' => array(
      'administer mylivechat',
    ),
    'file' => 'mylivechat.admin.inc',
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}
function mylivechat_init() {
  mylivechat::get_instance()
    ->install_codes();
}
function mylivechat_block($op = 'list', $delta = '', $edit = array()) {
  $mylivechat = mylivechat::get_instance();

  // The $op parameter determines what piece of information is being requested.
  switch ($op) {
    case 'list':

      // If $op is "list", we just need to return a list of block descriptions.
      // This is used to provide a list of possible blocks to the administrator;
      // end users will not see these descriptions.
      $blocks['live-chat-display'] = array(
        'info' => t('MyLiveChat'),
      );

      // A block can provide default settings. In this case we'll enable the
      // block and make it visible only on the 'node/*' pages.
      return $blocks;
    case 'view':

      // If $op is "view", then we need to generate the block for display
      // purposes. The $delta parameter tells us which block is being requested.
      switch ($delta) {
        case 'live-chat-display':

          // The content of the block is typically generated by calling a custom
          // function.
          $block['content'] = $mylivechat
            ->getChatCode();
          break;
      }
      return $block;
  }
}