function party_party_party_pieces in Party 8.2
Same name and namespace in other branches
- 7 party.party_info.inc \party_party_party_pieces()
Implements hook_party_party_pieces().
Defines:
- the basic piece for showing a party itself
- pieces that data sets provide
- pieces provided by Views as display plugins.
File
- ./
party.module, line 651 - Provides a generic CRM party entity.
Code
function party_party_party_pieces() {
$pieces = array(
// The main party piece.
// By default this is the default tab, but the MENU_DEFAULT_LOCAL_TASK
// is supplied in hook_menu() to allow the piece order setting to change
// the default tab accordingly.
'party' => array(
'title' => 'Party',
'page callback' => 'party_page_view',
'page arguments' => array(
1,
),
'file' => 'party.pages.inc',
'access arguments' => array(
'view contacts',
),
'weight' => -10,
),
);
// Party data sets may provide a piece each. Here we handle those of type
// 'callback'; type 'views' is handled by our party_views_default_views()
// and our Views display plugin.
$sets = party_get_data_set_info();
//dsm($sets);
foreach ($sets as $set_name => $set) {
if (isset($set['piece']) && in_array($set['piece']['maker'], array(
'callback',
'core',
))) {
if ($set['piece']['maker'] == 'core') {
// 'core' is a special case of 'callback' where we supply the details.
$set['piece'] += array(
'title' => $set['label'],
'page callback' => 'party_view_data_set',
'page arguments' => array(
1,
$set_name,
),
'access callback' => 'party_access',
'access arguments' => array(
'view',
1,
$set_name,
),
'file' => 'party.pages.inc',
);
}
// The path becomes the piece's key.
$path = $set['piece']['path'];
unset($set['piece']['path']);
// Add a key to say we came from a dataset.
$set['piece']['data_set'] = $set_name;
$pieces[$path] = $set['piece'];
}
}
// Custom pieces can be created as Views plugins.
if (module_exists('views')) {
// Get all views displays that implement our hook.
// There's no need to cache: views_menu() doesn't cache for page displays.
$views = views_get_all_views();
foreach ($views as $view) {
// Disabled views get nothing.
if (!empty($view->disabled)) {
continue;
}
$view
->init_display();
foreach ($view->display as $display_id => $display) {
if (isset($display->handler) && !empty($display->handler->definition['uses hook party_party_pieces'])) {
$result = $display->handler
->execute_hook_party_party_pieces();
if (is_array($result)) {
// Add in access properties.
foreach ($result as $path => $piece) {
$result[$path] += array(
'access callback' => 'party_access',
'access arguments' => array(
'view',
1,
$piece['data_set'],
),
);
}
$pieces = array_merge($pieces, $result);
}
}
}
}
}
return $pieces;
}