This topic is locked
[SOLVED]

  New event (IsRecordEditable).

9/12/2012 1:49:36 AM
PHPRunner General questions
D
droogers author

Hello,
yesterday I saw the new versiopn of phprunner 6.2. (Great work !)

There is a new event (IsRecordEditable). How does it work ? Does anyone have an example ?

Sergey Kornilov admin 9/12/2012

You can implement custom edit permissions using this event. This event will be executed once for each record on the List page as well as on the Edit page.

Description

Occurs after table initialized.

Use this event to retrieve record permissions. Avoid printing anything in this event.
Parameters

$values - array of values has been written to the database. To access specific

field value use $values["FieldName"]

$isEditable - calculated for the current record editing flag


Here is the sample code. For example, you don't want data in certain table to be edited on weekends. Here is the code you can add to this event:

$dw = date("w", time());

$isEditable = $dw!=6 && $dw!=0;

return $isEditable;


Another example: how you can only allow records with odd IDs (1,3,5 ...) to be editable:

if ($values["ID"] & 1)

return false;

else

return true;
D
droogers author 9/13/2012

Thanks a lot <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=67744&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />



You can implement custom edit permissions using this event. This event will be executed once for each record on the List page as well as on the Edit page.

Description

Occurs after table initialized.

Use this event to retrieve record permissions. Avoid printing anything in this event.
Parameters

$values - array of values has been written to the database. To access specific

field value use $values["FieldName"]

$isEditable - calculated for the current record editing flag


Here is the sample code. For example, you don't want data in certain table to be edited on weekends. Here is the code you can add to this event:

$dw = date("w", time());

$isEditable = $dw!=6 && $dw!=0;

return $isEditable;


Another example: how you can only allow records with odd IDs (1,3,5 ...) to be editable:

if ($values["ID"] & 1)

return false;

else

return true;