I am using PHPR version 5.0 Build 766. I have a table that can be accessed by different users. The records are set so that they are editable by different users, but can be deleted only by the user who created (added) it. The ownership info of the record is stored in the field "owner". To prevent the records to be deleted by other users, I tried to add a BeforeDelete event (alert box) on List page:
if(@$_POST["a"]=="delete")
{
if ($deleted_values["owner"]!=@$_SESSION["UserID"])
{
echo "<script>alert('You cann't delete other people's records!')</script>";
return false;
}
else
return true;
}
The code did not work.
Then I checked the _list.php file and guess perhaps I could do the alert by modifying the default deletion confirmation line found at:
$xt->assign("deletelink_attrs","onclick=\"
if(\$('input[@type=checkbox][@checked][@name^=selection]').length && confirm('"."Do you really want to delete these records?"."'))
frmAdmin.submit();
What I want to add isan if/else statement between onclick=\" and if(\$('input[@type=...... But I am a javascript newbie. Could someone "convert" my PHP coding into javascript and insert it in between for me, if it makes any sense at all? Thanks.