diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/dashboard/languages/en.php | 14 | ||||
-rw-r--r-- | mod/dashboard/start.php | 8 | ||||
-rw-r--r-- | mod/dashboard/views/default/widgets/group_activity/content.php | 36 | ||||
-rw-r--r-- | mod/dashboard/views/default/widgets/group_activity/edit.php | 45 |
4 files changed, 103 insertions, 0 deletions
diff --git a/mod/dashboard/languages/en.php b/mod/dashboard/languages/en.php new file mode 100644 index 000000000..e1378f2f1 --- /dev/null +++ b/mod/dashboard/languages/en.php @@ -0,0 +1,14 @@ +<?php +/** + * User dashboard languages + */ + +$english = array( + 'dashboard:widget:group:title' => 'Group activity', + 'dashboard:widget:group:desc' => 'View the activity in one of your groups', + 'dashboard:widget:group:select' => 'Select a group', + 'dashboard:widget:group:noactivity' => 'There is no activity in this group', + 'dashboard:widget:group:noselect' => 'Edit this widget to select a group', +); + +add_translation("en", $english); diff --git a/mod/dashboard/start.php b/mod/dashboard/start.php index 69572bd32..5635ead57 100644 --- a/mod/dashboard/start.php +++ b/mod/dashboard/start.php @@ -18,6 +18,14 @@ function dashboard_init() { 'section' => 'alt', )); + elgg_register_widget_type( + 'group_activity', + elgg_echo('dashboard:widget:group:title'), + elgg_echo('dashboard:widget:group:desc'), + 'dashboard', + true + ); + elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'dashboard_default_widgets'); } diff --git a/mod/dashboard/views/default/widgets/group_activity/content.php b/mod/dashboard/views/default/widgets/group_activity/content.php new file mode 100644 index 000000000..60a9b352c --- /dev/null +++ b/mod/dashboard/views/default/widgets/group_activity/content.php @@ -0,0 +1,36 @@ +<?php +/** + * Group activity widget + */ + +$num = (int) $vars['entity']->num_display; +$guid = $vars['entity']->group_guid; + +$content = ''; + +if ($guid) { + $title = get_entity($guid)->name; + $content = "<h3>$title</h3>"; + + elgg_push_context('widgets'); + $db_prefix = elgg_get_config('dbprefix'); + $activity = elgg_list_river(array( + 'limit' => $num, + 'pagination' => false, + 'joins' => array("JOIN {$db_prefix}entities e1 ON e1.guid = rv.object_guid"), + 'wheres' => array("(e1.container_guid = $guid)"), + )); + if (!$activity) { + $activity = '<p>' . elgg_echo('dashboard:widget:group:noactivity') . '</p>'; + } + elgg_pop_context(); + + $content .= $activity; +} else { + // no group selected yet + if ($vars['entity']->canEdit()) { + $content = '<p>' . elgg_echo('dashboard:widget:group:noselect') . '</p>'; + } +} + +echo $content; diff --git a/mod/dashboard/views/default/widgets/group_activity/edit.php b/mod/dashboard/views/default/widgets/group_activity/edit.php new file mode 100644 index 000000000..4e10f6ad4 --- /dev/null +++ b/mod/dashboard/views/default/widgets/group_activity/edit.php @@ -0,0 +1,45 @@ +<?php +/** + * Group activity widget settings + */ + +// once autocomplete is working use that +$groups = elgg_get_logged_in_user_entity()->getGroups("", 0); +$mygroups = array(); +if (!$vars['entity']->group_guid) { + $mygroups[0] = ''; +} +foreach ($groups as $group) { + $mygroups[$group->guid] = $group->name; +} +$params = array( + 'name' => 'params[group_guid]', + 'value' => $vars['entity']->group_guid, + 'options_values' => $mygroups, +); +$group_dropdown = elgg_view('input/dropdown', $params); +?> +<div> + <?php echo elgg_echo('dashboard:widget:group:select'); ?>: + <?php echo $group_dropdown; ?> +</div> +<?php + +// set default value for number to display +if (!isset($vars['entity']->num_display)) { + $vars['entity']->num_display = 8; +} + +$params = array( + 'name' => 'params[num_display]', + 'value' => $vars['entity']->num_display, + 'options' => array(5, 8, 10, 12, 15, 20), +); +$num_dropdown = elgg_view('input/dropdown', $params); + +?> +<div> + <?php echo elgg_echo('widget:numbertodisplay'); ?>: + <?php echo $num_dropdown; ?> +</div> + |