Commit 017ab75b authored by Nigel McNie's avatar Nigel McNie
Browse files

Revert "Removed groups from the system. Database patches to come."

Wrong branch...

This reverts commit 21fedcd0.
parent bf8b38bf
<?php
/**
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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 core
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'mycontacts');
define('SUBMENUITEM', 'mygroups');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
define('TITLE', get_string('creategroup'));
$creategroup = pieform(array(
'name' => 'creategroup',
'method' => 'post',
'plugintype' => 'core',
'pluginname' => 'groups',
'elements' => array(
'name' => array(
'type' => 'text',
'title' => get_string('groupname'),
'rules' => array( 'required' => true ),
'help' => true,
),
'description' => array(
'type' => 'wysiwyg',
'title' => get_string('groupdescription'),
'rows' => 10,
'cols' => 70,
'help' => true,
),
'members' => array(
'type' => 'userlist',
'title' => get_string('groupmembers'),
'rules' => array( 'required' => true ),
'filter' => false,
'help' => true,
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('creategroup'), get_string('cancel')),
),
),
));
function creategroup_validate(Pieform $form, $values) {
global $USER;
$gid = get_field('usr_group', 'id', 'owner', $USER->get('id'), 'name', $values['name']);
if($gid) {
$form->set_error('name', get_string('groupalreadyexists'));
}
}
function creategroup_cancel_submit() {
redirect('/contacts/groups/');
}
function creategroup_submit(Pieform $form, $values) {
global $USER;
global $SESSION;
db_begin();
$now = db_format_timestamp(time());
$gid = insert_record(
'usr_group',
(object) array(
'name' => $values['name'],
'owner' => $USER->get('id'),
'description' => $values['description'],
'ctime' => $now,
'mtime' => $now,
),
'id',
true
);
foreach ($values['members'] as $member) {
insert_record(
'usr_group_member',
(object) array(
'grp' => $gid,
'member'=> $member,
'ctime' => $now,
)
);
}
$SESSION->add_ok_msg(get_string('groupcreated'));
db_commit();
redirect('/contacts/groups/');
}
$smarty = smarty();
$smarty->assign('creategroup', $creategroup);
$smarty->display('contacts/groups/create.tpl');
?>
<?php
/**
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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 core
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'mycontacts');
define('SUBMENUITEM', 'mygroups');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
define('TITLE', get_string('editgroup'));
$id = param_integer('id',null);
$group_data = get_record('usr_group', 'id', $id, 'owner', $USER->get('id'));
if (!$group_data) {
$SESSION->add_error_msg(get_string('canteditdontown'));
redirect('/contacts/groups/');
}
$group_members = get_column('usr_group_member', 'member', 'grp', $group_data->id);
$editgroup = pieform(array(
'name' => 'editgroup',
'method' => 'post',
'plugintype' => 'core',
'pluginname' => 'groups',
'elements' => array(
'name' => array(
'type' => 'text',
'title' => get_string('groupname'),
'rules' => array( 'required' => true ),
'defaultvalue' => $group_data->name,
'help' => true,
),
'description' => array(
'type' => 'wysiwyg',
'title' => get_string('groupdescription'),
'rows' => 10,
'cols' => 70,
'defaultvalue' => $group_data->description,
'help' => true,
),
'members' => array(
'type' => 'userlist',
'title' => get_string('groupmembers'),
'rules' => array( 'required' => true ),
'defaultvalue' => $group_members,
'help' => true,
'filter' => false,
),
'id' => array(
'type' => 'hidden',
'value' => $id,
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('savegroup'), get_string('cancel')),
),
),
));
function editgroup_validate(Pieform $form, $values) {
global $USER;
global $SESSION;
$gid = get_field('usr_group', 'id', 'owner', $USER->get('id'), 'name', $values['name']);
if ($gid && $gid != $values['id']) {
$form->set_error('name', get_string('groupalreadyexists'));
}
// check owner
$id = get_field('usr_group', 'id', 'id', $values['id'], 'owner', $USER->get('id'));
if (!$id) {
$SESSION->add_error_msg(get_string('canteditdontown'));
redirect('/contacts/groups/');
}
}
function editgroup_cancel_submit() {
redirect('/contacts/groups/');
}
function editgroup_submit(Pieform $form, $values) {
global $USER;
global $SESSION;
db_begin();
$now = db_format_timestamp(time());
update_record(
'usr_group',
(object) array(
'id' => $values['id'],
'name' => $values['name'],
'owner' => $USER->get('id'),
'description' => $values['description'],
'mtime' => $now,
),
'id'
);
delete_records('usr_group_member', 'grp', $values['id']);
foreach ($values['members'] as $member) {
insert_record(
'usr_group_member',
(object) array(
'grp' => $values['id'],
'member'=> $member,
'ctime' => $now,
)
);
}
$SESSION->add_ok_msg(get_string('groupsaved'));
db_commit();
redirect('/contacts/groups/');
}
$smarty = smarty();
$smarty->assign('editgroup', $editgroup);
$smarty->display('contacts/groups/edit.tpl');
?>
<?php
/**
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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 core
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
json_headers();
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$action = param_variable('action', 'list');
$dbprefix = get_config('dbprefix');
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('view_access_group', 'grp', $id);
delete_records('usr_group_member', 'grp', $id);
delete_records('usr_group', 'id', $id);
db_commit();
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.grp) AS count, (SELECT COUNT(*) FROM ' . $dbprefix . 'view_access_group vag WHERE vag.grp=g.id) 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) {
$data = array();
}
print json_encode(array(
'count' => $count,
'limit' => $limit,
'offset' => $offset,
'data' => $data,
));
}
?>
<?php
/**
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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 core
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'mycontacts');
define('SUBMENUITEM', 'mygroups');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'contacts');
define('SECTION_PAGE', 'groups');
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'));
$enc_confirmdelete_hasviews = json_encode(get_string('confirmdeletegrouphasviews'));
$javascript = <<<JAVASCRIPT
var grouplist = new TableRenderer(
'grouplist',
'index.json.php',
[
'name',
'count',
function(r) {
var editLink = BUTTON({'type': 'button', 'class': 'button'}, {$enc_edit});
connect(editLink, 'onclick', function (e) {
e.stop();
window.location.href = 'edit.php?id=' + r.id;
});
var deleteLink = BUTTON({'type':'button', 'class': 'button'}, {$enc_delete});
connect(deleteLink, 'onclick', function (e) {
e.stop();
var message = (r.hasviews > 0) ?
{$enc_confirmdelete_hasviews} :
{$enc_confirmdelete};
if (!confirm(message)) {
return;
}
sendjsonrequest(
'index.json.php',
{
'action': 'delete',
'id': r.id
},
'POST',
function (data) {
grouplist.doupdate();
}
);
});
return TD(
null,
editLink,
' ',
deleteLink
)
}
]
);
grouplist.updateOnLoad();
JAVASCRIPT;
$smarty = smarty(array('tablerenderer'));
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->display('contacts/groups/index.tpl');
?>
......@@ -28,6 +28,9 @@ addLoadEvent(function() {
case 'f':
document.location.href = config.wwwroot + 'artefact/file/';
break;
case 'g':
document.location.href = config.wwwroot + 'contacts/groups/';
break;
case 'c':
document.location.href = config.wwwroot + 'contacts/communities/';
break;
......
<h3>Description</h3>
<p>You may choose to write a Description of your Group for your reference. Members of the Group will not see this Description.</p>
<h3>Group members</h3>
<p>Select potential Group members from the list on the left and using the arrow buttons add them to the Group box on the right. You can also Search for specific users. </p>
<p>Members of a Group do not see the name or details of any other member and are no aware that they have been assigned to a Group within your portfolio.</p>
<h3>Name</h3>
<p>Enter the Name you would like use to identify this Group. Each of your Groups must have a unique name. </p>
<h3>Access Start Date/Time</h3>
<p>You can chose the date and time you want your View to become accessible to those Communities and Individuals you select in View Creation Step 4.</p>
<p>You can chose the date and time you want your View to become accessible to those Groups, Communities and Individuals you select in View Creation Step 4.</p>
<p>You can either enter in the date and time using the below format or use the Calendar to select your desired Access Start Date.</p>
<h4>Date and Time Format</h4>
......
<h3>Access End Date/Time</h3>
<p>You can chose the date and time you want your View to stop being accessible to those Communities and Individuals you select in View Creation Step 4.</p>
<p>You can chose the date and time you want your View to stop being accessible to those Groups, Communities and Individuals you select in View Creation Step 4.</p>
<p>You can either enter in the date and time using the below format or use the Calendar to select your desired Access End Date.</p>
<h4>Date and Time Format</h4>
<p>
......
<h3>Description</h3>
<p>You may choose to write a Description of your Group for your reference. Members of the Group will not see this Description.</p>
<h3>Edit</h3>
<p>Use Edit Group to change the Name or Description or update membership of your Group.</p>
<h3>Group members</h3>
<p>Select potential Group members from the list on the left and using the arrow buttons add them to the Group box on the right. You can also Search for specific users. </p>
<p>Members of a Group do not see the name or details of any other member and are no aware that they have been assigned to a Group within your portfolio.</p>
<h3>Name</h3>
<p>Enter the Name you would like use to identify this Group. Each of your Groups must have a unique name. </p>
......@@ -41,10 +41,10 @@
Notification of activity on any Artefact, View or Community you are monitoring via your Watchlist.</dd>
<dt>New Views</dt>
<dd>
Notification that you have been given access to another user&#8217;s new View either as an individual or as a member of a Community. You are not notified when a publicly available View is created.</dd>
Notification that you have been given access to another user&#8217;s new View either as an individual or as a member of a Group or Community. You are not notified when a publicly available View is created.</dd>
<dt>New Views Access</dt>
<dd>
Notification that you have been given access to another user&#8217;s existing View either as an individual or as a member of a Community. You are not notified when a publicly available View is created.</dd>
Notification that you have been given access to another user&#8217;s existing View either as an individual or as a member of a Group or Community. You are not notified when a publicly available View is created.</dd>
<dt>Administration Messages</dt> (Site Administrators only)
<dd>
Notifications and service requests for Site Administrators. </dd>
......
<h3>My Communities</h3>
<p>Communities are a collection of users, grouped in some way.</p>
<p>Communities, like Groups, are a collection of users, but they are created at the site level rather than within an individual&#8217;s ePortfolio. </p>
<p>Your Communities page lists those Communities of which you are an approved member.</p>
<p>Depending on the membership option selected by the Community Owner you can usually join a new Community via a Communities main page. A Community page may be accessed via a Community Search. </p>
<p>You can assign any Community you are a member or owner of, access rights to any of your Views. When you assign a Community access to a View, all members of that Community will also be given access.</p>
......
<h3>My Groups</h3>
<p>Groups allow you to create a personal collection of users from the site. You can assign a Group and it&#8217;s members access to any number of your Views. Creating Groups allows you to quickly assign View access to specific users.</p>
<h3>My Owned Communities</h3>
<p>Communities are a collection of users, grouped in some way.</p>
<p>Communities, like Groups, are a collection of users but they are created at the site level rather than within an individual&#8217;s ePortfolio. </p>
<p>Your Owned Communities area lists those Communities that you have created and any Pending Membership Requests (depending on the which membership setting you have selected).</p>
<p>For privacy reasons unless you are a Site Administrator or Staff user you will only see a Community member&#8217;s Preferred Name listed.</p>
<p>You can assign any Community you are a member or owner of, access rights to any of your Views. When you assign a Community access to a View, all members of that Community will also be given access.</p>
......
<h3>Create View Step 4</h3>
<p>In Create View Step 4 you can assign View access to any of your available Communities and Individuals for a set period of time.</p>
<p>You can search for specific users and Communities or choose a user from the list given. Click Add against the selected user and enter a start and finish date for their access in the box to the right. If you do not enter in a date here, access for this user will default to the start and end dates of the View itself.</p>
<p>In Create View Step 4 you can assign View access to any of your Groups, available Communities and Individuals for a set period of time.</p>
<p>You can search for specific users, Groups and Communities or choose a user from the list given. Click Add against the selected user and enter a start and finish date for their access in the box to the right. If you do not enter in a date here, access for this user will default to the start and end dates of the View itself.</p>
<p>Depending on the site settings you may also be able to give View access to all logged in users, the general public or those people listed in your Friends area.</p>
<h3>Edit View Acces</h3>
<p>In Edit View Acces you can assign View access to any of your available Communities and Individuals for a set period of time.</p>
<p>You can search for specific users and Communities or choose a user from the list given. Click Add against the selected user and enter a start and finish date for their access in the box to the right. If you do not enter in a date here, access for this user will default to the start and end dates of the View itself.</p>
<p>In Edit View Acces you can assign View access to any of your Groups, available Communities and Individuals for a set period of time.</p>
<p>You can search for specific users, Groups and Communities or choose a user from the list given. Click Add against the selected user and enter a start and finish date for their access in the box to the right. If you do not enter in a date here, access for this user will default to the start and end dates of the View itself.</p>
<p>Depending on the site settings you may also be able to give View access to all logged in users, the general public or those people listed in your Friends area.</p>
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