diff --git a/languages/en.php b/languages/en.php index 32a809d1..99911520 100644 --- a/languages/en.php +++ b/languages/en.php @@ -352,10 +352,10 @@ 'widgets:group_forum_topics:description' => "Show the latest discussions", // index_groups - 'widgets:index_groups:description' => "Show the latest groups on your community", + 'widgets:index_groups:description' => "List groups from your community", 'widgets:index_groups:show_members' => "Show members count", 'widgets:index_groups:featured' => "Show only featured groups", - 'widgets:index_groups:apply_sorting' => "Apply sorting if available", + 'widgets:index_groups:sorting' => "How to sort the groups", 'widgets:index_groups:filter:field' => "Filter groups based on group field", 'widgets:index_groups:filter:value' => "with value", diff --git a/languages/nl.php b/languages/nl.php index bc2ed08e..b6296827 100644 --- a/languages/nl.php +++ b/languages/nl.php @@ -88,7 +88,7 @@ 'widgets:discussion:settings:group_only' => 'Toon alleen discussies uit je eigen groepen', 'widgets:discussion:more' => 'Bekijk meer discussies', 'widgets:discussion:description' => 'Toont de laatste discussies', - 'widgets:index_groups:description' => 'Toon de laatste groepen uit de community', + 'widgets:index_groups:description' => 'Toont groepen uit de community', 'widgets:index_groups:show_members' => 'Toon aantal groepsleden', 'widgets:index_groups:featured' => 'Toon enkel aangeraden groepen', 'widgets:group_news:settings:group_icon_size' => 'Groep icoon grootte', diff --git a/views/default/widgets/index_groups/content.php b/views/default/widgets/index_groups/content.php index 119adc98..29a2aa72 100644 --- a/views/default/widgets/index_groups/content.php +++ b/views/default/widgets/index_groups/content.php @@ -1,4 +1,4 @@ -apply_sorting == "yes"){ - $dbprefix = elgg_get_config("dbprefix"); - $order_id = add_metastring("order"); - - $options["selects"] = array( - "IFNULL((SELECT order_ms.string as order_val FROM " . $dbprefix . "metadata mo JOIN " . $dbprefix . "metastrings order_ms ON mo.value_id = order_ms.id WHERE e.guid = mo.entity_guid AND mo.name_id = " . $order_id . "), 99999) AS order_val" - ); - - $options["order_by"] = "CAST(order_val AS SIGNED) ASC, e.time_created DESC"; + $sorting_value = $widget->sorting; + if (empty($sorting_value) && ($widget->apply_sorting == "yes")) { + $sorting_value = "ordered"; } + $getter = "elgg_get_entities_from_metadata"; + // check if groups should respect a specific order + switch ($sorting_value) { + case "ordered": + $dbprefix = elgg_get_config("dbprefix"); + $order_id = add_metastring("order"); + + $options["selects"] = array( + "IFNULL((SELECT order_ms.string as order_val FROM " . $dbprefix . "metadata mo JOIN " . $dbprefix . "metastrings order_ms ON mo.value_id = order_ms.id WHERE e.guid = mo.entity_guid AND mo.name_id = " . $order_id . "), 99999) AS order_val" + ); + + $options["order_by"] = "CAST(order_val AS SIGNED) ASC, e.time_created DESC"; + break; + case "popular": + $getter = "elgg_get_entities_from_relationship_count"; + + $options["relationship"] = "member"; + $options["inverse_relationship"] = false; + break; + default: + // just use default time created sorting + break; + } + // show group member count if($widget->show_members == "yes"){ $show_members = true; @@ -68,7 +85,7 @@ } // list groups - if($groups = elgg_list_entities_from_metadata($options)){ + if($groups = elgg_list_entities($options, $getter)){ echo $groups; } else { echo elgg_echo("groups:none"); diff --git a/views/default/widgets/index_groups/edit.php b/views/default/widgets/index_groups/edit.php index 8d9ad7f1..b5ddfeb2 100644 --- a/views/default/widgets/index_groups/edit.php +++ b/views/default/widgets/index_groups/edit.php @@ -1,4 +1,4 @@ - elgg_echo("groups:newest"), + "popular" => elgg_echo("groups:popular"), + "ordered" => elgg_echo("group_tools:groups:sorting:ordered") + ); + + $sorting_value = $widget->sorting; + if (empty($sorting_value) && ($widget->apply_sorting == "yes")) { + $sorting_value = "ordered"; + } + ?>

@@ -35,21 +46,21 @@
- "params[show_members]", "options_values" => $noyes_options, "value" => $widget->show_members)); ?>
- "params[featured]", "options_values" => $noyes_options, "value" => $widget->featured)); ?>
-
- "params[apply_sorting]", "options_values" => $noyes_options, "value" => $widget->apply_sorting)); + "params[sorting]", "options_values" => $sorting_options, "value" => $sorting_value)); ?>