Making WordPress.org


Ignore:
Timestamp:
10/07/2022 07:42:52 AM (3 years ago)
Author:
coffee2code
Message:

Photo Directory, Uploads: Allow users with 30 or more published photos to bulk check the submission checkboxes.

Props topher1kenobe, coffee2code.
Fixes #6239.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/user.php

    r12057 r12110  
    1919     */
    2020    const MAX_PENDING_SUBMISSIONS = 5;
     21
     22    /**
     23     * The number of published posts before a given user is permitted to toggle
     24     * all of the confirmation checkboxes when submitting a photo.
     25     *
     26     * @var int
     27     */
     28    const TOGGLE_ALL_THRESHOLD = 30;
    2129
    2230    public static function init() {
     
    8997    }
    9098
     99    /**
     100     * Determines if a user is eligible to toggle all confirmation checkboxes on
     101     * the photo upload form.
     102     *
     103     * The intent is that users who have submitted a decent number of published
     104     * photos are as aware of the listed criteria as they're going to be and have
     105     * demonstrated that they are able to abide by them.
     106     *
     107     * @todo Handle eventual case when a new checkbox is added or one is changed
     108     *       enough to warrant making the user manually re-check the checkboxes.
     109     *       The latest checkbox update date can be stored as a constant and, if
     110     *       set, the contributor must also have a post (or N posts) published
     111     *       after that date to requalify for the bulk toggle.
     112     *
     113     * @param int $user_id Optional. The user ID. If not defined, assumes current
     114     *                     user. Default false.
     115     * @return bool True if user can toggle confirmation checkboxes, else false.
     116     */
     117    public static function can_toggle_confirmation_checkboxes( $user_id = false ) {
     118        $can = false;
     119
     120        if ( ! $user_id ) {
     121            $user_id = get_current_user_id();
     122        }
     123
     124        if ( $user_id && self::count_published_photos( $user_id ) >= self::TOGGLE_ALL_THRESHOLD ) {
     125            $can = true;
     126        }
     127
     128        return $can;
     129    }
     130
    91131}
    92132
Note: See TracChangeset for help on using the changeset viewer.