This topic is locked

edit is disabled at this situation

11/15/2007 1:20:54 AM
PHPRunner General questions
A
amuro author

Hi, can someone advise please.
At list page, when the record has been processed(a column shows finished status) , the edit button must be disabled.
It means that users can edit the records retrieved from DB no longer.
Thank you!

A
amuro author 11/15/2007

work it out.

at Visual Editor, find the code "foreach from=$rowinfo item=row",

add smarty contional script below, {}

<TD>

{if $value == specific contion}

Edit

{else}

the default script at PHPRunner

{/if}

</TD>
the $value is the variable from $rowinfo <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=23361&image=1&table=forumreplies' class='bbc_emoticon' alt=':lol:' />

Alexey admin 11/15/2007

Amuro,
you can do this using Visual Editor and After record processedevent.
Open your List page in Visual Editor, select the Edit link and switch to HTML mode.

Enclose your Edit link into this:

{if $row.enable_edit} ... {/if}

Then use this code in After record processed event:

if($data["FieldName"]=="finished")

$row["enable_edit"]=false;

else

$row["enable_edit"]=true;

L
laonian 11/23/2007

Open your List page in Visual Editor, select the Edit link and switch to HTML mode.

Enclose your Edit link into this:

{if $row.enable_edit} ... {/if}


Sorry, I don't know how to do this part. My Edit link looks like this:
<TD class=borderbody vAlign=middle align=middle><A class=tablelinks

href="filename_edit.php?{$row.1editlink}">Edit</A>

</TD>
How should I wrap the Edit link with the {if...} ...{/if} tags?

if($data["FieldName"]=="finished")

$row["enable_edit"]=false;

else

$row["enable_edit"]=true;


When the above is working, is the Edit function disabled completely or you can still type the URL in browsers like:
http://host.domain.com/folder/filename_edit.php?editid1=3
and do editing from there on? Thanks.

J
Jane 11/26/2007

Hi,
here is a sample:

<TD class=borderbody vAlign=middle align=middle>{if $row.enable_edit}<A class=tablelinks href="filename_edit.php?{$row.1editlink}">Edit</A>{/if}</TD>

This method just remove edit link on the list page.

To restrict user access to edit page use Edit page: Before Process event on the Events tab.

global $conn;

if ($_REQUEST["editid1"])

{

$str = "select * from TableName where IDField=".$_REQUEST["editid1"];

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

if ($data["FieldName"]=="finished")

{

header("Location: TableName_list.php");

exit();

}

}



where IDField and FieldName are your actual field names, TableName is your actual table name.