Show pageOld revisionsBacklinksExport to PDFFold/unfold allBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== pears.NetHasPermission ====== <WRAP center round info> Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. </WRAP> ===== Original SQL ===== <code sql> create function "pears"."NetHasPermission"( in "pWebUserID" char(20),in "pPersonID" char(20),in "pCompanyID" char(20) ) returns integer // IQXWeb begin declare "rv" integer; declare "userclass" char(20); declare "divid" char(20); set "rv" = 0; select "iqxnetuserclassid" into "userclass" from "iqxnetuser" where "iqxnetuserid" = "pwebuserid"; if "userclass" = 'CANDIDATE' then set "rv" = (select first 1 from "iqxnetuserlink" where "personid" = "ppersonid" and "iqxnetuserid" = "pwebuserid") else if "userclass" = 'CLIENT' then set "rv" = (select first 1 from "employment" as "e" key join "iqxnetuserlink" as "x" where "e"."companyid" = "pcompanyid" and "x"."iqxnetuserid" = "pwebuserid") else if "userclass" = 'AGENCY' then set "rv" = (select first 1 from "pay_employee" as "pe" key join "company" key join "employment" key join "iqxnetuserlink" as "x" where "pe"."personid" = "ppersonid" and "x"."iqxnetuserid" = "pwebuserid") else if "userclass" = 'OWNER' then set "divid" = "isnull"((select first "divisionid" from "person" where "personid" = "pPersonID" order by 1 asc),(select first "divisionid" from "company" where "companyid" = "pCompanyID" order by 1 asc),''); if "divid" = any(select "DivisionID" from "DashboardStaffDivisions"()) then set "rv" = 1 end if end if end if end if end if; return "isnull"("rv",0) end /* DOC 2016-08-30 PC doc and test 2018-10-22 MHS improved OWNER logic to properly respect staff division rights inputs: pWebUserID pPersonID pCompanyID outputs: (integer) - 0 or 1 tests: test all null test invalid pWebUserID test valid pWebUserID as person and invalid pPersonID test valid pWebUserID as person and valid pPersonID test valid pWebUserID as client and pPersonID and valid pCompanyID test valid pWebUserID as agency and pPersonID and valid pCompanyID test valid pWebUserID as owner and pPersonID and valid pCompanyID */ /* TEST call NetTestSetup('','NetHasPermission'); update company set divisionid='test' where companyid='test'; update person set divisionid='TEST' where personid='test'; update staff set divisionid='TEST' where staffid='TEST'; insert into pay_employee (personid, secondaryagencyid) on existing update values ('test','test'); select NetHasPermission(null,null,null); expect 0; select NetHasPermission('test.candidate','T9',null); expect 0; select NetHasPermission('test.candidate','Test',null); expect 1; select NetHasPermission('TEST.client','test','test'); expect 1; select NetHasPermission('TEST.agency','test','test'); expect 1; select NetHasPermission('TEST.owner','test','test'); expect 1; */ </code> database/functions/pears_nethaspermission.txt Last modified: 2026/08/07 19:24by 127.0.0.1