--[[ $Id: $ $DateTime: $ $Author: $ $Change: $ ]]-- --[[ The purpose of this Lua extension is to restrict client views. This would prevent a user from accidentally creating a client with a too wide open view where the workspace would end up with the whole depot or depots. This script handle this with a simple wide restriction on how many directory level must be supplied. For example, if num_level is set to 3, then this is accepted: //depot/dir1/dir2/... while this would be rejected //depot/dir1/... ]]-- package.path = Helix.Core.Server.GetArchDirFileName( "?.lua" ) local utils = require "ExtUtils" local check = require "SpecViewCheck" local initDone = false function init() if not initdone then initDone = true utils.init() end end function GlobalConfigFields() return { "" } end function InstanceConfigFields() --num_level = the minimum number of directory level --exempt_users = this rectriction might not apply to some users (such as those -- compiling final product on build machine) return { num_level = "insert minimum number of level across all", exempt_users = "Space-separated list of which users do NOT have this restriction" } end function InstanceConfigEvents() init() -- This example Extension is to keep users from saving client specs -- with a too wide map and is set for client with the field -- used for it being View (see SpecViewCheck). These could be changed -- by changing these values based on the need return { ["form-in"] = "client" } end function FormIn() init() -- Check if user in the list excluded if not utils.UserNeedsRestrictions() then return true end local form_file = Helix.Core.Server.GetVar( "formfile" ); local level = utils.iCfgData[ "num_level" ] local ok, data = check.Verify( form_file, level ) if not ok then Helix.Core.Server.SetClientMsg( utils.msgHeader() .. data ) return false end return true end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 30808 | C. Thomas Tyler |
Promoted from 2019.1/... to main/... |
||
//guest/perforce_software/extensions/2019.1/narrow_workspace_mappings/main.lua | |||||
#1 | 25601 | Jason Gibson |
Import example Extensions. p19.1@1797741 |