Commit fd4ee3c2 authored by Evan Goldenberg's avatar Evan Goldenberg

Revert "usability: always show list of blogs, even if there is only one"

Since the vast majority of users will only ever use one blog, always
showing the list of blogs replaces one usability issue with another. This
commit attempts to rectify things by disabling multiple blogs for
user's who only have one blog (everyone by default!) but adding an
account preference to enable multiple blogs.

 - Users with more than one blog always see the list of blogs,
   regardless of the new setting's value
 - Users with only one blog who have not enabled multiple blogs are
   taken directly to their blog, and have no direct way of adding a new
   blog
 - Users with only one blog who have enabled multiple blogs see the list
   of blogs (the assumption is that if they were clever enough to enable
   the option, this should not confuse them)

This reverts commit f257176e.
Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent fb17f587
......@@ -154,6 +154,13 @@ $elements['addremovecolumns'] = array(
'separator' => '<br>',
'help' => 'true'
);
// TODO: add a way for plugins (like blog!) to have account preferences
$elements['multipleblogs'] = array(
'type' => 'checkbox',
'title'=> get_string('enablemultipleblogs' ,'account'),
'description' => get_string('enablemultipleblogsdescription', 'account'),
'defaultvalue' => $prefs->multipleblogs,
);
if (get_config('showtagssideblock')) {
$elements['tagssideblockmaxtags'] = array(
'type' => 'text',
......
......@@ -49,6 +49,31 @@ $blogs = (object) array(
list($blogs->count, $blogs->data) = ArtefactTypeBlog::get_blog_list($blogs->limit, $blogs->offset);
// If the user has exactly one blog, and has not enabled multiple blogs, skip the blog listing and display it
if (!$delete && $blogs->offset == 0 && !empty($blogs->data) && count($blogs->data) == 1 && !$USER->get_account_preference('multipleblogs')) {
define('TITLE', get_string('viewblog','artefact.blog'));
define('SECTION_PAGE', 'view');
$record = end($blogs->data);
$id = $record->id;
$blog = new ArtefactTypeBlog($id, $record);
// This javascript is used to generate a list of blog posts.
$js = '';
if ($blog->count_children()) {
$js = require(get_config('docroot') . 'artefact/blog/view/index.js.php');
}
$smarty = smarty(array('tablerenderer'));
$smarty->assign_by_ref('blog', $blog);
$smarty->assign_by_ref('INLINEJAVASCRIPT', $js);
$smarty->assign('PAGEHEADING', hsc($blog->get('title')));
$smarty->assign('strnopostsaddone',
get_string('nopostsaddone', 'artefact.blog',
'<a href="' . get_config('wwwroot') . 'artefact/blog/post.php?blog=' . $blog->get('id') . '">', '</a>'));
$smarty->display('artefact:blog:view.tpl');
exit;
}
define('TITLE', get_string('myblogs','artefact.blog'));
define('SECTION_PAGE', 'index');
......
......@@ -60,6 +60,9 @@ $string['showviewcolumns'] = 'Show controls to add and remove columns when editi
$string['tagssideblockmaxtags'] = 'Maximum tags in cloud';
$string['tagssideblockmaxtagsdescription'] = 'Maximum number of tags to display in your Tag Cloud';
$string['enablemultipleblogs'] = 'Enable multiple blogs';
$string['enablemultipleblogsdescription'] = 'By default, Mahara gives you one blog. If you would like to keep more than one blog, check this option.';
$string['hiderealname'] = 'Hide real name';
$string['hiderealnamedescription'] = 'Check this box if you have set a display name and you do not want other users to be able to find you by your real name in user searches.';
......
......@@ -1383,6 +1383,32 @@ function xmldb_core_upgrade($oldversion=0) {
delete_records('config', 'field', 'captchaonregisterform');
}
if ($oldversion < 2010041201) {
$sql = "
SELECT u.id
FROM {usr} u
JOIN {artefact} a
ON a.owner = u.id
WHERE a.artefacttype = 'blog'
GROUP BY u.id
HAVING COUNT(a.id) > 1";
$manyblogusers = get_records_sql_array($sql, null);
foreach($manyblogusers as $u) {
$where = (object)array(
'usr' => $u->id,
'field' => 'multipleblogs',
);
$data = (object)array(
'usr' => $u->id,
'field' => 'multipleblogs',
'value' => 1,
);
ensure_record_exists('usr_account_preference', $where, $data);
}
}
return $status;
}
......@@ -204,6 +204,7 @@ function expected_account_preferences() {
'maildisabled' => 0,
'tagssideblockmaxtags' => get_config('tagssideblockmaxtags'),
'hiderealname' => 0,
'multipleblogs' => 0,
);
}
......
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010041200;
$config->version = 2010041201;
$config->release = '1.3.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
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