Last active
August 29, 2015 14:04
-
-
Save acao/8102b7eb2fc43164c528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_node_accces(). | |
*/ | |
function example_schedules_node_access($node, $op, $account) { | |
if ($op !== 'view' && $node->type == 'class') { | |
if($profile = example_account_profile($account->uid)){ | |
if ($profile->type == 'teacher') { | |
if ($op == 'create'){ | |
return NODE_ACCESS_ALLOW; | |
} | |
$teacher = isset($node->field_teacher[LANGUAGE_NONE][0]['target_id']) ? $node->field_teacher[LANGUAGE_NONE][0]['target_id'] : 0; | |
if ($teacher == $profile->nid) { | |
return NODE_ACCESS_ALLOW; | |
} | |
} | |
else { | |
$venue = isset($node->field_venue[LANGUAGE_NONE][0]['target_id']) ? $node->field_venue[LANGUAGE_NONE][0]['target_id'] : 0; | |
if ($venue == $profile->nid) { | |
return NODE_ACCESS_ALLOW; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment