Commit 83381911 authored by Hugh Davenport's avatar Hugh Davenport
Browse files

Create a mechanism to retain access on copied pages



Change-Id: I6d44a6ad4dade82037610a14ee6d7aa342bcb2bc
Signed-off-by: default avatarHugh Davenport <hugh@catalyst.net.nz>
parent 64b8b9de
......@@ -275,8 +275,11 @@ $string['changeviewtheme'] = 'The theme you have chosen for this page is no long
// Templates
$string['Template'] = 'Template';
$string['allowcopying'] = 'Allow copying';
$string['retainviewrights'] = 'Retain view access on copied pages';
$string['templatedescription'] = 'Check this box if you would like the people who can see your page to be able to make their own copies of it, along with any files and folders it contains.';
$string['templatedescriptionplural'] = 'Check this box if you would like the people who can see your pages to be able to make their own copies of them, along with any files and folders they contain.';
$string['retainviewrightsdescription'] = 'Check this box if you would like to add access for you to view copies of this page or collection that are copied by other users. Those users can revoke this access after they copy it if they wish. Pages that are copied from a copy of this page or collection will not have this same access.';
$string['retainviewrightsgroupdescription'] = 'Check this box if you would like to add access for members of this group to view copies of this page that are copied by other users. Those users can revoke this access after they copy it if they wish. Pages that are copied from a copy of this page will not have this same access.';
$string['choosetemplatepagedescription'] = '<p>Here you can search through the pages that you are allowed to copy as a starting point for making a new page. You can see a preview of each page by clicking on its name. Once you have found the page you wish to copy, click the corresponding "Copy Page" button to make a copy and begin customising it. You may also choose to copy the entire collection that the page belongs to by clicking the corresponding "Copy Collection" button.</p>';
$string['choosetemplategrouppagedescription'] = '<p>Here you can search through the pages that this group is allowed to copy as a starting point for making a new page. You can see a preview of each page by clicking on its name. Once you have found the page you wish to copy, click the corresponding "Copy Page" button to make a copy and begin customising it.</p><p><strong>Note:</strong> Groups cannot currently make copies of Journals or Journal Entriess.</p>';
$string['choosetemplateinstitutionpagedescription'] = '<p>Here you can search through the pages that this institution is allowed to copy as a starting point for making a new page. You can see a preview of each page by clicking on its name. Once you have found the page you wish to copy, click the corresponding "Copy Page" button to make a copy and begin customising it.</p><p><strong>Note:</strong> Institutions cannot currently make copies of Journals or Journal Entries.</p>';
......@@ -309,6 +312,7 @@ $string['nocopyableviewsfound'] = 'No pages that you can copy';
$string['noownersfound'] = 'No owners found';
$string['Preview'] = 'Preview';
$string['viewscopiedfornewusersmustbecopyable'] = 'You must allow copying before you can set a page to be copied for new users.';
$string['viewswithretainviewrightsmustbecopyable'] = 'You must allow copying before you can set a page to retain view access.';
$string['viewscopiedfornewgroupsmustbecopyable'] = 'You must allow copying before you can set a page to be copied for new groups.';
$string['copynewusergroupneedsloggedinaccess'] = 'Pages copied for new users or groups must give access to logged-in users.';
$string['viewcopywouldexceedquota'] = 'Copying this page would exceed your file quota.';
......
......@@ -414,6 +414,7 @@ class Collection {
'startdate' => $firstview->get('startdate'),
'stopdate' => $firstview->get('stopdate'),
'template' => $firstview->get('template'),
'retainview' => $firstview->get('retainview'),
'allowcomments' => $firstview->get('allowcomments'),
'approvecomments' => (int) ($firstview->get('allowcomments') && $firstview->get('approvecomments')),
'accesslist' => $firstview->get_access(),
......
......@@ -613,6 +613,7 @@
<FIELD NAME="layout" TYPE="int" LENGTH="10" NOTNULL="false"/>
<FIELD NAME="theme" TYPE="char" LENGTH="255" NOTNULL="false"/>
<FIELD NAME="template" TYPE="int" LENGTH="1" DEFAULT="0" NOTNULL="true" />
<FIELD NAME="retainview" TYPE="int" LENGTH="1" DEFAULT="0" NOTNULL="true" />
<FIELD NAME="copynewuser" TYPE="int" LENGTH="1" DEFAULT="0" NOTNULL="true" />
<FIELD NAME="type" TYPE="char" LENGTH="50" NOTNULL="true" />
<FIELD NAME="visits" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" />
......
......@@ -2353,5 +2353,12 @@ function xmldb_core_upgrade($oldversion=0) {
add_field($table, $field);
}
if ($oldversion < 2011060700) {
$table = new XMLDBTable('view');
$field = new XMLDBField('retainview');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
}
return $status;
}
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2011053101;
$config->version = 2011060700;
$config->release = '1.5.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -61,6 +61,7 @@ class View {
private $categorydata;
private $editingroles;
private $template;
private $retainview;
private $copynewuser = 0;
private $copynewgroups;
private $type;
......@@ -250,6 +251,16 @@ class View {
insert_record('view_artefact', $va);
}
}
if ($template->get('retainview') && !$template->get('institution')) {
$obj = new StdClass;
$obj->view = $view->get('id');
$obj->ctime = db_format_timestamp(time());
$obj->usr = $template->get('owner');
$obj->group = $template->get('group');
insert_record('view_access', $obj);
}
db_commit();
return array(
......@@ -705,6 +716,7 @@ class View {
$v->set('startdate', $config['startdate']);
$v->set('stopdate', $config['stopdate']);
$v->set('template', $config['template']);
$v->set('retainview', $config['retainview']);
$v->set('allowcomments', $config['allowcomments']);
$v->set('approvecomments', $config['approvecomments']);
if (isset($config['copynewuser'])) {
......
......@@ -246,6 +246,28 @@ addLoadEvent(function() {
});
EOF;
} else {
$form['elements']['more']['elements']['retainview'] = array(
'type' => 'checkbox',
'title' => get_string('retainviewrights', 'view'),
'description' => $group ? get_string('retainviewrightsgroupdescription', 'view') : get_string('retainviewrightsdescription', 'view'),
'defaultvalue' => $view->get('template') && $view->get('retainview'),
);
$js .= <<< EOF
function update_retainview() {
if ($('editaccess_template').checked) {
removeElementClass($('editaccess_retainview_container'), 'hidden');
}
else {
addElementClass($('editaccess_retainview_container'), 'hidden');
$('editaccess_retainview').checked = false;
update_loggedin_access();
}
};
addLoadEvent(function() {
update_retainview();
connect('editaccess_template', 'onclick', update_retainview);
});
EOF;
$js .= "function update_loggedin_access() {}\n";
}
......@@ -377,6 +399,10 @@ function editaccess_validate(Pieform $form, $values) {
$form->set_error('copyfornewgroups', get_string('viewscopiedfornewgroupsmustbecopyable', 'view'));
}
}
$retainview = $values['retainview'];
if ($retainview && !$values['template']) {
$form->set_error('retainview', get_string('viewswithretainviewrightsmustbecopyable', 'view'));
}
if ($values['startdate'] && $values['stopdate'] && $values['startdate'] > $values['stopdate']) {
$form->set_error('startdate', get_string('newstartdatemustbebeforestopdate', 'view', 'Overriding'));
}
......@@ -462,6 +488,7 @@ function editaccess_submit(Pieform $form, $values) {
'startdate' => $values['startdate'],
'stopdate' => $values['stopdate'],
'template' => (int) $values['template'],
'retainview' => (int) $values['retainview'],
'allowcomments' => (int) $values['allowcomments'],
'approvecomments' => (int) ($values['allowcomments'] && $values['approvecomments']),
'accesslist' => $values['accesslist'],
......
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