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
7712593a
Commit
7712593a
authored
Nov 28, 2006
by
Penny Leach
Browse files
added recursive delete to watchlist
parent
a4b9cf24
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/account/watchlist/index.json.php
View file @
7712593a
...
...
@@ -33,6 +33,8 @@ json_headers();
$stopmonitoring
=
param_integer
(
'stopmonitoring'
,
0
);
$getartefacts
=
param_integer
(
'getartefacts'
,
0
);
$prefix
=
get_config
(
'dbprefix'
);
if
(
$stopmonitoring
)
{
$userid
=
$USER
->
get
(
'id'
);
$count
=
0
;
...
...
@@ -40,10 +42,27 @@ if ($stopmonitoring) {
try
{
foreach
(
$_GET
as
$k
=>
$v
)
{
if
(
preg_match
(
'/^stopviews\-(\d+)$/'
,
$k
,
$m
))
{
$recurse
=
param_boolean
(
$k
.
'-recurse'
,
null
);
if
(
!
empty
(
$recurse
))
{
$sql
=
'DELETE FROM '
.
$prefix
.
'usr_watchlist_artefact
WHERE usr = ? AND (artefact IN (
SELECT artefact FROM '
.
$prefix
.
'artefact_parent_cache WHERE parent IN (
SELECT artefact FROM '
.
$prefix
.
'view_artefact WHERE view = ? ) )
OR artefact IN (
SELECT artefact FROM '
.
$prefix
.
'view_artefact WHERE view = ?))'
;
delete_records_sql
(
$sql
,
array
(
$userid
,
$m
[
1
],
$m
[
1
]));
}
delete_records
(
'usr_watchlist_view'
,
'usr'
,
$userid
,
'view'
,
$m
[
1
]);
$count
++
;
}
else
if
(
preg_match
(
'/^stopartefacts\-(\d+)$/'
,
$k
,
$m
))
{
$recurse
=
param_boolean
(
$k
.
'-recurse'
,
null
);
if
(
!
empty
(
$recurse
))
{
$sql
=
'DELETE FROM '
.
$prefix
.
'usr_watchlist_artefact
WHERE usr = ? AND artefact IN (
SELECT artefact FROM '
.
$prefix
.
'artefact_parent_cache WHERE parent = ?)'
;
delete_records_sql
(
$sql
,
array
(
$userid
,
$m
[
1
]));
}
delete_records
(
'usr_watchlist_artefact'
,
'usr'
,
$userid
,
'artefact'
,
$m
[
1
]);
$count
++
;
}
...
...
htdocs/account/watchlist/index.php
View file @
7712593a
...
...
@@ -40,6 +40,12 @@ $savesuccess = get_string('stopmonitoringsuccess', 'activity');
$getartefactsjson
=
get_config
(
'wwwroot'
)
.
'json/getartefacts.php'
;
$recursestr
=
'[<a href="" onClick="toggleChecked(\'tocheck-r\'); return false;">'
.
get_string
(
'recurseall'
,
'activity'
)
.
'</a>]'
;
$recursestrjs
=
str_replace
(
"'"
,
"\'"
,
$recursestr
);
$javascript
=
<<<JAVASCRIPT
var watchlist = new TableRenderer(
'watchlist',
...
...
@@ -53,6 +59,14 @@ var watchlist = new TableRenderer(
},
function (r, d) {
return TD(null, INPUT({'type' : 'checkbox', 'class': 'tocheck', 'name': 'stop' + d.type + '-' + r.id}));
},
function (r, d) {
if (d.type != 'communities') {
return TD(null, INPUT({'type' : 'checkbox', 'class': 'tocheck-r', 'name': 'stop' + d.type + '-' + r.id + '-recurse'}));
}
else {
return '';
}
}
]
);
...
...
@@ -70,8 +84,9 @@ function changeTitle(title) {
}
function stopmonitoring(form) {
var c = 'tocheck';
var e = getElementsByTagAndClassName(null,'tocheck',form);
var e1 = getElementsByTagAndClassName(null,'tocheck',form);
var e2 = getElementsByTagAndClassName(null,'tocheck-r',form);
var e = concat(e1, e2);
var pd = {};
for (cb in e) {
...
...
@@ -101,16 +116,27 @@ function stopmonitoring(form) {
)
}
function typeChange(element) {
watchlist.doupdate({'type': element.options[element.selectedIndex].value});
changeTitle(element.options[element.selectedIndex].value);
$('messagediv').innerHTML = '';
if (element.options[element.selectedIndex].value == 'communities') {
$('recurseheader').innerHTML = '';
}
else {
$('recurseheader').innerHTML = '{$recursestrjs}';
}
JAVASCRIPT;
}
$typechange
=
'watchlist.doupdate({\'type\':this.options[this.selectedIndex].value}); changeTitle(this.options[this.selectedIndex].value); $(\'messagediv\').innerHTML = \'\';'
;
JAVASCRIPT
;
$smarty
=
smarty
(
array
(
'tablerenderer'
));
$smarty
->
assign
(
'site_menu'
,
site_menu
());
$smarty
->
assign
(
'typechange'
,
$
type
c
hange
);
$smarty
->
assign
(
'typechange'
,
'
type
C
hange
(this);'
);
$smarty
->
assign
(
'typestr'
,
get_string
(
'views'
,
'activity'
));
$smarty
->
assign
(
'selectall'
,
'toggleChecked(\'tocheck\'); return false;'
);
$smarty
->
assign
(
'recursestr'
,
$recursestr
);
$smarty
->
assign
(
'stopmonitoring'
,
'stopmonitoring(this); return false;'
);
$smarty
->
assign
(
'INLINEJAVASCRIPT'
,
$javascript
);
$smarty
->
display
(
'account/watchlist/index.tpl'
);
...
...
htdocs/lang/en.utf8/activity.php
View file @
7712593a
...
...
@@ -46,6 +46,7 @@ $string['unread'] = 'Unread';
$string
[
'markasread'
]
=
'Mark as read'
;
$string
[
'selectall'
]
=
'Select all'
;
$string
[
'recurseall'
]
=
'Recurse all'
;
$string
[
'alltypes'
]
=
'All types'
;
$string
[
'markedasread'
]
=
'Marked your notifications as read'
;
...
...
htdocs/theme/default/templates/account/watchlist/index.tpl
View file @
7712593a
...
...
@@ -18,9 +18,9 @@
<table
id=
"watchlist"
>
<thead>
<tr>
<th></th>
<th></th>
<th>
[
<a
href=
""
onClick=
"
{
$selectall
}
"
>
{
str
section
=
'activity'
tag
=
'selectall'
}
</a>
]
</th>
<th
id=
"recurseheader"
>
{
$recursestr
}
</th>
</tr>
</thead>
<tbody>
...
...
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