Commit Graph

26 Commits

Author SHA1 Message Date
Toon Claes b90f1098cf Add User#full_private_access? to check if user has Private access
In CE only the admin has access to all private groups & projects. In EE also an
auditor can have full private access.

To overcome merge conflicts, or accidental incorrect access rights, abstract
this out in `User#full_private_access?`.

`User#admin?` now only should be used for admin-only features. For private
access-related features `User#full_private_access?` should be used.

Backported from gitlab-org/gitlab-ee!2199
2017-06-23 11:15:35 +02:00
Yorick Peterse d29347220c
Refactor ProjectsFinder#init_collection
This changes ProjectsFinder#init_collection so it no longer relies on a
UNION. For example, to get starred projects of a user we used to run:

    SELECT projects.*
    FROM projects
    WHERE projects.pending_delete = 'f'
    AND (
        projects.id IN (
            SELECT projects.id
            FROM projects
            INNER JOIN users_star_projects
                ON users_star_projects.project_id = projects.id
            INNER JOIN project_authorizations
                ON projects.id = project_authorizations.project_id
            WHERE projects.pending_delete = 'f'
            AND project_authorizations.user_id = 1
            AND users_star_projects.user_id = 1

            UNION

            SELECT projects.id
            FROM projects
            INNER JOIN users_star_projects
                ON users_star_projects.project_id = projects.id
            WHERE projects.visibility_level IN (20, 10)
            AND users_star_projects.user_id = 1
        )
    )
    ORDER BY projects.id DESC;

With these changes the above query is turned into the following instead:

    SELECT projects.*
    FROM projects
    INNER JOIN users_star_projects
        ON users_star_projects.project_id = projects.id
    WHERE projects.pending_delete = 'f'
    AND (
        EXISTS (
            SELECT 1
            FROM project_authorizations
            WHERE project_authorizations.user_id = 1
            AND (project_id = projects.id)
        )
        OR projects.visibility_level IN (20,10)
    )
    AND users_star_projects.user_id = 1
    ORDER BY projects.id DESC;

This query in turn produces a better execution plan and takes less time,
though the difference is only a few milliseconds (this however depends
on the amount of data involved and additional conditions that may be
added).
2017-06-16 13:49:09 +02:00
Bob Van Landuyt bdebe849b8 Translate project & repository pages 2017-06-07 20:13:44 +00:00
Rémy Coutable 4cfa5ce4a9
Enable the Style/PreferredHashMethods cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-02 19:11:26 +02:00
blackst0ne 11aff97d88 Remove the User#is_admin? method 2017-04-09 13:20:57 +11:00
Toon Claes 71306f14f6 Make level_value accept string integers
When a VisibilityLevel is an integer formatted as a string, convert it
to an integer, instead of looking it up in the hash map.

When the value is not recognized, default to PRIVATE.
2017-03-20 22:53:29 +01:00
Toon Claes a3fdd6acd2 Use string based `visibility` getter & setter
Add `visibility` & `visibility=` methods to the
`Gitlab::VisibilityLevel` module so the `visibility_level` can be
get/set with a string value.
2017-03-02 12:15:25 +01:00
Toon Claes fc28719145 A VisibilityLevel also can be presented as string
For the API, the VisibilityLevel will be exposed as String instead of
Integer. So add the string values and method to translate a level
integer to a string.
2017-03-02 09:28:41 +01:00
Douwe Maan 75f5fa997d Enable Rails/Delegate 2017-02-23 09:32:42 -06:00
Douwe Maan ffcbc63693 List all groups/projects for admins on explore pages 2017-02-06 21:02:07 -06:00
Kamil Trzcinski b7f4553e3e
Backport changes introduced by https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1083 2017-01-20 12:25:53 +01:00
Felipe Artur 5273335247 Fix forks creation when visibility level is restricted 2016-05-25 10:57:00 -04:00
Douwe Maan 45e8650c4f Fix specs 2016-03-20 23:26:58 +01:00
Douwe Maan 8db1292139 Tweaks, refactoring, and specs 2016-03-20 21:04:07 +01:00
Zeger-Jan van de Weg b959ae553b Improve group visibility level feature 2016-03-18 16:58:04 -03:00
Felipe Artur 0a7f716119 Code fixes 2016-03-17 19:42:46 -03:00
Felipe Artur c3e70280df Prevent projects to have higher visibility than groups
Prevent Groups to have smaller visibility than projects
Add default_group_visibility_level to configuration
Code improvements
2016-03-10 10:38:36 -03:00
Tomasz Maczukin 3bc012db77 Fix GitlabV::isibilityLevel::level_name method 2015-11-04 22:13:40 +01:00
Tomasz Maczukin 9e1db139eb Move level_name resolving to Gitlan::VisibilityLevel 2015-11-03 17:23:19 +01:00
Valery Sizov 111ebe5471 Fork visibility level fix 2015-07-06 17:40:33 +03:00
Marin Jankovski 63f7129483 Move application setting to separate variable. 2015-03-18 13:55:41 -07:00
Vinnie Okada e535d21768 Handle nil restricted visibility settings
Return `true` from `non_restricted_level?` when the
`restricted_visibility_levels` setting is nil.
2015-03-18 12:50:27 -06:00
Vinnie Okada cacac147de Move restricted visibility settings to the UI
Add checkboxes to the application settings page for restricted
visibility levels, and remove those settings from gitlab.yml.
2015-03-07 13:11:08 -07:00
Job van der Voort 68fd66c6e3 block visibility level restriction override in controller 2014-08-28 20:33:41 +02:00
Jeroen van Baarsen 3c439888a6 Removed some constant allready defined warnings
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2014-07-16 20:12:46 +02:00
Jason Hollingsworth d9bb4230cc Adding authenticated public mode (internal).
Added visibility_level icons to project view (rather than just text).
Added public projects to search results.
Added ability to restrict visibility levels standard users can set.
2013-11-26 22:22:07 -06:00