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