function redhen_activity_activity_page in RedHen CRM 7
Page callback for a list of activities.
_type
Parameters
$entity:
Return value
array
1 string reference to 'redhen_activity_activity_page'
- redhen_activity_menu in modules/
redhen_activity/ redhen_activity.module - Implements hook_menu().
File
- modules/
redhen_activity/ redhen_activity.module, line 512
Code
function redhen_activity_activity_page($entity = NULL, $entity_type = NULL) {
global $language;
$header = array(
'timestamp' => array(
'field' => 'timestamp',
'type' => 'property',
'data' => t('Created'),
'specifier' => 'timestamp',
'sort' => 'desc',
),
'type' => array(
'field' => 'Type',
'type' => 'property',
'data' => t('Type'),
'specifier' => 'type',
),
'author' => array(
'data' => t('Author'),
),
'source' => array(
'data' => t('Source'),
),
'message' => array(
'data' => t('Message'),
),
);
// Need to ensure the query doesn't execute when posing the form.
$result = FALSE;
if (!isset($_POST['form_id'])) {
$fields = array();
if ($entity && $entity_type) {
$fields = array(
"message_{$entity_type}" => array(
LANGUAGE_NONE => array(
array(
'target_id' => $entity
->internalIdentifier(),
),
),
),
);
}
$bundle = isset($_GET['bundle']) ? $_GET['bundle'] : redhen_activity_message_types();
$properties = isset($_GET['properties']) ? $_GET['properties'] : array();
$fields += isset($_GET['fields']) ? $_GET['fields'] : array();
$result = redhen_filter_query('message', $header, $bundle, $properties, $fields);
}
$messages = array();
$rows = array();
if ($result) {
$messages = message_load_multiple(array_keys($result['message']));
if (!empty($messages)) {
foreach ($messages as $message) {
$message_type = message_type_load($message->type);
$author = $message
->user();
$url = user_uri($author);
$source_entity = redhen_activity_source_entity($message);
if ($source_entity) {
$source_uri = entity_uri($source_entity
->entityType(), $source_entity);
$source = l($source_entity
->label(), $source_uri['path']);
}
$rows[$message->mid] = array(
'data' => array(
'timestamp' => redhen_format_date($message->timestamp),
'type' => $message_type->description,
'author' => array(
'data' => array(
'#type' => 'link',
'#title' => $author->name,
'#href' => $url['path'],
),
),
'source' => $source,
'message' => $message
->getText($language->language),
),
);
}
}
}
return array(
'form' => drupal_get_form('redhen_filter_form', 'message'),
'messages' => array(
'#theme' => 'redhen_activity_list',
'#messages' => $messages,
'#header' => $header,
'#rows' => $rows,
),
);
}