How do I get instance of the current record in block func?
Posted: Wed Dec 30, 2009 5:28 pm
In Dataface/templates/Dataface_Form_Section_Template.html at line 69 is as following:
{define_slot name="`$element.field.name`_delete_link"}<a class="delete-file-link" href="#" title="Delete this file" onclick="Xataface.deleteFile ...
What it does is to provide a link to delete the file uploaded. Now I want to make this link disappear when a condition is satisfied, like the logged_in user permission and/or some criteria in the current record are met, like status == 'approved'. I created a function in the table's delegate class like function block__source_attachment_1_delete_link(). I can do it for the permission with the following code just like the getPermission():
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
//If the user is null then nobody is logged in... no access. This will force a login prompt.
if (!isset($user)) return Dataface_PermissionsTool::NO_ACCESS();
$role = $user->val('user_role');
if ($role == "ADMIN") return Dataface_PermissionsTool::getRolePermissions($role);
if ($role == "GUEST") return Dataface_PermissionsTool::getRolePermissions("READ ONLY");
However, There is no way to get the current record so I can check if certain criteria in the current record are met. Does somebody know how to do it? What parameter does this function take? Can I just pass a &$record as arguement to this function?
{define_slot name="`$element.field.name`_delete_link"}<a class="delete-file-link" href="#" title="Delete this file" onclick="Xataface.deleteFile ...
What it does is to provide a link to delete the file uploaded. Now I want to make this link disappear when a condition is satisfied, like the logged_in user permission and/or some criteria in the current record are met, like status == 'approved'. I created a function in the table's delegate class like function block__source_attachment_1_delete_link(). I can do it for the permission with the following code just like the getPermission():
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
//If the user is null then nobody is logged in... no access. This will force a login prompt.
if (!isset($user)) return Dataface_PermissionsTool::NO_ACCESS();
$role = $user->val('user_role');
if ($role == "ADMIN") return Dataface_PermissionsTool::getRolePermissions($role);
if ($role == "GUEST") return Dataface_PermissionsTool::getRolePermissions("READ ONLY");
However, There is no way to get the current record so I can check if certain criteria in the current record are met. Does somebody know how to do it? What parameter does this function take? Can I just pass a &$record as arguement to this function?