Commit 62fa55e7 authored by Richard Mansfield's avatar Richard Mansfield

Merge branch 'master' of git+ssh://git.mahara.org/git/mahara

Conflicts:

	htdocs/lib/db/upgrade.php
	htdocs/lib/version.php
parents 6714a894 7e290af5
......@@ -115,7 +115,7 @@ function xmldb_artefact_blog_upgrade($oldversion=0) {
}
}
if ($oldversion < 2008101600) {
if ($oldversion < 2008101602) {
$table = new XMLDBTable('artefact_blog_blogpost_file_pending');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('oldextension', XMLDB_TYPE_TEXT, null);
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2008101600;
$config->version = 2008101602;
$config->release = '0.1.1';
?>
......@@ -137,7 +137,7 @@ function xmldb_artefact_file_upgrade($oldversion=0) {
execute_sql("UPDATE {artefact_file_files} SET fileid = artefact WHERE NOT size IS NULL");
}
if ($oldversion < 2008101400) {
if ($oldversion < 2008101602) {
$table = new XMLDBTable('artefact_file_files');
$field = new XMLDBField('filetype');
$field->setAttributes(XMLDB_TYPE_TEXT);
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2008101400;
$config->version = 2008101602;
$config->release = '0.4.3';
?>
......@@ -1354,14 +1354,6 @@ function xmldb_core_upgrade($oldversion=0) {
install_blocktype_viewtypes_for_plugin(blocktype_single_to_namespaced($bt->name, $bt->artefactplugin));
}
}
// migrate all users to their default profile view
// These profile views are deleted in the next upgrade.
if ($userids = get_column('usr', 'id')) {
foreach ($userids as $user) {
install_default_profile_view(array('id' => $user));
}
}
}
if ($oldversion < 2008091603) {
......@@ -1372,33 +1364,7 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
// Delete all the empty profile views & recreate them from the
// site template.
$viewids = get_column('view', 'id', 'type', 'profile');
if ($viewids) {
require_once(get_config('libroot') . 'view.php');
foreach ($viewids as $id) {
$view = new View($id);
$view->delete();
}
}
install_system_profile_view();
if ($userids = get_column('usr', 'id')) {
foreach ($userids as $user) {
if ($user > 0) {
install_default_profile_view(array('id' => $user));
}
}
}
// This record already exists on an install from scratch, but
// not in an upgrade
if (!record_exists('event_subscription', 'event', 'createuser', 'callfunction', 'install_default_profile_view')) {
insert_record('event_subscription', (object)array('event' => 'createuser', 'callfunction' => 'install_default_profile_view'));
}
}
if ($oldversion < 2008091604) {
......@@ -1419,7 +1385,13 @@ function xmldb_core_upgrade($oldversion=0) {
// next upgrade should probably set disablelogin = false and
// minupgradefrom = 2008092000 in version.php.
if ($oldversion < 2008101300) {
if ($oldversion < 2008101500) {
// Remove event subscription for new user accounts to have a default
// profile view created, they're now created on demand
execute_sql("DELETE FROM {event_subscription} WHERE event = 'createuser' AND callfunction = 'install_default_profile_view';");
}
if ($oldversion < 2008101602) {
// Move artefact/internal/profileicons directory to artefact/file
$artefactdata = get_config('dataroot') . 'artefact/';
rename($artefactdata . 'internal/profileicons', $artefactdata . 'file/profileicons');
......
......@@ -669,10 +669,6 @@ function core_install_firstcoredata_defaults() {
'event' => 'createuser',
'callfunction' => 'activity_set_defaults',
),
array(
'event' => 'createuser',
'callfunction' => 'install_default_profile_view'
),
);
foreach ($subs as $sub) {
......
......@@ -1218,20 +1218,19 @@ function copy_views_for_user($userid, $templateids) {
}
/**
* Installs a user's profile view.
*
* This function installs the default profile view for a user
* upon the createuser event (and a migration upgrade)
*
* @param mixed eventdata data that is passed to handle_event
* @param id $userid ID of user to create the profile view for
*/
function install_default_profile_view($eventdata) {
require_once(get_config('libroot') . 'view.php');
function install_profile_view($userid) {
static $systemprofileviewid = null;
$viewid = install_system_profile_view();
if ($eventdata['id'] == 0) {
return;
if (is_null($systemprofileviewid)) {
$systemprofileviewid = get_field('view', 'id', 'owner', 0, 'type', 'profile');
}
$view = copy_view_for_user($eventdata['id'], $viewid);
require_once(get_config('libroot') . 'view.php');
$view = copy_view_for_user($userid, $systemprofileviewid);
$view->set_access(array(
array(
'type' => 'loggedin',
......@@ -1239,18 +1238,21 @@ function install_default_profile_view($eventdata) {
'stopdate' => null,
),
));
$id = $view->get('id');
unset($view);
return $id;
}
/**
*
* This function installs the site's default profile view
*
* @throws SystemException if the system profile view is already installed
*/
function install_system_profile_view() {
$viewid = get_field('view', 'id', 'owner', 0, 'type', 'profile');
if ($viewid) {
return $viewid;
throw new SystemException('A system profile view already seems to be installed');
}
require_once(get_config('libroot') . 'view.php');
require_once(get_config('docroot') . 'blocktype/lib.php');
......
......@@ -27,8 +27,8 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2008101300;
$config->release = '1.1.0alpha4dev';
$config->version = 2008101602;
$config->release = '1.1.0beta2dev';
$config->minupgradefrom = 2007080700;
$config->minupgraderelease = '0.8.0 (release tag 0.8.0_RELEASE)';
$config->disablelogin = true;
......
......@@ -1386,7 +1386,11 @@ class View {
* @param int $userid the user id to fetch the profile view for
*/
public static function profile_view($userid) {
return new View(get_field('view', 'id', 'type', 'profile', 'owner', $userid));
$viewid = get_field('view', 'id', 'type', 'profile', 'owner', $userid);
if (!$viewid) {
$viewid = install_profile_view($userid);
}
return new View($viewid);
}
public static function get_myviews_data($limit=5, $offset=0, $groupid=null, $institution=null) {
......
......@@ -49,6 +49,11 @@ body {
margin-top: -1px;
padding-right: .5em;
}
.sitemessage a,
.sitemessage a:link {
color: #00f;
text-decoration: underline;
}
.hidden {
display: none;
......
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