Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
9b961958
Commit
9b961958
authored
Feb 27, 2014
by
Aaron Wells
Committed by
Gerrit Code Review
Feb 27, 2014
Browse files
Merge "Removed Contact info blocktype (Bug #892684)"
parents
c2a4db8a
b5c9e316
Changes
9
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/internal/blocktype/contactinfo/lang/en.utf8/blocktype.contactinfo.php
deleted
100644 → 0
View file @
c2a4db8a
<?php
/**
*
* @package mahara
* @subpackage blocktype-contactinfo
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
defined
(
'INTERNAL'
)
||
die
();
$string
[
'title'
]
=
'Contact information'
;
$string
[
'description'
]
=
'Choose contact information to display'
;
$string
[
'dontshowemail'
]
=
'Don\'t show email address'
;
$string
[
'fieldstoshow'
]
=
'Fields to show'
;
htdocs/artefact/internal/blocktype/contactinfo/lib.php
deleted
100644 → 0
View file @
c2a4db8a
<?php
/**
*
* @package mahara
* @subpackage blocktype-contactinfo
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
defined
(
'INTERNAL'
)
||
die
();
class
PluginBlocktypeContactinfo
extends
PluginBlocktype
{
public
static
function
get_title
()
{
return
get_string
(
'title'
,
'blocktype.internal/contactinfo'
);
}
public
static
function
get_description
()
{
return
get_string
(
'description'
,
'blocktype.internal/contactinfo'
);
}
public
static
function
get_categories
()
{
return
array
(
'internal'
);
}
public
static
function
render_instance
(
BlockInstance
$instance
,
$editing
=
false
)
{
require_once
(
get_config
(
'docroot'
)
.
'artefact/lib.php'
);
$smarty
=
smarty_core
();
$configdata
=
$instance
->
get
(
'configdata'
);
$data
=
array
();
// add in the selected email address
if
(
!
empty
(
$configdata
[
'email'
]))
{
$configdata
[
'artefactids'
][]
=
$configdata
[
'email'
];
}
// Get data about the profile fields in this blockinstance
if
(
!
empty
(
$configdata
[
'artefactids'
]))
{
$viewowner
=
get_field
(
'view'
,
'owner'
,
'id'
,
$instance
->
get
(
'view'
));
foreach
(
$configdata
[
'artefactids'
]
as
$id
)
{
try
{
$artefact
=
artefact_instance_from_id
(
$id
);
if
(
is_a
(
$artefact
,
'ArtefactTypeProfile'
)
&&
$artefact
->
get
(
'owner'
)
==
$viewowner
)
{
$rendered
=
$artefact
->
render_self
(
array
(
'link'
=>
true
));
$data
[
$artefact
->
get
(
'artefacttype'
)]
=
$rendered
[
'html'
];
}
}
catch
(
ArtefactNotFoundException
$e
)
{
log_debug
(
'Artefact not found when rendering contactinfo block instance. '
.
'There might be a bug with deleting artefacts of this type? '
.
'Original error follows:'
);
log_debug
(
$e
->
getMessage
());
}
}
}
$smarty
->
assign
(
'profileinfo'
,
$data
);
return
$smarty
->
fetch
(
'blocktype:contactinfo:content.tpl'
);
}
public
static
function
has_instance_config
()
{
return
true
;
}
public
static
function
instance_config_form
(
$instance
)
{
$configdata
=
$instance
->
get
(
'configdata'
);
$form
=
array
();
// email addresses
$result
=
get_records_sql_array
(
'SELECT a.id, a.title, a.note
FROM {artefact} a
WHERE artefacttype = \'email\'
AND a.owner = (
SELECT "owner"
FROM {view}
WHERE id = ?
)
ORDER BY a.id'
,
array
(
$instance
->
get
(
'view'
)));
$options
=
array
(
0
=>
get_string
(
'dontshowemail'
,
'blocktype.internal/contactinfo'
),
);
foreach
(
$result
as
$email
)
{
$options
[
$email
->
id
]
=
$email
->
title
;
}
$form
[
'email'
]
=
array
(
'type'
=>
'radio'
,
'title'
=>
get_string
(
'email'
,
'artefact.internal'
),
'options'
=>
$options
,
'defaultvalue'
=>
(
isset
(
$configdata
[
'email'
]))
?
$configdata
[
'email'
]
:
0
,
'separator'
=>
'<br>'
,
);
// Which fields does the user want
$form
[]
=
self
::
artefactchooser_element
((
isset
(
$configdata
[
'artefactids'
]))
?
$configdata
[
'artefactids'
]
:
null
);
return
$form
;
}
// TODO: make decision on whether this should be abstract or not
public
static
function
artefactchooser_element
(
$default
=
null
)
{
safe_require
(
'artefact'
,
'internal'
);
return
array
(
'name'
=>
'artefactids'
,
'type'
=>
'artefactchooser'
,
'title'
=>
get_string
(
'fieldstoshow'
,
'blocktype.internal/contactinfo'
),
'defaultvalue'
=>
$default
,
'blocktype'
=>
'contactinfo'
,
'limit'
=>
655360
,
// 640K profile fields is enough for anyone!
'selectone'
=>
false
,
'search'
=>
false
,
'artefacttypes'
=>
array_diff
(
PluginArtefactInternal
::
get_contactinfo_artefact_types
(),
array
(
'email'
)),
'template'
=>
'artefact:internal:artefactchooser-element.tpl'
,
);
}
/**
* Deliberately enforce _no_ sort order. The database will return them in
* the order they were inserted, which means roughly the order that they
* are listed in the profile screen
*/
public
static
function
artefactchooser_get_sort_order
()
{
return
''
;
}
public
static
function
rewrite_blockinstance_config
(
View
$view
,
$configdata
)
{
if
(
$view
->
get
(
'owner'
)
!==
null
)
{
$artefacttypes
=
array_diff
(
PluginArtefactInternal
::
get_contactinfo_artefact_types
(),
array
(
'email'
));
$artefactids
=
get_column_sql
(
'
SELECT a.id FROM {artefact} a
WHERE a.owner = ? AND a.artefacttype IN ('
.
join
(
','
,
array_map
(
'db_quote'
,
$artefacttypes
))
.
')'
,
array
(
$view
->
get
(
'owner'
)));
$configdata
[
'artefactids'
]
=
$artefactids
;
if
(
isset
(
$configdata
[
'email'
]))
{
if
(
$newemail
=
get_field
(
'artefact_internal_profile_email'
,
'artefact'
,
'principal'
,
1
,
'owner'
,
$view
->
get
(
'owner'
)))
{
$configdata
[
'email'
]
=
$newemail
;
}
else
{
unset
(
$configdata
[
'email'
]);
}
}
}
else
{
$configdata
[
'artefactids'
]
=
array
();
}
return
$configdata
;
}
public
static
function
default_copy_type
()
{
return
'shallow'
;
}
/**
* Contactinfo blocktype is only allowed in personal views, because
* there's no such thing as group/site profiles
*/
public
static
function
allowed_in_view
(
View
$view
)
{
return
$view
->
get
(
'owner'
)
!=
null
;
}
/**
* Overrides the default implementation so we can export enough information
* to reconstitute profile information again.
*
* Leap2A export doesn't export profile related artefacts as entries, so we
* need to take that into account when exporting config for it.
*/
public
static
function
export_blockinstance_config_leap
(
BlockInstance
$bi
)
{
return
PluginArtefactInternal
::
export_blockinstance_config_leap
(
$bi
);
}
/**
* Sister method to export_blockinstance_config_leap (creates block
* instance based of what that method exports)
*/
public
static
function
import_create_blockinstance_leap
(
array
$biconfig
,
array
$viewconfig
)
{
return
PluginArtefactInternal
::
import_create_blockinstance_leap
(
$biconfig
,
$viewconfig
);
}
}
htdocs/artefact/internal/blocktype/contactinfo/theme/raw/content.tpl
deleted
100644 → 0
View file @
c2a4db8a
<ul>
{
foreach
from
=
$profileinfo
key
=
key
item
=
item
}
<li><strong>
{
str
tag
=
$key
section
=
artefact
.
internal
}
:
</strong>
{
$item
|
clean_html
|
safe
}
</li>
{/
foreach
}
</ul>
\ No newline at end of file
htdocs/artefact/internal/blocktype/contactinfo/theme/raw/static/images/thumb.png
deleted
100755 → 0
View file @
c2a4db8a
1.57 KB
htdocs/artefact/internal/blocktype/contactinfo/version.php
deleted
100644 → 0
View file @
c2a4db8a
<?php
/**
*
* @package mahara
* @subpackage blocktype-contactinfo
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
defined
(
'INTERNAL'
)
||
die
();
$config
=
new
StdClass
;
$config
->
version
=
2008040200
;
$config
->
release
=
'1.0.0'
;
htdocs/artefact/internal/db/upgrade.php
View file @
9b961958
...
...
@@ -26,5 +26,13 @@ function xmldb_artefact_internal_upgrade($oldversion=0) {
execute_sql
(
"DROP TABLE
{
artefact_internal_profile_icon
}
"
);
}
if
(
$oldversion
<
2014022700
)
{
// Remove the unnecessary Contact information block and change all current instances to Profile information
execute_sql
(
"UPDATE
{
block_instance
}
SET blocktype='profileinfo' WHERE blocktype='contactinfo'"
);
execute_sql
(
"DELETE FROM
{
blocktype_installed_viewtype
}
WHERE blocktype='contactinfo'"
);
execute_sql
(
"DELETE FROM
{
blocktype_installed_category
}
WHERE blocktype='contactinfo'"
);
execute_sql
(
"DELETE FROM
{
blocktype_installed
}
WHERE name='contactinfo'"
);
}
return
$status
;
}
htdocs/artefact/internal/version.php
View file @
9b961958
...
...
@@ -12,5 +12,5 @@
defined
(
'INTERNAL'
)
||
die
();
$config
=
new
StdClass
;
$config
->
version
=
201
10712
00
;
$config
->
version
=
201
40227
00
;
$config
->
release
=
'1.1.0'
;
htdocs/lib/db/upgrade.php
View file @
9b961958
...
...
@@ -3155,5 +3155,11 @@ function xmldb_core_upgrade($oldversion=0) {
drop_field
(
$table
,
$field
);
}
if
(
$oldversion
<
2014022700
)
{
if
(
$data
=
check_upgrades
(
'artefact.internal'
))
{
upgrade_plugin
(
$data
);
}
}
return
$status
;
}
htdocs/lib/version.php
View file @
9b961958
...
...
@@ -15,7 +15,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/index.php/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config
->
version
=
2014022
6
00
;
$config
->
version
=
2014022
7
00
;
$config
->
release
=
'1.9.0dev'
;
$config
->
minupgradefrom
=
2009022600
;
$config
->
minupgraderelease
=
'1.1.0 (release tag 1.1.0_RELEASE)'
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment