BP_Group_tinychat

The BuddyPress Group Tiny Chat BP Group tinychat class.

Defined (1)

The class is defined in the following location(s).

/includes/bp-group-tinychat-core.php  
  1. class BP_Group_tinychat extends BP_Group_Extension {  
  2.  
  3. function bp_group_tinychat() { 
  4. global $bp; 
  5.  
  6. $this->name = 'Group Chat'; 
  7. $this->slug = 'group-chat'; 
  8.  
  9. $this->create_step_position = 16; 
  10. $this->nav_item_position = 31; 
  11.  
  12. if ( groups_get_groupmeta( $bp->groups->current_group->id, 'bp_group_tinychat_enabled' ) == '1' ) { 
  13. $this->enable_nav_item = true; 
  14. } else { 
  15. $this->enable_nav_item = false; 
  16. }  
  17.  
  18. }  
  19.  
  20. function create_screen() { 
  21. global $bp; 
  22.  
  23. if ( !bp_is_group_creation_step( $this->slug ) ) 
  24. return false; 
  25.  
  26. wp_nonce_field( 'groups_create_save_' . $this->slug ); 
  27. ?> 
  28. <input type="checkbox" name="bp_group_tinychat_enabled" id="bp_group_tinychat_enabled" value="1"  
  29. <?php  
  30. if ( groups_get_groupmeta( $bp->groups->current_group->id, 'bp_group_tinychat_enabled' ) == '1' ) { 
  31. echo 'checked=1'; 
  32. ?> 
  33. /> 
  34. Enable <a href="http://wordpress.org/extend/plugins/bp-group-tinychat/" target="_blank">Group-Tinychat</a> 
  35. <hr> 
  36. <?php 
  37.  
  38. function create_screen_save() { 
  39. global $bp; 
  40.  
  41. check_admin_referer( 'groups_create_save_' . $this->slug );  
  42.  
  43. if ( $_POST['bp_group_tinychat_enabled'] == 1 ) { 
  44. groups_update_groupmeta( $bp->groups->current_group->id, 'bp_group_tinychat_enabled', 1 ); 
  45.  
  46. function edit_screen() { 
  47. global $bp; 
  48.  
  49. if ( !groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 
  50. return false; 
  51.  
  52. if ( !bp_is_group_admin_screen( $this->slug ) ) 
  53. return false; 
  54.  
  55. wp_nonce_field( 'groups_edit_save_' . $this->slug ); 
  56. ?> 
  57. <input type="checkbox" name="bp_group_tinychat_enabled" id="bp_group_tinychat_enabled" value="1"  
  58. <?php  
  59. if ( groups_get_groupmeta( $bp->groups->current_group->id, 'bp_group_tinychat_enabled' ) == '1' ) { 
  60. echo 'checked=1'; 
  61. ?> 
  62. /> 
  63. Enable <a href="http://wordpress.org/extend/plugins/bp-group-tinychat/" target="_blank">Group-Tinychat</a> 
  64.  
  65. <hr> 
  66. <input type="submit" name="save" value="Save" /> 
  67. <?php 
  68.  
  69. function edit_screen_save() { 
  70. global $bp; 
  71.  
  72. if ( !isset( $_POST['save'] ) ) 
  73. return false; 
  74.  
  75. check_admin_referer( 'groups_edit_save_' . $this->slug ); 
  76.  
  77. if ( $_POST['bp_group_tinychat_enabled'] == 1 ) { 
  78. groups_update_groupmeta( $bp->groups->current_group->id, 'bp_group_tinychat_enabled', 1 ); 
  79. } else { 
  80. groups_update_groupmeta( $bp->groups->current_group->id, 'bp_group_tinychat_enabled', 0 ); 
  81.  
  82. bp_core_add_message( __( 'Settings saved successfully', 'buddypress' ) ); 
  83.  
  84. bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/' . $this->slug ); 
  85.  
  86.  
  87. function display() { 
  88. global $bp; 
  89.  
  90. if ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) || groups_is_user_mod( $bp->loggedin_user->id, $bp->groups->current_group->id ) || groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) || is_super_admin() ) { 
  91.  
  92. $tinychat_display = true; 
  93. $name = apply_filters( 'bp_get_group_name', $bp->groups->current_group->name ); 
  94. $urlparts = parse_url(site_url()); 
  95. $domain = $urlparts [host]; 
  96. $domainparts = explode(".", $domain); 
  97. $domain = $domainparts[count($domainparts)-2] . "." . $domainparts[count($domainparts)-1]; 
  98. $domain = substr($domain, 0, 5); 
  99. $string = $domain.$name; 
  100. $string = ereg_replace("[^A-Za-z0-9]", "", $string ); 
  101. $string = substr($string, 0, 15); 
  102. $name = strtolower($string); 
  103. for ($i = 5; $i < strlen($name); $i++) {  
  104. $asciiValue = ord($name{$i}); 
  105. if ($asciiValue >= 97 && $asciiValue < 106) {  
  106. $name{$i} = $asciiValue - 96; }  
  107. if ($asciiValue >= 106 && $asciiValue < 115) {  
  108. $name{$i} = $asciiValue - 105; } 
  109. if ($asciiValue >= 115 && $asciiValue < 123) {  
  110. $name{$i} = $asciiValue - 114; } 
  111. }  
  112. ?> 
  113. <script type="text/javascript">var tinychat = { room: "<?php echo $name; ?>", colorbk: "0xffffff", join: "auto", api: "list", owner: "none", desktop: "true"}; </script><script src="http://tinychat.com/js/embed.js"></script> 
  114. <?php 
  115.  
  116. }  
  117. else { 
  118. echo '<div id="message" class="error"><p>Group_tinychat only available to group members.</p></div>'; 
  119.  
  120. function widget_display() {  
  121. // Not used