Commit 56ff83d9 authored by Penny Leach's avatar Penny Leach
Browse files

more work on communitie view page (release views)

parent 9fbb52b6
......@@ -53,14 +53,20 @@ switch ($type) {
AND ( v.stopdate IS NULL OR v.stopdate < ? )
AND ( a.startdate IS NULL OR a.startdate < ? )
AND ( a.stopdate IS NULL OR a.stopdate < ? )';
$values = array($id, $dbnow, $dbnow, $dbnow, $dbnow);
if ($submitted) {
$where .= ' AND v.submittedto = ?';
$values[] = $id;
}
$count = count_records_sql('SELECT COUNT(v.id) FROM ' . $prefix . 'view_access_community a
JOIN ' . $prefix . 'view v ON a.view = v.id ' . $where,
array($id, $dbnow, $dbnow, $dbnow, $dbnow));
JOIN ' . $prefix . 'view v ON a.view = v.id ' . $where, $values);
$data = get_records_sql_array('SELECT v.*,u.firstname,u.lastname, u.preferredname,u.id AS usr
FROM ' . $prefix . 'view_access_community a JOIN ' . $prefix . 'view v ON a.view = v.id
FROM ' . $prefix . 'view_access_community a
JOIN ' . $prefix . 'view v ON a.view = v.id
JOIN ' . $prefix.'usr u ON v.owner = u.id ' . $where,
array($id, $dbnow, $dbnow, $dbnow, $dbnow),
$offset, $limit);
$values, $offset, $limit);
if (empty($data)) {
$data = array();
}
......@@ -94,7 +100,7 @@ switch ($type) {
$d->displayname = display_name($d);
}
break;
case 'control':
case 'membercontrol':
foreach ($_REQUEST as $k => $v) {
if (preg_match('/member-(\d+)/', $k, $m)) {
$user = $m[1];
......@@ -135,6 +141,13 @@ switch ($type) {
}
json_reply(false, get_string('memberchangesuccess'));
break;
case 'release':
$view = param_integer('view');
require_once(get_config('libroot') . 'view.php');
$view = new View($view);
$view->release($id);
json_reply(false, get_string('viewreleasedsuccess'));
break;
}
if (!$data) {
......
......@@ -51,6 +51,7 @@ $releaseviewstr = get_string('releaseview');
$tutorstr = get_string('tutor');
$memberstr = get_string('member');
$removestr = get_string('remove');
$updatefailedstr = get_string('updatefailed');
$tutor = ($membership < COMMUNITY_MEMBERSHIP_MEMBER);
$controlled = ($community->jointype == 'controlled');
......@@ -71,7 +72,7 @@ viewlist = new TableRenderer(
},
function (r,d) {
if (r.submittedto && {$tutor}) {
return TD(null, A({'href': '', 'onclick': 'releaseView(' + r.id + ');'}, '{$releaseviewstr}'));
return TD(null, A({'href': '', 'onclick': 'return releaseView(' + r.id + ');'}, '{$releaseviewstr}'));
}
return TD(null);
}
......@@ -139,25 +140,32 @@ function memberControl(id, type) {
}
function releaseView(id) {
var pd = {'type': 'release', 'id': '{$community->id}', 'view': id};
var d = loadJSONDoc('view.json.php', pd);
d.addCallbacks(function (data) {
$('messagediv').innerHTML = data.message;
viewlist.doupdate();
},
function () {
$('messagediv').innerHTML = '{$updatefailedstr}';
});
return false;
}
function updateMembership() {
var pd = {'type': 'control', 'id': '{$community->id}'};
var pd = {'type': 'membercontrol', 'id': '{$community->id}'};
var e = getElementsByTagAndClassName(null, 'member');
for (s in e) {
pd[e[s].name] = e[s].options[e[s].selectedIndex].value;
}
debugObject(pd);
var d = loadJSONDoc('view.json.php', pd);
d.addCallbacks(function (data) {
$('messagediv').innerHTML = data.message;
memberlist.doupdate();
},
function () {
$('messagediv').innerHTML = data.message;
}
)
function () {
$('messagediv').innerHTML = '{$updatefailedstr}';
});
}
EOF;
......
......@@ -51,6 +51,7 @@ $string['accept'] = 'Accept';
$string['reject'] = 'Reject';
$string['mainmenu'] = 'Main menu';
$string['updatefailed'] = 'Update failed';
// auth
$string['accessforbiddentoadminsection'] = 'You are forbidden from accessing the administration section';
......@@ -363,6 +364,9 @@ $string['remove'] = 'Remove';
$string['updatemembership'] = 'Update membership';
$string['memberchangefailed'] = 'Failed to update some membership information';
$string['memberchangesuccess'] = 'Membership status changed successfully';
$string['viewreleasedsubject'] = 'Your view has been released';
$string['viewreleasedmessage'] = 'The view that you submitted to community %s has been released back to you by %s';
$string['viewreleasedsuccess'] = 'View was released successfully';
// friendslist
$string['reasonoptional'] = 'Reason (optional)';
......
......@@ -15,6 +15,7 @@
{elseif $canrequestjoin} <p><a href="" onClick="return memberControl({$community->id}, 'request');">{str tag='requestjoincommunity'}</a></p>
{elseif $canjoin} <p><a href="" onClick="return memberControl({$community->id}, 'join');">{str tag='joincommunity'}</a></p>
{elseif $canacceptinvite} <p><a href="" onClick="return memberControl({$community->id}, 'invite');">{str tag='invitedjoincommunity'}</a></p>{/if}
<div id="messagediv"></div>
{if $member}
<div class="communityviews">
<h5>{str tag='views'}</h5>
......@@ -57,7 +58,6 @@
</tbody>
</table>
<input type="button" value="{str tag='updatemembership'}" onClick="return updateMembership();" />
<div id="messagediv"></div>
</div>
{/if}
</div>
......
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