Gossamer Forum
Home : Products : DBMan : Customization :

Is there a way to automatically change permissions after a user adds a record???

Quote Reply
Is there a way to automatically change permissions after a user adds a record???
Say i give a user theses permissions when they sign up

Code:
@auth_default_permissions = (0,1,0,0,0);
which allows them only to add a record.

Is there a way to automatically change the user permission to

Code:
@auth_default_permissions = (1,1,1,1,0);
so they can view, add, modify, and view records??



------------------
Jonathan
jwilliam@umfort.cs.ecsu.edu
Quote Reply
Re: Is there a way to automatically change permissions after a user adds a record??? In reply to
Jonathan:

Are you trying to find a means of forcing a new user to add a record prior to then being able to use your database?

If so, the simple solution may be to just add this to your sub html_home:

if ($per_add) {
%rec = &get_record($db_userid);
if (!%rec) {
print "Location: $db_script_url?db=user&uid=$db_uid&add_form=1\n\n";
return;
}
}

I believe JPDeni said for this to work you should have your $db_key set in your .cfg file as the userid field.

Hope this helps Smile
Quote Reply
Re: Is there a way to automatically change permissions after a user adds a record??? In reply to
That really is the best way to go about this. It is possible to change the permissions, but the code is messy and this is a lot easier. I would suggest that you take out

&html_footer;

from sub html_add_form. That way, users won't have any option but to fill out the form.


------------------
JPD





Quote Reply
Re: Is there a way to automatically change permissions after a user adds a record??? In reply to
This goes at the beginning of html_home right?
Quote Reply
Re: Is there a way to automatically change permissions after a user adds a record??? In reply to
It did not work, i got errors, is it possible to use the other method, because every time i use that method, it did not work
Quote Reply
Re: Is there a way to automatically change permissions after a user adds a record??? In reply to
Can you give me the exact code you used in sub html_home?

Also, is your userid field the $db_key field?



------------------
JPD





Quote Reply
Re: Is there a way to automatically change permissions after a user adds a record??? In reply to
Here it is

Code:
sub html_home {
# --------------------------------------------------------
# The database manager home page.



$days = 3; # set this one day more than you want records to be considered "new."
# If you want to include records from the previous 7 days, set the number
# to 8.

$new = &get_date(time() - ($days * 86400));




&html_print_headers;



print qq|
<!-------------------- BEGIN COPYING THE JAVASCRIPT SECTION HERE ------------------->

<script language="JavaScript">
<!-- hide this script from non-javascript-enabled browsers

if (document.images) {
mainmenu_r4_c1_F1 = new Image(210,30); mainmenu_r4_c1_F1.src = "images/mainmenu_r4_c1.gif";
mainmenu_r4_c1_F2 = new Image(210,30); mainmenu_r4_c1_F2.src = "images/mainmenu_r4_c1_F2.gif";
}

/* Function that swaps images. */

function di20(id, newSrc) {
var theImage = FWFindImage(document, id, 0);
if (theImage) {
theImage.src = newSrc;
}
}

/* Functions that track and set toggle group button states. */

function FWFindImage(doc, name, j) {
var theImage = false;
if (doc.images) {
theImage = doc.images[name];
}
if (theImage) {
return theImage;
}
if (doc.layers) {
for (j = 0; j < doc.layers.length; j++) {
theImage = FWFindImage(doc.layers[j].document, name, 0);
if (theImage) {
return (theImage);
}
}
}
return (false);
}

// stop hiding -->
</script>

<!-------------------------- STOP COPYING THE JAVASCRIPT HERE -------------------------->

</head>

<body background="../../_themes/apa2/bzback.gif" bgcolor="#000000"
text="#CC9900" link="#CC9900" vlink="#FFFFFF" alink="#00CC33">
<center>

<table border="0" cellpadding="0" cellspacing="0" width="500">

<tr><!-- Shim row, height 1. -->
<td><img src="images/shim.gif" width="210" height="1" border="0"></td>
<td><img src="images/shim.gif" width="123" height="1" border="0"></td>
<td><img src="images/shim.gif" width="160" height="1" border="0"></td>
<td><img src="images/shim.gif" width="7" height="1" border="0"></td>
<td><img src="images/shim.gif" width="1" height="1" border="0"></td>
</tr>

<tr><!-- row 1 -->
<td colspan="4"><img name="mainmenu_r1_c1" src="images/mainmenu_r1_c1.gif" width="500" height="91" border="0"></td>
<td><img src="images/shim.gif" width="1" height="91" border="0"></td>
</tr>

<tr><!-- row 2 -->



<td rowspan="2" colspan="2"><img name="mainmenu_r2_c1" src="images/mainmenu_r2_c1.gif" width="333" height="277" border="0"></td>
<td>|; print qq!<P align=center><$font>!;




print qq! <A HREF="$db_script_link_url"><img src="images/home.gif" align=absmiddle border=0></A> !;
print qq! <a href="$db_script_link_url&Date-gt=$new&view_records=1"><img src="images/newest.gif" align=absmiddle border=0></a> ! if ($per_view);

print qq! <A HREF="$db_script_link_url&add_form=1"><img src="images/add.gif" align=absmiddle border=0></A> ! if ($per_add);
if (!$per_admin && $auth_view_own) {
print qq! <A HREF="$db_script_link_url&view_records=1&$db_key=*"><img src="images/add.gif" border=0 align=absmiddle></A> ! if ($per_view);
}
else {
print qq! <A HREF="$db_script_link_url&view_search=1"><img src="images/search.gif" align=absmiddle border=0></A> ! if ($per_view);
print qq! <A HREF="$db_script_link_url&view_records=1&$db_key=*"><img src="images/listall.gif" align=absmiddle border=0></A> ! if ($per_view);
}
if (!$per_admin && $auth_modify_own) {
print qq! <A HREF="$db_script_link_url&delete_form=1&$db_key=*"><img src="images/delete.gif" align=absmiddle border=0></A> ! if ($per_del);
print qq! <A HREF="$db_script_link_url&modify_form=1&$db_key=*"><img src="images/update.gif" align=absmiddle border=0></A> ! if ($per_mod);
}
else {
print qq! <A HREF="$db_script_link_url&delete_search=1"><img src="images/delete.gif" align=absmiddle border=0></A> ! if ($per_del);
print qq! <A HREF="$db_script_link_url&modify_search=1"><img src="images/update.gif" border=0></A> ! if ($per_mod);
}
print qq! <A HREF="$db_script_link_url&admin_display=1">Admin</A> ! if ($per_admin);
print qq! <A HREF="$db_script_link_url&logoff=1"><img src="images/logoff.gif" border=0></A> !;
print qq!</font></p>!; print qq|</td>
<td rowspan="4"><img name="mainmenu_r2_c4" src="images/mainmenu_r2_c4.gif" width="7" height="309" border="0"></td>
<td><img src="images/shim.gif" width="1" height="269" border="0"></td>
</tr>

<tr><!-- row 3 -->
<td rowspan="3"><img name="mainmenu_r3_c3" src="images/mainmenu_r3_c3.gif" width="160" height="40" border="0"></td>
<td><img src="images/shim.gif" width="1" height="8" border="0"></td>
</tr>

<tr><!-- row 4 -->
<td><a href="mailto:jwilliam\@umfort.cs.ecsu.edu" onMouseOut="di20('mainmenu_r4_c1','images/mainmenu_r4_c1.gif');" onMouseOver="di20('mainmenu_r4_c1','images/mainmenu_r4_c1_F2.gif');" ><img name="mainmenu_r4_c1" src="images/mainmenu_r4_c1.gif" width="210" height="30" border="0" alt="Questions or Comments"></a></td>
<td rowspan="2"><img name="mainmenu_r4_c2" src="images/mainmenu_r4_c2.gif" width="123" height="32" border="0"></td>
<td><img src="images/shim.gif" width="1" height="30" border="0"></td>
</tr>

<tr><!-- row 5 -->
<td><img name="mainmenu_r5_c1" src="images/mainmenu_r5_c1.gif" width="210" height="2" border="0"></td>
<td><img src="images/shim.gif" width="1" height="2" border="0"></td>
</tr>

</table>
Newest Members<br>

|;

$in{'Date-gt'} = $new;my ($status,
@hits) = &query("view"); if ($status eq
"ok") { my ($numhits) = ($#hits+1) /
($#db_cols+1); my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'})
: ($maxhits = $db_max_hits); for (0 .. $numhits - 1) { %rec
= &array_to_hash($_, @hits); print qq|<font size=2>
<a href="$db_script_link_url&$db_key=$rec{$db_key}&ww=1&view_records=1"><B>$rec{'Name'}</B>,<I> $rec{'Season'} $rec{'Year'}</I></a><br></font>|;
}}

# < -- End page text -->

&html_page_bottom;
}

The site is located at http://bzaphia.hypermart.net/cgi-bin/dbman/db.cgi
Quote Reply
Re: Is there a way to automatically change permissions after a user adds a record??? In reply to
You need to put the codes that Lois gave you:

Code:
if ($per_add) {
%rec = &get_record($db_userid);
if (!%rec) {
print "Location: $db_script_url?db=user&uid=$db_uid&add_form=1\n\n";
return;
}
}

BEFORE the &html_print_headers; codes in the sub html_home routine.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums