Commit 42d47dd6 authored by Son Nguyen's avatar Son Nguyen
Browse files

Manually and automatically copying of institution and site collections


(Bug #886080)

Copying a site or institution collection which has several pages
to new user's porfolio or to new group's portfolio

Change-Id: I635224386b5a5c5230617e0d09fe0f1da45d6b2b
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent ac9f056d
......@@ -1119,7 +1119,7 @@ class User {
// Get list of available collections
$templatecollectionids = get_column_sql("
SELECT c.id
SELECT DISTINCT c.id
FROM {view} v
INNER JOIN {collection_view} cv ON v.id = cv.view
INNER JOIN {collection} c ON cv.collection = c.id
......@@ -1157,7 +1157,7 @@ class User {
// Get list of available collections
$templatecollectionids = get_column_sql("
SELECT c.id
SELECT DISTINCT c.id
FROM {view} v
INNER JOIN {collection_view} cv ON v.id = cv.view
INNER JOIN {collection} c ON cv.collection = c.id
......
......@@ -437,7 +437,7 @@ function group_create($data) {
}
// Copy collections for the new group
$templates = get_records_sql_array("
SELECT c.id, c.name
SELECT DISTINCT c.id, c.name
FROM {view} v
INNER JOIN {view_autocreate_grouptype} vag ON vag.view = v.id
INNER JOIN {collection_view} cv ON v.id = cv.view
......
......@@ -88,7 +88,7 @@ $form = array(
// For institution views, force edit access of one view at a time for now. Editing multiple
// institution views requires doing some tricky stuff with the 'copy for new users/groups'
// options, and there's not much room for the 'Share' tab in the admin area anyway
if (!$institution && $view->get('type') != 'profile') {
if ($view->get('type') != 'profile') {
list($collections, $views) = View::get_views_and_collections(
$view->get('owner'), $group, $institution, $view->get('accessconf'), false
);
......@@ -534,39 +534,36 @@ function editaccess_submit(Pieform $form, $values) {
}
$viewconfig['copynewgroups'] = $createfor;
}
$toupdate[] = $view->get('id');
}
else {
if (isset($values['collections'])) {
foreach ($values['collections'] as $cid) {
if (!isset($collections[$cid])) {
throw new UserException(get_string('editaccessinvalidviewset', 'view'));
}
$toupdate = array_merge($toupdate, array_keys($collections[$cid]['views']));
if (isset($values['collections'])) {
foreach ($values['collections'] as $cid) {
if (!isset($collections[$cid])) {
throw new UserException(get_string('editaccessinvalidviewset', 'view'));
}
$toupdate = array_merge($toupdate, array_keys($collections[$cid]['views']));
}
if (isset($values['views'])) {
foreach ($values['views'] as $viewid) {
if (!isset($views[$viewid])) {
throw new UserException(get_string('editaccessinvalidviewset', 'view'));
}
$toupdate[] = $viewid;
}
if (isset($values['views'])) {
foreach ($values['views'] as $viewid) {
if (!isset($views[$viewid])) {
throw new UserException(get_string('editaccessinvalidviewset', 'view'));
}
$toupdate[] = $viewid;
}
else if ($view->get('type') == 'profile') {
// Force default Advanced options
$felements = $form->get_property('elements');
if (!empty($felements['more']['elements'])) {
foreach (array_keys($felements['more']['elements']) as $ename) {
if (property_exists($view, $ename)) {
$viewconfig[$ename] = $view->get($ename);
}
}
else if ($view->get('type') == 'profile') {
// Force default Advanced options
$felements = $form->get_property('elements');
if (!empty($felements['more']['elements'])) {
foreach (array_keys($felements['more']['elements']) as $ename) {
if (property_exists($view, $ename)) {
$viewconfig[$ename] = $view->get($ename);
}
}
$toupdate[] = $view->get('id');
}
$toupdate[] = $view->get('id');
}
if (!empty($toupdate)) {
......
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