Skip to content
GitLab
Menu
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
d52de9ef
Commit
d52de9ef
authored
Apr 30, 2010
by
Richard Mansfield
Browse files
Select activity types by name & allow multiple types to be selected
Signed-off-by:
Richard Mansfield
<
richardm@catalyst.net.nz
>
parent
94f6d74b
Changes
3
Hide whitespace changes
Inline
Side-by-side
htdocs/account/activity/index.json.php
View file @
d52de9ef
...
...
@@ -85,7 +85,7 @@ else if ($delete) {
// normal processing
$type
=
param_
alphanum
(
'type'
,
'all'
);
$type
=
param_
variable
(
'type'
,
'all'
);
$limit
=
param_integer
(
'limit'
,
10
);
$offset
=
param_integer
(
'offset'
,
0
);
...
...
@@ -107,12 +107,18 @@ if ($type == 'all') {
$records
=
get_records_sql_array
(
$sql
,
array
(
$userid
,
1
),
$offset
,
$limit
);
}
else
{
$count
=
count_records_select
(
'notification_internal_activity'
,
'usr = ? AND type = ?'
,
array
(
$userid
,
$type
));
$sql
=
'SELECT a.*, at.name AS type,at.plugintype, at.pluginname FROM {notification_internal_activity} a
$types
=
split
(
','
,
preg_replace
(
'/[^a-z,]+/'
,
''
,
$type
));
if
(
$types
)
{
$typesql
=
' AND at.name IN ('
.
join
(
','
,
array_map
(
'db_quote'
,
$types
))
.
')'
;
}
$from
=
"
FROM
{
notification_internal_activity
}
a
JOIN
{
activity_type
}
at ON a.type = at.id
WHERE a.usr = ? AND a.type = ?'
;
$records
=
get_records_sql_array
(
$sql
,
array
(
$userid
,
$type
),
$offset
,
$limit
);
WHERE a.usr = ?
$typesql
"
;
$values
=
array
(
$userid
);
$count
=
count_records_sql
(
'SELECT COUNT(*)'
.
$from
,
$values
);
$records
=
get_records_sql_array
(
'
SELECT a.*, at.name AS type,at.plugintype, at.pluginname'
.
$from
,
$values
,
$offset
,
$limit
);
}
if
(
empty
(
$records
))
{
...
...
htdocs/account/activity/index.php
View file @
d52de9ef
...
...
@@ -35,25 +35,36 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once
(
'pieforms/pieform.php'
);
define
(
'TITLE'
,
get_string
(
'inbox'
));
$types
=
get_records_assoc
(
'activity_type'
,
'admin'
,
0
,
'plugintype,pluginname,name'
,
'id,name,plugintype,pluginname'
);
$types
=
array_map
(
create_function
(
'$a'
,
'
if (!empty($a->plugintype)) {
$section = "{$a->plugintype}.{$a->pluginname}";
}
else {
$section = "activity";
$installedtypes
=
get_records_assoc
(
'activity_type'
,
''
,
''
,
'plugintype,pluginname,name'
,
'name,admin,plugintype,pluginname'
);
$options
=
array
(
'all'
=>
get_string
(
'alltypes'
,
'activity'
),
);
foreach
(
$installedtypes
as
&
$t
)
{
if
(
!
$t
->
admin
)
{
$section
=
$t
->
pluginname
?
"
{
$t
->
plugintype
}
.
{
$t
->
pluginname
}
"
:
'activity'
;
$options
[
$t
->
name
]
=
get_string
(
'type'
.
$t
->
name
,
$section
);
}
return get_string("type" . $a->name, $section);
'
),
$types
);
}
if
(
$USER
->
get
(
'admin'
))
{
$
type
s
[
'adminmessages'
]
=
get_string
(
'typeadminmessages'
,
'activity'
);
$
option
s
[
'adminmessages'
]
=
get_string
(
'typeadminmessages'
,
'activity'
);
}
$type
=
param_alphanum
(
'type'
,
'all'
);
if
(
!
isset
(
$types
[
$type
]))
{
$type
=
'all'
;
$type
=
param_variable
(
'type'
,
'all'
);
if
(
!
isset
(
$options
[
$type
]))
{
// Comma-separated list; filter out anything that's not an installed type
$types
=
join
(
','
,
array_unique
(
array_filter
(
split
(
','
,
$type
),
create_function
(
'$a'
,
'global $installedtypes; return isset($installedtypes[$a]);'
)
)));
}
$strtype
=
json_encode
(
$type
);
$morestr
=
get_string
(
'more...'
);
...
...
@@ -214,7 +225,8 @@ $smarty->assign('selectalldel', 'toggleChecked(\'tocheckdel\'); return false;');
$smarty
->
assign
(
'markread'
,
'markread(this, \'read\'); return false;'
);
$smarty
->
assign
(
'markdel'
,
'markread(document.notificationlist, \'del\'); return false;'
);
$smarty
->
assign
(
'typechange'
,
'activitylist.type = this.options[this.selectedIndex].value; activitylist.doupdate();'
);
$smarty
->
assign
(
'types'
,
$types
);
$smarty
->
assign
(
'options'
,
$options
);
$smarty
->
assign
(
'type'
,
$type
);
$smarty
->
assign
(
'INLINEJAVASCRIPT'
,
$javascript
);
$smarty
->
assign
(
'PAGEHEADING'
,
hsc
(
get_string
(
'inbox'
)));
$smarty
->
assign
(
'deleteall'
,
$deleteall
);
...
...
htdocs/theme/raw/templates/account/activity/index.tpl
View file @
d52de9ef
...
...
@@ -4,8 +4,7 @@
<form
method=
"post"
>
<label>
{
str
section
=
'activity'
tag
=
'type'
}
:
</label>
<select
name=
"type"
onChange=
"
{
$typechange
}
"
>
<option
value=
"all"
>
{
str
section
=
'activity'
tag
=
'alltypes'
}
</option>
{
foreach
from
=
$types
item
=
name
key
=
type
}
{
foreach
from
=
$options
item
=
name
key
=
type
}
<option
value=
"
{
$type
}
"
>
{
$name
}
</option>
{/
foreach
}
</select>
{
contextualhelp
plugintype
=
'core'
pluginname
=
'activity'
section
=
'activitytypeselect'
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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