Commit a5a16f94 authored by Nigel McNie's avatar Nigel McNie

Merge commit 'origin/master'

Conflicts:

	htdocs/lib/db/upgrade.php
	htdocs/lib/version.php
parents 690a4696 cfa21585
......@@ -270,7 +270,7 @@ $string['selectaviewtocopy'] = 'Select the View you wish to copy:';
$string['listviews'] = 'List Views';
$string['nocopyableviewsfound'] = 'No Views that you can copy';
$string['noownersfound'] = 'No owners found';
$string['displayingviewsby'] = 'Displaying Views by %s';
$string['viewsby'] = 'Views by %s';
$string['Preview'] = 'Preview';
$string['closepreview'] = 'Close Preview';
......
......@@ -1356,6 +1356,7 @@ function xmldb_core_upgrade($oldversion=0) {
}
// 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));
......@@ -1363,7 +1364,44 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 2008091602) {
if ($oldversion < 2008091603) {
foreach(array('myviews', 'mygroups', 'myfriends', 'wall') as $blocktype) {
$data = check_upgrades("blocktype.$blocktype");
if ($data) {
upgrade_plugin($data);
}
}
// 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) {
$table = new XMLDBTable('usr');
$field = new XMLDBField('lastlastlogin');
$field->setAttributes(XMLDB_TYPE_DATETIME, null, null);
......
......@@ -586,6 +586,8 @@ function core_install_lastcoredata_defaults() {
insert_record('usr', $user);
}
install_system_profile_view();
// Insert the admin user
$user = new StdClass;
$user->username = 'admin';
......
......@@ -1155,23 +1155,32 @@ function create_user($user, $profile=array(), $institution=null, $remoteauth=nul
function copy_view_for_user($userid, $templateid) {
if (!$templateid) {
return;
}
$template = new View($templateid);
$v = new View(0, (object) array(
'template' => 0,
'numcolumns' => 3,
'owner' => $userid,
'title' => $template->get('title'),
'description' => $template->get('description'),
'type' => $template->get('type'),
));
$v->commit();
$v->copy_contents($template);
$v->commit();
return $v;
}
function copy_views_for_user($userid, $templateids) {
if (!$templateids) {
return;
}
require_once(get_config('libroot') . 'view.php');
foreach ($templateids as $tid) {
$template = new View($tid);
$v = new View(0, (object) array(
'template' => 0,
'numcolumns' => 3,
'owner' => $userid,
'title' => $template->get('title'),
'description' => $template->get('description'),
));
$v->commit();
$v->copy_contents($template);
$v->commit();
copy_view_for_user($userid, $tid);
}
}
......@@ -1184,24 +1193,57 @@ function copy_views_for_user($userid, $templateids) {
*/
function install_default_profile_view($eventdata) {
require_once(get_config('libroot') . 'view.php');
$viewid = install_system_profile_view();
$view = copy_view_for_user($eventdata['id'], $viewid);
$view->set_access(array(
array(
'type' => 'loggedin',
'startdate' => null,
'stopdate' => null,
),
));
}
/**
*
* This function installs the site's default profile view
*
*/
function install_system_profile_view() {
$viewid = get_field('view', 'id', 'owner', 0, 'type', 'profile');
if ($viewid) {
return $viewid;
}
require_once(get_config('libroot') . 'view.php');
require_once(get_config('docroot') . 'blocktype/lib.php');
$view = new View(0, array(
'type' => 'profile',
'owner' => $eventdata['id'],
'owner' => 0,
'numcolumns' => 2,
'ownerformat' => FORMAT_NAME_PREFERREDNAME,
'title' => get_string('profileviewtitle', 'view'),
'description' => '',
));
$view->commit();
// #TODO add blocks here
$view->set_access(array(
array(
'type' => 'loggedin',
'startdate' => null,
'stopdate' => null,
),
));
$blocktypes = array('myviews' => 1, 'mygroups' => 1, 'myfriends' => 2, 'wall' => 2); // column ids
$installed = get_column_sql('SELECT name FROM {blocktype_installed} WHERE name IN (' . join(',', array_map('db_quote', array_keys($blocktypes))) . ')');
$weights = array(1 => 0, 2 => 0);
foreach (array_keys($blocktypes) as $blocktype) {
if (in_array($blocktype, $installed)) {
$weights[$blocktypes[$blocktype]]++;
$newblock = new BlockInstance(0, array(
'blocktype' => $blocktype,
'title' => get_string('title', 'blocktype.' . $blocktype),
'view' => $view->get('id'),
'column' => $blocktypes[$blocktype],
'order' => $weights[$blocktypes[$blocktype]],
));
$newblock->commit();
}
}
return $view->get('id');
}
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2008091602;
$config->version = 2008091604;
$config->release = '1.1.0alpha2dev';
$config->minupgradefrom = 2007080700;
$config->minupgraderelease = '0.8.0 (release tag 0.8.0_RELEASE)';
......
......@@ -1532,8 +1532,8 @@ class View {
$loggedin = $USER->is_logged_in();
$viewerid = $USER->get('id');
$where = '
WHERE TRUE';
$where = "
WHERE v.type != 'profile'";
if ($ownedby) {
$where .= ' AND v.' . self::owner_sql($ownedby);
......@@ -2038,7 +2038,7 @@ class View {
}
}
}
$smarty->assign('ownername', get_string('displayingviewsby', 'view', $ownername));
$smarty->assign('ownername', get_string('viewsby', 'view', $ownername));
}
$search->html = $smarty->fetch('view/templatesearchresults.tpl');
$search->count = $results->count;
......
<table class="templateresults tablerenderer">
<thead>
{if ($ownername)}<tr><td colspan="3">{$ownername}</td></tr>{/if}
{if ($ownername)}
<tr><th colspan="3">{$ownername}</th></tr>
{else}
<tr>
<th>{str tag=name}</th>
<th>{str tag=Owner section=view}</th>
<th></th>
</tr>
{/if}
</thead>
<tbody>
{if !empty($results)}
{foreach from=$results item=row}
<tr class="r{cycle values=0,1}">
<td>
<td{if ($ownername)} colspan="2"{/if}>
<a class="viewlink" href="{$WWWROOT}view/view.php?id={$row.id|escape}" target="_blank">{$row.title|escape}</a>
</td>
<td>
{$row.sharedby|escape}
</td>
{if (!$ownername)}
<td>{$row.sharedby|escape}</td>
{/if}
<td>
{$row.form}
</td>
......
......@@ -37,6 +37,9 @@ if (!empty($loggedinid)) {
else {
$userid = param_integer('id');
}
if ($userid == 0) {
redirect();
}
if ($userid == $loggedinid) {
define('MENUITEM', 'profile/view');
}
......
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