Commit d5987ce2 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files
parents b87aef20 51e23b41
mahara (0.4.4-1) unstable; urgency=low
* Bugfix release
-- Martyn Smith <martyn@catalyst.net.nz> Fri, 26 Jan 2007 10:50:38 +1300
mahara (0.4.3-1) unstable; urgency=low
* Bugfix release
-- Martyn Smith <martyn@catalyst.net.nz> Thu, 25 Jan 2007 11:49:18 +1300
mahara (0.4.2-1) unstable; urgency=low
* Bugfix release
......
......@@ -33,27 +33,43 @@ json_headers();
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$action = param_variable('action', 'list');
$dbprefix = get_config('dbprefix');
$count = get_field('usr_group', 'COUNT(*)', 'owner', $USER->get('id'));
if ($action == 'delete') {
$id = param_integer('id');
// check owner
$owner = get_field('usr_group', 'owner', 'id', $id);
if ($owner != $USER->get('id')) {
json_reply('local', get_string('cantdeletegroupdontown'));
}
db_begin();
delete_records('usr_group_member', 'grp', $id);
delete_records('usr_group', 'id', $id);
db_commit();
$data = get_records_sql_array(
json_reply(null, get_string('deletegroupsuccessful'));
}
else {
$count = get_field('usr_group', 'COUNT(*)', 'owner', $USER->get('id'));
$data = get_records_sql_array(
'SELECT g.id, g.name, COUNT(m.*) AS count FROM ' . $dbprefix . 'usr_group g INNER JOIN ' . $dbprefix . 'usr_group_member m ON m.grp=g.id WHERE g.owner=? GROUP BY 1, 2 ORDER BY g.name',
array($USER->get('id')),
$offset,
$limit
);
);
if (!$data) {
if (!$data) {
$data = array();
}
}
print json_encode(array(
print json_encode(array(
'count' => $count,
'limit' => $limit,
'offset' => $offset,
'data' => $data,
));
));
}
?>
......@@ -30,6 +30,10 @@ define('SUBMENUITEM', 'mygroups');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('mygroups'));
$enc_edit = json_encode(get_string('edit'));
$enc_delete = json_encode(get_string('delete'));
$enc_confirmdelete = json_encode(get_string('confirmdeletegroup'));
$javascript = <<<JAVASCRIPT
var grouplist = new TableRenderer(
'grouplist',
......@@ -37,7 +41,37 @@ var grouplist = new TableRenderer(
[
'name',
'count',
function(r) { return TD(null,A({'href':'edit.php?id=' + r.id}, 'edit')); }
function(r) {
var deleteLink = BUTTON({'type':'button', 'class': 'button'}, {$enc_delete});
connect(deleteLink, 'onclick', function (e) {
e.stop();
if (!confirm({$enc_confirmdelete})) {
return;
}
sendjsonrequest(
'index.json.php',
{
'action': 'delete',
'id': r.id
},
function (data) {
grouplist.doupdate();
}
);
});
return TD(
null,
FORM(
{'action': 'edit.php?id=' + r.id, 'method': 'post'},
BUTTON({'type': 'submit', 'class': 'button'}, {$enc_edit}),
' ',
deleteLink
)
);
}
]
);
......
......@@ -15,6 +15,7 @@ if (typeof(dojo) != 'undefined') {
}
if (typeof(JSAN) != 'undefined') {
JSAN.use('MochiKit.Base', []);
JSAN.use('MochiKit.DOM', []);
}
try {
......
......@@ -266,6 +266,9 @@ $string['groupalreadyexists'] = 'A group by this name already exists';
$string['groupdescription'] = 'Group description';
$string['editgroup'] = 'Edit group';
$string['membercount'] = 'Member count';
$string['confirmdeletegroup'] = 'Are you sure you want to delete this group?';
$string['cantdeletegroupdontown'] = 'You can\'t delete this group, you don\'t own it';
$string['deletegroupsuccessful'] = 'Group successfully deleted';
// my account
$string['account'] = 'My account';
......
......@@ -1233,6 +1233,9 @@ function searchform() {
function get_loggedin_string() {
global $USER;
$str = get_string('youareloggedinas', 'mahara', display_name($USER));
safe_require('notification', 'internal');
$count = call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'));
if ($count == 1) {
......@@ -1241,11 +1244,14 @@ function get_loggedin_string() {
else {
$key = 'unreadmessages';
}
if ($count > 0) {
// these spans are here so that on the ajax page that marks messages as read, the contents can be updated.
$str = get_string('youareloggedinas', 'mahara', display_name($USER)) .
$str .=
' (<a href="' . get_config('wwwroot') . 'account/activity/">' .
'<span id="headerunreadmessagecount">' . $count . '</span> ' .
'<span id="headerunreadmessages">' . get_string($key) . '</span></a>)';
}
return $str;
}
......
Supports Markdown
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