Plugin Directory

Changeset 198063


Ignore:
Timestamp:
01/25/2010 09:24:28 PM (16 years ago)
Author:
bforchhammer
Message:

Added option to specify a minimum number of posts

Location:
author-avatars/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • author-avatars/trunk/js/tinymce.popup.js

    r129076 r198063  
    107107        }
    108108
     109        // min post count
     110        var min_post_count = jQuery("#min_post_count").val() || "";
     111        if (min_post_count.length > 0) {
     112            tagtext += " min_post_count=" + min_post_count;
     113        }
     114
    109115        // order
    110116        var order = jQuery("#order").val() || "";
  • author-avatars/trunk/lib/AuthorAvatarsEditorButton.class.php

    r122277 r198063  
    124124        $adv_left .= $form->renderFieldSortDirection('asc');
    125125        $adv_left .= $form->renderFieldLimit();
     126                $adv_left .= $form->renderFieldMinPostCount();
    126127        $adv_left .= $form->renderFieldHiddenUsers();
    127128       
  • author-avatars/trunk/lib/AuthorAvatarsForm.class.php

    r129082 r198063  
    272272        $html .= '<br />';
    273273        $html .= $this->renderFieldLimit($display_values['limit'], $name_base .'[limit]');
     274                $html .= '<br />';
     275                $html .= $this->renderFieldMinPostCount($display_values['min_post_count'], $name_base .'[min_post_count]');
    274276        $html .= '<br />';
    275277        $html .= $this->renderFieldAvatarSize($display_values['avatar_size'], $name_base . '[avatar_size]');
     
    393395        return '<p>'. FormHelper::input('text', $name, $value, $attributes) .'</p>';
    394396    }
     397
     398
     399    /**
     400     * Renders the "min_post_count" input field
     401     *
     402     * @param string $value the field value
     403     * @param string $name the field name
     404     * @return string
     405     */
     406    function renderFieldMinPostCount($value='', $name='min_post_count') {
     407        $attributes = array(
     408            'id' => $this->_getFieldId($name),
     409            'label' => __('Required minimum number of posts', 'author-avatars') . ': ',
     410            'size' => '5'
     411        );
     412        $name = $this->_getFieldName($name);
     413        return '<p>'. FormHelper::input('text', $name, $value, $attributes) .'</p>';
     414    }
    395415   
    396416    /**
  • author-avatars/trunk/lib/AuthorAvatarsShortcode.class.php

    r114302 r198063  
    101101            if ($limit > 0) $userlist->limit = $limit;
    102102        }
     103               
     104        // min. number of posts
     105        if (!empty($atts['min_post_count'])) {
     106            $min_post_count = intval($atts['min_post_count']);
     107            if ($min_post_count > 0) $userlist->min_post_count = min_post_count;
     108        }
    103109       
    104110        // display order
  • author-avatars/trunk/lib/AuthorAvatarsWidget.class.php

    r122277 r198063  
    2424                'avatar_size' => '',
    2525                'limit' => '',
     26                                'min_post_count' => '',
    2627                'order' => 'display_name',
    2728                'sort_direction' => 'asc',
     
    104105            $userlist->avatar_size = $instance['display']['avatar_size'];
    105106            $userlist->limit = $instance['display']['limit'];
     107                        $userlist->min_post_count = $instance['display']['min_post_count'];
    106108            $userlist->order = $instance['display']['order'];
    107109            $userlist->sort_direction = $instance['display']['sort_direction'];
     
    180182        $adv_left .= $form->renderFieldSortDirection($instance['display']['sort_direction'], 'display][sort_direction');
    181183        $adv_left .= $form->renderFieldLimit($instance['display']['limit'], 'display][limit');
     184                $adv_left .= $form->renderFieldMinPostCount($instance['display']['min_post_count'], 'display][min_post_count');
    182185        $adv_left .= $form->renderFieldHiddenUsers($instance['hiddenusers']);
    183186       
  • author-avatars/trunk/lib/UserList.class.php

    r129082 r198063  
    5151     */
    5252    var $limit = 0;
     53
     54        /**
     55         * Minimum number of posts which a user needs to have in order to be shown in the listing
     56         */
     57        var $min_post_count = 0;
    5358   
    5459    /**
     
    339344                    $add = false;
    340345                }
     346
     347                                // Remove users with zero posts
     348                                if (
     349                                        // if the flag is set to remove respective users
     350                                        $this->min_post_count > 0 &&
     351                                        // and they have zero posts
     352                                        $this->get_user_postcount($user->user_id) < $this->min_post_count ) {
     353                                        // do not add this user
     354                                        $add = false;
     355                                }
    341356                               
    342357                if ($add === true) {
Note: See TracChangeset for help on using the changeset viewer.