Commit c13f42e1 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Added an element for the create view ACL. Not complete yet.

parent cb131ac1
* This program is part of Mahara
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* @package mahara
* @subpackage form
* @author Nigel McNie <>
* @license GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd
* Provides an element to manage a view ACL
* @param array $element The element to render
* @param Pieform $form The form to render the element for
* @return string The HTML for the element
function pieform_render_viewacl($element, Pieform $form) {
// @todo addressbook stuff...
$smarty = smarty();
$smarty->left_delimiter = '{{';
$smarty->right_delimiter = '}}';
$value = $form->get_value($element);
// Look for the presets and split them into two groups
$presets = array('public', 'any', 'friends');
if ($value) {
foreach ($value as &$item) {
if (in_array($item['type'], $presets)) {
$item['name'] = get_string($item['type']);
$item['preset'] = true;
else {
$item['name'] = pieform_render_viewacl_getvaluebytype($item['type'], $item['id']);
$potentialpresets = $presets;
foreach ($potentialpresets as &$preset) {
$preset = array(
'type' => $preset,
'id' => $preset,
'start' => null,
'end' => null,
'name' => get_string($preset),
'preset' => true
$smarty->assign('potentialpresets', json_encode($potentialpresets));
$smarty->assign('accesslist', json_encode($value));
return $smarty->fetch('form/viewacl.tpl');
function pieform_render_viewacl_getvaluebytype($type, $id) {
switch ($type) {
case 'user':
$user = get_record('usr', 'id', $id);
return display_name($user);
case 'group':
return get_field('group', 'name', 'id', $id);
return "$type: $id";
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