Making WordPress.org

Changeset 3692


Ignore:
Timestamp:
07/17/2016 11:14:42 AM (10 years ago)
Author:
ocean90
Message:

Translate, Rosetta Roles: Improve docs and return always an array in WPorg_GP_Rosetta_Roles::get_project_id_access_list().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-rosetta-roles/wporg-gp-rosetta-roles.php

    r3691 r3692  
    6969                }
    7070
    71                 if ( $args['action'] !== 'approve' || ! in_array( $args['object_type'], array( 'project|locale|set-slug', 'translation-set' ) ) ) {
     71                if ( 'approve' !== $args['action'] || ! in_array( $args['object_type'], array( 'project|locale|set-slug', 'translation-set' ) ) ) {
    7272                        return false;
    7373                }
    … …  
    8282                $current_project_id = $locale_and_project_id->project_id;
    8383
    84                 // Simple check to see if they're an approver or not
     84                // Simple check to see if they're an approver or not.
    8585                if ( ! $this->is_approver_for_locale( $args['user_id'], $locale_slug ) ) {
    8686                        return false;
    8787                }
    8888
    89                 // Grab the list of Projects (or 'all') that the user can approve
     89                // Grab the list of Projects (or 'all') that the user can approve.
    9090                $project_access_list = $this->get_project_id_access_list( $args['user_id'], $locale_slug );
    9191                if ( ! $project_access_list ) {
    … …  
    127127
    128128        /**
    129          * Determine if a given user is a Global Admin.
     129         * Determines if a given user is a Global Admin.
    130130         *
    131131         * Users present as an administrator on global.wordpress.org are treated as a
    132132         * global administrator in GlotPress.
    133133         *
    134          * @param int $user A BackPress User object or user ID for the user to check.
    135          *
    136          * @return bool
     134         * @param int $user_id User ID.
     135         * @return bool True, if user is an admin, false if not.
    137136         */
    138137        public function is_global_administrator( $user_id ) {
    … …  
    148147
    149148        /**
    150          * Determine if a given user is a Translation Approver for a Locale.
    151          *
    152          * @param int $user A BackPress User object or user ID for the user to check.
    153          *
    154          * @return bool
     149         * Determines if a given user is a Translation Approver for a Locale.
     150         *
     151         * @param int    $user_id     User ID.
     152         * @param string $locale_slug The Locale for which we are checking.
     153         * @return bool True, if user is an approver, false if not.
    155154         */
    156155        public function is_approver_for_locale( $user_id, $locale_slug ) {
    … …  
    191190
    192191        /**
    193          * Retrieve a list of Project ID's which the current user can approve for.
     192         * Retrieves a list of project ID's which a user can approve for.
    194193         *
    195194         * This is likely to be incorrrect in the event that the user is a Translation Editor or Global Admin.
    196195         * The array item 'all' is special, which means to allow access to all projects.
    197196         *
    198          * @param int    $user            A BackPress User object or user ID for the user to check.
    199          * @param string $locale_slug     The Locale for which we are checking
    200          * @param int    $include_children Whether to include the children project ID's in the return
    201          *
     197         * @param int    $user_id          User ID.
     198         * @param string $locale_slug      The Locale for which we are checking.
     199         * @param bool   $include_children Whether to include the children project ID's in the return.
    202200         * @return array A list of the Project ID's for which the current user can approve translations for.
    203201         */
    … …  
    227225
    228226                if ( ! $project_access_list ) {
    229                         return false;
     227                        return array();
    230228                }
    231229
    … …  
    382380         * @param string $object_type Current object type.
    383381         * @param string $object_id   Current object ID.
    384          * @return array Locale and project ID.
     382         * @return array|false Locale and project ID, false on failure.
    385383         */
    386384        public function get_locale_and_project_id( $object_type, $object_id ) {
Note: See TracChangeset for help on using the changeset viewer.