WordPress.org

Plugin Directory

Changeset 1586440


Ignore:
Timestamp:
02/01/17 11:45:36 (9 months ago)
Author:
anmari
Message:

various fixes v 4.2, custom formatting, display of id, multisite network admin

Location:
amr-users/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • amr-users/trunk/amr-users.php

    r1582456 r1586440  
    66Description: Configurable users listings by meta keys and values, comment count and post count. Includes  display, inclusion, exclusion, sorting configuration and an option to export to CSV. If you found this useful, please <a href="http://wordpress.org/extend/plugins/amr-users/">  or rate it</a>, or write a post. 
    77Author: anmari 
    8 Version: 4.1 
     8Version: 4.2 
    99Text Domain: amr-users 
    1010Domain Path: /languages 
     
    5252        [headings]  (in html) 
    5353*/ 
    54 define ('AUSERS_VERSION', '4.1'); 
     54define ('AUSERS_VERSION', '4.2'); 
    5555define( 'AUSERS_URL', plugin_dir_url( __FILE__ ) ); 
    5656define ('AUSERS_DIR', plugin_dir_path( __FILE__ )  ); 
     
    431431        add_action('admin_menu',            'amr_meta_menu'); 
    432432        add_action('admin_menu',            'amr_users_plus_updates_menu', 100);  //add after users menu has loaded, if there are licenses 
     433        add_action('network_admin_menu',            'amr_users_plus_updates_menu', 100);  //add after users menu has loaded, if there are licenses 
    433434        add_filter('plugin_action_links',   'ausers_plugin_action', -10, 2);     
    434435        add_filter('contextual_help',       'amrmeta_mainhelp',10,3);        
  • amr-users/trunk/css/amrusersfront.css

    r1553219 r1586440  
    5757} 
    5858 
    59 #userslist1, #userslist2, #userslist3, #userslist4 { 
    60     overflow-x:scroll; 
     59#userslist1, #userslist2, #userslist3, #userslist4 { /* 20170201 take out the overflow-x*/ 
    6160    clear: both; 
    6261} 
  • amr-users/trunk/includes/ameta-admin-configure.php

    r1582456 r1586440  
    381381            if (!empty($ftype)) echo ' '.'('.$ftype.')</td>'; 
    382382        } 
    383         else echo '<td></td>'; 
     383        else echo '<td><a href="' 
     384        .admin_url('admin.php?page=ameta-admin-nice-names.php') 
     385        .'">' 
     386        .__('To see formats for this field, specify the fieldtype once for all lists','amr-users') 
     387        .'</a></td>'; 
    384388         
    385389        if (isset($sel[$i]) and (!strpos($sel[$i],'.'))) { 
     
    798802        } 
    799803        else { 
    800             echo 'Function not active'; 
     804            echo '<p>'.__('Requires amr-users-plus functionality','amr-users').'</p>'; //20170201 
    801805            return; 
    802806            } 
     
    811815        } 
    812816        else { 
    813             _e('Grouping Function not active', 'amr-users'); 
     817            echo '<p>'.__('Grouping Function not active', 'amr-users').'</p>'; 
    814818            return; 
    815819            } 
     
    818822    elseif (isset($_GET['config']) and ($_GET['config'] == 'filtering'))    { 
    819823         
     824        if (!function_exists('amrmeta_filtering_page')) { 
     825            echo '<p>'.__('Requires amr-users-plus functionality','amr-users').'</p>'; //20170201 
     826            return; 
     827        }    
    820828        amrmeta_filtering_page($ulist); // doesn't exist? 
    821829        echo ausers_form_end(); 
  • amr-users/trunk/includes/ameta-admin-overview.php

    r1575884 r1586440  
    432432    __('If list is public, show per page option.', 'amr-users').'">?</a>');          
    433433     
    434      
    435     foreach ($amain['names'] as $i => $name) { 
    436         amr_echo_setting_html('show_perpage',$i,$amain['show_perpage'][$i]); 
     434    foreach ($amain['names'] as $i => $name) { 
     435        if (empty($amain['show_perpage'][$i])) $sp = false; 
     436        else $sp = $amain['show_perpage'][$i]; 
     437        amr_echo_setting_html('show_perpage',$i,$sp); 
    437438    }    
    438439         
     
    443444     
    444445    foreach ($amain['names'] as $i => $name) { 
    445         amr_echo_setting_html('show_search',$i,$amain['show_search'][$i]); 
     446        if (empty($amain['show_search'][$i])) $sp = false; 
     447        else $sp = $amain['show_search'][$i]; 
     448        amr_echo_setting_html('show_search',$i,$sp); 
    446449    } 
    447450 
     
    451454        __('If list is public, show pagination, else just show top n results.', 'amr-users').'">?</a>');                     
    452455    foreach ($amain['names'] as $i => $name) { 
    453         amr_echo_setting_html('show_pagination',$i,$amain['show_pagination'][$i]); 
     456        if (empty($amain['show_pagination'][$i])) $sp = false; 
     457        else $sp = $amain['show_pagination'][$i]; 
     458        amr_echo_setting_html('show_pagination',$i,$sp); 
    454459    } 
    455460     
     
    459464            __('If list is public, show column headings.', 'amr-users').'">?</a>');                      
    460465    foreach ($amain['names'] as $i => $name) { 
    461         amr_echo_setting_html('show_headings',$i,$amain['show_headings'][$i]); 
     466        if (empty($amain['show_headings'][$i])) $sp = false; 
     467        else $sp = $amain['show_headings'][$i]; 
     468        amr_echo_setting_html('show_headings',$i,$sp); 
    462469    } 
    463470             
     
    467474    __('If list is public, show a link to csv export file', 'amr-users').'">?</a>');             
    468475    foreach ($amain['names'] as $i => $name) { 
    469         amr_echo_setting_html('show_csv',$i,$amain['show_csv'][$i]); 
     476        if (empty($amain['show_csv'][$i])) $sp = false; 
     477        else $sp = $amain['show_csv'][$i];       
     478        amr_echo_setting_html('show_csv',$i,$sp); 
    470479    }    
    471480     
     
    474483    __('If list is public, show a link to refresh the cache', 'amr-users').'">?</a>');           
    475484    foreach ($amain['names'] as $i => $name) { 
    476         amr_echo_setting_html('show_refresh',$i,$amain['show_refresh'][$i]); 
     485        if (empty($amain['show_refresh'][$i])) $sp = false; 
     486        else $sp = $amain['show_refresh'][$i];   
     487        amr_echo_setting_html('show_refresh',$i,$sp); 
    477488    }    
    478489             
     
    482493    __('Offer sorting of the cached list by clicking on the columns.', 'amr-users').'">?</a>');              
    483494    foreach ($amain['names'] as $i => $name) { 
    484         amr_echo_setting_html('sortable',$i,$amain['sortable'][$i]); 
     495        if (empty($amain['sortable'][$i])) $sp = false; 
     496        else $sp = $amain['sortable'][$i];   
     497        amr_echo_setting_html('sortable',$i,$sp); 
    485498    }    
    486499     
     
    491504         
    492505    foreach ($amain['names'] as $i => $name) { 
    493         amr_echo_setting_html('customnav',$i,$amain['customnav'][$i], $plusstatus); 
     506        if (empty($amain['customnav'][$i])) $sp = false; 
     507        else $sp = $amain['customnav'][$i]; 
     508        amr_echo_setting_html('customnav',$i,$sp, $plusstatus); 
    494509    }    
    495510             
  • amr-users/trunk/includes/ameta-building.php

    r1575884 r1586440  
    1414        $where = ' INNER JOIN ' . $wpdb->usermeta .   
    1515       ' ON      ' . $wpdb->users  
    16        . '.ID = ' . $wpdb->usermeta . '.user_id  
    17         WHERE   ' . $wpdb->usermeta .'.meta_key =\'' . $wpdb->prefix . 'capabilities\'' ; 
     16       . '.ID = ' . $wpdb->usermeta . '.user_id '; 
     17       // 20170201 No, must get all users if it is network admin WHERE   ' . $wpdb->usermeta .'.meta_key =\'' . $wpdb->prefix . 'capabilities\'' ; 
    1818         
    1919        // not using 
     
    4242    $metalist = $wpdb->get_results($query, OBJECT_K); 
    4343 
     44 
    4445    //track_progress('After get users meta'); 
    4546 
     
    4849    $query = "SELECT ID, user_login, user_nicename, user_email, user_url, user_registered, display_name FROM $wpdb->users ".$where;  
    4950    $users = $wpdb->get_results($query, OBJECT_K);  // so returns id as key - NOT WORKING IN EVERY SITE 
    50      
     51 
     52    //if (WP_DEBUG) echo '<p>Got '.count($users).' users with '.$query.'</p>';   
    5153    //track_progress('After get users without meta'); 
    5254     
     
    6365 
    6466} 
    65 /* ---------------------------------------------------------*/   
     67 
    6668 
    6769function amr_get_alluserdata( $list ) { /*  get all user data and attempt to extract out any object values into arrays for listing  */ 
     
    365367return ($users);     
    366368} 
    367 /* ------------------------------------------------------------------*/  
     369     
    368370 
    369371function amr_get_userdata($id){ 
     
    375377        return ($data); 
    376378}; 
    377 /* -------------------------------------------*/     
     379     
    378380 
    379381function ameta_cache_enable () { 
     
    409411    return true; 
    410412} 
    411     /* ---------------------------------*/ 
     413      
    412414 
    413415function ameta_cachelogtable_name() { 
     
    421423        return($table_name); 
    422424    } 
    423     /* ---------------------------------*/ 
     425      
    424426 
    425427function ameta_cachetable_name() { 
     
    432434        return($table_name); 
    433435    } 
    434     /* ---------------------------------*/ 
     436      
    435437 
    436438function ameta_cachelogging_enable() { 
     
    467469        return true; 
    468470} 
    469 /* ---------------------------------*/ 
     471  
    470472function amr_if_values_in_user_field ($in, $field) { 
    471473// field could be csv multiple values maybe?  
     
    786788                                $line[0] = ''; 
    787789                                 
     790                            //var_dump($sel2);  echo '<br/>'; 
    788791                            foreach ($sel2 as $is => $v) {  /* defines the column order */ 
    789792                             
  • amr-users/trunk/includes/ameta-includes.php

    r1582456 r1586440  
    146146} 
    147147 
    148 function amr_remove_grouping_field ($icols) { 
     148function amr_remove_grouping_field ($icols) { // note cannot group and filter on the same field 
    149149global $aopt, $amr_current_list; 
     150 
    150151    if (!empty($aopt['list'][$amr_current_list]['grouping'])) {  
    151152            $grouping_field = $aopt['list'][$amr_current_list]['grouping'][1]; 
    152      
    153         foreach ($icols as $i => $col) { 
    154             if ($col == $grouping_field) { 
     153        foreach ($icols as $i => $col) {  
     154            if ($col == $grouping_field) {  
    155155                unset($icols[$i]); 
    156156            } 
    157157        } 
    158158    } 
     159     
    159160    return($icols); 
    160161}    
     
    182183        //} 
    183184    }    
    184  
    185     $iline = array_unique($iline);  // why do we need this ? 
     185     
     186    //$iline = array_unique($iline);    // why do we need this ? 
    186187    // what happens if grouping field also in use ? #20150106 
    187      
     188    // this is messing up the use of ID #20170201 
     189 
    188190    return ($iline); 
    189191}        
  • amr-users/trunk/includes/ameta-list.php

    r1575884 r1586440  
    534534                $icols = str_getcsv( $headinglines[0]['csvcontent'], ',','"','\\'); 
    535535 
    536             $icols = array_unique($icols);  //since may end up with two indices, eg if filtering and grouping by same value  
    537536                 
    538537            if (!defined('str_getcsv')) 
     
    541540                $cols = str_getcsv( $headinglines[1]['csvcontent'], ',','"','\\'); 
    542541 
    543             //IF (WP_DEBUG) {echo '<br />What options:'; var_dump($options);} 
     542        //  var_dump($icols); 
     543        // 20170201  
     544            //$icols = array_unique($icols);    //since may end up with two indices, eg if filtering and grouping by same value  
     545            // but loses the id if is being shown, so do the count comparision below, if cols has more, then they are the extra indices on the end 
     546            $ic = count($icols); 
     547            $cc = count($cols); 
     548            if ($cc < $ic) {  // we have indices in icols 
     549                $icols = array_slice ($icols, 0, $cc); 
     550            } 
     551 
     552        //  IF (WP_DEBUG) {echo '<br />'; var_dump($icols);} 
    544553             
    545554            $fetch_amount = $rowsperpage;  // default 
     
    577586            $cols   = amr_build_col_headings($s); 
    578587            $icols  = amr_build_cols ($s); 
    579  
     588             
    580589            foreach ($lines as $i => $j) { 
    581590                $lines[$i] = amr_convert_indices ($j, $icols); 
  • amr-users/trunk/includes/amr-users-headings-forms.php

    r1575884 r1586440  
    8686global $aopt; 
    8787 
    88     if (amr_is_plugin_active('amr-users-plus-grouping/amr-users-plus-grouping.php')) { 
     88    if (amr_is_plugin_active('amr-users-plus-groupings/amr-users-plus-groupings.php')) {  
     89        //20170201 ouch plugin name changed stopped this working for a bit 
    8990        $icols = amr_remove_grouping_field ($icols); 
     91             
    9092    } 
     93 
    9194    $html = '';  
    92     $cols = amr_users_get_column_headings ($ulist, $cols, $icols ); // should be added to cache rather   
     95    $cols = amr_users_get_column_headings ($ulist, $cols, $icols ); // should be added to cache rather       
    9396    $cols = apply_filters('amr-users-headings', $cols,$icols,$ulist);  //**** test this 
    9497 
     98 
     99     
    95100    foreach ($icols as $ic => $cv) { /* use the icols as our controlling array, so that we have the internal field names */ 
    96101 
  • amr-users/trunk/includes/ausers-pluggable.php

    r1582456 r1586440  
    11<?php  
    2 // is_plugin_active only gets declared by wp in admin and late it seems, lots of trouble tryingto use it apparemtly clashing 
     2// is_plugin_active only gets declared by wp in admin and late it seems, lots of trouble tryingto use it apparently clashing 
     3// doesnt work for network active plugins 
    34function amr_is_plugin_active( $plugin ) { 
    4         if (function_exists(('is_plugin_active')))  
     5        if (function_exists(('is_plugin_active'))) {  
    56            return (is_plugin_active($plugin)); 
    6         else  
    7             return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ); 
     7            } 
     8        else { 
     9         
     10            $active = (array) get_option( 'active_plugins', array() ); 
     11 
     12            if (in_array( $plugin, $active )) return true; 
     13             
     14            if ( !is_multisite() )            return false; 
     15            $plugins = get_site_option( 'active_sitewide_plugins');      
     16            if (isset($plugins[$plugin])) return true; 
     17            return false; 
     18        }    
    819} 
    920 
     
    2637        } 
    2738        else { 
     39            $format = $aopt['list'][$amr_current_list]['formatdatetime']; 
    2840            $text = amru_localised_formatted_datetime ($dt, $format);        
    2941            return $text; 
     
    3345 
    3446if (!function_exists('amr_format_field')) { 
    35     function amr_format_field($fld, $val, $u) { // get the fieldtype and the requested format 
     47    function amr_format_field($fld, $val, $u) { // get the fieldtype and the requested format, return false if none 
    3648        global  $aopt, 
    3749                $amr_current_list; 
     
    4557                 
    4658        if (!empty($l['format']) and (!empty($l['format'][$fld]))) { 
     59            //if (WP_DEBUG) echo '<br />Using format '.$l['format'][$fld].' for '.$fld ; 
    4760            $format = $l['format'][$fld]; 
    4861            $func = amru_get_func_name ($fld, $format); 
     
    5265            } 
    5366            else { 
    54                 return $val; 
    55                 } 
    56         } 
    57         else return $val; 
     67                return false; 
     68                } 
     69        } 
     70        else return false; 
    5871    } 
    5972} 
     
    526539 
    527540    if (!$text) {  // then we do not have a configured format, try for function or other logic 
    528          
     541        //if (WP_DEBUG) echo '<br />No custom format for '.$i.' '; 
    529542        // now get the value if special formatting required 
    530543        $generic_i = str_replace('-','_',$i); // cannot have function with dashes, so any special function must use underscores 
     
    538551            $text =  (call_user_func('ausers_format_'.$generic_i, $v, $u, $line)); 
    539552        } 
    540         else { //if (WP_DEBUG) echo '<br />didnt find custom function: ausers_format_'.$generic_i; 
     553        else {  
     554        //if (WP_DEBUG) echo '<br />didnt find custom function: ausers_format_'.$generic_i; 
    541555            switch ($i) { 
    542556                case 'description': {   
     
    552566        }    
    553567    } 
     568    //else if (WP_DEBUG) echo '<br />Found custom format for '.$i.' '; 
    554569     
    555570    if (!empty($text)) {  
     
    562577    } 
    563578    else { 
    564         //$text = '&nbsp';  // else tables with borders dont look right 
    565         $text = '';  // remove this ?  folks can add back in with a filter ? 
     579         
     580        $text = $v;  //20170131 - return the value if no formatting 
    566581    }    
    567582/*  unfortunately - due to fields being in columns and columns being what is cached,  
     
    604619        $linehtml = ''; 
    605620         
     621        //var_dump($icols); 
    606622        foreach ($icols as $ic => $c) {              
    607623            $w = amr_format_user_cell($c, $line[$c], $user, $line);// add line in case need those values 
     
    740756 
    741757// now fix the icols and cols for any special functioning-------------------------- 
    742              
    743         if ((isset($icols[0])) and ($icols[0] == 'ID')) {  /* we only saved the ID so that we can access extra info on display - we don't want to always display it */ 
    744             unset ($icols[0]);unset ($cols[0]); 
     758    //  var_dump($icols);    
     759    //  echo '</br>'; 
     760    //  var_dump($cols);     
     761        if ((isset($icols[0])) and ($icols[0] === 'ID')) {  /* we only saved the ID so that we can access extra info on display - we don't want to always display it */ 
     762        // unless we specifically requested? 
     763            unset ($icols[0]); 
     764            unset ($cols[0]); 
    745765        } 
    746766             
     
    809829        and (empty($_REQUEST['filtering']) and (empty($_REQUEST['headings']))) ) { 
    810830                // ym *** 
    811             if (function_exists('amr_ym_bulk_update'))           
    812                 $name = 'ps'; 
    813             else  
     831//          if (function_exists('amr_ym_bulk_update'))           
     832//              $name = 'ps'; 
     833//          else  
    814834                $name = 'users';     
    815835                         
     
    878898            else   
    879899                $colspan = count($icols); 
     900                 
    880901            $fhtml .= $ahtm ['th'].' colspan="'.$colspan.'">' 
    881902            .amr_users_give_credit()    ; 
     
    10591080// now fix the icols and cols for any special functioning-------------------------- 
    10601081             
    1061         if ((isset($icols[0])) and ($icols[0] == 'ID')) {  /* we only saved the ID so that we can access extra info on display - we don't want to always display it */ 
     1082        if ((isset($icols[0])) and ($icols[0] === 'ID')) {  /* we only saved the ID so that we can access extra info on display - we don't want to always display it */ 
    10621083            unset ($icols[0]);unset ($cols[0]); 
    10631084        } 
     
    10731094            } 
    10741095            else { 
    1075                 if (!isset($cols[$i])) unset ($icols[$i]); 
     1096                if (!isset($cols[$i])) { 
     1097                    unset ($icols[$i]); 
     1098                    //if (WP_DEBUG) echo '<br /> unsetting icols '.$i; 
     1099                }    
    10761100            }    
    10771101        } 
  • amr-users/trunk/readme.txt

    r1582456 r1586440  
    44Tags: user, users, reports, lists, members, membership, authors, csv, export, search 
    55 
    6 Version: 4.1 
     6Version: 4.2 
    77 
    88Requires at least: 2.7  
     
    5050 
    5151== Changelog == 
     52= 4.2 = 
     53*  Fixed: small bug where if using 'direct query' in network admin with amr-users-multisite, then only main site users were selected instead of all users in multisite.  If not in network admin then only the 'site' users are selected. 
     54*  Fixed: id anomaly, which made it hard to use user_id in a list.  was a problem with array_unique. 
     55*  Fixed: 'new' custom format bug where custom function was not being used when it existed. 
     56*  Added text in config format screen to highlight that plugin needs to know the 'type' of a field before it can add custom format options. 
     57*  Fixed: if headings were used in a grouping list, the grouping field heading was not being properly removed, particulary in front end of multisite 
     58*  Initialised some variables better to remove notices if there were unsaved options 
    5259 
    5360= 4.1 = 
Note: See TracChangeset for help on using the changeset viewer.