This topic is locked

Locking of Record

4/15/2008 9:18:07 PM
PHPRunner General questions
I
indigo author

I need to lock a record and freeze certain fields so they cannot be edited after locking. Preferably a field for locking is perfect.
So, if a user is setting 'locked' to 'yes' then the record cannot be edited again and he should not be allowed to unlock.

How do I achieve this?

J
Jane 4/16/2008

Hi,
you can do the following:

  1. add lock field to the table on the Datasource tables tab,
  2. check value of this field on the Edit page: Before process event and redirect to list page if record is locked.

    Here is a sample event code:
    global $conn;

    $str = "select LockField from TableName where RecordID=".$_REQUEST["editid1"];

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

    $data = db_fqtch_array($rs);
    if ($data["LockField"]==true)

    {

    header("Location: ..._list.php");

    exit();

    }

I
indigo author 4/18/2008

How do I redirect to "View Record" page of that specific record?

I
indigo author 4/18/2008

I got this. Thanks.

Putting it here for others' benefit...

global $conn;

$str = "select Status from 3140_Project where ProjID=".$_REQUEST["editid1"];

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

$data = db_fetch_array($rs);

if ($data["Status"]=="Completed")

{

header("Location: 3140_Project_view.php?editid1=".$_REQUEST["editid1"]);

exit();

}

N
nitro23456 5/16/2009

Hi
I am trying to get this to work, so that if my field 'MY FIELD' contains any information at all it will redirect, but if it is empty it will inline_edit as usual:

global $conn;

$str = "select MY FIELD from MY TABLE where RecordID=".$_REQUEST["editid1"];

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

$data = db_fqtch_array($rs);
if ($data["MY FIELD"]==true)

{

header("Location: MY_TABLE_view.php?editid1=".$_REQUEST["editid1"]);

exit();

}

else

{
}


Currently, with this code, it doesnt redirect if the field is full..... it also wont let me inline edit if it is empty either! help.