Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to breakout security settings of # code 1

Status
Not open for further replies.

XrayboX

Technical User
Oct 8, 2002
105
US
[tt]Hi I been a reading Tek-Tips for a while, and for the first time can't find an answer. (couldn't figure out search question)
Here what I've got.
crystal reports XI, ODBC connection to an informix database.
the numbers are in user_scrty.usec_cd,
the text is not stored in the database
my problem is,
there are 28 features each feature has a number from 1 to 134217728 that is double the previous

1 Delete a Trans
2 Cancel a Trans
4 reprint a Trans
8 Reprice a Trans
16 Post a Deposit
32 Cash a Check
64 Cash Drawer Paid Out
128 Recall A trans
.
..
....
13421772 assembly entry change features

if the user can delete,cancel, and reprint a trans
then his user_scrty.usec_cd = 7
if he can also cash a check, his user_scrty.usec_cd = 39
how can I create a formula to print what he is authorized to do, or even breakout the numbers ?


Thanks for looking
You folks have been the best help( already )
[/tt]
 
Create a formula of:

select {user_scrty.usec_cd}
case 0 to 1 : "Delete a Trans"
case 2 to 3 : "Cancel a Trans"
case 4 to 7 : "reprint a Trans"
default : "Unknown";

Note that I didn't code out all of your possibilities, left a bit for you to do.

-k
 
If you want to print out all user privileges per user, and you have a field in your main report table that just shows the number per user, while your user_scrty table shows all values, then you could place SV's formula in the detail section of a subreport that references the full user_scrty table. Link the subreport to the main report on {user_scrty.usec_cd} and then in the record selection formula of the subreport, change the formula to:

{?pm-table.usec_cd} <= {user_scrty.usec_cd}

Then create another formula within the subreport like:

//{@accum}:
whileprintingrecords;
stringvar privs := privs + {@SVformula} + ", ";

Then in the subreport report footer, use this formula:

//{@display}:
whileprintingrecords;
stringvar privs;
left(privs,len(privs)-2)

Format the formula to "can grow". Then suppress all sections of the subreport except the report footer.

-LB
 
First Thanks for the instant responses, sorry I wasn't clear
My problem is {user_scrty.usec_cd} contains one number that is the SUM of the user's privileges .

Thus if a user can use all 28 features his user_scrty.usec_cd is 268435455 (sum 1,2,4,8,.....,13421772).
 
Are you saying that it is possible for a user to have any combination of privileges, i.e., that the privileges do not build on each other and that certain privileges could be skipped? Since the user ID represents a sum, is there any place where you can access the individual privileges contributing to the total per User ID?

-LB

 
Lbass said:
Are you saying that it is possible for a user to have any combination of privileges, i.e., that the privileges do not build on each other and that certain privileges could be skipped?
Yes he can have any combination of privilages, and the privilages he has are added to the sum.
[tt]
1
2
4
8
16
32
user_scrty.usec_cd= 37[/tt]




Since the user ID represents a sum, is there any place where you can access the individual privileges contributing to the total per User ID?
No, it is only stored in the one field ( and I can't get the database modified )
 
There are thousands of potential combinations of privileges then. In order to assign the security codes, there must be a table of sorts or a formula that creates the number entered into your database. You need to make use of that.

-LB
 
From what I can see, you need some type of array processing formula formula

variable array s := makearray(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)

variable array d := makearray(1,2,4,8,16,32,64,...134217728);

numbervar rem := user_scrty.usec_cd;

Starting from 28 and working down to, find and subtract the highest unused double that is less than the vaue of user_scrty.usec_cd with each double only being used once until the final remainder = 0.

After the subtraction, set the corresponding array switch to 1

For example, if user_scrty.usec_cd = 37, then subtract 32 from 37 leaving Rem := 5. Set s[6] := 1

Loop through and subtract 4 from 5 leaving rem := 1 and S[3]:= 1

Loop through again and subtract 1 from 1 leaving rem := 0 and S[1] := 1

Evaluating the s array for 1's would give you 1,4,32

I think trhat's what you are trying to accomplish.
 
Thanks everybody for all the help
especially kskid
Your idea was perfect.
here's the code I ended up with
Code:
numbervar array CheckFlag := makearray(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

numbervar array securitybit := makearray(1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,
32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,
1677716,33554432,67108864,134217728);

stringvar array Securitytext := makearray(" Delete a Transaction  ","  Cancel a Transaction "," reprint a Transaction "," Reprice a Transaction "," Post a Deposit "," Cash a Check "," Cash Drawer Paid Out "," Recall A transaction "," Invoice From order or Qoute "," Order from Qoute "," post received on account "," Activate All Limeted access fields "," adjust assembly lines "," enter a trade discount "," delete a line "," cancel a line "," copy fropm an order or qoute "," copy from sales history "," copy fropm a permanent transaction "," inport an item range "," edit item description "," edit tax option "," edit freight options "," trans totals and cost inquiry "," item price inquiry "," item price and cost inquiry "," item on promotion inquiry "," assembly entry change features " );

numbervar workcode := {user_scrty.usec_cd};

numbervar counter:=28;

stringvar text;

while counter > 0 do
(if (workcode - securitybit[counter]) >= 0 
then
(workcode:= workcode-securitybit[counter];
Checkflag[counter]:=1);
counter:=counter-1);
while counter <28 do
(if checkflag[counter+1]=1
then 
text:= text + securitytext[counter+1]+chr(13);
counter:=counter+1);

text;
 
That's great. I'm glad it worked. Logically and mathematically, it looked right.


-lw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top