plugins/ajim/client.php
author Dan
Sun, 11 Jan 2009 21:38:42 -0500
changeset 0 db23957ad1c7
permissions -rw-r--r--
First commit; requires latest Enano from Hg. It works!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     1
<?php
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     2
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     3
$plugins->attachHook('compile_template', 'ajim_compile_sidebar();');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     4
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     5
function ajim_compile_sidebar()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     6
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     7
  global $db, $session, $paths, $template, $plugins; // Common objects
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     8
  global $lang;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     9
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    10
  $template->add_header('<link rel="stylesheet" type="text/css" href="' . scriptPath . '/plugins/ajim/shoutbox.css" />');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    11
  $template->add_header('<script type="text/javascript" src="' . scriptPath . '/plugins/ajim/shoutbox.js"></script>');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    12
  $can_mod = $session->get_permissions('ajim_mod') ? 'true' : 'false';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    13
  $template->add_header('<script type="text/javascript">
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    14
      var ajim_can_mod = ' . $can_mod . ';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    15
      var ajim_str_edit = "' . addslashes($lang->get('ajim_btn_edit')) . '";
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    16
      var ajim_str_delete = "' . addslashes($lang->get('ajim_btn_delete')) . '";
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    17
      var ajim_str_no_posts = "' . addslashes($lang->get('ajim_msg_no_posts')) . '";
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    18
      var ajim_user_id = ' . $session->user_id . ';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    19
    </script>');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    20
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    21
  $msg_loading = $lang->get('ajim_msg_loading');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    22
  $html = '<div class="ajim_wrapper">';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    23
  $html .= <<<__EOF
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    24
    <div id="ajim_messages" class="ajim_messages">
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    25
      <div id="ajim_error">
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    26
      </div>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    27
      <span class="ajim_noposts" id="ajim_noposts">
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    28
        $msg_loading
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    29
      </span>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    30
    </div>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    31
    <div class="ajim_form">
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    32
__EOF;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    33
  if ( $session->get_permissions('ajim_post') )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    34
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    35
    if ( $session->user_logged_in )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    36
    {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    37
      $html .= '<input type="hidden" id="ajim_nickname" value="' . htmlspecialchars($session->username) . '" />';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    38
    }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    39
    else
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    40
    {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    41
      $l_name = $lang->get('ajim_lbl_name');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    42
      $l_site = $lang->get('ajim_lbl_website');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    43
      $html .= <<<______EOF
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    44
        <table border="0" cellspacing="3">
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    45
          <tr>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    46
            <td>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    47
              $l_name
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    48
            </td>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    49
            <td>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    50
              <input type="text" class="ajim_field" id="ajim_nickname" value="Guest" />
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    51
            </td>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    52
          </tr>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    53
        </table>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    54
______EOF;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    55
    }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    56
    $b_submit = $lang->get('ajim_btn_submit');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    57
    $html .= '<textarea id="ajim_message" rows="2" cols="20"></textarea>';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    58
    $html .= <<<____EOF
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    59
      <div class="ajim_submit_wrap">
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    60
        <input type="submit" id="ajim_submit" value="{$b_submit}" onclick="ajim_submit_message();" />
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    61
      </div>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    62
____EOF;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    63
    if ( $session->get_permissions('ajim_mod') )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    64
    {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    65
      $html .= '<div id="ajim_mod">';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    66
      if ( $session->auth_level < USER_LEVEL_CHPREF )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    67
      {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    68
        $html .= '<a href="#" class="ajim_modlink" onclick="ajim_handle_click_mod(); return false;">' . $lang->get('ajim_btn_mod') . '</a>';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    69
      }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    70
      $html .= '</div>';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    71
    }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    72
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    73
  else
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    74
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    75
    $msg_nopost = $lang->get('ajim_msg_no_post');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    76
    $html .= <<<____EOF
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    77
      $msg_nopost
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    78
____EOF;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    79
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    80
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    81
  $html .= '  </div>
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    82
            </div>';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    83
  $template->sidebar_widget('AjIM Shoutbox', $html);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    84
}