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
3e7e5ef0
Commit
3e7e5ef0
authored
Apr 30, 2010
by
Richard Mansfield
Browse files
Simplify json script & add unnamed option to the drop-down
Signed-off-by:
Richard Mansfield
<
richardm@catalyst.net.nz
>
parent
d52de9ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/account/activity/index.json.php
View file @
3e7e5ef0
...
...
@@ -91,36 +91,29 @@ $offset = param_integer('offset', 0);
$userid
=
$USER
->
get
(
'id'
);
if
(
$type
==
'all'
)
{
$count
=
count_records
(
'notification_internal_activity'
,
'usr'
,
$userid
);
$sql
=
'SELECT a.*, at.name AS type,at.plugintype, at.pluginname FROM {notification_internal_activity} a
JOIN {activity_type} at ON a.type = at.id
WHERE a.usr = ? ORDER BY ctime DESC'
;
$records
=
get_records_sql_array
(
$sql
,
array
(
$userid
),
$offset
,
$limit
);
}
else
if
(
$type
==
'adminmessages'
&&
$USER
->
get
(
'admin'
))
{
$count
=
count_records_select
(
'notification_internal_activity'
,
'usr = ? AND type IN (
SELECT id FROM {activity_type} WHERE admin = ?)'
,
array
(
$userid
,
1
));
$sql
=
'SELECT a.*, at.name AS type,at.plugintype, at.pluginname FROM {notification_internal_activity} a
JOIN {activity_type} at ON a.type = at.id
WHERE a.usr = ? AND at.admin = ? ORDER BY ctime DESC'
;
$records
=
get_records_sql_array
(
$sql
,
array
(
$userid
,
1
),
$offset
,
$limit
);
}
else
{
$typesql
=
''
;
if
(
$type
!=
'all'
)
{
$types
=
split
(
','
,
preg_replace
(
'/[^a-z,]+/'
,
''
,
$type
));
if
(
$types
)
{
$typesql
=
' AND at.name IN ('
.
join
(
','
,
array_map
(
'db_quote'
,
$types
))
.
')'
;
$typesql
=
' at.name IN ('
.
join
(
','
,
array_map
(
'db_quote'
,
$types
))
.
')'
;
if
(
in_array
(
'adminmessages'
,
$types
))
{
$typesql
=
'('
.
$typesql
.
' OR at.admin = 1)'
;
}
$typesql
=
' AND '
.
$typesql
;
}
$from
=
"
FROM
{
notification_internal_activity
}
a
JOIN
{
activity_type
}
at ON a.type = at.id
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
);
}
$from
=
"
FROM
{
notification_internal_activity
}
a
JOIN
{
activity_type
}
at ON a.type = at.id
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
.
'
ORDER BY a.ctime DESC'
,
$values
,
$offset
,
$limit
);
if
(
empty
(
$records
))
{
$records
=
array
();
}
...
...
htdocs/theme/raw/templates/account/activity/index.tpl
View file @
3e7e5ef0
...
...
@@ -4,8 +4,9 @@
<form
method=
"post"
>
<label>
{
str
section
=
'activity'
tag
=
'type'
}
:
</label>
<select
name=
"type"
onChange=
"
{
$typechange
}
"
>
{
foreach
from
=
$options
item
=
name
key
=
type
}
<option
value=
"
{
$type
}
"
>
{
$name
}
</option>
<option
value=
"all"
>
--
</option>
{
foreach
from
=
$options
item
=
name
key
=
t
}
<option
value=
"
{
$t
}
"
{
if
$type
==
$t
}
selected
{/
if
}
>
{
$name
}
</option>
{/
foreach
}
</select>
{
contextualhelp
plugintype
=
'core'
pluginname
=
'activity'
section
=
'activitytypeselect'
}
</form>
...
...
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