function _pmperson_user_load in Drupal PM (Project Management) 7
Finds PM Person nodes attached to a given user account.
12 calls to _pmperson_user_load()
- pmexpense_node_grants in pmexpense/
pmexpense.module - Implements hook_node_grants().
- pminvoice_node_grants in pminvoice/
pminvoice.module - Implements hook_node_grants().
- pmnote_node_grants in pmnote/
pmnote.module - Implements hook_node_grants().
- pmorganization_node_grants in pmorganization/
pmorganization.module - Implements hook_node_grants().
- pmperson_init in pmperson/
pmperson.module - Implements hook_init().
File
- pmperson/
pmperson.module, line 586
Code
function _pmperson_user_load(&$account) {
static $loaded_persons = array();
if (isset($loaded_persons[$account->uid])) {
if (is_object($loaded_persons[$account->uid])) {
$account->pmperson_nid = $loaded_persons[$account->uid]->nid;
$account->pmorganization_nid = $loaded_persons[$account->uid]->organization_nid;
}
}
else {
$result = db_select('pmperson', 'pmper')
->fields('pmper', array(
'nid',
'organization_nid',
))
->condition('user_uid', $account->uid)
->execute();
$record = $result
->fetchObject();
if ($record) {
$loaded_persons[$account->uid] = new stdClass();
$loaded_persons[$account->uid]->nid = $record->nid;
$loaded_persons[$account->uid]->organization_nid = $record->organization_nid;
$account->pmperson_nid = $loaded_persons[$account->uid]->nid;
$account->pmorganization_nid = $loaded_persons[$account->uid]->organization_nid;
if (module_exists('pmteam')) {
$result = db_select('pmteam', 'pmt')
->fields('pmt', array(
'nid',
))
->condition('pmt.mnid', $account->pmperson_nid)
->execute();
$loaded_persons[$account->uid]->team = array();
foreach ($result as $pmteam) {
$loaded_persons[$account->uid]->team[] = $pmteam->nid;
}
$account->pmteam = $loaded_persons[$account->uid]->team;
}
}
else {
$loaded_persons[$account->uid] = 0;
$account->pmperson_nid = NULL;
$account->pmorganization_nid = NULL;
}
}
}