Commit 5b07a0c6 authored by Penny Leach's avatar Penny Leach
Browse files

more work on watchlist

parent bc9a36a2
...@@ -75,11 +75,12 @@ $prefix = get_config('dbprefix'); ...@@ -75,11 +75,12 @@ $prefix = get_config('dbprefix');
if ($type == 'views') { if ($type == 'views') {
$count = count_records('usr_watchlist_view', 'usr', $userid); $count = count_records('usr_watchlist_view', 'usr', $userid);
$sql = 'SELECT v.* $sql = 'SELECT v.*, v.title AS name
FROM ' . $prefix . 'view v FROM ' . $prefix . 'view v
JOIN ' . $prefix . 'usr_watchlist_view w ON w.view = v.id JOIN ' . $prefix . 'usr_watchlist_view w ON w.view = v.id
WHERE w.usr = ?'; WHERE w.usr = ?
if ($records = get_rows_sql($sql, array($userid), 'v.mtime DESC', '*', $offset, $limit)) { ORDER BY v.mtime DESC';
if ($records = get_rows_sql($sql, array($userid), $offset, $limit)) {
foreach ($records as &$r) { foreach ($records as &$r) {
// @todo session expandey stuff // @todo session expandey stuff
} }
...@@ -90,23 +91,23 @@ else if ($type == 'communities') { ...@@ -90,23 +91,23 @@ else if ($type == 'communities') {
$sql = 'SELECT c.* $sql = 'SELECT c.*
FROM ' . $prefix . 'community c FROM ' . $prefix . 'community c
JOIN ' . $prefix . 'usr_watchlist_community w ON w.community = c.id JOIN ' . $prefix . 'usr_watchlist_community w ON w.community = c.id
WHERE w.usr = ?'; WHERE w.usr = ?
$records = get_rows_sql($sql, array($userid), 'c.mtime DESC', '*', $offset, $limit); ORDER BY c.mtime DESC';
$records = get_rows_sql($sql, array($userid), $offset, $limit);
} }
if (empty($records)) { if (empty($records)) {
$records = array(); $records = array();
} }
$activity = array( $activity = array(
'count' => $count, 'count' => $count,
'offset' => $offset, 'offset' => $offset,
'limit' => $limit, 'limit' => $limit,
'data' => $records, 'data' => $records,
'type' => $type, 'type' => $type,
'minusicon' => theme_get_image_path('minus.gif'), 'minusicon' => theme_get_image_path('minus.png'),
'plusicon' => theme_get_image_path('plus.gif'), 'plusicon' => theme_get_image_path('plus.png'),
'minusalt' => get_string('collapse'), 'minusalt' => get_string('collapse'),
'plusalt' => get_string('expand'), 'plusalt' => get_string('expand'),
); );
......
...@@ -44,12 +44,12 @@ var watchlist = new TableRenderer( ...@@ -44,12 +44,12 @@ var watchlist = new TableRenderer(
return TD(null, ''); return TD(null, '');
} }
if (r.expanded) { if (r.expanded) {
return TD(null, A({'href': '', 'onClick' : 'collapse(' + r.id | ')'}), return TD(null, A({'href': '', 'onclick': 'collapse(' + r.id + '); return false;'},
IMG({'src' : d.minusicon, 'alt' : d.minusalt})); IMG({'src' : d.minusicon, 'alt' : d.minusalt, 'border': 0})));
} }
else { else {
return TD(null, A({'href': '', 'onClick' : 'collapse(' + r.id | ')'}), return TD(null, A({'href': '', 'onclick': 'expand(' + r.id + '); return false;'},
IMG({'src' : d.plusicon, 'alt' : d.plusalt})); IMG({'src' : d.plusicon, 'alt' : d.plusalt, 'border': 0})));
} }
}, },
function(r) { function(r) {
...@@ -59,7 +59,7 @@ var watchlist = new TableRenderer( ...@@ -59,7 +59,7 @@ var watchlist = new TableRenderer(
return TD(null,r.name); return TD(null,r.name);
}, },
function (r) { function (r) {
return TD(null, INPUT({'type' : 'checkbox', 'class' : 'viewcheck', 'name' : 'view-' + r.id})); return TD(null, INPUT({'type' : 'checkbox', 'class': 'tocheck', 'name': 'view-' + r.id}));
} }
] ]
); );
...@@ -73,6 +73,14 @@ function changeTitle(title) { ...@@ -73,6 +73,14 @@ function changeTitle(title) {
$('typeheader').innerHTML = '{$monitoredstring} ' + titles[title]; $('typeheader').innerHTML = '{$monitoredstring} ' + titles[title];
} }
function collapse(id) {
}
function expand(id) {
}
JAVASCRIPT; JAVASCRIPT;
$typechange = 'watchlist.doupdate({\'type\':this.options[this.selectedIndex].value}); changeTitle(this.options[this.selectedIndex].value);'; $typechange = 'watchlist.doupdate({\'type\':this.options[this.selectedIndex].value}); changeTitle(this.options[this.selectedIndex].value);';
...@@ -81,6 +89,7 @@ $smarty = smarty(array('tablerenderer')); ...@@ -81,6 +89,7 @@ $smarty = smarty(array('tablerenderer'));
$smarty->assign('site_menu', site_menu()); $smarty->assign('site_menu', site_menu());
$smarty->assign('typechange', $typechange); $smarty->assign('typechange', $typechange);
$smarty->assign('typestr', get_string('viewsandartefacts', 'activity')); $smarty->assign('typestr', get_string('viewsandartefacts', 'activity'));
$smarty->assign('selectall', 'toggleChecked(\'tocheck\'); return false;');
$smarty->assign('INLINEJAVASCRIPT', $javascript); $smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->display('account/watchlist/index.tpl'); $smarty->display('account/watchlist/index.tpl');
......
...@@ -55,5 +55,6 @@ $string['stopmonitoring'] = 'Stop monitoring'; ...@@ -55,5 +55,6 @@ $string['stopmonitoring'] = 'Stop monitoring';
$string['viewsandartefacts'] = 'Views and artefacts'; $string['viewsandartefacts'] = 'Views and artefacts';
$string['communities'] = 'Communities'; $string['communities'] = 'Communities';
$string['monitored'] = 'Monitored'; $string['monitored'] = 'Monitored';
$string['stopmonitoring'] = 'Stop monitoring';
?> ?>
...@@ -214,6 +214,8 @@ $string['height'] = 'Height'; ...@@ -214,6 +214,8 @@ $string['height'] = 'Height';
$string['widthshort'] = 'w'; $string['widthshort'] = 'w';
$string['heightshort'] = 'h'; $string['heightshort'] = 'h';
$string['filter'] = 'Filter'; $string['filter'] = 'Filter';
$string['expand'] = 'Expand';
$string['collapse'] = 'Collapse';
$string['nohelpfound'] = 'There was no help found for this item'; $string['nohelpfound'] = 'There was no help found for this item';
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<option value="communities">{str section='activity' tag='communities'}</option> <option value="communities">{str section='activity' tag='communities'}</option>
</select> </select>
</form> </form>
<div id="typeheader">{str section='activity' tag='monitored'} {$typestr}</div> <p><b><div id="typeheader">{str section='activity' tag='monitored'} {$typestr}</div></b></p>
<form method="post" onSubmit="{$stopmonitoring}"> <form method="post" onSubmit="{$stopmonitoring}">
<table id="watchlist"> <table id="watchlist">
<thead> <thead>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<tfoot> <tfoot>
<tr> <tr>
<td align="right" colspan="4"><div id="messagediv"></div></td> <td align="right" colspan="4"><div id="messagediv"></div></td>
<td align="right"><input type="submit" value="{str tag='update'}" /></td> <td align="right"><input type="submit" value="{str tag='stopmonitoring' section='activity'}" /></td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment