Commit 03cbfafc authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow copies of non-portfolio views to keep the original viewtype

parent 633c134d
......@@ -719,7 +719,7 @@ class User {
require_once(get_config('libroot') . 'view.php');
$views = array();
foreach (get_records_select_array('view', 'id IN (' . implode(', ', db_array_to_ph($templateids)) . ')', $templateids, '', 'id, title, description') as $result) {
foreach (get_records_select_array('view', 'id IN (' . implode(', ', db_array_to_ph($templateids)) . ')', $templateids, '', 'id, title, description, type') as $result) {
$views[$result->id] = $result;
}
......@@ -729,6 +729,7 @@ class User {
'owner' => $this->get('id'),
'title' => $views[$tid]->title,
'description' => $views[$tid]->description,
'type' => $views[$tid]->type == 'profile' && $checkviewaccess ? 'portfolio' : $views[$tid]->type,
), $tid, $this->get('id'), $checkviewaccess);
}
db_commit();
......
......@@ -130,6 +130,7 @@ class View {
* @param int $templateid The ID of the View to copy
* @param int $userid The user who has issued the command to create the
* view. See View::_create
* @param int $checkaccess Whether to check that the user can see the view before copying it
* @return array A list consisting of the new view, the template view and
* information about the copy - i.e. how many blocks and
* artefacts were copied
......@@ -221,6 +222,11 @@ class View {
}
}
// Users can only have one view of each non-portfolio type
if ($viewdata['type'] != 'portfolio' && get_record('view', 'owner', $viewdata['owner'], 'type', $viewdata['type'])) {
$viewdata['type'] = 'portfolio';
}
}
if (isset($viewdata['group'])) {
......
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