Commit 5aaf127f authored by Evan Goldenberg's avatar Evan Goldenberg Committed by Richard Mansfield
Browse files

usability improvements for profile and dashboard views



    - disable editing of title and description for special view types,
      but give them good fixed values
    - include the description when installing profile and dashboard views,
      since they aren't included when copying a template
    - don't show view submission form for profile and dashboard views
    - move access control for the profile view to the "my portfolio" page
    - exclude dashboard views from search results
Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent 35849995
......@@ -448,6 +448,7 @@ class User {
list($view) = View::create_from_template(array(
'owner' => $this->get('id'),
'title' => get_field('view', 'title', 'id', $systemprofileviewid),
'description' => get_string('profiledescription'),
'type' => 'profile',
), $systemprofileviewid, $this->get('id'));
......@@ -509,6 +510,7 @@ class User {
list($view) = View::create_from_template(array(
'owner' => $this->get('id'),
'title' => get_field('view', 'title', 'id', $systemdashboardviewid),
'description' => get_string('dashboarddescription'),
'type' => 'dashboard',
), $systemdashboardviewid, $this->get('id'));
......
......@@ -886,12 +886,13 @@ $string['remotehost'] = 'Remote host %s';
$string['Copyof'] = 'Copy of %s';
// Profile views
$string['loggedinusersonly'] = 'Logged in users only';
$string['allowpublicaccess'] = 'Allow public (non logged in) access';
$string['loggedinusersonly'] = 'Allow logged in users only';
$string['allowpublicaccess'] = 'Allow public access';
$string['thisistheprofilepagefor'] = 'This is the profile page for %s';
$string['viewmyprofilepage'] = 'View profile page';
$string['editmyprofilepage'] = 'Edit profile page';
$string['usersprofile'] = "%s's Profile";
$string['profiledescription'] = 'Your profile view is what others see when they click on your name or profile icon';
// Dashboard views
$string['mydashboard'] = 'My Dashboard';
......
......@@ -1662,6 +1662,7 @@ function xmldb_core_upgrade($oldversion=0) {
'numcolumns' => 2,
'ownerformat' => FORMAT_NAME_PREFERREDNAME,
'title' => get_string('dashboardviewtitle', 'view'),
'description' => get_string('dashboarddescription'),
'template' => 1,
'ctime' => $dbtime,
'atime' => $dbtime,
......@@ -1731,6 +1732,5 @@ function xmldb_core_upgrade($oldversion=0) {
execute_sql('ALTER TABLE {usr} ADD COLUMN showhomeinfo SMALLINT NOT NULL DEFAULT 1');
set_config('homepageinfo', 1);
}
return $status;
}
......@@ -1674,7 +1674,7 @@ function install_system_profile_view() {
'numcolumns' => 2,
'ownerformat' => FORMAT_NAME_PREFERREDNAME,
'title' => get_string('profileviewtitle', 'view'),
'description' => '',
'description' => get_string('profiledescription'),
'template' => 1,
));
$view->set_access(array(array(
......
......@@ -2960,6 +2960,59 @@ function objection_form_cancel_submit(Pieform $form) {
));
}
function togglepublic_form($viewid) {
$view = new View($viewid);
$public = array_filter($view->get_access(),
create_function(
'$item',
'return $item[\'type\'] == \'public\';'
)
);
$togglepublic = pieform(array(
'name' => 'togglepublic',
'autofocus' => false,
'renderer' => 'div',
'elements' => array(
'changeto' => array(
'type' => 'hidden',
'value' => ($public) ? 'loggedin' : 'public'
),
'id' => array(
'type' => 'hidden',
'value' => $viewid
),
'submit' => array(
'type' => 'submit',
'value' => ($public) ? get_string('loggedinusersonly') : get_string('allowpublicaccess'),
),
),
));
return $togglepublic;
}
function togglepublic_submit(Pieform $form, $values) {
global $SESSION, $userid;
$access = array(
array(
'type' => 'loggedin',
'startdate' => null,
'stopdate' => null,
),
);
if ($values['changeto'] == 'public') {
$access[] = array(
'type' => 'public',
'startdate' => null,
'stopdate' => null,
);
}
$view = new View($values['id']);
$view->set_access($access);
$SESSION->add_ok_msg(get_string('viewaccesseditedsuccessfully', 'view'));
redirect('/view');
}
/**
* display format for author names in views - firstname
......
......@@ -27,7 +27,6 @@
<div>{str tag=requestedmembershipin section=group}{$requestedlist}</div>
{/if}
<div class="btn-add">{if $addform}{$addform}{/if}</div>
<div class="btn-bold btn-edit">{$togglepublic}</div>
</div>
{if $relationship == 'pending'}
<div class="message">
......
......@@ -33,7 +33,9 @@
{else}
{if $view.removable}<div class="rbuttons"><a href="{$WWWROOT}view/delete.php?id={$view.id}" class="btn-del">{str tag="deletethisview" section="view"}</a></div>{/if}
<div class="vi">
{if $view.type != 'profile' && $view.type != 'dashboard'}
<h4><a href="{$WWWROOT}view/edit.php?id={$view.id}" id="editviewdetails">{str tag="edittitleanddescription" section="view"}</a></h4>
{/if}
{if $view.description}
<div class="videsc">{$view.description}</div>
{/if}
......@@ -49,9 +51,12 @@
{/if}
</div>
{/if}
{if $view.type != 'profile' && $view.type != 'dashboard'}
<div class="vi">
{if $view.togglepublic}
{$view.togglepublic}
{elseif $view.type != 'profile' && $view.type != 'dashboard'}
<h4><a href="{$WWWROOT}view/access.php?id={$view.id}" id="editviewaccess">{str tag="editaccess" section="view"}</a></h4>
{/if}
{if $view.access}
<div class="videsc">{$view.access}</div>
{/if}
......@@ -78,8 +83,7 @@
<div class="videsc">{str tag="nobodycanseethisview2" section="view"}</div>
{/if}
</div>
{/if}
{if $view.submitto}
{if $view.submitto && $view.type != 'profile' && $view.type != 'dashboard'}
<div class="vi submit-viewitem">{$view.submitto}</div>
{/if}
</div></td>
......
......@@ -269,32 +269,6 @@ if (!empty($loggedinid) && $loggedinid != $userid) {
$smarty->assign('relationship', $relationship);
}
else if (!empty($loggedinid)) {
if (get_config('allowpublicprofiles')) {
$public = array_filter($view->get_access(),
create_function(
'$item',
'return $item[\'type\'] == \'public\';'
)
);
$togglepublic = pieform(array(
'name' => 'togglepublic',
'autofocus' => false,
'renderer' => 'div',
'elements' => array(
'changeto' => array(
'type' => 'hidden',
'value' => ($public) ? 'loggedin' : 'public'
),
'submit' => array(
'type' => 'submit',
'value' => ($public) ? get_string('loggedinusersonly') : get_string('allowpublicaccess'),
),
),
));
$smarty->assign('togglepublic', $togglepublic);
}
}
if ($userid != $USER->get('id') && $USER->is_admin_for_user($user) && is_null($USER->get('parentuser'))) {
$loginas = get_string('loginasuser', 'admin', hsc($user->username));
......@@ -381,27 +355,5 @@ function approve_deny_friendrequest_submit(Pieform $form, $values) {
}
}
function togglepublic_submit(Pieform $form, $values) {
global $SESSION, $userid, $view;
$access = array(
array(
'type' => 'loggedin',
'startdate' => null,
'stopdate' => null,
),
);
if ($values['changeto'] == 'public') {
$access[] = array(
'type' => 'public',
'startdate' => null,
'stopdate' => null,
);
}
$view->set_access($access);
$SESSION->add_ok_msg(get_string('viewaccesseditedsuccessfully', 'view'));
redirect('/user/view.php?id=' . $userid);
}
?>
......@@ -56,6 +56,9 @@ else {
if (empty($view['submittedto'])) {
$view['submitto'] = view_group_submission_form($view['id'], $tutorgroupdata);
}
if ($view['type'] == 'profile' && get_config('allowpublicprofiles')) {
$view['togglepublic'] = togglepublic_form($view['id']);
}
}
}
......
Supports Markdown
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