b2evolution PHP Cross Reference Blogging Systems

Source: /inc/users/model/_user_js.funcs.php - 111 lines - 3700 bytes - Summary - Text - Print

   1  <?php
   2  
   3  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
   4  
   5  ?>
   6  
   7  <script type="text/javascript">
   8  /**

   9   * Init autocomplete event for Specific criteria input

  10   */
  11  function userfield_criteria_autocomplete( obj_this )
  12  {
  13      if( obj_this.find( 'option:selected[rel=suggest]' ).length > 0 )
  14      {    // Selected field type can be suggested with values
  15          var field_type_id = obj_this.val();
  16          obj_this.next().find( 'input' ).autocomplete({
  17              source: function(request, response) {
  18                  jQuery.getJSON( htsrv_url + 'anon_async.php?action=get_user_field_autocomplete', {
  19                      term: request.term, attr_id: field_type_id
  20                  }, response);
  21              },
  22          });
  23      }
  24      else
  25      {    // Destroy autocomplete event from previous binding
  26          obj_this.next().find( 'input' ).autocomplete( 'destroy' );
  27      }
  28  }
  29  
  30  jQuery( document ).on( 'change', 'select[id^=criteria_type]', function()
  31  {
  32      userfield_criteria_autocomplete( jQuery( this ) );
  33  } );
  34  
  35  if( jQuery( 'select[id^=criteria_type]:first' ).val() == '' )
  36  {    // Pre-select a random option
  37      var count_options = parseInt( jQuery( 'select[id^=criteria_type]:first option' ).length );
  38      var index = Math.ceil( Math.random() * count_options );
  39      if( index == count_options )
  40      {    // Exclude empty value
  41          index = 1;
  42      }
  43      jQuery( 'select[id^=criteria_type]:first option:eq(' + index + ')' ).attr( 'selected', 'selected' );
  44  }
  45  
  46  for(var c = 0; c < jQuery( 'select[id^=criteria_type]' ).length; c++ )
  47  {    // Bind autocomplete event for each Specific criteria
  48      userfield_criteria_autocomplete( jQuery( 'select[id^=criteria_type]:eq(' + c + ')' ) );
  49  }
  50  
  51  jQuery( document ).on( 'click', 'span[rel=add_criteria]', function()
  52  {    // Add new criteria to search
  53      obj_this = jQuery( this ).parent().parent();
  54      jQuery.ajax({
  55      type: 'POST',
  56      url: '<?php echo get_samedomain_htsrv_url(); ?>anon_async.php',
  57      data: 'action=get_userfields_criteria',
  58      success: function( result )
  59          {    // Display fieldset of new Specific criteria
  60              obj_this.after( ajax_debug_clear( result ) );
  61  
  62              // Preselect a random option

  63              obj_new = obj_this.next().next();
  64              var count_options = parseInt( obj_new.find( 'option' ).length );
  65              var index = Math.ceil( Math.random() * count_options );
  66              if( index == count_options )
  67              {    // Exclude empty value
  68                  index = 1;
  69              }
  70              obj_new.find( 'option:eq(' + index + ')' ).attr( 'selected', 'selected' );
  71  
  72              // Bind auto complete event to the new select

  73              userfield_criteria_autocomplete( obj_new.find( 'select' ) );
  74          }
  75      });
  76  } );
  77  
  78  <?php
  79  global $current_User;
  80  if( is_admin_page() && is_logged_in() && $current_User->check_perm( 'users', 'edit', false ) )
  81  {    // If user can edit the users - Init js to edit user level by AJAX
  82  ?>
  83  jQuery(document).ready( function()
  84  {
  85      jQuery('.user_level_edit').editable( htsrv_url+'async.php?action=user_level_edit&<?php echo url_crumb( 'userlevel' )?>',
  86      {
  87          data : function(value, settings){
  88                  value = ajax_debug_clear( value );
  89                  var re = /rel="(.*)"/;
  90                  var result = value.match(re);
  91                  return {'0':'0','1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'8','9':'9','10':'10', 'selected' : result[1]}
  92              },
  93          type     : 'select',
  94          name     : 'new_user_level',
  95          tooltip  : '<?php echo TS_('Click to edit'); ?>',
  96          event    : 'click',
  97          callback : function (settings, original){
  98                  evoFadeSuccess(this);
  99              },
 100          onsubmit: function(settings, original) {},
 101          submitdata : function(value, settings) {
 102                  var user_ID =  jQuery(':first',jQuery(this).parent()).text();
 103                  return {user_ID: user_ID}
 104              },
 105          onerror : function(settings, original, xhr) {
 106                  evoFadeFailure(original);
 107              }
 108      } );
 109  });
 110  <?php } ?>
 111  </script>

title

Description

title

Description

title

Description

title

title

Body