Changeset 396162
- Timestamp:
- 06/12/2011 06:39:06 AM (15 years ago)
- File:
-
- 1 edited
-
chat/trunk/chat.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
chat/trunk/chat.php
r381641 r396162 1 <?php 2 /* 3 Plugin Name: Chat Lite 4 Plugin URI: http://premium.wpmudev.org/project/wordpress-chat-plugin 5 Description: Provides you with a fully featured chat area either in a 6 post, page or bottom corner of your site - once activated configure <a 7 href="options-general.php?page=chat">here</a> and drop into a post or 8 page by clicking on the new chat icon in your post/page editor. 9 Author: S H Mohanjith (Incsub) 10 WDP ID: 223 11 Version: 1.0.5 12 Stable tag: trunk 13 Author URI: http://premium.wpmudev.org 14 */ 15 /** 16 * @global object $chat Convenient access to the chat object 17 */ 18 global $chat; 19 20 /** 21 * Chat object (PHP4 compatible) 22 * 23 * Allow your readers to chat with you 24 * 25 * @since 1.0.0 26 * @author S H Mohanjith <[email protected]> 27 */ 28 if (!class_exists('Chat')) { 29 class Chat { 30 /** 31 * @todo Update version number for new releases 32 * 33 * @var string $chat_current_version Current version 34 */ 35 var $chat_current_version = '1.0.4'; 36 37 /** 38 * @var string $translation_domain Translation domain 39 */ 40 var $translation_domain = 'chat'; 41 42 /** 43 * @var array $auth_type_map Authentication methods map 44 */ 45 var $auth_type_map = array(1 => 'current_user', 2 => 'network_user', 3 => 'facebook', 4 => 'twitter', 5 => 'public_user'); 46 47 /** 48 * @var array $fonts_list List of fonts 49 */ 50 var $fonts_list = array( 51 "Arial" => "Arial, Helvetica, sans-serif", 52 "Arial Black" => "'Arial Black', Gadget, sans-serif", 53 "Bookman Old Style" => "'Bookman Old Style', serif", 54 "Comic Sans MS" => "'Comic Sans MS', cursive", 55 "Courier" => "Courier, monospace", 56 "Courier New" => "'Courier New', Courier, monospace", 57 "Garamond" => "Garamond, serif", 58 "Georgia" => "Georgia, serif", 59 "Impact" => "Impact, Charcoal, sans-serif", 60 "Lucida Console" => "'Lucida Console', Monaco, monospace", 61 "Lucida Sans Unicode" => "'Lucida Sans Unicode', 'Lucida Grande', sans-serif", 62 "MS Sans Serif" => "'MS Sans Serif', Geneva, sans-serif", 63 "MS Serif" => "'MS Serif', 'New York', sans-serif", 64 "Palatino Linotype" => "'Palatino Linotype', 'Book Antiqua', Palatino, serif", 65 "Symbol" => "Symbol, sans-serif", 66 "Tahoma" => "Tahoma, Geneva, sans-serif", 67 "Times New Roman" => "'Times New Roman', Times, serif", 68 "Trebuchet MS" => "'Trebuchet MS', Helvetica, sans-serif", 69 "Verdana" => "Verdana, Geneva, sans-serif", 70 "Webdings" => "Webdings, sans-serif", 71 "Wingdings" => "Wingdings, 'Zapf Dingbats', sans-serif" 72 ); 73 74 /** 75 * @var array $_chat_options Consolidated options 76 */ 77 var $_chat_options = array(); 78 79 /** 80 * Get the table name with prefixes 81 * 82 * @global object $wpdb 83 * @param string $table Table name 84 * @return string Table name complete with prefixes 85 */ 86 function tablename($table) { 87 global $wpdb; 88 // We use a single table for all chats accross the network 89 return $wpdb->base_prefix.'chat_'.$table; 90 } 91 92 /** 93 * Initializing object 94 * 95 * Plugin register actions, filters and hooks. 96 */ 97 function Chat() { 98 99 // Activation deactivation hooks 100 101 register_activation_hook(__FILE__, array(&$this, 'install')); 102 register_deactivation_hook(__FILE__, array(&$this, 'uninstall')); 103 104 // Actions 105 106 add_action('init', array(&$this, 'init')); 107 add_action('wp_head', array(&$this, 'wp_head'), 1); 108 add_action('wp_head', array(&$this, 'output_css')); 109 add_action('wp_footer', array(&$this, 'wp_footer'), 1); 110 // add_action('admin_head', array($this, 'admin_head')); 111 add_action('save_post', array(&$this, 'post_check')); 112 add_action('edit_user_profile', array(&$this, 'profile')); 113 add_action('show_user_profile', array(&$this, 'profile')); 114 115 add_action('admin_print_styles-settings_page_chat', array(&$this, 'admin_styles')); 116 add_action('admin_print_scripts-settings_page_chat', array(&$this, 'admin_scripts')); 117 118 // Filters 119 // From process.php 120 add_action('wp_ajax_chatProcess', array(&$this, 'process')); 121 add_action('wp_ajax_nopriv_chatProcess', array(&$this, 'process')); 122 123 // Only authenticated users (admin) can clear and archive 124 add_action('wp_ajax_chatArchive', array(&$this, 'archive')); 125 add_action('wp_ajax_chatClear', array(&$this, 'clear')); 126 127 // TinyMCE options 128 add_action('wp_ajax_chatTinymceOptions', array(&$this, 'tinymce_options')); 129 130 add_filter('wp_redirect', array(&$this, 'profile_process'), 1, 1); 131 add_filter('admin_menu', array(&$this, 'admin_menu')); 132 133 // White list the options to make sure non super admin can save chat options 134 add_filter('whitelist_options', array(&$this, 'whitelist_options')); 135 136 // Add shortcode 137 add_shortcode('chat', array(&$this, 'process_shortcode')); 138 139 $this->_chat_options['default'] = get_option('chat_default', array( 140 'sound' => 'enabled', 141 'avatar' => 'enabled', 142 'emoticons' => 'disabled', 143 'date_show' => 'disabled', 144 'time_show' => 'disabled', 145 'width' => '', 146 'height' => '', 147 'background_color' => '#FFFFFF', 148 'date_color' => '#6699CC', 149 'name_color' => '#666666', 150 'moderator_name_color' => '#6699CC', 151 'special_color' => '#660000', 152 'text_color' => '#000000', 153 'code_color' => '#FFFFCC', 154 'font' => '', 155 'font_size' => '12', 156 'log_creation' => 'disabled', 157 'log_display' => 'disabled', 158 'login_options' => array('current_user'), 159 'moderator_roles' => array('administrator','editor','author') 160 )); 161 162 $this->_chat_options['site'] = get_option('chat_site', array( 163 'site' => 'enabled', 164 'sound' => 'enabled', 165 'avatar' => 'enabled', 166 'emoticons' => 'disabled', 167 'date_show' => 'disabled', 168 'time_show' => 'disabled', 169 'width' => '', 170 'height' => '', 171 'border_color' => '#4b96e2', 172 'background_color' => '#FFFFFF', 173 'date_color' => '#6699CC', 174 'name_color' => '#666666', 175 'moderator_name_color' => '#6699CC', 176 'special_color' => '#660000', 177 'text_color' => '#000000', 178 'code_color' => '#FFFFCC', 179 'font' => '', 180 'font_size' => '12', 181 'log_creation' => 'disabled', 182 'log_display' => 'disabled', 183 'login_options' => array('current_user'), 184 'moderator_roles' => array('administrator','editor','author'))); 185 } 186 187 /** 188 * Activation hook 189 * 190 * Create tables if they don't exist and add plugin options 191 * 192 * @see http://codex.wordpress.org/Function_Reference/register_activation_hook 193 * 194 * @global object $wpdb 195 */ 196 function install() { 197 global $wpdb; 198 199 /** 200 * WordPress database upgrade/creation functions 201 */ 202 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 203 204 // Get the correct character collate 205 if ( ! empty($wpdb->charset) ) 206 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 207 if ( ! empty($wpdb->collate) ) 208 $charset_collate .= " COLLATE $wpdb->collate"; 209 210 if($wpdb->get_var("SHOW TABLES LIKE '". Chat::tablename('message') ."'") != Chat::tablename('message')) 211 { 212 // Setup chat message table 213 $sql_main = "CREATE TABLE ".Chat::tablename('message')." ( 214 id BIGINT NOT NULL AUTO_INCREMENT, 215 blog_id INT NOT NULL , 216 chat_id INT NOT NULL , 217 timestamp TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' , 218 name VARCHAR( 255 ) CHARACTER SET utf8 NOT NULL , 219 avatar VARCHAR( 1024 ) CHARACTER SET utf8 NOT NULL , 220 message TEXT CHARACTER SET utf8 NOT NULL , 221 moderator ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' , 222 archived ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' , 223 PRIMARY KEY (`id`), 224 KEY `blog_id` (`blog_id`), 225 KEY `chat_id` (`chat_id`), 226 KEY `timestamp` (`timestamp`), 227 KEY `archived` (`archived`) 228 ) ENGINE = InnoDB {$charset_collate};"; 229 dbDelta($sql_main); 230 } else { 231 $wpdb->query("ALTER TABLE ".Chat::tablename('message')." CHANGE name name VARCHAR( 255 ) CHARACTER SET utf8 NOT NULL;"); 232 $wpdb->query("ALTER TABLE ".Chat::tablename('message')." CHANGE avatar avatar VARCHAR( 1024 ) CHARACTER SET utf8 NOT NULL;"); 233 $wpdb->query("ALTER TABLE ".Chat::tablename('message')." CHANGE message message TEXT CHARACTER SET utf8 NOT NULL;"); 234 235 if ($wpdb->get_var("SHOW COLUMNS FROM ".Chat::tablename('message')." LIKE 'moderator'") != 'moderator') { 236 $wpdb->query("ALTER TABLE ".Chat::tablename('message')." ADD moderator ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER message;"); 237 } 238 } 239 240 // Setup the chat log table 241 $sql_main = "CREATE TABLE ".Chat::tablename('log')." ( 242 id BIGINT NOT NULL AUTO_INCREMENT, 243 blog_id INT NOT NULL , 244 chat_id INT NOT NULL , 245 start TIMESTAMP DEFAULT '0000-00-00 00:00:00' , 246 end TIMESTAMP DEFAULT '0000-00-00 00:00:00' , 247 created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 248 PRIMARY KEY (`id`), 249 KEY `blog_id` (`blog_id`), 250 KEY `chat_id` (`chat_id`) 251 ) ENGINE = InnoDB {$charset_collate};"; 252 dbDelta($sql_main); 253 254 // Default chat options 255 $this->_chat_options['default'] = array( 256 'sound' => 'enabled', 257 'avatar' => 'enabled', 258 'emoticons' => 'disabled', 259 'date_show' => 'disabled', 260 'time_show' => 'disabled', 261 'width' => '', 262 'height' => '', 263 'background_color' => '#ffffff', 264 'date_color' => '#6699CC', 265 'name_color' => '#666666', 266 'moderator_name_color' => '#6699CC', 267 'special_color' => '#660000', 268 'text_color' => '#000000', 269 'code_color' => '#FFFFCC', 270 'font' => '', 271 'font_size' => '12', 272 'log_creation' => 'disabled', 273 'log_display' => 'disabled', 274 'login_options' => array('current_user'), 275 'moderator_roles' => array('administrator','editor','author')); 276 277 // Site wide chat options 278 $this->_chat_options['site'] = array( 279 'site' => 'enabled', 280 'sound' => 'enabled', 281 'avatar' => 'enabled', 282 'emoticons' => 'disabled', 283 'date_show' => 'disabled', 284 'time_show' => 'disabled', 285 'width' => '', 286 'height' => '', 287 'border_color' => '#4b96e2', 288 'background_color' => '#ffffff', 289 'date_color' => '#6699CC', 290 'name_color' => '#666666', 291 'moderator_name_color' => '#6699CC', 292 'special_color' => '#660000', 293 'text_color' => '#000000', 294 'code_color' => '#FFFFCC', 295 'font' => '', 296 'font_size' => '12', 297 'log_creation' => 'disabled', 298 'log_display' => 'disabled', 299 'login_options' => array('current_user'), 300 'moderator_roles' => array('administrator','editor','author')); 301 302 add_option('chat_default', $this->_chat_options['default']); 303 add_option('chat_site', $this->_chat_options['site'], null, 'no'); 304 } 305 306 /** 307 * Deactivation hook 308 * 309 * @see http://codex.wordpress.org/Function_Reference/register_deactivation_hook 310 * 311 * @global object $wpdb 312 */ 313 function uninstall() { 314 global $wpdb; 315 // Nothing to do 316 } 317 318 /** 319 * Get chat options 320 * 321 * @param string $key 322 * @param mixed $default 323 * @param string $type 324 * @return mixed 325 */ 326 function get_option($key, $default = null, $type = 'default') { 327 if (isset($this->_chat_options[$type][$key])) { 328 return $this->_chat_options[$type][$key]; 329 } else { 330 return get_option($key, $default); 331 } 332 return $default; 333 } 334 335 /** 336 * Initialize the plugin 337 * 338 * @see http://codex.wordpress.org/Plugin_API/Action_Reference 339 * @see http://adambrown.info/p/wp_hooks/hook/init 340 */ 341 function init() { 342 if (preg_match('/mu\-plugin/', PLUGINDIR) > 0) { 343 load_muplugin_textdomain($this->translation_domain, dirname(plugin_basename(__FILE__)).'/languages'); 344 } else { 345 load_plugin_textdomain($this->translation_domain, false, dirname(plugin_basename(__FILE__)).'/languages'); 346 } 347 348 wp_register_script('chat_soundmanager', plugins_url('chat/js/soundmanager2-nodebug-jsmin.js'), array(), $this->chat_current_version); 349 wp_register_script('jquery-cookie', plugins_url('chat/js/jquery-cookie.js'), array('jquery')); 350 // wp_register_script('jquery-blockUI', plugins_url('chat/js/jquery.blockUI.js'), array('jquery')); 351 wp_register_script('chat_js', plugins_url('chat/js/chat.js'), array('jquery', 'jquery-cookie', 'chat_soundmanager'), $this->chat_current_version, true); 352 353 if (is_admin()) { 354 wp_register_script('farbtastic', plugins_url('chat/js/farbtastic.js'), array('jquery')); 355 wp_register_script('chat_admin_js', plugins_url('chat/js/chat-admin.js'), array('jquery','jquery-cookie','jquery-ui-core','jquery-ui-tabs','farbtastic'), $this->chat_current_version, true); 356 wp_register_style('chat_admin_css', plugins_url('chat/css/wp_admin.css')); 357 } 358 359 if ((current_user_can('edit_posts') || current_user_can('edit_pages')) && get_user_option('rich_editing') == 'true') { 360 add_filter("mce_external_plugins", array(&$this, "tinymce_add_plugin")); 361 add_filter('mce_buttons', array(&$this,'tinymce_register_button')); 362 add_filter('mce_external_languages', array(&$this,'tinymce_load_langs')); 363 } 364 365 // Need to stop any output until cookies are set 366 ob_start(); 367 } 368 369 /** 370 * Add the CSS (admin_head) 371 * 372 * @see http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head-(plugin_page) 373 */ 374 function admin_styles() { 375 wp_enqueue_style('chat_admin_css'); 376 } 377 378 function admin_scripts() { 379 wp_enqueue_script('jquery-cookie'); 380 wp_enqueue_script('farbtastic'); 381 //wp_enqueue_script('jquery-blockUI'); 382 wp_enqueue_script('chat_admin_js'); 383 } 384 385 /** 386 * Add the admin menus 387 * 388 * @see http://codex.wordpress.org/Adding_Administration_Menus 389 */ 390 function admin_menu() { 391 add_options_page(__('Chat Plugin Options', $this->translation_domain), __('Chat', $this->translation_domain), 8, 'chat', array(&$this, 'plugin_options')); 392 } 393 394 /** 395 * Is Twitter setup complete 396 * 397 * @return boolean Is Twitter setup complete. true or false 398 */ 399 function is_twitter_setup() { 400 if ($this->get_option('twitter_api_key', '') != '') { 401 return true; 402 } 403 return false; 404 } 405 406 /** 407 * Is Facebook setup complete 408 * 409 * @todo Validate the application ID and secret with Facebook 410 * 411 * @return boolean Is Facebook setup complete. true or false 412 */ 413 function is_facebook_setup() { 414 if ($this->get_option('facebook_application_id', '') != '' && $this->get_option('facebook_application_secret', '') != '') { 415 return true; 416 } 417 return false; 418 } 419 420 /** 421 * TinyMCE dialog content 422 */ 423 function tinymce_options() { 424 ?> 425 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 426 <html> 427 <head> 428 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 429 <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce_popup.js?ver=327-1235"></script> 430 <script type="text/javascript" src="../wp-includes/js/tinymce/utils/mctabs.js?ver=327-1235"></script> 431 <script type="text/javascript" src="../wp-includes/js/tinymce/utils/validate.js?ver=327-1235"></script> 432 433 <script type="text/javascript" src="../wp-includes/js/tinymce/utils/form_utils.js?ver=327-1235"></script> 434 <script type="text/javascript" src="../wp-includes/js/tinymce/utils/editable_selects.js?ver=327-1235"></script> 435 436 <script type="text/javascript" src="../wp-includes/js/jquery/jquery.js"></script> 437 438 <script type="text/javascript"> 439 var default_options = { 440 id: "<?php print $this->get_last_chat_id(); ?>", 441 sound: "<?php print $this->get_option('sound', 'enabled'); ?>", 442 avatar: "<?php print $this->get_option('avatar', 'enabled'); ?>", 443 emoticons: "<?php print $this->get_option('emoticons', 'disabled'); ?>", 444 date_show: "<?php print $this->get_option('date_show', 'disabled'); ?>", 445 time_show: "<?php print $this->get_option('time_show', 'disabled'); ?>", 446 width: "<?php print $this->get_option('width', ''); ?>", 447 height: "<?php print $this->get_option('height', ''); ?>", 448 background_color: "<?php print $this->get_option('background_color', '#ffffff'); ?>", 449 date_color: "<?php print $this->get_option('date_color', '#6699CC'); ?>", 450 name_color: "<?php print $this->get_option('name_color', '#666666'); ?>", 451 moderator_name_color: "<?php print $this->get_option('moderator_name_color', '#6699CC'); ?>", 452 text_color: "<?php print $this->get_option('text_color', '#000000'); ?>", 453 font: "<?php print $this->get_option('font', ''); ?>", 454 font_size: "<?php print $this->get_option('font_size', '12'); ?>", 455 log_creation: "<?php print $this->get_option('log_creation', 'disabled'); ?>", 456 log_display: "<?php print $this->get_option('log_display', 'disabled'); ?>", 457 login_options: "<?php print join(',', $this->get_option('login_options', array('current_user'))); ?>", 458 moderator_roles: "<?php print join(',', $this->get_option('moderator_roles', array('administrator','editor','author'))); ?>" 459 }; 460 461 var current_options = { 462 id: default_options.id+Math.floor(Math.random()*10), 463 sound: "<?php print $this->get_option('sound', 'enabled'); ?>", 464 avatar: "<?php print $this->get_option('avatar', 'enabled'); ?>", 465 emoticons: "<?php print $this->get_option('emoticons', 'disabled'); ?>", 466 date_show: "<?php print $this->get_option('date_show', 'disabled'); ?>", 467 time_show: "<?php print $this->get_option('time_show', 'disabled'); ?>", 468 width: "<?php print $this->get_option('width', ''); ?>", 469 height: "<?php print $this->get_option('height', ''); ?>", 470 background_color: "<?php print $this->get_option('background_color', '#ffffff'); ?>", 471 date_color: "<?php print $this->get_option('date_color', '#6699CC'); ?>", 472 name_color: "<?php print $this->get_option('name_color', '#666666'); ?>", 473 moderator_name_color: "<?php print $this->get_option('moderator_name_color', '#6699CC'); ?>", 474 text_color: "<?php print $this->get_option('text_color', '#000000'); ?>", 475 font: "<?php print $this->get_option('font', ''); ?>", 476 font_size: "<?php print $this->get_option('font_size', '12'); ?>", 477 log_creation: "<?php print $this->get_option('log_creation', 'disabled'); ?>", 478 log_display: "<?php print $this->get_option('log_display', 'disabled'); ?>", 479 login_options: "<?php print join(',', $this->get_option('login_options', array('current_user'))); ?>", 480 moderator_roles: "<?php print join(',', $this->get_option('moderator_roles', array('administrator','editor','author'))); ?>" 481 }; 482 483 parts = tinyMCEPopup.editor.selection.getContent().replace(' ]', '').replace('[', '').split(' '); 484 old_string = ''; 485 486 if (!(parts.length > 1 && parts[0] == 'chat')) { 487 _tmp = tinyMCEPopup.editor.getContent().split('[chat '); 488 if (_tmp.length > 1) { 489 _tmp1 = _tmp[1].split(' ]'); 490 old_string = '[chat '+_tmp1[0]+' ]'; 491 parts = (old_string).replace(' ]', '').replace('[', '').split(' '); 492 } 493 } 494 495 if (parts.length > 1 && parts[0] == 'chat') { 496 current_options.id = parts[1].replace('id="', '').replace('"', ''); 497 498 for (i=2; i<parts.length; i++) { 499 attr_parts = parts[i].split('='); 500 if (attr_parts.length > 1) { 501 current_options[attr_parts[0]] = attr_parts[1].replace('"', '').replace('"', ''); 502 } 503 } 504 } 505 506 var insertChat = function (ed) { 507 output ='[chat id="'+current_options.id+'" '; 508 509 if (default_options.sound != jQuery.trim(jQuery('#chat_sound').val())) { 510 output += 'sound="'+jQuery.trim(jQuery('#chat_sound').val())+'" '; 511 } 512 if (default_options.date_show != jQuery.trim(jQuery('#chat_date_show').val())) { 513 output += 'date_show="'+jQuery.trim(jQuery('#chat_date_show').val())+'" '; 514 } 515 if (default_options.time_show != jQuery.trim(jQuery('#chat_time_show').val())) { 516 output += 'time_show="'+jQuery.trim(jQuery('#chat_time_show').val())+'" '; 517 } 518 if (default_options.width != jQuery.trim(jQuery('#chat_width').val())) { 519 output += 'width="'+jQuery.trim(jQuery('#chat_width').val())+'" '; 520 } 521 if (default_options.height != jQuery.trim(jQuery('#chat_height').val())) { 522 output += 'height="'+jQuery.trim(jQuery('#chat_height').val())+'" '; 523 } 524 if (default_options.font != jQuery.trim(jQuery('#chat_font').val())) { 525 output += 'font="'+jQuery.trim(jQuery('#chat_font').val())+'" '; 526 } 527 if (default_options.font_size != jQuery.trim(jQuery('#chat_font_size').val())) { 528 output += 'font_size="'+jQuery.trim(jQuery('#chat_font_size').val())+'" '; 529 } 530 var chat_login_options_arr = []; 531 jQuery('input[name=chat_login_options]:checked').each(function() { 532 chat_login_options_arr.push(jQuery(this).val()) 533 }); 534 if (default_options.login_options != jQuery.trim(chat_login_options_arr.join(','))) { 535 output += 'login_options="'+jQuery.trim(chat_login_options_arr.join(','))+'" '; 536 } 537 538 var chat_moderator_roles_arr = []; 539 jQuery('input[name=chat_moderator_roles]:checked').each(function() { 540 chat_moderator_roles_arr.push(jQuery(this).val()) 541 }); 542 if (default_options.moderator_roles != jQuery.trim(chat_moderator_roles_arr.join(','))) { 543 output += 'moderator_roles="'+jQuery.trim(chat_moderator_roles_arr.join(','))+'" '; 544 } 545 546 output += ']'; 547 548 if (old_string == '') { 549 tinyMCEPopup.execCommand('mceReplaceContent', false, output); 550 } else { 551 tinyMCEPopup.execCommand('mceSetContent', false, tinyMCEPopup.editor.getContent().replace(old_string, output)); 552 } 553 554 // Return 555 tinyMCEPopup.close(); 556 }; 557 </script> 558 <style type="text/css"> 559 td.info { 560 vertical-align: top; 561 color: #777; 562 } 563 </style> 564 565 <title>{#chat_dlg.title}</title> 566 </head> 567 <body style="display: none"> 568 <form onsubmit="insertChat();return false;" action="#"> 569 <div class="tabs"> 570 <ul> 571 <li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');generatePreview();" onmousedown="return false;">{#chat_dlg.general}</a></span></li> 572 <li id="appearance_tab"><span><a href="javascript:mcTabs.displayTab('appearance_tab','appearance_panel');" onmousedown="return false;">{#chat_dlg.appearance}</a></span></li> 573 <li id="logs_tab"><span><a href="javascript:mcTabs.displayTab('logs_tab','logs_panel');" onmousedown="return false;">{#chat_dlg.logs}</a></span></li> 574 <li id="authentication_tab"><span><a href="javascript:mcTabs.displayTab('authentication_tab','authentication_panel');" onmousedown="return false;">{#chat_dlg.authentication}</a></span></li> 575 </ul> 576 </div> 577 578 <div class="panel_wrapper"> 579 <div id="general_panel" class="panel current"> 580 <fieldset> 581 <legend>{#chat_dlg.general}</legend> 582 583 <table border="0" cellpadding="4" cellspacing="0"> 584 <tr> 585 <td><label for="chat_sound">{#chat_dlg.sound}</label></td> 586 <td> 587 <select id="chat_sound" name="chat_sound" > 588 <option value="enabled" <?php print ($this->get_option('sound', 'enabled') == 'enabled')?'selected="selected"':''; ?>>{#chat_dlg.enabled}</option> 589 <option value="disabled" <?php print ($this->get_option('sound', 'enabled') == 'disabled')?'selected="selected"':''; ?>>{#chat_dlg.disabled}</option> 590 </select> 591 </td> 592 <td class="info"><?php _e("Play sound when a new message is received?", $this->translation_domain); ?></td> 593 </tr> 594 595 596 <tr class="chat_lite_disabled" > 597 <td><label for="chat_avatar">{#chat_dlg.avatar}</label></td> 598 <td> 599 <select id="chat_avatar" name="chat_avatar" disabled="disabled" > 600 <option value="enabled" <?php print ($this->get_option('avatar', 'enabled') == 'enabled')?'selected="selected"':''; ?>>{#chat_dlg.enabled}</option> 601 <option value="disabled" <?php print ($this->get_option('avatar', 'enabled') == 'disabled')?'selected="selected"':''; ?>>{#chat_dlg.disabled}</option> 602 </select> 603 </td> 604 <td class="info"><?php _e("Display the user's avatar with the message?", $this->translation_domain); ?></td> 605 </tr> 606 607 <tr class="chat_lite_disabled" > 608 <td><label for="chat_emoticons">{#chat_dlg.emoticons}</label></td> 609 <td> 610 <select id="chat_emoticons" name="chat_emoticons" disabled="disabled" > 611 <option value="enabled" <?php print ($this->get_option('emoticons', 'disabled') == 'enabled')?'selected="selected"':''; ?>>{#chat_dlg.enabled}</option> 612 <option value="disabled" <?php print ($this->get_option('emoticons', 'disabled') == 'disabled')?'selected="selected"':''; ?>>{#chat_dlg.disabled}</option> 613 </select> 614 </td> 615 <td class="info"><?php _e("Display emoticons bar?", $this->translation_domain); ?></td> 616 </tr> 617 618 <tr> 619 <td><label for="chat_date_show">{#chat_dlg.show_date}</label></td> 620 <td> 621 <select id="chat_date_show" name="chat_date_show" > 622 <option value="enabled" <?php print ($this->get_option('date_show', 'disabled') == 'enabled')?'selected="selected"':''; ?>>{#chat_dlg.enabled}</option> 623 <option value="disabled" <?php print ($this->get_option('date_show', 'disabled') == 'disabled')?'selected="selected"':''; ?>>{#chat_dlg.disabled}</option> 624 </select> 625 </td> 626 <td class="info"><?php _e("Display date the message was sent?", $this->translation_domain); ?></td> 627 </tr> 628 629 <tr> 630 <td><label for="chat_time_show">{#chat_dlg.show_time}</label></td> 631 <td> 632 <select id="chat_time_show" name="chat_time_show" > 633 <option value="enabled" <?php print ($this->get_option('time_show', 'disabled') == 'enabled')?'selected="selected"':''; ?>>{#chat_dlg.enabled}</option> 634 <option value="disabled" <?php print ($this->get_option('time_show', 'disabled') == 'disabled')?'selected="selected"':''; ?>>{#chat_dlg.disabled}</option> 635 </select> 636 </td> 637 <td class="info"><?php _e("Display the time the message was sent?", $this->translation_domain); ?></td> 638 </tr> 639 640 <tr> 641 <td><label for="chat_width">{#chat_dlg.dimensions}</label></td> 642 <td> 643 <input type="text" id="chat_width" name="chat_width" value="<?php print $this->get_option('width', ''); ?>" class="size" size="5" /> x 644 <input type="text" id="chat_height" name="chat_height" value="<?php print $this->get_option('height', ''); ?>" class="size" size="5" /> 645 </td> 646 <td class="info"><?php _e("Dimensions of the chat box", $this->translation_domain); ?></td> 647 </tr> 648 </table> 649 </fieldset> 650 </div> 651 652 <div id="appearance_panel" class="panel"> 653 <fieldset> 654 <legend>{#chat_dlg.colors}</legend> 655 656 <table border="0" cellpadding="4" cellspacing="0" class="chat_lite_disabled"> 657 <tr> 658 <td><label for="chat_background_color">{#chat_dlg.background}</label></td> 659 <td> 660 <input type="text" id="chat_background_color" name="chat_background_color" value="<?php print $this->get_option('background_color', '#ffffff'); ?>" class="color" size="7" disabled="disabled" /> 661 <div class="color" id="chat_background_color_panel"></div> 662 </td> 663 <td class="info"><?php _e("Chat box background color", $this->translation_domain); ?></td> 664 </tr> 665 666 <tr> 667 <td><label for="chat_date_color">{#chat_dlg.date}</label></td> 668 <td> 669 <input type="text" id="chat_date_color" name="chat_date_color" value="<?php print $this->get_option('date_color', '#6699CC'); ?>" class="color" size="7" disabled="disabled" /> 670 <div class="color" id="chat_date_color_panel"></div> 671 </td> 672 <td class="info"><?php _e("Date background color", $this->translation_domain); ?></td> 673 </tr> 674 675 <tr> 676 <td><label for="chat_name_color">{#chat_dlg.name}</label></td> 677 <td> 678 <input type="text" id="chat_name_color" name="chat_name_color" value="<?php print $this->get_option('name_color', '#666666'); ?>" class="color" size="7" disabled="disabled" /> 679 <div class="color" id="chat_name_color_panel"></div> 680 </td> 681 <td class="info"><?php _e("Name background color", $this->translation_domain); ?></td> 682 </tr> 683 684 <tr> 685 <td><label for="chat_moderator_name_color">{#chat_dlg.moderator_name}</label></td> 686 <td> 687 <input type="text" id="chat_moderator_name_color" name="chat_moderator_name_color" value="<?php print $this->get_option('moderator_name_color', '#6699CC'); ?>" class="color" size="7" disabled="disabled" /> 688 <div class="color" id="chat_moderator_name_color_panel"></div> 689 </td> 690 <td class="info"><?php _e("Moderator Name background color", $this->translation_domain); ?></td> 691 </tr> 692 693 <tr> 694 <td><label for="chat_text_color">{#chat_dlg.text}</label></td> 695 <td> 696 <input type="text" id="chat_text_color" name="chat_text_color" value="<?php print $this->get_option('text_color', '#000000'); ?>" class="color" size="7" disabled="disabled" /> 697 <div class="color" id="chat_text_color_panel"></div> 698 </td> 699 <td class="info"><?php _e("Text color", $this->translation_domain); ?></td> 700 </tr> 701 </table> 702 </fieldset> 703 704 <fieldset> 705 <legend>{#chat_dlg.fonts}</legend> 706 707 <table border="0" cellpadding="4" cellspacing="0"> 708 709 <tr> 710 <td><label for="chat_font">{#chat_dlg.font}</label></td> 711 <td> 712 <select id="chat_font" name="chat_font" class="font" > 713 <?php foreach ($this->fonts_list as $font_name => $font) { ?> 714 <option value="<?php print $font; ?>" <?php print ($this->get_option('font', '') == $font)?'selected="selected"':''; ?>" ><?php print $font_name; ?></option> 715 <?php } ?> 716 </select> 717 </td> 718 <td class="info"><?php _e("Chat box font", $this->translation_domain); ?></td> 719 </tr> 720 721 <tr> 722 <td><label for="chat_font_size">{#chat_dlg.font_size}</label></td> 723 <td> 724 <select id="chat_font_size" name="chat_font_size" class="font_size" > 725 <?php for ($font_size=8; $font_size<21; $font_size++) { ?> 726 <option value="<?php print $font_size; ?>" <?php print ($this->get_option('font_size', '12') == $font_size)?'selected="selected"':''; ?> ><?php print $font_size; ?></option> 727 <?php } ?> 728 </select> px 729 </td> 730 <td class="info"><?php _e("Chat box font size", $this->translation_domain); ?></td> 731 </tr> 732 </table> 733 </fieldset> 734 </div> 735 736 <div id="logs_panel" class="panel"> 737 <fieldset> 738 <legend>{#chat_dlg.logs}</legend> 739 740 <table border="0" cellpadding="4" cellspacing="0"> 741 <tr> 742 <td><label for="chat_log_creation">{#chat_dlg.creation}</label></td> 743 <td> 744 <select id="chat_log_creation" name="chat_log_creation" disabled="disabled" > 745 <option value="enabled" <?php print ($this->get_option('log_creation', 'disabled') == 'enabled')?'selected="selected"':''; ?>>{#chat_dlg.enabled}</option> 746 <option value="disabled" <?php print ($this->get_option('log_creation', 'disabled') == 'disabled')?'selected="selected"':''; ?>>{#chat_dlg.disabled}</option> 747 </select> 748 </td> 749 <td class="info"><?php _e("Log chat messages?", $this->translation_domain); ?></td> 750 </tr> 751 752 <tr> 753 <td><label for="chat_log_display">{#chat_dlg.display}</label></td> 754 <td> 755 <select id="chat_log_display" name="chat_log_display" disabled="disabled" > 756 <option value="enabled" <?php print ($this->get_option('log_display', 'disabled') == 'enabled')?'selected="selected"':''; ?>>{#chat_dlg.enabled}</option> 757 <option value="disabled" <?php print ($this->get_option('log_display', 'disabled') == 'disabled')?'selected="selected"':''; ?>>{#chat_dlg.disabled}</option> 758 </select> 759 </td> 760 <td class="info"><?php _e("Display chat logs?", $this->translation_domain); ?></td> 761 </tr> 762 </table> 763 </fieldset> 764 </div> 765 766 <div id="authentication_panel" class="panel"> 767 <fieldset> 768 <legend>{#chat_dlg.authentication}</legend> 769 770 <table border="0" cellpadding="4" cellspacing="0"> 771 <tr> 772 <td valign="top"><label for="chat_login_options">{#chat_dlg.login_options}</label></td> 773 <td> 774 <label><input type="checkbox" id="chat_login_options_current_user" name="chat_login_options" class="chat_login_options" value="current_user" <?php print (in_array('current_user', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Current user', $this->translation_domain); ?></label><br/> 775 <?php if (is_multisite()) { ?> 776 <label><input type="checkbox" id="chat_login_options_network_user" name="chat_login_options" class="chat_login_options" value="network_user" <?php print (in_array('network_user', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Network user', $this->translation_domain); ?></label><br/> 777 <?php } ?> 778 <label><input type="checkbox" id="chat_login_options_public_user" name="chat_login_options" class="chat_login_options" value="public_user" <?php print (in_array('public_user', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Public user', $this->translation_domain); ?></label><br/> 779 <?php if ($this->is_twitter_setup()) { ?> 780 <label><input type="checkbox" id="chat_login_options_twitter" name="chat_login_options" class="chat_login_options" value="twitter" <?php print (!$this->is_twitter_setup())?'disabled="disabled"':''; ?> <?php print (in_array('twitter', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Twitter', $this->translation_domain); ?></label><br/> 781 <?php } ?> 782 <?php if ($this->is_facebook_setup()) { ?> 783 <label><input type="checkbox" id="chat_login_options_facebook" name="chat_login_options" class="chat_login_options" value="facebook" <?php print (!$this->is_facebook_setup())?'disabled="disabled"':''; ?> <?php print (in_array('facebook', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Facebook', $this->translation_domain); ?></label><br/> 784 <?php } ?> 785 </td> 786 <td class="info"><?php _e("Authentication methods users can use", $this->translation_domain); ?></td> 787 </tr> 788 <tr> 789 <td valign="top"><label for="chat_moderator_roles">{#chat_dlg.moderator_roles}</label></td> 790 <td> 791 <?php 792 foreach (get_editable_roles() as $role => $details) { 793 $name = translate_user_role($details['name'] ); 794 ?> 795 <label><input type="checkbox" id="chat_moderator_roles_<?php print $role; ?>" name="chat_moderator_roles" class="chat_moderator_roles" value="<?php print $role; ?>" <?php print (in_array($role, $this->get_option('moderator_roles', array('administrator','editor','author'))) > 0)?'checked="checked"':''; ?> /> <?php _e($name, $this->translation_domain); ?></label><br/> 796 <?php 797 } 798 ?> 799 </td> 800 <td class="info"><?php _e("Select which roles are moderators", $this->translation_domain); ?></td> 801 </tr> 802 </table> 803 </fieldset> 804 </div> 805 </div> 806 807 <div class="mceActionPanel"> 808 <div style="float: left"> 809 <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" /> 810 </div> 811 812 <div style="float: right"> 813 <input type="submit" id="insert" name="insert" value="{#insert}" /> 814 </div> 815 </div> 816 </form> 817 <script type="text/javascript"> 818 jQuery(window).load(function() { 819 for (attr in current_options) { 820 if (attr == "id") continue; 821 822 if (current_options[attr].match(',')) { 823 jQuery("#chat_"+attr).val(current_options[attr].split(',')); 824 } else { 825 jQuery("#chat_"+attr).val(current_options[attr]); 826 } 827 } 828 }); 829 </script> 830 </body> 831 </html> 832 <?php 833 exit(0); 834 } 835 836 function whitelist_options($options) { 837 $added = array( 'chat' => array( 'chat_default', 'chat_site' ) ); 838 $options = add_option_whitelist( $added, $options ); 839 return $options; 840 } 841 842 /** 843 * Plugin options 844 */ 845 function plugin_options() { 846 ?> 847 <div class="wrap"> 848 <h2><?php _e('Chat Settings', $this->translation_domain); ?></h2> 849 <form method="post" action="options.php"> 850 <?php settings_fields('chat'); ?> 851 852 <div id="chat_tab_pane" class="chat_tab_pane"> 853 <ul> 854 <li><a href="#chat_default_panel"><span><?php _e('In post chat options', $this->translation_domain); ?></span></a></li> 855 <li><a href="#chat_site_panel"><span><?php _e('Bottom corner chat', $this->translation_domain); ?></span></a></li> 856 <li class="chat_lite_disabled_tab"><a href="#chat_twitter_api_panel"><span><?php _e('Twitter API', $this->translation_domain); ?></span></a></li> 857 <li class="chat_lite_disabled_tab"><a href="#chat_facebook_api_panel"><span><?php _e('Facebook API', $this->translation_domain); ?></span></a></li> 858 <li class="chat_lite_disabled_tab"><a href="#chat_advanced_panel"><span><?php _e('Advanced', $this->translation_domain); ?></span></a></li> 859 </ul> 860 861 <div id="chat_default_panel" class="chat_panel current"> 862 <p class="info"><b><?php printf(__('Grayed out options available in the full version. <a href="%s" target="_blank">**Upgrade to the full version now »**</a>', $this->translation_domain), 'http://premium.wpmudev.org/project/wordpress-chat-plugin'); ?></b></p> 863 864 <p class="info"><?php _e('Default options for in post chat boxes', $this->translation_domain); ?></p> 865 866 <fieldset> 867 <legend><?php _e('General', $this->translation_domain); ?></legend> 868 869 <table border="0" cellpadding="4" cellspacing="0"> 870 <tr> 871 <td><label for="chat_sound"><?php _e('Sound', $this->translation_domain); ?></label></td> 872 <td> 873 <select id="chat_sound" name="chat_default[sound]" > 874 <option value="enabled" <?php print ($this->get_option('sound', 'enabled') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 875 <option value="disabled" <?php print ($this->get_option('sound', 'enabled') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 876 </select> 877 </td> 878 <td class="info"><?php _e("Play sound when a new message is received?", $this->translation_domain); ?></td> 879 </tr> 880 881 <tr class="chat_lite_disabled"> 882 <td><label for="chat_avatar"><?php _e('Avatar', $this->translation_domain); ?></label></td> 883 <td> 884 <select id="chat_avatar" name="chat_default[avatar]" disabled="disabled" > 885 <option value="enabled" <?php print ($this->get_option('avatar', 'enabled') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 886 <option value="disabled" <?php print ($this->get_option('avatar', 'enabled') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 887 </select> 888 </td> 889 <td class="info"><?php _e("Display the user's avatar with the message?", $this->translation_domain); ?></td> 890 </tr> 891 892 <tr class="chat_lite_disabled"> 893 <td><label for="chat_emoticons"><?php _e('Emoticons', $this->translation_domain); ?></label></td> 894 <td> 895 <select id="chat_emoticons" name="chat_default[emoticons]" disabled="disabled" > 896 <option value="enabled" <?php print ($this->get_option('emoticons', 'disabled') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 897 <option value="disabled" <?php print ($this->get_option('emoticons', 'disabled') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 898 </select> 899 </td> 900 <td class="info"><?php _e("Display emoticons bar?", $this->translation_domain); ?></td> 901 </tr> 902 903 <tr> 904 <td><label for="chat_date_show"><?php _e('Show date', $this->translation_domain); ?></label></td> 905 <td> 906 <select id="chat_date_show" name="chat_default[date_show]" > 907 <option value="enabled" <?php print ($this->get_option('date_show', 'disabled') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 908 <option value="disabled" <?php print ($this->get_option('date_show', 'disabled') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 909 </select> 910 </td> 911 <td class="info"><?php _e("Display date the message was sent?", $this->translation_domain); ?></td> 912 </tr> 913 914 <tr> 915 <td><label for="chat_time_show"><?php _e('Show time', $this->translation_domain); ?></label></td> 916 <td> 917 <select id="chat_time_show" name="chat_default[time_show]" > 918 <option value="enabled" <?php print ($this->get_option('time_show', 'disabled') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 919 <option value="disabled" <?php print ($this->get_option('time_show', 'disabled') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 920 </select> 921 </td> 922 <td class="info"><?php _e("Display the time the message was sent?", $this->translation_domain); ?></td> 923 </tr> 924 925 <tr> 926 <td><label for="chat_width"><?php _e('Dimensions', $this->translation_domain); ?></label></td> 927 <td> 928 <input type="text" id="chat_width" name="chat_default[width]" value="<?php print $this->get_option('width', '100%'); ?>" class="size" size="5" /> x 929 <input type="text" id="chat_height" name="chat_default[height]" value="<?php print $this->get_option('height', '425px'); ?>" class="size" size="5" /> 930 </td> 931 <td class="info"><?php _e("Dimensions of the chat box", $this->translation_domain); ?></td> 932 </tr> 933 </table> 934 </fieldset> 935 936 <fieldset> 937 <legend><?php _e('Colors', $this->translation_domain); ?></legend> 938 939 <table border="0" cellpadding="4" cellspacing="0" class="chat_lite_disabled" > 940 <tr> 941 <td><label for="chat_background_color"><?php _e('Background', $this->translation_domain); ?></label></td> 942 <td> 943 <input type="text" id="chat_background_color" name="chat_default[background_color]" value="<?php print $this->get_option('background_color', '#ffffff'); ?>" class="color" size="7" disabled="disabled" /> 944 <div class="color" id="chat_background_color_panel"></div> 945 </td> 946 <td class="info"><?php _e("Chat box background color", $this->translation_domain); ?></td> 947 </tr> 948 949 <tr> 950 <td><label for="chat_date_color"><?php _e('Date', $this->translation_domain); ?></label></td> 951 <td> 952 <input type="text" id="chat_date_color" name="chat_default[date_color]" value="<?php print $this->get_option('date_color', '#6699CC'); ?>" class="color" size="7" disabled="disabled" /> 953 <div class="color" id="chat_date_color_panel"></div> 954 </td> 955 <td class="info"><?php _e("Date and time background color", $this->translation_domain); ?></td> 956 </tr> 957 958 <tr> 959 <td><label for="chat_name_color"><?php _e('Name', $this->translation_domain); ?></label></td> 960 <td> 961 <input type="text" id="chat_name_color" name="chat_default[name_color]" value="<?php print $this->get_option('name_color', '#666666'); ?>" class="color" size="7" disabled="disabled" /> 962 <div class="color" id="chat_name_color_panel"></div> 963 </td> 964 <td class="info"><?php _e("Name background color", $this->translation_domain); ?></td> 965 </tr> 966 967 <tr> 968 <td><label for="chat_moderator_name_color"><?php _e('Moderator Name', $this->translation_domain); ?></label></td> 969 <td> 970 <input type="text" id="chat_moderator_name_color" name="chat_default[moderator_name_color]" value="<?php print $this->get_option('moderator_name_color', '#6699CC'); ?>" class="color" size="7" disabled="disabled" /> 971 <div class="color" id="chat_moderator_name_color_panel"></div> 972 </td> 973 <td class="info"><?php _e("Moderator Name background color", $this->translation_domain); ?></td> 974 </tr> 975 976 <tr> 977 <td><label for="chat_text_color"><?php _e('Text', $this->translation_domain); ?></label></td> 978 <td> 979 <input type="text" id="chat_text_color" name="chat_default[text_color]" value="<?php print $this->get_option('text_color', '#000000'); ?>" class="color" size="7" disabled="disabled" /> 980 <div class="color" id="chat_text_color_panel"></div> 981 </td> 982 <td class="info"><?php _e("Text color", $this->translation_domain); ?></td> 983 </tr> 984 </table> 985 </fieldset> 986 987 <fieldset> 988 <legend><?php _e('Fonts', $this->translation_domain); ?></legend> 989 990 <table border="0" cellpadding="4" cellspacing="0"> 991 <tr> 992 <td><label for="chat_font"><?php _e('Font', $this->translation_domain); ?></label></td> 993 <td> 994 <select id="chat_font" name="chat_default[font]" class="font" > 995 <?php foreach ($this->fonts_list as $font_name => $font) { ?> 996 <option value="<?php print $font; ?>" <?php print ($this->get_option('font', '') == $font)?'selected="selected"':''; ?>" ><?php print $font_name; ?></option> 997 <?php } ?> 998 </select> 999 </td> 1000 <td class="info"><?php _e("Chat box font", $this->translation_domain); ?></td> 1001 </tr> 1002 1003 <tr> 1004 <td><label for="chat_font_size"><?php _e('Font size', $this->translation_domain); ?></label></td> 1005 <td> 1006 <select id="chat_font_size" name="chat_default[font_size]" class="font_size" > 1007 <?php for ($font_size=8; $font_size<21; $font_size++) { ?> 1008 <option value="<?php print $font_size; ?>" <?php print ($this->get_option('font_size', '12') == $font_size)?'selected="selected"':''; ?>" ><?php print $font_size; ?></option> 1009 <?php } ?> 1010 </select> px 1011 </td> 1012 <td class="info"><?php _e("Chat box font size", $this->translation_domain); ?></td> 1013 </tr> 1014 </table> 1015 </fieldset> 1016 1017 <fieldset> 1018 <legend><?php _e('Logs', $this->translation_domain); ?></legend> 1019 1020 <table border="0" cellpadding="4" cellspacing="0" class="chat_lite_disabled"> 1021 <tr> 1022 <td><label for="chat_log_creation"><?php _e('Creation', $this->translation_domain); ?></label></td> 1023 <td> 1024 <select id="chat_log_creation" name="chat_default[log_creation]" disabled="disabled" > 1025 <option value="enabled" <?php print ($this->get_option('log_creation', 'enabled') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1026 <option value="disabled" <?php print ($this->get_option('log_creation', 'enabled') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1027 </select> 1028 </td> 1029 <td class="info"><?php _e("Log chat messages?", $this->translation_domain); ?></td> 1030 </tr> 1031 1032 <tr> 1033 <td><label for="chat_log_display"><?php _e('Display', $this->translation_domain); ?></label></td> 1034 <td> 1035 <select id="chat_log_display" name="chat_default[log_display]" disabled="disabled" > 1036 <option value="enabled" <?php print ($this->get_option('log_display', 'enabled') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1037 <option value="disabled" <?php print ($this->get_option('log_display', 'enabled') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1038 </select> 1039 </td> 1040 <td class="info"><?php _e("Display chat logs?", $this->translation_domain); ?></td> 1041 </tr> 1042 </table> 1043 </fieldset> 1044 1045 <fieldset> 1046 <legend><?php _e('Authentication', $this->translation_domain); ?></legend> 1047 1048 <table border="0" cellpadding="4" cellspacing="0"> 1049 <tr> 1050 <td valign="top"><label for="chat_login_options"><?php _e('Login options', $this->translation_domain); ?></label></td> 1051 <td> 1052 <label><input type="checkbox" id="chat_login_options_current_user" name="chat_default[login_options][]" class="chat_login_options" value="current_user" <?php print (in_array('current_user', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Current user', $this->translation_domain); ?></label><br/> 1053 <?php if (is_multisite()) { ?> 1054 <label><input type="checkbox" id="chat_login_options_network_user" name="chat_default[login_options][]" class="chat_login_options" value="network_user" <?php print (in_array('network_user', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Network user', $this->translation_domain); ?></label><br/> 1055 <?php } ?> 1056 <label><input type="checkbox" id="chat_login_options_public_user" name="chat_default[login_options][]" class="chat_login_options" value="public_user" <?php print (in_array('public_user', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Public user', $this->translation_domain); ?></label><br/> 1057 <span class="chat_lite_disabled" ><label ><input type="checkbox" id="chat_login_options_twitter" name="chat_default[login_options][]" class="chat_login_options" value="twitter" <?php print (!$this->is_twitter_setup())?'disabled="disabled"':''; ?> <?php print (in_array('twitter', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Twitter', $this->translation_domain); ?></label><br/> 1058 <label ><input type="checkbox" id="chat_login_options_facebook" name="chat_default[login_options][]" class="chat_login_options" value="facebook" <?php print (!$this->is_facebook_setup())?'disabled="disabled"':''; ?> <?php print (in_array('facebook', $this->get_option('login_options', array('current_user'))) > 0)?'checked="checked"':''; ?> /> <?php _e('Facebook', $this->translation_domain); ?></label><br/></span> 1059 </td> 1060 <td class="info"><?php _e("Authentication methods users can use", $this->translation_domain); ?></td> 1061 </tr> 1062 1063 <tr class="chat_lite_disabled" > 1064 <td valign="top"><label for="chat_moderator_roles"><?php _e('Moderator roles', $this->translation_domain); ?></label></td> 1065 <td> 1066 <?php 1067 foreach (get_editable_roles() as $role => $details) { 1068 $name = translate_user_role($details['name'] ); 1069 ?> 1070 <label><input type="checkbox" id="chat_moderator_roles_<?php print $role; ?>" name="chat_default[moderator_roles][]" class="chat_moderator_roles" value="<?php print $role; ?>" <?php print (in_array($role, $this->get_option('moderator_roles', array('administrator','editor','author'))) > 0)?'checked="checked"':''; ?> disabled="disabled" /> <?php _e($name, $this->translation_domain); ?></label><br/> 1071 <?php 1072 } 1073 ?> 1074 </td> 1075 <td class="info"><?php _e("Select which roles are moderators", $this->translation_domain); ?></td> 1076 </tr> 1077 </table> 1078 </fieldset> 1079 </div> 1080 1081 <div id="chat_site_panel" class="chat_panel current"> 1082 <p class="info"><b><?php printf(__('Grayed out options available in the full version. <a href="%s" target="_blank">**Upgrade to the full version now »**</a>', $this->translation_domain), 'http://premium.wpmudev.org/project/wordpress-chat-plugin'); ?></b></p> 1083 1084 <p class="info"><?php _e('Options for the bottom corner chat', $this->translation_domain); ?></p> 1085 1086 <fieldset> 1087 <legend><?php _e('Main', $this->translation_domain); ?></legend> 1088 1089 <table border="0" cellpadding="4" cellspacing="0"> 1090 <tr> 1091 <td><label for="chat_site_1"><?php _e('Show', $this->translation_domain); ?></label></td> 1092 <td> 1093 <select id="chat_site_1" name="chat_site[site]" > 1094 <option value="enabled" <?php print ($this->get_option('site', 'enabled', 'site') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1095 <option value="disabled" <?php print ($this->get_option('site', 'enabled', 'site') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1096 </select> 1097 </td> 1098 <td class="info"><?php _e("Display bottom corner chat?", $this->translation_domain); ?></td> 1099 </tr> 1100 </table> 1101 </fieldset> 1102 1103 <fieldset> 1104 <legend><?php _e('General', $this->translation_domain); ?></legend> 1105 1106 <table border="0" cellpadding="4" cellspacing="0"> 1107 1108 <tr> 1109 <td><label for="chat_sound_1"><?php _e('Sound', $this->translation_domain); ?></label></td> 1110 <td> 1111 <select id="chat_sound_1" name="chat_site[sound]" > 1112 <option value="enabled" <?php print ($this->get_option('sound', 'enabled', 'site') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1113 <option value="disabled" <?php print ($this->get_option('sound', 'enabled', 'site') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1114 </select> 1115 </td> 1116 <td class="info"><?php _e("Play sound when a new message is received?", $this->translation_domain); ?></td> 1117 </tr> 1118 1119 <tr class="chat_lite_disabled"> 1120 <td><label for="chat_avatar_1"><?php _e('Avatar', $this->translation_domain); ?></label></td> 1121 <td> 1122 <select id="chat_avatar_1" name="chat_site[avatar]" disabled="disabled"> 1123 <option value="enabled" <?php print ($this->get_option('avatar', 'enabled', 'site') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1124 <option value="disabled" <?php print ($this->get_option('avatar', 'enabled', 'site') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1125 </select> 1126 </td> 1127 <td class="info"><?php _e("Display the user's avatar with the message?", $this->translation_domain); ?></td> 1128 </tr> 1129 1130 <tr class="chat_lite_disabled"> 1131 <td><label for="chat_emoticons_1"><?php _e('Emoticons', $this->translation_domain); ?></label></td> 1132 <td> 1133 <select id="chat_emoticons_1" name="chat_site[emoticons]" disabled="disabled"> 1134 <option value="enabled" <?php print ($this->get_option('emoticons', 'enabled', 'site') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1135 <option value="disabled" <?php print ($this->get_option('emoticons', 'enabled', 'site') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1136 </select> 1137 </td> 1138 <td class="info"><?php _e("Display emoticons bar?", $this->translation_domain); ?></td> 1139 </tr> 1140 1141 <tr> 1142 <td><label for="chat_date_show_1"><?php _e('Show date', $this->translation_domain); ?></label></td> 1143 <td> 1144 <select id="chat_date_show_1" name="chat_site[date_show]" > 1145 <option value="enabled" <?php print ($this->get_option('date_show', 'enabled', 'site') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1146 <option value="disabled" <?php print ($this->get_option('date_show', 'enabled', 'site') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1147 </select> 1148 </td> 1149 <td class="info"><?php _e("Display date the message was sent?", $this->translation_domain); ?></td> 1150 </tr> 1151 1152 <tr> 1153 <td><label for="chat_time_show_1"><?php _e('Show time', $this->translation_domain); ?></label></td> 1154 <td> 1155 <select id="chat_time_show_1" name="chat_site[time_show]" > 1156 <option value="enabled" <?php print ($this->get_option('time_show', 'enabled', 'site') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1157 <option value="disabled" <?php print ($this->get_option('time_show', 'enabled', 'site') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1158 </select> 1159 </td> 1160 <td class="info"><?php _e("Display the time the message was sent?", $this->translation_domain); ?></td> 1161 </tr> 1162 1163 <tr> 1164 <td><label for="chat_width_1"><?php _e('Dimensions', $this->translation_domain); ?></label></td> 1165 <td> 1166 <input type="text" id="chat_width_1" name="chat_site[width]" value="<?php print $this->get_option('width', '', 'site'); ?>" class="size" size="5" /> x 1167 <input type="text" id="chat_height_1" name="chat_site[height]" value="<?php print $this->get_option('height', '', 'site'); ?>" class="size" size="5" /> 1168 </td> 1169 <td class="info"><?php _e("Dimensions of the chat box", $this->translation_domain); ?></td> 1170 </tr> 1171 </table> 1172 </fieldset> 1173 1174 <fieldset> 1175 <legend><?php _e('Colors', $this->translation_domain); ?></legend> 1176 1177 <table border="0" cellpadding="4" cellspacing="0" class="chat_lite_disabled"> 1178 <tr> 1179 <td><label for="chat_border_color_1"><?php _e('Border', $this->translation_domain); ?></label></td> 1180 <td> 1181 <input type="text" id=chat_border_color_1 name="chat_site[border_color]" value="<?php print $this->get_option('border_color', '#4b96e2', 'site'); ?>" class="color" size="7" disabled="disabled" /> 1182 <div class="color" id="chat_border_color_1_panel"></div> 1183 </td> 1184 <td class="info"><?php _e("Chat box border color", $this->translation_domain); ?></td> 1185 </tr> 1186 1187 <tr> 1188 <td><label for="chat_background_color_1"><?php _e('Background', $this->translation_domain); ?></label></td> 1189 <td> 1190 <input type="text" id="chat_background_color_1" name="chat_site[background_color]" value="<?php print $this->get_option('background_color', '#ffffff', 'site'); ?>" class="color" size="7" disabled="disabled" /> 1191 <div class="color" id="chat_background_color_1_panel"></div> 1192 </td> 1193 <td class="info"><?php _e("Chat box background color", $this->translation_domain); ?></td> 1194 </tr> 1195 1196 <tr> 1197 <td><label for="chat_date_color"><?php _e('Date', $this->translation_domain); ?></label></td> 1198 <td> 1199 <input type="text" id="chat_date_color_1" name="chat_site[date_color]" value="<?php print $this->get_option('date_color', '#6699CC', 'site'); ?>" class="color" size="7" disabled="disabled" /> 1200 <div class="color" id="chat_date_color_1_panel"></div> 1201 </td> 1202 <td class="info"><?php _e("Date and time background color", $this->translation_domain); ?></td> 1203 </tr> 1204 1205 <tr> 1206 <td><label for="chat_name_color"><?php _e('Name', $this->translation_domain); ?></label></td> 1207 <td> 1208 <input type="text" id="chat_name_color_1" name="chat_site[name_color]" value="<?php print $this->get_option('name_color', '#666666', 'site'); ?>" class="color" size="7" disabled="disabled" /> 1209 <div class="color" id="chat_name_color_1_panel"></div> 1210 </td> 1211 <td class="info"><?php _e("Name background color", $this->translation_domain); ?></td> 1212 </tr> 1213 1214 <tr> 1215 <td><label for="chat_moderator_name_color"><?php _e('Moderator Name', $this->translation_domain); ?></label></td> 1216 <td> 1217 <input type="text" id="chat_moderator_name_color_1" name="chat_site[moderator_name_color]" value="<?php print $this->get_option('moderator_name_color', '#6699CC', 'site'); ?>" class="color" size="7" disabled="disabled" /> 1218 <div class="color" id="chat_moderator_name_color_1_panel"></div> 1219 </td> 1220 <td class="info"><?php _e("Moderator Name background color", $this->translation_domain); ?></td> 1221 </tr> 1222 1223 <tr> 1224 <td><label for="chat_text_color"><?php _e('Text', $this->translation_domain); ?></label></td> 1225 <td> 1226 <input type="text" id="chat_text_color_1" name="chat_site[text_color]" value="<?php print $this->get_option('text_color', '#000000', 'site'); ?>" class="color" size="7" disabled="disabled" /> 1227 <div class="color" id="chat_text_color_1_panel"></div> 1228 </td> 1229 <td class="info"><?php _e("Text color", $this->translation_domain); ?></td> 1230 </tr> 1231 </table> 1232 </fieldset> 1233 1234 <fieldset> 1235 <legend><?php _e('Fonts', $this->translation_domain); ?></legend> 1236 1237 <table border="0" cellpadding="4" cellspacing="0"> 1238 <tr> 1239 <td><label for="chat_font_1"><?php _e('Font', $this->translation_domain); ?></label></td> 1240 <td> 1241 <select id="chat_font_1" name="chat_site[font]" class="font" > 1242 <?php foreach ($this->fonts_list as $font_name => $font) { ?> 1243 <option value="<?php print $font; ?>" <?php print ($this->get_option('font', '', 'site') == $font)?'selected="selected"':''; ?>" ><?php print $font_name; ?></option> 1244 <?php } ?> 1245 </select> 1246 </td> 1247 <td class="info"><?php _e("Chat box font", $this->translation_domain); ?></td> 1248 </tr> 1249 1250 <tr> 1251 <td><label for="chat_font_size_1"><?php _e('Font size', $this->translation_domain); ?></label></td> 1252 <td><select id="chat_font_size_1" name="chat_site[font_size]" class="font_size" > 1253 <?php for ($font_size=8; $font_size<21; $font_size++) { ?> 1254 <option value="<?php print $font_size; ?>" <?php print ($this->get_option('font_size', '12', 'site') == $font_size)?'selected="selected"':''; ?>" ><?php print $font_size; ?></option> 1255 <?php } ?> 1256 </select> px 1257 </td> 1258 <td class="info"><?php _e("Chat box font size", $this->translation_domain); ?></td> 1259 </tr> 1260 </table> 1261 </fieldset> 1262 1263 <fieldset> 1264 <legend><?php _e('Logs', $this->translation_domain); ?></legend> 1265 1266 <table border="0" cellpadding="4" cellspacing="0" class="chat_lite_disabled" > 1267 <tr> 1268 <td><label for="chat_log_creation_1"><?php _e('Creation', $this->translation_domain); ?></label></td> 1269 <td> 1270 <select id="chat_log_creation_1" name="chat_site[log_creation]" disabled="disabled" > 1271 <option value="enabled" <?php print ($this->get_option('log_creation', 'enabled', 'site') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1272 <option value="disabled" <?php print ($this->get_option('log_creation', 'enabled', 'site') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1273 </select> 1274 </td> 1275 <td class="info"><?php _e("Log chat messages?", $this->translation_domain); ?></td> 1276 </tr> 1277 1278 <tr> 1279 <td><label for="chat_log_display_1"><?php _e('Display', $this->translation_domain); ?></label></td> 1280 <td> 1281 <select id="chat_log_display_1" name="chat_site[log_display]" disabled="disabled" > 1282 <option value="enabled" <?php print ($this->get_option('log_display', 'enabled', 'site') == 'enabled')?'selected="selected"':''; ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1283 <option value="disabled" <?php print ($this->get_option('log_display', 'enabled', 'site') == 'disabled')?'selected="selected"':''; ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1284 </select> 1285 </td> 1286 <td class="info"><?php _e("Display chat logs?", $this->translation_domain); ?></td> 1287 </tr> 1288 </table> 1289 </fieldset> 1290 1291 <fieldset> 1292 <legend><?php _e('Authentication', $this->translation_domain); ?></legend> 1293 1294 <table border="0" cellpadding="4" cellspacing="0"> 1295 <tr> 1296 <td valign="top"><label for="chat_login_options_1"><?php _e('Login options', $this->translation_domain); ?></label></td> 1297 <td> 1298 <label><input type="checkbox" id="chat_login_options_1_current_user" name="chat_site[login_options][]" class="chat_login_options" value="current_user" <?php print (in_array('current_user', $this->get_option('login_options', array('current_user'), 'site')) > 0)?'checked="checked"':''; ?> /> <?php _e('Current user', $this->translation_domain); ?></label><br/> 1299 <?php if (is_multisite()) { ?> 1300 <label><input type="checkbox" id="chat_login_options_1_network_user" name="chat_site[login_options][]" class="chat_login_options" value="network_user" <?php print (in_array('network_user', $this->get_option('login_options', array('current_user'), 'site')) > 0)?'checked="checked"':''; ?> /> <?php _e('Network user', $this->translation_domain); ?></label><br/> 1301 <?php } ?> 1302 <label><input type="checkbox" id="chat_login_options_1_public_user" name="chat_site[login_options][]" class="chat_login_options" value="public_user" <?php print (in_array('public_user', $this->get_option('login_options', array('current_user'), 'site')) > 0)?'checked="checked"':''; ?> /> <?php _e('Public user', $this->translation_domain); ?></label><br/> 1303 <label class="chat_lite_disabled"><input type="checkbox" id="chat_login_options_1_twitter" name="chat_site[login_options][]" class="chat_login_options" value="twitter" <?php print (!$this->is_twitter_setup())?'disabled="disabled"':''; ?> <?php print (in_array('twitter', $this->get_option('login_options', array('current_user'), 'site')) > 0)?'checked="checked"':''; ?> /> <?php _e('Twitter', $this->translation_domain); ?></label><br/> 1304 <label class="chat_lite_disabled"><input type="checkbox" id="chat_login_options_1_facebook" name="chat_site[login_options][]" class="chat_login_options" value="facebook" <?php print (!$this->is_facebook_setup())?'disabled="disabled"':''; ?> <?php print (in_array('facebook', $this->get_option('login_options', array('current_user'), 'site')) > 0)?'checked="checked"':''; ?> /> <?php _e('Facebook', $this->translation_domain); ?></label><br/> 1305 </td> 1306 <td class="info"><?php _e("Authentication methods users can use", $this->translation_domain); ?></td> 1307 </tr> 1308 1309 <tr class="chat_lite_disabled"> 1310 <td valign="top"><label for="chat_moderator_roles_1"><?php _e('Moderator roles', $this->translation_domain); ?></label></td> 1311 <td> 1312 <?php 1313 foreach (get_editable_roles() as $role => $details) { 1314 $name = translate_user_role($details['name'] ); 1315 ?> 1316 <label><input type="checkbox" id="chat_moderator_roles_1_<?php print $role; ?>" name="chat_site[moderator_roles][]" class="chat_moderator_roles" value="<?php print $role; ?>" <?php print (in_array($role, $this->get_option('moderator_roles', array('administrator','editor','author'), 'site')) > 0)?'checked="checked"':''; ?> disabled="disabled" /> <?php _e($name, $this->translation_domain); ?></label><br/> 1317 <?php 1318 } 1319 ?> 1320 </td> 1321 <td class="info"><?php _e("Select which roles are moderators", $this->translation_domain); ?></td> 1322 </tr> 1323 </table> 1324 </fieldset> 1325 </div> 1326 1327 <div id="chat_twitter_api_panel" class="chat_panel chat_auth_panel"> 1328 <table border="0" cellpadding="4" cellspacing="0"> 1329 <tr> 1330 <td colspan="4" ><p class="info"><b><?php printf(__('Only available in the full version. <a href="%s" target="_blank">**Upgrade to the full version now »**</a>', $this->translation_domain), 'http://premium.wpmudev.org/project/wordpress-chat-plugin'); ?></b></p></td> 1331 </tr> 1332 <tr class="chat_lite_disabled"> 1333 <td><label for="chat_twitter_api_key"><?php _e('@Anywhere API key', $this->translation_domain); ?></label></td> 1334 <td> 1335 <input type="text" id="chat_twitter_api_key" name="chat_default[twitter_api_key]" value="<?php print $this->get_option('twitter_api_key', ''); ?>" class="" size="40" disabled="disabled" /> 1336 </td> 1337 <td class="info"> 1338 <ol> 1339 <li><?php print sprintf(__('Register this site as an application on Twitter\'s <a target="_blank" href="%s">app registration page</a>', $this->translation_domain), "http://dev.twitter.com/apps/new"); ?></li> 1340 <li><?php _e('If you\'re not logged in, you can use your Twitter username and password', $this->translation_domain); ?></li> 1341 <li><?php _e('Your Application\'s Name will be what shows up after "via" in your twitter stream', $this->translation_domain); ?></li> 1342 <li><?php _e('Application Type should be set on Browser', $this->translation_domain); ?></li> 1343 <li><?php _e('The callback URL should be', $this->translation_domain); ?> <b><?php print get_bloginfo('url'); ?></b></li> 1344 <li><?php _e('Once you have registered your site as an application, you will be provided with @Anywhere API key.', $this->translation_domain); ?></li> 1345 <li><?php _e('Copy and paste them to the fields on the left', $this->translation_domain); ?></li> 1346 </ol> 1347 </td> 1348 </tr> 1349 </table> 1350 </div> 1351 1352 <div id="chat_facebook_api_panel" class="chat_panel chat_auth_panel"> 1353 <table border="0" cellpadding="4" cellspacing="0"> 1354 <tr> 1355 <td colspan="4" ><p class="info"><b><?php printf(__('Only available in the full version. <a href="%s" target="_blank">**Upgrade to the full version now »**</a>', $this->translation_domain), 'http://premium.wpmudev.org/project/wordpress-chat-plugin'); ?></b></p></td> 1356 </tr> 1357 <tr class="chat_lite_disabled"> 1358 <td><label for="chat_facebook_application_id"><?php _e('Application id', $this->translation_domain); ?></label></td> 1359 <td> 1360 <input type="text" id="chat_facebook_application_id" name="chat_default[facebook_application_id]" value="<?php print $this->get_option('facebook_application_id', ''); ?>" class="" size="40" disabled="disabled" /> 1361 </td> 1362 <td rowspan="2" class="info"> 1363 <ol> 1364 <li><?php print sprintf(__('Register this site as an application on Facebook\'s <a target="_blank" href="%s">app registration page</a>', $this->translation_domain), 'http://www.facebook.com/developers/createapp.php'); ?></li> 1365 <li><?php _e('If you\'re not logged in, you can use your Facebook username and password', $this->translation_domain); ?></li> 1366 <li><?php _e('The site URL should be', $this->translation_domain); ?> <b><?php print get_bloginfo('url'); ?></b></li> 1367 <li><?php _e('Once you have registered your site as an application, you will be provided with a Application ID and a Application secret.', $this->translation_domain); ?></li> 1368 <li><?php _e('Copy and paste them to the fields on the left', $this->translation_domain); ?></li> 1369 </ol> 1370 </td> 1371 </tr> 1372 1373 <tr class="chat_lite_disabled"> 1374 <td><label for="chat_facebook_application_secret"><?php _e('Application secret', $this->translation_domain); ?></label></td> 1375 <td> 1376 <input type="text" id="chat_facebook_application_secret" name="chat_default[facebook_application_secret]" value="<?php print $this->get_option('facebook_application_secret', ''); ?>" class="" size="40" disabled="disabled" /> 1377 </td> 1378 </tr> 1379 </table> 1380 </div> 1381 1382 <div id="chat_advanced_panel" class="chat_panel chat_advanced_panel"> 1383 <table border="0" cellpadding="4" cellspacing="0" > 1384 <tr> 1385 <td colspan="4" ><p class="info"><b><?php printf(__('Only available in the full version. <a href="%s" target="_blank">**Upgrade to the full version now »**</a>', $this->translation_domain), 'http://premium.wpmudev.org/project/wordpress-chat-plugin'); ?></b></p></td> 1386 </tr> 1387 <tr class="chat_lite_disabled"> 1388 <td><label for="chat_interval"><?php _e('Interval', $this->translation_domain); ?></label></td> 1389 <td> 1390 <input type="text" id="chat_interval" name="chat_default[interval]" value="<?php print $this->get_option('interval', 1); ?>" class="" size="2" disabled="disabled" /> 1391 </td> 1392 <td class="info"> 1393 Refresh interval in seconds 1394 </td> 1395 </tr> 1396 </table> 1397 </div> 1398 </div> 1399 1400 <input type="hidden" name="page_options" value="chat_default,chat_site" /> 1401 1402 <p class="submit"><input type="submit" name="Submit" 1403 value="<?php _e('Save Changes', $this->translation_domain) ?>" /></p> 1404 </form> 1405 </div> 1406 <?php 1407 } 1408 1409 /** 1410 * Title filter 1411 * 1412 * @see http://codex.wordpress.org/Function_Reference/wp_head 1413 * 1414 * @global object $current_user 1415 * @global object $post 1416 * @global array $chat_localized 1417 * @param string $title 1418 */ 1419 function wp_head() { 1420 global $current_user, $post, $chat_localized; 1421 1422 get_currentuserinfo(); 1423 1424 if ( !in_array('subscriber',$current_user->roles) ) { 1425 $vip = 'yes'; 1426 } else { 1427 $vip = 'no'; 1428 } 1429 1430 $chat_sounds = get_usermeta($current_user->ID, 'chat_sounds', 'enabled'); 1431 if (empty($chat_sounds)) { 1432 $chat_sounds = $this->get_option('sounds', "enabled"); 1433 } 1434 1435 if (!is_array($chat_localized)) { 1436 $chat_localized = array(); 1437 } 1438 1439 $chat_localized["url"] = site_url()."/wp-admin/admin-ajax.php"; 1440 $chat_localized["plugin_url"] = plugins_url("chat/"); 1441 $chat_localized["facebook_text_sign_out"] = __('Sign out of Facebook', $this->translation_domain); 1442 $chat_localized["twitter_text_sign_out"] = __('Sign out of Twitter', $this->translation_domain); 1443 $chat_localized["please_wait"] = __('Please wait...', $this->translation_domain); 1444 1445 $chat_localized["minimize"] = __('Minimize', $this->translation_domain); 1446 $chat_localized["minimize_button"] = plugins_url('chat/images/16-square-blue-remove.png'); 1447 $chat_localized["maximize"] = __('Maximize', $this->translation_domain); 1448 $chat_localized["maximize_button"] = plugins_url('chat/images/16-square-green-add.png'); 1449 1450 $chat_localized["interval"] = $this->get_option('interval', 1); 1451 1452 if ( is_user_logged_in() ) { 1453 $chat_localized['name'] = $current_user->display_name; 1454 $chat_localized['vip'] = $vip; 1455 $chat_localized['sounds'] = $chat_sounds; 1456 $chat_localized['post_id'] = $post->ID; 1457 } else { 1458 $chat_localized['name'] = ""; 1459 $chat_localized['vip'] = false; 1460 $chat_localized['sounds'] = "enabled"; 1461 $chat_localized['post_id'] = $post->ID; 1462 } 1463 1464 if ($this->get_option('twitter_api_key') != '') { 1465 $chat_localized["twitter_active"] = true; 1466 wp_enqueue_script('twitter', 'http://platform.twitter.com/anywhere.js?id='.$this->get_option('twitter_api_key').'&v=1'); 1467 } else { 1468 $chat_localized["twitter_active"] = false; 1469 } 1470 if ($this->get_option('facebook_application_id') != '') { 1471 $chat_localized["facebook_active"] = true; 1472 $chat_localized["facebook_app_id"] = $this->get_option('facebook_application_id'); 1473 wp_enqueue_script('facebook', 'http://connect.facebook.net/en_US/all.js'); 1474 } else { 1475 $chat_localized["facebook_active"] = false; 1476 } 1477 wp_enqueue_script('jquery'); 1478 wp_enqueue_script('jquery-cookie'); 1479 wp_enqueue_script('chat_js'); 1480 1481 if ($this->get_option('site', 'enabled', 'site') == 'enabled') { 1482 $atts = array( 1483 'id' => 1, 1484 'sound' => $this->get_option('sound', 'enabled', 'site'), 1485 'avatar' => $this->get_option('avatar', 'enabled', 'site'), 1486 'emoticons' => $this->get_option('emoticons', 'enabled', 'site'), 1487 'date_show' => $this->get_option('date_show', 'disabled', 'site'), 1488 'time_show' => $this->get_option('time_show', 'disabled', 'site'), 1489 'width' => $this->get_option('width', '', 'site'), 1490 'height' => $this->get_option('height', '', 'site'), 1491 'background_color' => $this->get_option('background_color', '#ffffff', 'site'), 1492 'date_color' => $this->get_option('date_color', '#6699CC', 'site'), 1493 'name_color' => $this->get_option('name_color', '#666666', 'site'), 1494 'moderator_name_color' => $this->get_option('moderator_name_color', '#6699CC', 'site'), 1495 'text_color' => $this->get_option('text_color', '#000000', 'site'), 1496 'font' => $this->get_option('font', '', 'site'), 1497 'font_size' => $this->get_option('font_size', '', 'site'), 1498 'log_creation' => $this->get_option('log_creation', 'disabled', 'site'), 1499 'log_display' => $this->get_option('log_display', 'disabled', 'site'), 1500 'login_options' => join(',', $this->get_option('login_options', array('current_user'), 'site')), 1501 'moderator_roles' => join(',', $this->get_option('moderator_roles', array('administrator','editor','author'))), 1502 ); 1503 $this->process_shortcode($atts); 1504 } 1505 } 1506 1507 /** 1508 * Check the post for the short code and mark it 1509 * 1510 * @deprecated No longer relevant with site wide chat as well 1511 */ 1512 function post_check($post_ID) { 1513 $post = get_post($post_ID); 1514 if ( $post->post_content != str_replace('[chat', '', $post->post_content) ) { 1515 update_post_meta($post_ID, '_has_chat', 'yes'); 1516 } else { 1517 delete_post_meta($post_ID, '_has_chat'); 1518 } 1519 } 1520 1521 /** 1522 * Handle profile update 1523 * 1524 * @see http://codex.wordpress.org/Function_Reference/wp_redirect 1525 * 1526 * @global object $current_user 1527 * @param string $location 1528 * @return string $location 1529 */ 1530 function profile_process($location) { 1531 global $current_user; 1532 if ( !empty( $_GET['user_id'] ) ) { 1533 $uid = $_GET['user_id']; 1534 } else { 1535 $uid = $current_user->ID; 1536 } 1537 if ( !empty( $_POST['chat_sounds'] ) ) { 1538 update_usermeta( $uid, 'chat_sounds', $_POST['chat_sounds'] ); 1539 } 1540 return $location; 1541 } 1542 1543 /** 1544 * Add sound preferences to user profile 1545 * 1546 * @global object $current_user 1547 */ 1548 function profile() { 1549 global $current_user; 1550 1551 if (!empty( $_GET['user_id'])) { 1552 $uid = $_GET['user_id']; 1553 } else { 1554 $uid = $current_user->ID; 1555 } 1556 1557 $chat_sounds = get_usermeta( $uid, 'chat_sounds' ); 1558 ?> 1559 <h3><?php _e('Chat Settings', $this->translation_domain); ?></h3> 1560 1561 <table class="form-table"> 1562 <tr> 1563 <th><label for="chat_sounds"><?php _e('Chat sounds', $this->translation_domain); ?></label></th> 1564 <td> 1565 <select name="chat_sounds" id="chat_sounds"> 1566 <option value="enabled"<?php if ( $chat_sounds == 'enabled' ) { echo ' selected="selected" '; } ?>><?php _e('Enabled', $this->translation_domain); ?></option> 1567 <option value="disabled"<?php if ( $chat_sounds == 'disabled' ) { echo ' selected="selected" '; } ?>><?php _e('Disabled', $this->translation_domain); ?></option> 1568 </select> 1569 </td> 1570 </tr> 1571 </table> 1572 <?php 1573 } 1574 1575 /** 1576 * Output CSS 1577 */ 1578 function output_css() { 1579 echo '<link rel="stylesheet" href="' . plugins_url('chat/css/style.css') . '" type="text/css" />'; 1580 } 1581 1582 /** 1583 * Validate and return the Facebook cookie payload 1584 * 1585 * @see http://developers.facebook.com/docs/guides/web#login 1586 */ 1587 function get_facebook_cookie() { 1588 $app_id = $this->get_option('facebook_application_id', ''); 1589 $application_secret = $this->get_option('facebook_application_secret', ''); 1590 1591 $args = array(); 1592 parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args); 1593 ksort($args); 1594 $payload = ''; 1595 1596 foreach ($args as $key => $value) { 1597 if ($key != 'sig') { 1598 $payload .= $key . '=' . $value; 1599 } 1600 } 1601 1602 if (md5($payload . $application_secret) != $args['sig']) { 1603 return null; 1604 } 1605 return $args; 1606 } 1607 1608 /** 1609 * Authenticate user 1610 * 1611 * @global object $current_user 1612 * @param array $options Login options 1613 * @return int How the user was authenticated or false (1,2,3,4,5) 1614 */ 1615 function authenticate($options = array()) { 1616 global $current_user; 1617 1618 // current user 1619 if (is_user_logged_in() && current_user_can('read')) { 1620 return 1; 1621 } 1622 // Network user 1623 if (in_array('network_user', $options) && is_user_logged_in()) { 1624 return 2; 1625 } 1626 if (in_array('twitter', $options) && preg_match('/twitter/', $_COOKIE['chat_stateless_user_type_104']) > 0) { 1627 return 4; 1628 } 1629 if (in_array('public_user', $options) && preg_match('/public_user/', $_COOKIE['chat_stateless_user_type_104']) > 0) { 1630 return 5; 1631 } 1632 return false; 1633 } 1634 1635 1636 /** 1637 * Get the user name 1638 * 1639 * So many loggin options, this will decide the display name of the user 1640 * 1641 * @global object $current_user 1642 * @param array $options Login options 1643 * @return string User name or false 1644 */ 1645 function get_user_name($options = array()) { 1646 global $current_user; 1647 1648 // current_user or network_user 1649 if ((is_user_logged_in() && current_user_can('read')) || (in_array('network_user', $options) && is_user_logged_in())) { 1650 return $current_user->display_name; 1651 } 1652 if (in_array('twitter', $options) && isset($_COOKIE['chat_stateless_user_type_104']) && preg_match('/twitter/', $_COOKIE['chat_stateless_user_type_104']) > 0) { 1653 return $_COOKIE['chat_stateless_user_name_twitter']; 1654 } 1655 if (in_array('public_user', $options) && isset($_COOKIE['chat_stateless_user_type_104']) && preg_match('/public_user/', $_COOKIE['chat_stateless_user_type_104']) > 0) { 1656 return $_COOKIE['chat_stateless_user_name_public_user']; 1657 } 1658 return false; 1659 } 1660 1661 /** 1662 * Do our magic in the footer and add the site wide chat 1663 */ 1664 function wp_footer() { 1665 $atts = array( 1666 'id' => 1, 1667 'sound' => $this->get_option('sound', 'enabled', 'site'), 1668 'avatar' => $this->get_option('avatar', 'enabled', 'site'), 1669 'emoticons' => $this->get_option('emoticons', 'enabled', 'site'), 1670 'date_show' => $this->get_option('date_show', 'disabled', 'site'), 1671 'time_show' => $this->get_option('time_show', 'disabled', 'site'), 1672 'width' => $this->get_option('width', '', 'site'), 1673 'height' => $this->get_option('height', '', 'site'), 1674 'background_color' => $this->get_option('background_color', '#ffffff', 'site'), 1675 'date_color' => $this->get_option('date_color', '#6699CC', 'site'), 1676 'name_color' => $this->get_option('name_color', '#666666', 'site'), 1677 'moderator_name_color' => $this->get_option('moderator_name_color', '#6699CC', 'site'), 1678 'text_color' => $this->get_option('text_color', '#000000', 'site'), 1679 'font' => $this->get_option('font', '', 'site'), 1680 'font_size' => $this->get_option('font_size', '', 'site'), 1681 'log_creation' => $this->get_option('log_creation', 'disabled', 'site'), 1682 'log_display' => $this->get_option('log_display', 'disabled', 'site'), 1683 'login_options' => join(',', $this->get_option('login_options', array('current_user'), 'site')), 1684 'moderator_roles' => join(',', $this->get_option('moderator_roles', array('administrator','editor','author'))), 1685 ); 1686 1687 if ($this->get_option('site', 'enabled', 'site') == 'enabled') { 1688 $width = $this->get_option('width', '', 'site'); 1689 if (!empty($width)) { 1690 $width_str = 'width: '.$width; 1691 $width_style = ''; 1692 } else { 1693 $width_style = ' free-width'; 1694 } 1695 echo '<div id="chat-block-site" class="chat-block-site closed'.$width_style.'" style="'.$width_str.'; background-color: '.$this->get_option('border_color', '#4b96e2', 'site').';">'; 1696 echo '<div id="chat-block-header" class="chat-block-header"><span class="chat-title-text">'.__('Chat', $this->translation_domain).'</span><span class="chat-prompt-text">'.__('Click here to chat!', $this->translation_domain).'</span>'; 1697 echo '<img src="'.plugins_url('chat/images/16-square-green-add.png').'" alt="+" width="16" height="16" title="'.__('Maximize', $this->translation_domain).'" class="chat-toggle-button" id="chat-toggle-button" />'; 1698 echo '</div>'; 1699 echo '<div id="chat-block-inner" style="background: '.$this->get_option('background_color', '#ffffff', 'site').';">'.$this->process_shortcode($atts).'</div>'; 1700 echo '</div>'; 1701 } 1702 } 1703 1704 /** 1705 * Process short code 1706 * 1707 * @global object $post 1708 * @global array $chat_localized Localized strings and options 1709 * @return string Content 1710 */ 1711 function process_shortcode($atts) { 1712 global $post, $chat_localized; 1713 1714 $a = shortcode_atts(array( 1715 'id' => 1, 1716 'sound' => $this->get_option('sound', 'enabled'), 1717 'avatar' => $this->get_option('avatar', 'enabled'), 1718 'emoticons' => $this->get_option('emoticons', 'enabled'), 1719 'date_show' => $this->get_option('date_show', 'disabled'), 1720 'time_show' => $this->get_option('time_show', 'disabled'), 1721 'width' => $this->get_option('width', '700px'), 1722 'height' => $this->get_option('height', '425px'), 1723 'background_color' => $this->get_option('background_color', '#ffffff'), 1724 'date_color' => $this->get_option('date_color', '#6699CC'), 1725 'name_color' => $this->get_option('name_color', '#666666'), 1726 'moderator_name_color' => $this->get_option('moderator_name_color', '#6699CC'), 1727 'text_color' => $this->get_option('text_color', '#000000'), 1728 'font' => $this->get_option('font', ''), 1729 'font_size' => $this->get_option('font_size', ''), 1730 'log_creation' => $this->get_option('log_creation', 'disabled'), 1731 'log_display' => $this->get_option('log_display', 'disabled'), 1732 'login_options' => join(',', $this->get_option('login_options', array('current_user'))), 1733 'moderator_roles' => join(',', $this->get_option('moderator_roles', array('administrator','editor','author'))), 1734 ), $atts); 1735 1736 foreach ($a as $k=>$v) { 1737 $chat_localized[$k.'_'.$a['id']] = $v; 1738 } 1739 1740 $font_style = ""; 1741 1742 if (!empty($a['font'])) { 1743 $font_style .= 'font-family: '.$a['font'].';'; 1744 } 1745 if (!empty($a['font_size'])) { 1746 $font_style .= 'font-size: '.$a['font_size'].'px;'; 1747 } 1748 1749 if ($post && $post->ID) { 1750 $permalink = get_permalink($post->ID); 1751 } else { 1752 $permalink = ""; 1753 } 1754 1755 $chat_url = $_SERVER['REQUEST_URI']; 1756 $chat_url = rtrim($chat_url, "/"); 1757 $chat_url = substr($chat_url, -8); 1758 1759 if (empty($permalink) || preg_match('/\?/', $permalink) > 0) { 1760 $url_separator = "&"; 1761 } else { 1762 $url_separator = "?"; 1763 } 1764 1765 $smilies_list = array(':)', ':D', ':(', ':o', '8O', ':?', '8)', ':x', ':P', ':|', ';)', ':lol:', ':oops:', ':cry:', ':evil:', ':twisted:', ':roll:', ':!:', ':?:', ':idea:', ':arrow:', ':mrgreen:'); 1766 1767 if ($post) { 1768 $content = '<div id="chat-box-'.$a['id'].'" class="chat-box" style="width: '.$a['width'].' !important; background-color: '.$a['background_color'].'; '.$font_style.'" >'; 1769 } else { 1770 $content = '<div id="chat-box-'.$a['id'].'" class="chat-box" style="width: '.$a['width'].' !important; height: '.$a['height'].' !important; background-color: '.$a['background_color'].'; '.$font_style.'" >'; 1771 } 1772 $content .= '<div id="chat-wrap-'.$a['id'].'" class="chat-wrap avatar-'.$a['avatar'].'" >'; 1773 if ($post) { 1774 $content .= '<div id="chat-area-'.$a['id'].'" class="chat-area" style="height: '.$a['height'].' !important;" ></div></div>'; 1775 } else { 1776 $content .= '<div id="chat-area-'.$a['id'].'" class="chat-area" ></div></div>'; 1777 } 1778 $chat_localized['type_'.$a['id']] = $this->authenticate(preg_split('/,/', $a['login_options'])); 1779 if ( $chat_localized['type_'.$a['id']] ) { 1780 $chat_localized['name_'.$a['id']] = $this->get_user_name(preg_split('/,/', $a['login_options'])); 1781 1782 $content .= '<div class="chat-note"><p><strong>' . __('Message', $this->translation_domain) . '</strong></p></div>'; 1783 $content .= '<form id="send-message-area">'; 1784 $content .= '<input type="hidden" name="chat-post-id" id="chat-post-id-'.$a['id'].'" value="'.$a['id'].'" class="chat-post-id" />'; 1785 1786 $content .= '<div class="chat-tool-bar-wrap"><div class="chat-note">'; 1787 1788 if ($a['emoticons'] == 'enabled') { 1789 $content .= '<div id="chat-emoticons-list-'.$a['id'].'" class="chat-emoticons-list chat-tool-bar">'; 1790 foreach ($smilies_list as $smilie) { 1791 $content .= convert_smilies($smilie); 1792 } 1793 $content .= '</div>'; 1794 } 1795 1796 $content .= '<div class="chat-clear"></div></div></div>'; 1797 1798 $content .= '<div id="chat-send-wrap">'; 1799 $content .= '<div class="chat-clear"></div>'; 1800 $content .= '<div class="chat-send-wrap"><textarea id="chat-send-'.$a['id'].'" class="chat-send"></textarea></div>'; 1801 $content .= '<div class="chat-note">' . __('"Enter" to send', $this->translation_domain) . '. ' . __('Place code in between code tags', $this->translation_domain) . '.</div>'; 1802 if ( $this->authenticate(preg_split('/,/', $a['login_options'])) > 2 ) { 1803 $content .= '<div class="chat-note"><input type="button" value="'. __('Logout', $this->translation_domain) .'" name="chat-logout-submit" class="chat-logout-submit" id="chat-logout-submit-'.$a['id'].'" /></div>'; 1804 } 1805 $content .= '</div>'; 1806 $content .= '<div class="chat-tool-bar-wrap"><div class="chat-note">'; 1807 1808 $content .= '<div class="chat-clear"></div></div></div>'; 1809 $content .= '</form>'; 1810 } else { 1811 if (preg_match('/public_user|twitter|facebook/', $a['login_options']) > 0) { 1812 if (preg_match('/public_user/', $a['login_options']) > 0) { 1813 $content .= '<div class="login-message">'.__('To get started just enter your email address and desired username', $this->translation_domain).': </div>'; 1814 $content .= '<form id="chat-login-'.$a['id'].'" class="chat-login">'; 1815 $content .= '<div id="chat-login-wrap-'.$a['id'].'" class="chat-login-wrap">'; 1816 $content .= '<label for="chat-login-name-'.$a['id'].'">'.__('Name', $this->translation_domain) . '</label> <input id="chat-login-name-'.$a['id'].'" name="chat-login-name" class="chat-login-name" type="text" /> '; 1817 $content .= '<label for="chat-login-email-'.$a['id'].'">' . __('E-mail', $this->translation_domain) . '</label> <input id="chat-login-email-'.$a['id'].'" name="chat-login-email" class="chat-login-email" type="text" /> '; 1818 $content .= '<input type="submit" value="'. __('Login', $this->translation_domain) .'" name="chat-login-submit" id="chat-login-submit-'.$a['id'].'" />'; 1819 $content .= '</div>'; 1820 $content .= '</form>'; 1821 } 1822 if (preg_match('/twitter|facebook/', $a['login_options']) > 0 && ($this->get_option('twitter_api_key') != '' or $this->get_option('facebook_application_id') != '')) { 1823 $content .= '<div class="login-message">Log in using your: </div>'; 1824 $content .= '<div class="chat-login-wrap">'; 1825 if (preg_match('/twitter/', $a['login_options']) > 0 && $this->get_option('twitter_api_key') != '') { 1826 $content .= '<span id="chat-twitter-signin-btn-'.$a['id'].'" class="chat-auth-button chat-twitter-signin-btn"></span>'; 1827 } 1828 if (preg_match('/facebook/', $a['login_options']) > 0 && $this->get_option('facebook_application_id') != '') { 1829 $content .= '<span id="chat-facebook-signin-btn-'.$a['id'].'" class="chat-auth-button chat-facebook-signin-btn"></span>'; 1830 } 1831 $content .= '</div>'; 1832 } 1833 } else { 1834 $content .= '<div class="login-message"><strong>' . __('You must be logged in to participate in chats', $this->translation_domain) . '</strong></div>'; 1835 } 1836 $content .= '<form id="send-message-area">'; 1837 $content .= '<input type="hidden" name="chat-post-id" id="chat-post-id-'.$a['id'].'" value="'.$a['id'].'" class="chat-post-id" />'; 1838 $content .= '</form>'; 1839 } 1840 1841 if ( $a['log_display'] == 'enabled' && $a['id'] != 1) { 1842 $dates = $this->get_archives($a['id']); 1843 1844 if ( $dates && is_array($dates) ) { 1845 $content .= '<br />'; 1846 $content .= '<div class="chat-note"><p><strong>' . __('Chat Logs', $this->translation_domain) . '</strong></p></div>'; 1847 foreach ($dates as $date) { 1848 $date_content .= '<li><a class="chat-log-link" style="text-decoration: none;" href="' . $permalink . $url_separator . 'lid=' . $date->id . '">' . date_i18n(get_option('date_format').' '.get_option('time_format'), strtotime($date->start) + get_option('gmt_offset') * 3600, false) . ' - ' . date_i18n(get_option('date_format').' '.get_option('time_format'), strtotime($date->end) + get_option('gmt_offset') * 3600, false) . '</a>'; 1849 if (isset($_GET['lid']) && $_GET['lid'] == $date->id) { 1850 $_POST['cid'] = $a['id']; 1851 $_POST['archived'] = 'yes'; 1852 $_POST['function'] = 'update'; 1853 $_POST['since'] = strtotime($date->start); 1854 $_POST['end'] = strtotime($date->end); 1855 $_POST['date_color'] = $a['date_color']; 1856 $_POST['name_color'] = $a['name_color']; 1857 $_POST['moderator_name_color'] = $a['moderator_name_color']; 1858 $_POST['text_color'] = $a['text_color']; 1859 $_POST['date_show'] = $a['date_show']; 1860 $_POST['time_show'] = $a['time_show']; 1861 $_POST['avatar'] = $a['avatar']; 1862 1863 $date_content .= '<div class="chat-wrap avatar-'.$a['avatar'].'" style="background-color: '.$a['background_color'].'; '.$font_style.'"><div class="chat-area" >'; 1864 $date_content .= $this->process('yes'); 1865 $date_content .= '</div></div>'; 1866 } 1867 $date_content .= '</li>'; 1868 } 1869 $content .= '<div id="chat-log-wrap-'.$a['id'].'" class="chat-log-wrap" style="background-color: '.$a['background_color'].'; '.$font_style.'"><div id="chat-log-area-'.$a['id'].'" class="chat-log-area"><ul>' . $date_content . '</ul></div></div>'; 1870 } 1871 } 1872 $content .= '<div class="chat-clear"></div></div>'; 1873 1874 wp_localize_script('chat_js', 'chat_localized', $chat_localized); 1875 1876 return $content; 1877 } 1878 1879 /** 1880 * @see http://codex.wordpress.org/TinyMCE_Custom_Buttons 1881 */ 1882 function tinymce_register_button($buttons) { 1883 array_push($buttons, "separator", "chat"); 1884 return $buttons; 1885 } 1886 1887 /** 1888 * @see http://codex.wordpress.org/TinyMCE_Custom_Buttons 1889 */ 1890 function tinymce_load_langs($langs) { 1891 $langs["chat"] = plugins_url('chat/tinymce/langs/langs.php'); 1892 return $langs; 1893 } 1894 1895 /** 1896 * @see http://codex.wordpress.org/TinyMCE_Custom_Buttons 1897 */ 1898 function tinymce_add_plugin($plugin_array) { 1899 $plugin_array['chat'] = plugins_url('chat/tinymce/editor_plugin.js'); 1900 return $plugin_array; 1901 } 1902 1903 /** 1904 * Process chat requests 1905 * 1906 * Mostly copied from process.php 1907 * 1908 * @global object $current_user 1909 * @param string $return Return? 'yes' or 'no' 1910 * @return string If $return is yes will return the output else echo 1911 */ 1912 function process($return = 'no') { 1913 global $current_user; 1914 get_currentuserinfo(); 1915 1916 $function = $_POST['function']; 1917 1918 if ( empty($function) ) { 1919 $function = $_GET['function']; 1920 } 1921 1922 $log = array(); 1923 1924 switch($function) { 1925 case 'update': 1926 $chat_id = $_POST['cid']; 1927 $since = $_POST['since']; 1928 $since_id = $_POST['since_id']; 1929 $end = isset($_POST['end'])?$_POST['end']:0; 1930 $archived = isset($_POST['archived'])?$_POST['archived']:'no'; 1931 1932 $rows = $this->get_messages($chat_id, $since, $end, $archived, $since_id); 1933 1934 if ($rows) { 1935 $text = array(); 1936 1937 foreach ($rows as $row) { 1938 $message = stripslashes($row->message); 1939 $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; 1940 1941 if(($message) != "\n" && ($message) != "<br />" && ($message) != "") { 1942 if(preg_match($reg_exUrl, $message, $url)) { 1943 $message = preg_replace($reg_exUrl, '<a href="'.$url[0].'" target="_blank">'.$url[0].'</a>', $message); 1944 } 1945 } 1946 1947 $message = preg_replace(array('/\[code\]/','/\[\/code\]/'), array('<code style="background: '.$this->get_option('code_color', '#FFFFCC').'; padding: 4px 8px;">', '</code>'), $message); 1948 1949 $message = str_replace("\n", "<br />", $message); 1950 1951 $prepend = ""; 1952 if ($_POST['avatar'] == 'enabled') { 1953 if (preg_match('/@/', $row->avatar)) { 1954 $avatar = get_avatar($row->avatar, 50, null, $row->name); 1955 } else { 1956 $avatar = "<img alt='{$row->name}' src='{$row->avatar}' class='avatar photo' />"; 1957 } 1958 $prepend .= "$avatar "; 1959 } 1960 1961 if ($_POST['date_show'] == 'enabled') { 1962 $prepend .= ' <span class="date" style="background: '.$_POST['date_color'].';">'. date_i18n(get_option('date_format'), strtotime($row->timestamp) + get_option('gmt_offset') * 3600, false) . '</span>'; 1963 } 1964 if ($_POST['time_show'] == 'enabled') { 1965 $prepend .= ' <span class="time" style="background: '.$_POST['date_color'].';">'. date_i18n(get_option('time_format'), strtotime($row->timestamp) + get_option('gmt_offset') * 3600, false) . '</span>'; 1966 } 1967 1968 if ($row->moderator == 'yes') { 1969 $name_color = $_POST['moderator_name_color']; 1970 } else { 1971 $name_color = $_POST['name_color']; 1972 } 1973 1974 $prepend .= ' <span class="name" style="background: '.$name_color.';">'.stripslashes($row->name).'</span>'; 1975 1976 $text[$row->id] = " <div id='row-".strtotime($row->timestamp)."' class='row'>{$prepend}<span class='message' style='color: ".$_POST['text_color']."'>".convert_smilies($message)."</span><div class='chat-clear'></div></div>"; 1977 $last_check = $row->timestamp; 1978 } 1979 1980 $log['text'] = $text; 1981 $log['time'] = strtotime($last_check)+1; 1982 } 1983 break; 1984 case 'send': 1985 $chat_id = $_POST['cid']; 1986 $name = htmlentities(strip_tags($_POST['name'])); 1987 $avatar = (isset($_COOKIE['chat_stateless_user_image_'.$this->auth_type_map[$_POST['type']]]) && !empty($_COOKIE['chat_stateless_user_image_'.$this->auth_type_map[$_POST['type']]]))?$_COOKIE['chat_stateless_user_image_'.$this->auth_type_map[$_POST['type']]]:$current_user->user_email; 1988 // $avatar = ($current_user && $current_user->user_email && $current_user->display_name == $_POST['name'])?$current_user->user_email:$avatar; 1989 $message = $_POST['message']; 1990 1991 $moderator_roles = explode(',', $_POST['moderator_roles']); 1992 $moderator = $this->is_moderator($moderator_roles); 1993 1994 $message = preg_replace(array('/<code>/','/<\/code>/'), array('[code]', '[/code]'), $message); 1995 1996 $message = htmlentities(strip_tags($message)); 1997 $smessage = base64_decode($message); 1998 1999 2000 $this->send_message($chat_id, $name, $avatar, base64_encode($smessage), $moderator); 2001 break; 2002 } 2003 2004 if ($return == 'yes') { 2005 if (isset($log['text']) && is_array($log['text'])) { 2006 return "<p>".join("</p><p>", $log['text'])."</p>"; 2007 } else { 2008 return ""; 2009 } 2010 } else { 2011 echo json_encode($log); 2012 exit(0); 2013 } 2014 } 2015 2016 /** 2017 * Test whether logged in user is a moderator 2018 * 2019 * @param Array $moderator_roles Moderator roles 2020 * @return bool $moderator True if moderator False if not 2021 */ 2022 function is_moderator($moderator_roles) { 2023 global $current_user; 2024 2025 if ($current_user->ID) { 2026 foreach ($moderator_roles as $role) { 2027 if (in_array($role, $current_user->roles)) { 2028 return true; 2029 } 2030 } 2031 } 2032 return false; 2033 } 2034 2035 /** 2036 * Get message 2037 * 2038 * @global object $wpdb 2039 * @global int $blog_id 2040 * @param int $chat_id Chat ID 2041 * @param int $since Start Unix timestamp 2042 * @param int $end End Unix timestamp 2043 * @param string $archived Archived? 'yes' or 'no' 2044 */ 2045 function get_messages($chat_id, $since = 0, $end = 0, $archived = 'no', $since_id = false) { 2046 global $wpdb, $blog_id; 2047 2048 $chat_id = $wpdb->escape($chat_id); 2049 $archived = $wpdb->escape($archived); 2050 $since_id = $wpdb->escape($since_id); 2051 2052 if (empty($end)) { 2053 $end = time(); 2054 } 2055 2056 $start = date('Y-m-d H:i:s', $since); 2057 $end = date('Y-m-d H:i:s', $end); 2058 2059 if ($since_id == false) { 2060 $since_id = 0; 2061 } else { 2062 $start = date('Y-m-d H:i:s', 0); 2063 } 2064 2065 return $wpdb->get_results( 2066 "SELECT * FROM `".Chat::tablename('message')."` WHERE blog_id = '$blog_id' AND chat_id = '$chat_id' AND archived = '$archived' AND timestamp BETWEEN '$start' AND '$end' AND id > '$since_id' ORDER BY timestamp ASC;" 2067 ); 2068 } 2069 2070 /** 2071 * Send the message 2072 * 2073 * @global object $wpdb 2074 * @global int $blog_id 2075 * @param int $chat_id Chat ID 2076 * @param string $name Name 2077 * @param string $avatar URL or e-mail 2078 * @param string $message Payload message 2079 * @param string $moderator Moderator 2080 */ 2081 function send_message($chat_id, $name, $avatar, $message, $moderator) { 2082 global $wpdb, $blog_id; 2083 2084 $wpdb->real_escape = true; 2085 2086 $time_stamp = date("Y-m-d H:i:s"); 2087 2088 $chat_id = $wpdb->_real_escape($chat_id); 2089 $name = $wpdb->_real_escape(trim(base64_decode($name))); 2090 $avatar = $wpdb->_real_escape(trim($avatar)); 2091 $message = $wpdb->_real_escape(trim(base64_decode($message))); 2092 $moderator_str = 'no'; 2093 2094 if (empty($message)) { 2095 return false; 2096 } 2097 if ($moderator) { 2098 $moderator_str = 'yes'; 2099 } 2100 2101 return $wpdb->query("INSERT INTO ".Chat::tablename('message')." 2102 (blog_id, chat_id, timestamp, name, avatar, message, archived, moderator) 2103 VALUES ('$blog_id', '$chat_id', '$time_stamp', '$name', '$avatar', '$message', 'no', '$moderator_str');"); 2104 } 2105 2106 /** 2107 * Get the last chat id for the given blog 2108 * 2109 * @global object $wpdb 2110 * @global int $blog_id 2111 */ 2112 function get_last_chat_id() { 2113 global $wpdb, $blog_id; 2114 2115 $last_id = $wpdb->get_var("SELECT chat_id FROM `".Chat::tablename('message')."` WHERE blog_id = '{$blog_id}' ORDER BY chat_id DESC LIMIT 1"); 2116 2117 if ($last_id) { 2118 return substr($last_id, 0, -1); 2119 } 2120 return 1; 2121 } 2122 2123 /** 2124 * Clear a chat log 2125 * 2126 * @global object $wpdb 2127 * @global int $blog_id 2128 */ 2129 function clear() { 2130 global $wpdb, $blog_id; 2131 2132 $since = date('Y-m-d H:i:s', $_POST['since']); 2133 $chat_id = $wpdb->escape($_POST['cid']); 2134 2135 if (current_user_can('edit_posts') && current_user_can('edit_pages')) { 2136 $wpdb->query("DELETE FROM `".Chat::tablename('message')."` WHERE blog_id = '{$blog_id}' AND chat_id = '{$chat_id}' AND timestamp <= '{$since}' AND archived = 'no';"); 2137 } 2138 exit(0); 2139 } 2140 2141 /** 2142 * Archive a chat log 2143 * 2144 * @global object $wpdb 2145 * @global int $blog_id 2146 */ 2147 function archive() { 2148 global $wpdb, $blog_id; 2149 2150 $since = date('Y-m-d H:i:s', $_POST['since']); 2151 $chat_id = $wpdb->escape($_POST['cid']); 2152 $created = date('Y-m-d H:i:s'); 2153 2154 if (current_user_can('edit_posts') && current_user_can('edit_pages')) { 2155 $start = $wpdb->get_var("SELECT timestamp FROM `".Chat::tablename('message')."` WHERE blog_id = '{$blog_id}' AND chat_id = '{$chat_id}' AND timestamp <= '{$since}' AND archived = 'no' ORDER BY timestamp ASC LIMIT 1;"); 2156 $end = $wpdb->get_var("SELECT timestamp FROM `".Chat::tablename('message')."` WHERE blog_id = '{$blog_id}' AND chat_id = '{$chat_id}' AND timestamp <= '{$since}' AND archived = 'no' ORDER BY timestamp DESC LIMIT 1;"); 2157 2158 $sql = array(); 2159 2160 $sql[] = "SELECT timestamp FROM `".Chat::tablename('message')."` WHERE blog_id = '{$blog_id}' AND chat_id = '{$chat_id}' AND timestamp <= '{$since}' AND archived = 'no' ORDER BY timestamp DESC LIMIT 1;"; 2161 $sql[] = "SELECT timestamp FROM `".Chat::tablename('message')."` WHERE blog_id = '{$blog_id}' AND chat_id = '{$chat_id}' AND timestamp <= '{$since}' AND archived = 'no' ORDER BY timestamp ASC LIMIT 1; "; 2162 $sql[] = "UPDATE `".Chat::tablename('message')."` set archived = 'yes' WHERE blog_id = '{$blog_id}' AND chat_id = '{$chat_id}' AND timestamp BETWEEN '{$start}' AND '{$end}' AND archived = 'no';"; 2163 2164 $wpdb->query("UPDATE `".Chat::tablename('message')."` set archived = 'yes' WHERE blog_id = '{$blog_id}' AND chat_id = '{$chat_id}' AND timestamp BETWEEN '{$start}' AND '{$end}' AND archived = 'no';"); 2165 2166 $wpdb->query("INSERT INTO ".Chat::tablename('log')." 2167 (blog_id, chat_id, start, end, created) 2168 VALUES ('$blog_id', '$chat_id', '$start', '$end', '$created');"); 2169 } 2170 2171 exit(0); 2172 } 2173 2174 /** 2175 * Get a list of archives for the given chat 2176 * 2177 * @global object $wpdb 2178 * @global int $blog_id 2179 * @param int $chat_id Chat ID 2180 * @return array List of archives 2181 */ 2182 function get_archives($chat_id) { 2183 global $wpdb, $blog_id; 2184 2185 $chat_id = $wpdb->escape($chat_id); 2186 2187 return $wpdb->get_results( 2188 "SELECT * FROM `".Chat::tablename('log')."` WHERE blog_id = '$blog_id' AND chat_id = '$chat_id' ORDER BY created ASC;" 2189 ); 2190 } 2191 } 2192 } 2193 2194 // Lets get things started 2195 $chat = new Chat();
Note: See TracChangeset
for help on using the changeset viewer.