Commit 7014538c authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Put forms for adding users to communities on view user page

parent 3ceceba2
......@@ -218,6 +218,8 @@ $string['viewsubmittedto'] = 'This view has been submitted to %s';
// view user
$string['fullname'] = 'Full name';
$string['studentid'] = 'ID number';
$string['inviteusertojoincommunity'] = 'Invite this user to join a community';
$string['addusertocommunity'] = 'Add this user to a community';
$string['emailname'] = 'Mahara System'; // robot!
......
......@@ -4,6 +4,9 @@
<div class="content">
{$INVITEFORM}
{$ADDFORM}
<h3>{$NAME}</h3>
<table><tbody>
{foreach from=$USERFIELDS key=key item=item}
......@@ -11,27 +14,23 @@
{/foreach}
</tbody></table>
{foreach from=$PROFILE key=key item=item name=profile}
{if $smarty.foreach.profile.first}
{if $PROFILE}
<h4>{str section=artefact.internal tag=profile}</h4>
<table><tbody>
{/if}
{foreach from=$PROFILE key=key item=item name=profile}
<tr><td>{str section=artefact.internal tag=$key}</td><td>{$item}</td></tr>
{if $smarty.foreach.profile.last}
{/foreach}
</tbody></table>
{/if}
{/foreach}
{foreach from=$VIEWS key=key item=item name=view}
{if $smarty.foreach.view.first}
{if $VIEWS}
<h4>{str section=mahara tag=views}</h4>
<ul>
{/if}
{foreach from=$VIEWS key=key item=item name=view}
<li><a href="{$WWWROOT}view/view.php?id={$key}">{$item}</a></li>
{if $smarty.foreach.view.last}
{/foreach}
</ul>
{/if}
{/foreach}
</div>
......
......@@ -27,8 +27,11 @@
define('INTERNAL', 1);
require(dirname(dirname(__FILE__)).'/init.php');
$loggedinid = $USER->get('id');
$userid = param_integer('id','');
// Get the user's details
$profile = array();
$userfields = array();
if (!$user = get_record('usr', 'id', $userid)) {
......@@ -77,8 +80,85 @@ else {
}
}
// Get the logged in user's "invite only" communities
$communities = get_records_select_array('community',
'owner = ' . $loggedinid . "AND jointype = 'invite'",
null, 'name', 'id,name');
if ($communities) {
$invitelist = array();
foreach ($communities as $community) {
$invitelist[$community->id] = $community->name;
}
}
// Get the "controlled membership" communities in which the logged in user is a tutor
$prefix = get_config('dbprefix');
$communities = get_records_sql_array('SELECT c.id, c.name
FROM ' . $prefix . 'community c
JOIN ' . $prefix . 'community_member cm ON c.id = cm.community
WHERE cm.member = ' . $loggedinid . " AND cm.tutor = 1 AND c.jointype = 'controlled'",'');
if ($communities) {
$controlledlist = array();
foreach ($communities as $community) {
$controlledlist[$community->id] = $community->name;
}
}
log_debug($invitelist);
log_debug($controlledlist);
if ($invitelist || $controlledlist) {
require_once('pieforms/pieform.php');
}
if ($invitelist) {
$inviteform = pieform(array(
'name' => 'invite',
'ajaxpost' => true,
'elements' => array(
'community' => array(
'type' => 'select',
'title' => get_string('inviteusertojoincommunity'),
'collapseifoneoption' => false,
'options' => $invitelist
),
'submit' => array(
'type' => 'submit',
'value' => get_string('sendinvitation'),
),
),
));
}
if ($controlledlist) {
$addform = pieform(array(
'name' => 'add',
'ajaxpost' => true,
'elements' => array(
'community' => array(
'type' => 'select',
'title' => get_string('addusertocommunity'),
'collapseifoneoption' => false,
'options' => $controlledlist
),
'submit' => array(
'type' => 'submit',
'value' => get_string('add'),
),
),
));
}
$smarty = smarty();
$smarty->assign('searchform',searchform());
if (isset($inviteform)) {
$smarty->assign('INVITEFORM',$inviteform);
}
if (isset($addform)) {
$smarty->assign('ADDFORM',$addform);
}
$smarty->assign('NAME',$name);
$smarty->assign('USERFIELDS',$userfields);
$smarty->assign('PROFILE',$profile);
......
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