diff --git a/htdocs/blocktype/lib.php b/htdocs/blocktype/lib.php
index b730e4de5..074398966 100644
--- a/htdocs/blocktype/lib.php
+++ b/htdocs/blocktype/lib.php
@@ -941,6 +941,9 @@ class BlockInstance {
* javascript to run
*/
public function render_editing($configure=false, $new=false, $jsreply=false) {
+ // Learningworks
+ global $view;
+
safe_require('blocktype', $this->get('blocktype'));
$movecontrols = array();
@@ -1039,6 +1042,8 @@ class BlockInstance {
$smarty->assign('strmovetitletext', $title == '' ? get_string('movethisblock', 'view') : get_string('moveblock', 'view', "'$title'"));
$smarty->assign('strconfigtitletext', $title == '' ? get_string('configurethisblock1', 'view', $id) : get_string('configureblock1', 'view', "'$title'", $id));
$smarty->assign('strremovetitletext', $title == '' ? get_string('removethisblock1', 'view', $id) : get_string('removeblock1', 'view', "'$title'", $id));
+ // Learningworks
+ $smarty->assign('lockblocks', $view->get('lockblocks'));
if (!$configure && $title) {
$configdata = $this->get('configdata');
diff --git a/htdocs/lang/en.utf8/view.php b/htdocs/lang/en.utf8/view.php
index 25f272031..c8458b2a3 100644
--- a/htdocs/lang/en.utf8/view.php
+++ b/htdocs/lang/en.utf8/view.php
@@ -507,3 +507,6 @@ $string['textbox1'] = 'Note';
$string['image'] = 'Image';
$string['addcontent'] = 'Add Content';
$string['theme'] = 'Theme';
+
+$string['lockblocks'] = "Lock blocks";
+$string['lockblocksdescription'] = "You can lock the blocks on the page and prevent that they are removed when people copy the page.";
\ No newline at end of file
diff --git a/htdocs/lib/collection.php b/htdocs/lib/collection.php
index a86136697..2c2e5bd91 100644
--- a/htdocs/lib/collection.php
+++ b/htdocs/lib/collection.php
@@ -904,6 +904,7 @@ class Collection {
'allowcomments' => $firstview->get('allowcomments'),
'approvecomments' => (int) ($firstview->get('allowcomments') && $firstview->get('approvecomments')),
'accesslist' => $firstview->get_access(),
+ 'lockblocks' => $firstview->get('lockblocks'),
);
View::update_view_access($viewconfig, $viewids);
}
diff --git a/htdocs/lib/db/install.xml b/htdocs/lib/db/install.xml
index 8bca7abd3..2ed90d80a 100644
--- a/htdocs/lib/db/install.xml
+++ b/htdocs/lib/db/install.xml
@@ -787,6 +787,7 @@
+
diff --git a/htdocs/lib/db/upgrade.php b/htdocs/lib/db/upgrade.php
index 1e94da2ca..eb65402f9 100644
--- a/htdocs/lib/db/upgrade.php
+++ b/htdocs/lib/db/upgrade.php
@@ -5941,5 +5941,14 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
+ // Add lockblocks working to views
+ if ($oldversion < 2018022503) {
+ log_debug('Create a new "lockblock" field in "view" table');
+ $table = new XMLDBTable('view');
+ $field = new XMLDBField('lockblocks');
+ $field->setAttributes(XMLDB_TYPE_INTEGER, 1);
+ add_field($table, $field);
+ }
+
return $status;
}
\ No newline at end of file
diff --git a/htdocs/lib/view.php b/htdocs/lib/view.php
index aa9140955..5650cd4ee 100644
--- a/htdocs/lib/view.php
+++ b/htdocs/lib/view.php
@@ -12,7 +12,8 @@
defined('INTERNAL') || die();
class View {
-
+ // Learningworks Addition
+ private $lockblocks;
private $dirty;
private $deleted;
private $id;
@@ -464,6 +465,9 @@ class View {
return array(null, $template, array('quotaexceeded' => true));
}
+ // Lockblocks if set on template
+ $view->set('lockblocks', $template->get('lockblocks'));
+
$view->commit();
// if layout is set, and it's not a default layout
@@ -604,6 +608,8 @@ class View {
'type' => 'portfolio',
'title' => (array_key_exists('title', $viewdata)) ? $viewdata['title'] : self::new_title(get_string('Untitled', 'view'), (object)$viewdata),
'anonymise' => 0,
+ // LEARNING WORKS
+ 'lockblocks' => 0,
);
$data = (object)array_merge($defaultdata, $viewdata);
@@ -613,6 +619,7 @@ class View {
$data->urlid = self::new_urlid($data->urlid, $data);
}
+
$view = new View(0, $data);
$view->commit();
@@ -1127,7 +1134,8 @@ class View {
|| ($c = strcmp($a->startdate, $b->startdate))
|| ($c = !empty($a->stopdate) - !empty($b->stopdate))
|| ($c = strcmp($a->stopdate, $b->stopdate))
- || ($c = $a->allowcomments - $b->allowcomments)) {
+ || ($c = $a->allowcomments - $b->allowcomments)
+ || ($c = $a->lockblocks - $b->lockblocks)) {
return $c;
}
return $a->approvecomments - $b->approvecomments;
@@ -1146,6 +1154,7 @@ class View {
$v->set('retainview', $config['retainview']);
$v->set('allowcomments', $config['allowcomments']);
$v->set('approvecomments', $config['approvecomments']);
+ $v->set('lockblocks', $config['lockblocks']);
if (isset($config['copynewuser'])) {
$v->set('copynewuser', $config['copynewuser']);
}
@@ -5873,6 +5882,8 @@ class View {
public function copy_contents($template, &$artefactcopies) {
+ // Learningworks
+ $this->set('lockblocks', $template->get('lockblocks'));
$this->set('numrows', $template->get('numrows'));
$this->set('layout', $template->get('layout'));
diff --git a/htdocs/view/access.php b/htdocs/view/access.php
index c7f40cc81..7843ab08e 100644
--- a/htdocs/view/access.php
+++ b/htdocs/view/access.php
@@ -188,6 +188,12 @@ $form['elements']['more'] = array(
'description' => get_string('moderatecommentsdescription2', 'artefact.comment'),
'defaultvalue' => $view->get('approvecomments'),
),
+ 'lockblocks' => array(
+ 'type' => 'switchbox',
+ 'title' => get_string('lockblocks', 'view'),
+ 'description' => get_string('lockblocksdescription', 'view'),
+ 'defaultvalue' => $view->get('lockblocks'),
+ ),
'template' => array(
'type' => 'switchbox',
'title' => get_string('allowcopying', 'view'),
@@ -503,6 +509,7 @@ function editaccess_submit(Pieform $form, $values) {
'allowcomments' => (int) $values['allowcomments'],
'approvecomments' => (int) ($values['allowcomments'] && $values['approvecomments']),
'accesslist' => $values['accesslist'],
+ 'lockblocks' => $values['lockblocks'],
);
$toupdate = array();
diff --git a/htdocs/view/accessurl.php b/htdocs/view/accessurl.php
index 0a856be8f..06f08e56d 100644
--- a/htdocs/view/accessurl.php
+++ b/htdocs/view/accessurl.php
@@ -120,6 +120,12 @@ $form['elements']['more'] = array(
'description' => get_string('moderatecommentsdescription2', 'artefact.comment'),
'defaultvalue' => $view->get('approvecomments'),
),
+ 'lockblocks' => array(
+ 'type' => 'switchbox',
+ 'title' => get_string('lockblocks', 'view'),
+ 'description' => get_string('lockblocksdescription', 'view'),
+ 'defaultvalue' => $view->get('lockblocks'),
+ ),
'template' => array(
'type' => 'switchbox',
'title' => get_string('allowcopying', 'view'),
@@ -424,6 +430,7 @@ function accessurl_submit(Pieform $form, $values) {
'allowcomments' => (int) $values['allowcomments'],
'approvecomments' => (int) ($values['allowcomments'] && $values['approvecomments']),
'accesslist' => $values['accesslist'],
+ 'lockblocks' => $values['lockblocks'],
);
if ($group) {
diff --git a/htdocs/view/editlayout.php b/htdocs/view/editlayout.php
index 35d60f50c..74196b3e0 100644
--- a/htdocs/view/editlayout.php
+++ b/htdocs/view/editlayout.php
@@ -277,6 +277,12 @@ function get_basic_elements() {
'defaultvalue' => $view->get('description'),
'rules' => array('maxlength' => 65536),
),
+ 'lockblocks' => array(
+ 'type' => 'switchbox',
+ 'title' => get_string('lockblocks', 'view'),
+ 'description' => get_string('lockblocksdescription', 'view'),
+ 'defaultvalue' => $view->get('lockblocks'),
+ ),
'tags' => array(
'type' => 'tags',
'title' => get_string('tags'),
@@ -928,6 +934,9 @@ function set_view_title_and_description(Pieform $form, $values){
if (isset($values['locked'])) {
$view->set('locked', (int)$values['locked']);
}
+ if (isset($values['lockblocks'])) {
+ $view->set('lockblocks', (int)$values['lockblocks']);
+ }
if (isset($values['ownerformat']) && $view->get('owner')) {
$view->set('ownerformat', $values['ownerformat']);
}