function views_plugin_argument_default_contact_id::get_argument in CRM Core 7
Same name and namespace in other branches
- 8.2 modules/crm_core_user_sync/views/views_plugin_argument_default_contact_id.inc \views_plugin_argument_default_contact_id::get_argument()
Return the default argument.
This needs to be overridden by every default argument handler to properly do what is needed.
Overrides views_plugin_argument_default::get_argument
File
- modules/
crm_core_user_sync/ views/ views_plugin_argument_default_contact_id.inc, line 32 - Contains the user from URL argument default plugin.
Class
- views_plugin_argument_default_contact_id
- Default argument plugin to extract a user via menu_get_object
Code
function get_argument() {
foreach (range(1, 3) as $i) {
$user = menu_get_object('user', $i);
if (!empty($user)) {
$contact = _crm_core_user_sync_get_related_entity('user', $user->uid, 'crm_core_user_sync');
if (!empty($contact)) {
return $contact->contact_id;
}
}
}
foreach (range(1, 3) as $i) {
$user = menu_get_object('user_uid_optional', $i);
if (!empty($user)) {
$contact = _crm_core_user_sync_get_related_entity('user', $user->uid, 'crm_core_user_sync');
if (!empty($contact)) {
return $contact->contact_id;
}
}
}
if (!empty($this->options['user'])) {
foreach (range(1, 3) as $i) {
$node = menu_get_object('node', $i);
if (!empty($node)) {
$contact = _crm_core_user_sync_get_related_entity('user', $node->uid, 'crm_core_user_sync');
if (!empty($contact)) {
return $contact->contact_id;
}
}
}
}
if (arg(0) == 'user' && is_numeric(arg(1))) {
$uid = arg(1);
$contact = _crm_core_user_sync_get_related_entity('user', $uid, 'crm_core_user_sync');
if (!empty($contact)) {
return $contact->contact_id;
}
}
if (!empty($this->options['user'])) {
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
if ($node) {
$contact = _crm_core_user_sync_get_related_entity('user', $node->uid, 'crm_core_user_sync');
if (!empty($contact)) {
return $contact->contact_id;
}
}
}
}
// If the current page is a view that takes uid as an argument, return the uid.
$views_page = views_get_page_view();
if ($views_page && isset($views_page->view->argument['uid'])) {
return $views_page->view->argument['uid']->argument;
}
}