Commit 690edccd authored by Gold's avatar Gold
Browse files

Bug 1916833 - Annotation can be updated on a page

Config gear icon removed from the Annotation blocks.
In order to still initially create these when added we needed to check
if the Block was a new instance or not. To achieve that we are now
passing the block instance into the has_instance_config() method.

BlockInstance has been extended and will set a 'new' parameter if the ID
in the constructor is 0.

AuthPlugin* classes also have the has_instance_config(). These do not
need the BlockInstance passed in.

Change-Id: Ifac69fc1d48b45c079b6f66e610776cead3dee63
parent 34b3b2e1
......@@ -72,7 +72,7 @@ class PluginBlocktypeResumefield extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:resumefield:content.tpl');;
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -137,7 +137,7 @@ class PluginBlocktypeCourseinfo extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:courseinfo:courseinfo.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -82,7 +82,7 @@ class PluginBlocktypeCreativecommons extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:creativecommons:statement.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -132,7 +132,7 @@ class PluginBlocktypeExternalfeed extends MaharaCoreBlocktype {
);
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -242,7 +242,7 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:externalvideo:content.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -68,7 +68,7 @@ class PluginBlocktypeGoogleApps extends MaharaCoreBlocktype {
return get_string('badurlerror', 'blocktype.googleapps', $url);
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -57,7 +57,7 @@ class PluginBlocktypeGroupInfo extends MaharaCoreBlocktype {
return $dwoo->fetch('blocktype:groupinfo:groupinfo.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return false;
}
......
......@@ -98,7 +98,7 @@ class PluginBlocktypeGroupMembers extends MaharaCoreBlocktype {
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -192,7 +192,7 @@ class PluginBlocktypeGroupViews extends MaharaCoreBlocktype {
return $dwoo->fetch('blocktype:groupviews:groupviews.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -77,7 +77,7 @@ class PluginBlocktypeInbox extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:inbox:inboxmr.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -465,7 +465,7 @@ EOF;
* this is specific to this TYPE of plugin and relates to whether individual instances
* can be configured within a view
*/
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return false;
}
......@@ -875,8 +875,17 @@ class BlockInstance {
private $width;
private $height;
/**
* Set to true if the block is being created.
* @var boolean $new
* */
private $new;
public function __construct($id=0, $data=null) {
if (!empty($id)) {
if ($id == 0) {
$this->set_new();
}
if (!empty($id)) {
if (empty($data)) {
if (!$data = get_record('block_instance','id',$id)) {
// TODO: 1) doesn't need get string here if this is the
......@@ -1270,7 +1279,7 @@ class BlockInstance {
$smarty->assign('height', $this->get('height'));
$smarty->assign('blocktype', $this->get('blocktype'));
$smarty->assign('configurable', call_static_method($blocktypeclass, 'has_instance_config'));
$smarty->assign('configurable', call_static_method($blocktypeclass, 'has_instance_config', $this));
$smarty->assign('configure', $configure); // Used by the javascript to rewrite the block, wider.
$smarty->assign('configtitle', $configtitle);
$smarty->assign('content', $content);
......@@ -2397,6 +2406,27 @@ class BlockInstance {
}
}
/**
* Set the new state of this block instance.
*/
public function set_new() {
$this->new = true;
}
/**
* Return the new state of this block instance.
*
* @return boolean
* Return the current state of 'new' or false if not set.
*/
public function is_new() {
if (!empty($this->new)) {
return $this->new;
}
return false;
}
}
function require_blocktype_plugins() {
......
......@@ -143,7 +143,7 @@ class PluginBlocktypeMyfriends extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:myfriends:myfriends.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return false;
}
......
......@@ -116,7 +116,7 @@ class PluginBlocktypeMyGroups extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:mygroups:mygroups.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -139,7 +139,7 @@ class PluginBlocktypeMyviews extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:myviews:myviews.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return false;
}
......
......@@ -69,7 +69,7 @@ class PluginBlocktypeNavigation extends MaharaCoreBlocktype {
return new Collection($id);
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -59,7 +59,7 @@ class PluginBlocktypeNewViews extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:newviews:newviews.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -368,7 +368,7 @@ class PluginBlocktypeOpenbadgedisplayer extends SystemBlocktype {
return strtotime($assertion->expires) < time();
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -46,7 +46,7 @@ class PluginBlocktypePlaceholder extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:placeholder:body.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -134,7 +134,7 @@ class PluginBlocktypeRecentForumPosts extends MaharaCoreBlocktype {
return '';
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
......@@ -70,7 +70,7 @@ class PluginBlocktypeText extends MaharaCoreBlocktype {
return $smarty->fetch('blocktype:text:content.tpl');
}
public static function has_instance_config() {
public static function has_instance_config(BlockInstance $instance) {
return true;
}
......
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