Commit bd0dff6d authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files
parents dd3bd845 89fdc919
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
......
......@@ -152,6 +152,7 @@ function profileform_submit(Pieform $form, $values) {
try {
email_user(
(object)array(
'username' => $USER->get('username'),
'firstname' => $USER->get('firstname'),
'lastname' => $USER->get('lastname'),
'preferredname' => $USER->get('preferredname'),
......
......@@ -641,7 +641,7 @@ function auth_handle_account_expiries() {
$wwwroot = get_config('wwwroot');
// Expiry warning messages
if ($users = get_records_sql_array('SELECT u.id, u.firstname, u.lastname, u.preferredname, u.email, i.defaultaccountinactivewarn AS timeout
if ($users = get_records_sql_array('SELECT u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, i.defaultaccountinactivewarn AS timeout
FROM ' . $prefix . 'usr u, ' . $prefix . 'institution i
WHERE u.institution = i.name
AND ? - ' . db_format_tsfield('u.expiry', false) . ' < i.defaultaccountinactivewarn
......@@ -670,7 +670,7 @@ function auth_handle_account_expiries() {
}
// Inactivity (lastlogin is too old)
if ($users = get_records_sql_array('SELECT u.id, u.firstname, u.lastname, u.preferredname, u.email, i.defaultaccountinactivewarn AS timeout
if ($users = get_records_sql_array('SELECT u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, i.defaultaccountinactivewarn AS timeout
FROM ' . $prefix . 'usr u, ' . $prefix . 'institution i
WHERE u.institution = i.name
AND (? - ' . db_format_tsfield('u.lastlogin', false) . ') > (i.defaultaccountinactiveexpire - i.defaultaccountinactivewarn)
......
......@@ -79,7 +79,7 @@ switch ($type) {
);
$data = get_records_sql_array('
SELECT v.*,u.firstname,u.lastname, u.preferredname,u.id AS usr
SELECT v.*, u.username, u.firstname, u.lastname, u.preferredname, u.id AS usr
FROM ' . $prefix . 'view v
LEFT OUTER JOIN ' . $prefix . 'view_access_community a ON a.view=v.id
INNER JOIN ' . $prefix.'usr u ON v.owner = u.id ' . $where,
......@@ -97,7 +97,7 @@ switch ($type) {
}
break;
case 'members':
$sql = 'SELECT u.*,c.tutor
$sql = 'SELECT u.*, c.tutor
FROM ' . $prefix . 'usr u JOIN ' . $prefix . 'community_member c
ON c.member = u.id
WHERE c.community = ?';
......
......@@ -40,13 +40,15 @@ if (!$community = get_record('community', 'id', $id)) {
$community->ownername = display_name(get_record('usr', 'id', $community->owner));
$membership = user_can_access_community($id);
// $membership is a bit string summing all membership types
$ismember = (bool) ($membership & COMMUNITY_MEMBERSHIP_MEMBER);
if (!empty($joincontrol)) {
// leave, join, acceptinvite, request
switch ($joincontrol) {
case 'leave':
// make sure they're a member and can leave
if ($membership == COMMUNITY_MEMBERSHIP_MEMBER && $community->jointype != 'controlled') {
if ($ismember && $community->jointype != 'controlled') {
community_remove_member($id, $USER->get('id'));
$SESSION->add_ok_msg(get_string('leftcommunity'));
}
......@@ -55,7 +57,7 @@ if (!empty($joincontrol)) {
}
break;
case 'join':
if (empty($membership) && $community->jointype == 'open') {
if (!$ismember && $community->jointype == 'open') {
community_add_member($id, $USER->get('id'));
$SESSION->add_ok_msg(get_string('joinedcommunity'));
}
......@@ -80,7 +82,7 @@ if (!empty($joincontrol)) {
$SESSION->add_ok_msg($message);
break;
case 'request':
if (empty($membership) && $community->jointype == 'request'
if (!$ismember && $community->jointype == 'request'
&& !record_exists('community_member_request', 'community', $id, 'member', $USER->get('id'))) {
$cmr = new StdClass;
$cmr->reason = param_variable('reason', null);
......@@ -135,14 +137,14 @@ $removefromwatchliststr = get_string('removefromwatchlist', 'activity');
$addtowatchliststr = get_string('addtowatchlist', 'activity');
// all the permissions stuff
$tutor = (int)($membership < COMMUNITY_MEMBERSHIP_MEMBER);
$tutor = (int)($membership && ($membership < COMMUNITY_MEMBERSHIP_MEMBER));
$controlled = (int)($community->jointype == 'controlled');
$admin = (int)($membership == COMMUNITY_MEMBERSHIP_ADMIN);
$admin = (int)($membership & COMMUNITY_MEMBERSHIP_ADMIN != 0);
$canremove = (int)(($tutor && $controlled) || $admin);
$canpromote = (int)$tutor;
$canleave = ($membership == COMMUNITY_MEMBERSHIP_MEMBER && $community->jointype != 'controlled');
$canrequestjoin = (empty($membership) && empty($invited) && empty($requested) && $community->jointype == 'request');
$canjoin = (empty($membership) && $community->jointype == 'open');
$canleave = ($ismember && $community->jointype != 'controlled');
$canrequestjoin = (!$ismember && empty($invited) && empty($requested) && $community->jointype == 'request');
$canjoin = (!$ismember && $community->jointype == 'open');
$javascript = '';
if ($membership) {
......
......@@ -61,7 +61,7 @@ if ($control) {
// normal processing (getting friends list)
if (empty($pending)) {
$count = count_records_select('usr_friend', 'usr1 = ? OR usr2 = ?', array($userid, $userid));
$sql = 'SELECT u.id,u.firstname,u.lastname,u.preferredname
$sql = 'SELECT u.id,u.username,u.firstname,u.lastname,u.preferredname
FROM ' . $prefix . 'usr u
WHERE u.id IN (
SELECT (CASE WHEN usr1 = ? THEN usr2 ELSE usr1 END) AS userid
......
......@@ -200,9 +200,9 @@ function get_tutor_communities($userid=0, $jointype=null) {
// constants for community membership type
define('COMMUNITY_MEMBERSHIP_ADMIN', 1);
define('COMMUNITY_MEMBERSHIP_STAFF', 2);
define('COMMUNITY_MEMBERSHIP_OWNER', 3);
define('COMMUNITY_MEMBERSHIP_TUTOR', 4);
define('COMMUNITY_MEMBERSHIP_MEMBER', 5);
define('COMMUNITY_MEMBERSHIP_OWNER', 4);
define('COMMUNITY_MEMBERSHIP_TUTOR', 8);
define('COMMUNITY_MEMBERSHIP_MEMBER', 16);
/**
......@@ -238,25 +238,27 @@ function user_can_access_community($community, $user=null) {
throw new InvalidArgumentException("not useful community arg given to user_can_access_community: $community");
}
$membertypes = 0;
if ($user->get('admin')) {
return COMMUNITY_MEMBERSHIP_ADMIN;
$membertypes = COMMUNITY_MEMBERSHIP_ADMIN;
}
if ($user->get('staff')) {
return COMMUNITY_MEMBERSHIP_STAFF;
$membertypes = $membertypes | COMMUNITY_MEMBERSHIP_STAFF;
}
if ($community->owner == $user->get('id')) {
return COMMUNITY_MEMBERSHIP_OWNER;
$membertypes = $membertypes | COMMUNITY_MEMBERSHIP_OWNER;
}
if (!$membership = get_record('community_member', 'community', $community->id, 'member', $user->get('id'))) {
return false;
return $membertypes;
}
if ($membership->tutor) {
return COMMUNITY_MEMBERSHIP_TUTOR;
$membertypes = $membertypes | COMMUNITY_MEMBERSHIP_TUTOR;
}
return COMMUNITY_MEMBERSHIP_MEMBER;
return ($membertypes | COMMUNITY_MEMBERSHIP_MEMBER);
}
......
......@@ -54,7 +54,7 @@ class PluginNotificationEmaildigest extends PluginNotification {
$users = array();
$sitename = get_config('sitename');
$sql = 'SELECT q.id, u.firstname,u.lastname,u.preferredname,u.email,q.*,' . db_format_tsfield('ctime').'
$sql = 'SELECT q.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, q.*,' . db_format_tsfield('ctime').'
FROM ' . get_config('dbprefix') . 'usr u
JOIN ' . get_config('dbprefix') . 'notification_emaildigest_queue q
ON q.usr = u.id
......
......@@ -15,9 +15,13 @@
return;
}
var members = new Array();
var members = {};
var counter = 0;
forEach($('{{$name}}_members').childNodes, function(node) {
members[node.value] = 1;
if (node.nodeName == 'OPTION') {
members[node.value] = 1;
counter++;
}
});
replaceChildNodes('{{$name}}_potential');
......@@ -29,7 +33,14 @@
});
if(users.count > users.limit) {
replaceChildNodes('{{$name}}_messages', DIV(null, 'Only showing first ' + users.limit + ' results of ' + users.count));
replaceChildNodes('{{$name}}_messages',
DIV(null,
'Only showing first ',
SPAN({'id': '{{$name}}_userlimit'}, users.limit),
' results of ',
SPAN({'id': '{{$name}}_usercount'}, users.count - counter)
)
);
}
},
function (err) {
......@@ -70,6 +81,18 @@
node.selected = false;
});
// Update the counters if they are present
if ($('{{$name}}_userlimit')) {
if (from.id == '{{$name}}_potential') {
replaceChildNodes('{{$name}}_userlimit', parseInt($('{{$name}}_userlimit').innerHTML) - list.length);
replaceChildNodes('{{$name}}_usercount', parseInt($('{{$name}}_usercount').innerHTML) - list.length);
}
else {
replaceChildNodes('{{$name}}_userlimit', parseInt($('{{$name}}_userlimit').innerHTML) + list.length);
replaceChildNodes('{{$name}}_usercount', parseInt($('{{$name}}_usercount').innerHTML) + list.length);
}
}
var members = new Array();
forEach($('{{$name}}_members').childNodes, function(node) {
if (typeof(node) == 'object' && typeof(node.value) == 'string') {
......
......@@ -73,7 +73,7 @@ function title(r, communities) {
var assess = assessselect(r.id,communities);
}
var f = FORM({'id':('form'+r.id),'method':'post','enctype':'multipart/form-data',
'encoding':'multipart/form-data','onclick':"formsubmit(" + r.id + ");"},
'encoding':'multipart/form-data'},
DIV(null,buttons),
DIV(null,assess));
return [TD(null,A({'href':'view.php?view='+r.id},r.title)),
......
......@@ -169,7 +169,7 @@ function feedbackform() {
}
}
appendChildNodes(form,
TABLE(null,
TABLE({'border':0, 'cellspacing':0, 'id':'feedback'},
TBODY(null,
TR(null, TH(null, LABEL(null, {$getstring['message']}))),
TR(null, TD(null, TEXTAREA({'rows':5, 'cols':80, 'name':'message'}))),
......@@ -200,7 +200,7 @@ function objectionform() {
return false;
}
appendChildNodes(form,
TABLE({'border':0, 'cellspacing':0},
TABLE({'border':0, 'cellspacing':0, 'id':'objection'},
TBODY(null,
TR(null, TH(null, LABEL(null, {$getstring['complaint']}))),
TR(null, TD(null, TEXTAREA({'rows':5, 'cols':80, 'name':'message'}))),
......
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