// This function reports the hierarchy for the selected portion of the DOORS database hierarchy /* Created 10/31/00 by Kevin Bostic, Telelogic North America Inc., for DOORS v5.0 PC Modified 3/28/01 by Kevin Bostic, Telelogic North America Inc., for DOORS v5.1 PC - updated output slightly Modified 4/2/01 by Kevin Bostic, Telelogic North America Inc., for DOORS v5.1 PC - updated output slightly Modified 4/17/01 by Kevin Bostic, Telelogic North America Inc., for DOORS v5.1 PC - changed function from simple hierarchy report to a full access rights reporter! Modified 4/25/01 by Kevin Bostic, Telelogic North America Inc. - include inherited access */ // Global variable declarations string msg string now = (dateOf intOf today) "" // DB and DBE variable declarations DB db DBE pathFieldDBE DBE showIDToggleDBE DBE showModulesToggleDBE DBE showFoldersToggleDBE DBE showProjectsToggleDBE DBE showInheritedAccessToggleDBE // Functions bool isInherited (Item i) { bool isinh if !null isAccessInherited (i,isinh) then { ack "Problem!" halt } return isinh } string absoluteName (Item passedItem) { if null passedItem then halt if (null getParentFolder passedItem) return "/" if (null getParentFolder getParentFolder passedItem) return fullName passedItem return (absoluteName item path passedItem) "/" name passedItem } string accessRecs (Item i) { if isInherited i then return "" AccessRec ar string perm = "" int n = 0 string user = "" string s = "" for ar in i do { user = username ar if user == "" then user = "Everybody else" s = s "\t" user " : " if read ar then perm = "R" else perm = "" if modify ar then perm = perm "M" if create ar then perm = perm "C" if delete ar then perm = perm "D" if control ar then perm = perm "A" s = s " " perm "\n" } Permission p if !null getImplied (i,p) then ack "Problem!" s = s "\t" "Propagated: " Permission m = modify Permission md = modify|delete Permission mda = modify|delete|control if null p then s = s "None" if p == m then s = s "M" if p == md then s = s "MD" if p == mda then s = s "MDA" return s } void processItem (Item passedItem) { if (!get showModulesToggleDBE and (type passedItem == "Formal" or type passedItem == "Link" or type passedItem == "Descriptive")) then return if !get showFoldersToggleDBE and type passedItem == "Folder" then return if !get showProjectsToggleDBE and type passedItem == "Project" then return if null passedItem then { ack "You must put something in the path field!" halt } if (isDeleted passedItem) { msg = msg "[Deleted] '" } else { msg = msg "'" } msg = msg absoluteName passedItem if get showIDToggleDBE then msg = msg " {ID:" uniqueID passedItem "}" msg = msg "' (" msg = msg type passedItem if type passedItem == "Formal" or type passedItem == "Link" or type passedItem == "Descriptive" then msg = msg " Module" msg = msg ")\n" if !isInherited passedItem then { msg = msg "" (accessRecs passedItem) "\n" } else { msg = msg " (Inherited)\n" if get showInheritedAccessToggleDBE then { while (isInherited passedItem and !null getParentFolder passedItem) { Folder f = getParentFolder passedItem passedItem = item fullName f } msg = msg "" (accessRecs passedItem) "\n" } } } void recurseOnItem (Item passedItem) { processItem passedItem if null passedItem then halt if null folder passedItem then return Item childItem for childItem in all folder passedItem do recurseOnItem childItem } // Main db = create "Database Hierarchy Report" label (db,"This function generates a report of the acccess rights for all items fo the selected type(s) for the selected path of your DOORS database hierarchy.") separator db string dbPath = absoluteName item fullName current Folder void choosePathCB (DBE) { set (pathFieldDBE,absoluteName item fnMiniExplorer(db,MINI_EXP_FP,"Hierarchy Browser","Select a portion of the database hierarchy:")) } pathFieldDBE = field (db,"Path:",dbPath,75,false) beside db button(db,"Browse...",choosePathCB) left db label(db,"Include:") beside db showProjectsToggleDBE = toggle (db,"Projects",true) showFoldersToggleDBE = toggle (db,"Folders",true) showModulesToggleDBE = toggle (db,"Modules",true) showInheritedAccessToggleDBE = toggle (db,"Inherited Access",false) showIDToggleDBE = toggle (db,"ID's",false) void processApply (DB) { string pathToGet = get pathFieldDBE msg = "Generated by DOORS user \"" doorsname "\" on " now[0:7] " at " now[9:] "\nThis report lists all folders, projects, and modules in the section of the database hierarchy that you selected: \"" pathToGet "\"\n\n" recurseOnItem item get pathFieldDBE DB db2 = create "Hierarchy Report for '" pathToGet "'" DBE msgDBE = text (db2,"",msg,700,400,true) show db2 } void processOK (DB) { string pathToGet = get pathFieldDBE msg = "Generated by DOORS user \"" doorsname "\" on " now[0:7] " at " now[9:] "\nThis report lists all folders, projects, and modules in the section of the database hierarchy that you selected: \"" pathToGet "\"\n\n" recurseOnItem item get pathFieldDBE hide db DB db2 = create "Hierarchy Report for '" pathToGet "'" DBE msgDBE = text (db2,"",msg,700,400,true) show db2 } apply (db,"Apply",processApply) apply (db,"OK",processOK) show db y (db,"OK",processOK