b2evolution PHP Cross Reference Blogging Systems

Source: /inc/comments/model/_comment_js.funcs.php - 391 lines - 9707 bytes - Summary - Text - Print

   1  <?php
   2  
   3  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
   4  
   5  global $Blog, $current_User, $Session, $admin_url, $status_list;
   6  
   7  ?>
   8  <script type="text/javascript">
   9  
  10  var modifieds = new Array();
  11  
  12  function isDefined( variable )
  13  {
  14      return (typeof(variable) != 'undefined');
  15  }
  16  
  17  //Fade in background color
  18  function fadeIn( id, color )
  19  {
  20      var bg_color = jQuery('#' + id).css( 'backgroundColor' );
  21      jQuery('#' + id).animate({ backgroundColor: color }, 200);
  22      return bg_color;
  23  }
  24  
  25  function fadeInStatus( id, status )
  26  {
  27      switch(status)
  28      {
  29  
  30          case 'published':
  31              return fadeIn( id, '#99EE44' );
  32          case 'community':
  33              return fadeIn( id, '#2E8BB9' );
  34          case 'protected':
  35              return fadeIn( id, '#FF9C2A' );
  36          case 'review':
  37              return fadeIn( id, '#CC0099' );
  38          case 'deprecated':
  39              return fadeIn( id, '#656565' );
  40          case 'deleted':
  41              return fadeIn( id, '#fcc' );
  42          case 'spam':
  43              return fadeIn( id, '#ffc9c9' );
  44          case 'notsure':
  45              return fadeIn( id, '#bbbbbb' );
  46          case 'ok':
  47              return fadeIn( id, '#bcffb5' );
  48      }
  49  }
  50  
  51  function delete_comment_url( comment_id )
  52  {
  53      var divid = 'commenturl_' + comment_id;
  54      fadeIn(divid, '#fcc');
  55  
  56      jQuery.ajax({
  57          type: 'POST',
  58          url: '<?php echo get_samedomain_htsrv_url(); ?>async.php',
  59          data: 'blogid=' + <?php echo $Blog->ID ?> + '&commentid=' + comment_id + '&action=delete_comment_url' + '&' + <?php echo '\''.url_crumb('comment').'\''; ?>,
  60          success: function(result) { jQuery('#' + divid).remove(); }
  61      });
  62  }
  63  
  64  function show_modifieds()
  65  {
  66      for(var id in modifieds)
  67      {
  68          fadeInStatus( id, modifieds[id] );
  69      }
  70  }
  71  
  72  // Set comments status
  73  function setCommentStatus( id, status, redirect_to )
  74  {
  75      var divid = 'c' + id;
  76      fadeInStatus( divid, status );
  77      modifieds[divid] = status;
  78  
  79      var statuses = get_show_statuses();
  80      var expiry_status = get_expiry_status();
  81      var currentpage = get_current_page();
  82      var item_id = get_itemid();
  83      var limit = get_limit();
  84  
  85      jQuery.ajax({
  86      type: 'POST',
  87      url: '<?php echo get_samedomain_htsrv_url(); ?>async.php',
  88      data:
  89          { 'blogid': <?php echo '\''.$Blog->ID.'\''; ?>,
  90              'commentid': id,
  91              'status': status,
  92              'limit': limit,
  93              'action': 'set_comment_status',
  94              'moderation': 'commentlist',
  95              'statuses': statuses,
  96              'expiry_status': expiry_status,
  97              'itemid': item_id,
  98              'currentpage': currentpage,
  99              'redirect_to': redirect_to,
 100              'crumb_comment': <?php echo '\''.get_crumb('comment').'\''; ?>,
 101          },
 102      success: function(result)
 103          {
 104              delete modifieds[divid];
 105              jQuery( '#comments_container' ).html( ajax_debug_clear( result ) );
 106              jQuery( '.vote_spam' ).show();
 107              show_modifieds();
 108          }
 109      });
 110  }
 111  
 112  // Display voting tool when JS is enable
 113  jQuery( 'document' ).ready( function() { jQuery( '.vote_spam' ).show(); } );
 114  // Set comments vote
 115  function setCommentVote( id, type, vote )
 116  {
 117      var color = fadeInStatus( 'c' + id, vote );
 118  
 119      var highlight_class = '';
 120      switch(vote)
 121      {
 122          case 'spam':
 123              highlight_class = 'roundbutton_red';
 124              break;
 125          case 'ok':
 126              highlight_class = 'roundbutton_green';
 127              break;
 128      }
 129  
 130      if( highlight_class != '' )
 131      {
 132          jQuery( '#vote_'+type+'_'+id ).find( 'a.roundbutton, span.roundbutton' ).addClass( highlight_class );
 133      }
 134  
 135      jQuery.ajax({
 136      type: 'POST',
 137      url: '<?php echo get_samedomain_htsrv_url(); ?>anon_async.php',
 138      data:
 139          { 'blogid': <?php echo '\''.$Blog->ID.'\''; ?>,
 140              'commentid': id,
 141              'type': type,
 142              'vote': vote,
 143              'action': 'set_comment_vote',
 144              'crumb_comment': <?php echo '\''.get_crumb('comment').'\''; ?>,
 145          },
 146      success: function(result)
 147          {
 148              fadeIn( 'c' + id, color );
 149              jQuery('#vote_'+type+'_'+id).after( ajax_debug_clear( result ) );
 150              jQuery('#vote_'+type+'_'+id).remove();
 151          }
 152      });
 153  }
 154  
 155  //Delete comment
 156  function deleteComment( commentIds )
 157  {
 158      if( ! (commentIds instanceof Array) )
 159      {
 160          commentIds = [commentIds];
 161      }
 162      for(var id in commentIds)
 163      {
 164          var divid = 'c' + commentIds[id];
 165          if( jQuery('#'+divid) != null )
 166          {
 167              fadeIn(divid, '#fcc');
 168              modifieds[divid] = 'deleted';
 169          }
 170      }
 171  
 172      var statuses = get_show_statuses();
 173      var expiry_status = get_expiry_status();
 174      var item_id = get_itemid();
 175      var currentpage = get_current_page();
 176      var limit = get_limit();
 177  
 178      jQuery.ajax({
 179      type: 'POST',
 180      url: '<?php echo get_samedomain_htsrv_url(); ?>async.php',
 181      data: 'action=get_opentrash_link&' + <?php echo '\''.url_crumb('comment').'\''; ?>,
 182      success: function(result)
 183          {
 184              jQuery('#recycle_bin').replaceWith( ajax_debug_clear( result ) );
 185          }
 186      });
 187  
 188      jQuery.ajax({
 189      type: 'POST',
 190      url: '<?php echo get_samedomain_htsrv_url(); ?>async.php',
 191      data:
 192          { 'blogid': '<?php echo $Blog->ID; ?>',
 193              'commentIds': commentIds,
 194              'action': 'delete_comments',
 195              'itemid': item_id,
 196              'statuses': statuses,
 197              'expiry_status': expiry_status,
 198              'currentpage': currentpage,
 199              'limit': limit,
 200              'crumb_comment': '<?php echo get_crumb('comment'); ?>',
 201          },
 202      success: function(result)
 203          {
 204              jQuery( '#' + divid ).effect( 'transfer', { to: jQuery( '#recycle_bin' ) }, 700, function() {
 205                  delete modifieds[divid];
 206                  jQuery( '#comments_container' ).html( ajax_debug_clear( result ) );
 207                  jQuery( '.vote_spam' ).show();
 208                  show_modifieds();
 209              });
 210          }
 211      });
 212  }
 213  
 214  //This is called when we get the response from the server:
 215  function antispamSettings( the_html )
 216  {
 217      // add placeholder for antispam settings form:
 218      jQuery( 'body' ).append( '<div id="screen_mask" onclick="closeAntispamSettings()"></div><div id="overlay_page"></div>' );
 219      var evobar_height = jQuery( '#evo_toolbar' ).height();
 220      jQuery( '#screen_mask' ).css({ top: evobar_height });
 221      jQuery( '#screen_mask' ).fadeTo(1,0.5).fadeIn(200);
 222      jQuery( '#overlay_page' ).html( the_html ).addClass( 'overlay_page_active' );
 223      AttachServerRequest( 'antispam_ban' ); // send form via hidden iframe
 224      jQuery( '#close_button' ).bind( 'click', closeAntispamSettings );
 225      jQuery( '.SaveButton' ).bind( 'click', refresh_overlay );
 226  
 227      // Close antispam popup if Escape key is pressed:
 228      var keycode_esc = 27;
 229      jQuery(document).keyup(function(e)
 230      {
 231          if( e.keyCode == keycode_esc )
 232          {
 233              closeAntispamSettings();
 234          }
 235      });
 236  }
 237  
 238  // This is called to close the antispam ban overlay page
 239  function closeAntispamSettings()
 240  {
 241      jQuery( '#overlay_page' ).hide();
 242      jQuery( '.action_messages').remove();
 243      jQuery( '#server_messages' ).insertBefore( '.first_payload_block' );
 244      jQuery( '#overlay_page' ).remove();
 245      jQuery( '#screen_mask' ).remove();
 246      return false;
 247  }
 248  
 249  // Ban comment url
 250  function ban_url( authorurl )
 251  {
 252      <?php global $rsc_url; ?>
 253      antispamSettings( '<img src="<?php echo $rsc_url; ?>img/ajax-loader2.gif" alt="<?php echo T_('Loading...'); ?>" title="<?php echo T_('Loading...'); ?>" style="display:block;margin:auto;position:absolute;top:0;bottom:0;left:0;right:0;" />' );
 254      jQuery.ajax({
 255          type: 'POST',
 256          url: '<?php echo $admin_url; ?>',
 257          data: 'ctrl=antispam&action=ban&display_mode=js&mode=iframe&request=checkban&keyword=' + authorurl +
 258                '&' + <?php echo '\''.url_crumb('antispam').'\''; ?>,
 259          success: function(result)
 260          {
 261              antispamSettings( result );
 262          }
 263      });
 264  }
 265  
 266  // Refresh overlay page after Check&ban button click
 267  function refresh_overlay()
 268  {
 269      var parameters = jQuery( '#antispam_add' ).serialize();
 270  
 271      jQuery.ajax({
 272          type: 'POST',
 273          url: '<?php echo $admin_url; ?>',
 274          data: 'action=ban&display_mode=js&mode=iframe&request=checkban&' + parameters,
 275          success: function(result)
 276          {
 277              antispamSettings( result );
 278          }
 279      });
 280      return false;
 281  }
 282  
 283  // Refresh comments on dashboard after ban url -> delete comment
 284  function refreshAfterBan( deleted_ids )
 285  {
 286      var comment_ids = String(deleted_ids).split(',');
 287      for( var i=0;i<comment_ids.length; ++i )
 288      {
 289          var divid = 'c' + comment_ids[i];
 290          fadeIn(divid, '#fcc');
 291      }
 292      var item_id = get_itemid();
 293      refresh_item_comments( item_id );
 294  }
 295  
 296  function startRefreshComments( item_id, currentpage )
 297  {
 298      jQuery('#comments_container').fadeTo( 'slow', 0.1, function() {
 299          refresh_item_comments( item_id, currentpage );
 300      } );
 301  }
 302  
 303  function endRefreshComments( result )
 304  {
 305      jQuery('#comments_container').html(result);
 306      jQuery('#comments_container').fadeTo( "slow", 1 );
 307  }
 308  
 309  function get_current_page()
 310  {
 311      if( ( isDefined( jQuery('#currentpage') ) ) && isDefined( jQuery('#currentpage').attr('value') ) )
 312      {
 313          return jQuery('#currentpage').attr('value');
 314      }
 315      return 1;
 316  }
 317  
 318  function get_limit()
 319  {
 320      var limit = jQuery( 'select[name$=_per_page]' );
 321      if( ( isDefined( limit ) ) )
 322      {
 323          return limit.val();
 324      }
 325      return 0;
 326  }
 327  
 328  function get_show_statuses()
 329  {
 330      if( jQuery('#only_draft') && jQuery('#only_draft').attr('checked') )
 331      {
 332          return '(draft)';
 333      }
 334      else if( jQuery('#only_published') && jQuery('#only_published').attr('checked') )
 335      {
 336          return '(published)';
 337      }
 338  
 339      return '(published,community,protected,private,review,draft,deprecated)';
 340  }
 341  
 342  function get_expiry_status()
 343  {
 344      var expiry_status = 'active';
 345      if( jQuery('#show_expiry_all') && jQuery('#show_expiry_all').attr('checked') )
 346      {
 347          expiry_status = 'all';
 348      }
 349  
 350      return expiry_status;
 351  }
 352  
 353  function get_itemid()
 354  {
 355      var item_id = jQuery('#comments_container').attr('value');
 356      if( ! isDefined( item_id) )
 357      {
 358          item_id = -1;
 359      }
 360      return item_id;
 361  }
 362  
 363  function refresh_item_comments( item_id, currentpage )
 364  {
 365      var statuses = get_show_statuses();
 366      var expiry_status = get_expiry_status();
 367  
 368      if( ! isDefined( currentpage ) )
 369      {
 370          currentpage = get_current_page();
 371      }
 372      if( ! isDefined( item_id) )
 373      { // show all comments
 374          item_id = -1;
 375      }
 376      jQuery.ajax({
 377          type: 'POST',
 378          url: '<?php echo get_samedomain_htsrv_url(); ?>async.php',
 379          data: 'blogid=' + <?php echo $Blog->ID; ?> + '&action=refresh_item_comments&itemid=' + item_id + '&statuses=' + statuses + '&currentpage=' + currentpage + '&expiry_status=' + expiry_status,
 380          success: function(result)
 381          {
 382              endRefreshComments( ajax_debug_clear( result ) );
 383              show_modifieds();
 384          }
 385      });
 386  }
 387  
 388  </script>
 389  <?php
 390  //end
 391  ?>

title

Description

title

Description

title

Description

title

title

Body