Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
0b40d632
Commit
0b40d632
authored
Jun 23, 2010
by
Richard Mansfield
Browse files
Add latest members ordering option to groupmembers block
Signed-off-by:
Richard Mansfield
<
richardm@catalyst.net.nz
>
parent
dc05c081
Changes
5
Hide whitespace changes
Inline
Side-by-side
htdocs/blocktype/groupmembers/lang/en.utf8/blocktype.groupmembers.php
View file @
0b40d632
...
...
@@ -35,4 +35,10 @@ $string['options_rows_title'] = 'Rows';
$string
[
'options_rows_desc'
]
=
'The amount of rows you want to display.'
;
$string
[
'options_columns_title'
]
=
'Columns'
;
$string
[
'options_columns_desc'
]
=
'The columns of rows you want to display.'
;
\ No newline at end of file
$string
[
'options_columns_desc'
]
=
'The columns of rows you want to display.'
;
$string
[
'options_order_title'
]
=
'Order'
;
$string
[
'options_order_desc'
]
=
'You can choose to display the latest group members or a random selection.'
;
$string
[
'Latest'
]
=
'Latest'
;
$string
[
'Random'
]
=
'Random'
;
\ No newline at end of file
htdocs/blocktype/groupmembers/lib.php
View file @
0b40d632
...
...
@@ -55,10 +55,11 @@ class PluginBlocktypeGroupMembers extends SystemBlocktype {
$configdata
=
$instance
->
get
(
'configdata'
);
$rows
=
$configdata
[
'rows'
];
$columns
=
$configdata
[
'columns'
]
?
$configdata
[
'columns'
]
:
3
;
$order
=
$configdata
[
'order'
]
?
$configdata
[
'order'
]
:
'latest'
;
$groupid
=
$instance
->
get_view
()
->
get
(
'group'
);
require_once
(
'searchlib.php'
);
$groupmembers
=
get_group_user_search_results
(
$groupid
,
''
,
0
,
(
$rows
+
$columns
),
''
,
true
);
$groupmembers
=
get_group_user_search_results
(
$groupid
,
''
,
0
,
(
$rows
+
$columns
),
''
,
$order
);
if
(
$groupmembers
[
'count'
])
{
$groupmembersarray
=
array_chunk
(
$groupmembers
[
'data'
],
$columns
);
...
...
@@ -107,6 +108,16 @@ class PluginBlocktypeGroupMembers extends SystemBlocktype {
'defaultvalue'
=>
$configdata
[
'columns'
]
?
$configdata
[
'columns'
]
:
3
,
'options'
=>
$options
,
),
'order'
=>
array
(
'type'
=>
'select'
,
'title'
=>
get_string
(
'options_order_title'
,
'blocktype.groupmembers'
),
'description'
=>
get_string
(
'options_order_desc'
,
'blocktype.groupmembers'
),
'defaultvalue'
=>
!
empty
(
$configdata
[
'order'
])
?
$configdata
[
'order'
]
:
'latest'
,
'options'
=>
array
(
'latest'
=>
get_string
(
'Latest'
,
'blocktype.groupmembers'
),
'random'
=>
get_string
(
'Random'
,
'blocktype.groupmembers'
),
),
),
);
}
...
...
htdocs/lib/db/upgrade.php
View file @
0b40d632
...
...
@@ -1804,6 +1804,12 @@ function xmldb_core_upgrade($oldversion=0) {
'column'
=>
1
,
'config'
=>
null
,
),
array
(
'blocktype'
=>
'groupmembers'
,
'title'
=>
get_string
(
'title'
,
'blocktype.groupmembers'
),
'column'
=>
1
,
'config'
=>
null
,
),
);
$installed
=
get_column_sql
(
'SELECT name FROM {blocktype_installed}'
);
foreach
(
$blocktypes
as
$k
=>
$blocktype
)
{
...
...
htdocs/lib/searchlib.php
View file @
0b40d632
...
...
@@ -341,7 +341,7 @@ function admin_user_search($queries, $constraints, $offset, $limit, $sortfield,
* @param bool $random Set to true if you want the result to be ordered by random, default false
*
*/
function
get_group_user_search_results
(
$group
,
$query
,
$offset
,
$limit
,
$membershiptype
,
$
random
=
false
)
{
function
get_group_user_search_results
(
$group
,
$query
,
$offset
,
$limit
,
$membershiptype
,
$
order
=
null
)
{
$queries
=
array
();
$constraints
=
array
();
if
(
!
empty
(
$query
))
{
...
...
@@ -364,7 +364,7 @@ function get_group_user_search_results($group, $query, $offset, $limit, $members
}
}
$results
=
group_user_search
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$
random
);
$results
=
group_user_search
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$
order
);
if
(
$results
[
'count'
])
{
$userids
=
array_map
(
create_function
(
'$a'
,
'return $a["id"];'
),
$results
[
'data'
]);
$introductions
=
get_records_sql_assoc
(
"SELECT
\"
owner
\"
, title
...
...
@@ -384,11 +384,11 @@ function get_group_user_search_results($group, $query, $offset, $limit, $members
}
function
group_user_search
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$
random
=
false
)
{
function
group_user_search
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$
order
=
null
)
{
$plugin
=
get_config
(
'searchplugin'
);
safe_require
(
'search'
,
$plugin
);
return
call_static_method
(
generate_class_name
(
'search'
,
$plugin
),
'group_search_user'
,
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$
random
);
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$
order
);
}
/**
...
...
htdocs/search/internal/lib.php
View file @
0b40d632
...
...
@@ -352,7 +352,7 @@ class PluginSearchInternal extends PluginSearch {
}
public
static
function
group_search_user
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$
random
=
false
)
{
public
static
function
group_search_user
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$
order
=
null
)
{
// Only handle OR/AND expressions at the top level. Eventually we may need subexpressions.
$searchsql
=
''
;
$values
=
array
();
...
...
@@ -427,9 +427,12 @@ class PluginSearchInternal extends PluginSearch {
AND gm.group = ?'
;
$values
[]
=
$group
;
$orderby
=
"gm.role = 'admin' DESC, gm.ctime, u.firstname, u.lastname, u.id"
;
if
(
$order
==
'latest'
)
{
$orderby
=
'gm.ctime DESC, u.firstname, u.lastname, u.id'
;
}
}
if
(
$random
)
{
if
(
$
order
==
'
random
'
)
{
$orderby
=
db_random
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment