2011-02-01 09:57:29 +08:00
|
|
|
#
|
2012-07-12 07:20:39 +08:00
|
|
|
# Copyright (C) 2011 - 2012 Instructure, Inc.
|
2011-02-01 09:57:29 +08:00
|
|
|
#
|
|
|
|
# This file is part of Canvas.
|
|
|
|
#
|
|
|
|
# Canvas is free software: you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
# Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2012-07-12 07:20:39 +08:00
|
|
|
class UserProfile < ActiveRecord::Base
|
|
|
|
belongs_to :user
|
|
|
|
|
|
|
|
delegate :short_name, :name, :asset_string, :opaque_identifier, :to => :user
|
2012-05-12 06:32:11 +08:00
|
|
|
|
2012-07-12 07:20:39 +08:00
|
|
|
attr_accessible :title, :bio
|
2012-05-12 06:32:11 +08:00
|
|
|
|
2012-07-28 07:56:28 +08:00
|
|
|
has_many :links, :class_name => 'UserProfileLink', :dependent => :destroy
|
2012-07-19 03:03:46 +08:00
|
|
|
|
2013-08-23 05:49:33 +08:00
|
|
|
validates_length_of :title, :maximum => maximum_string_length, :allow_blank => true
|
|
|
|
|
2012-06-02 06:45:39 +08:00
|
|
|
TAB_PROFILE, TAB_COMMUNICATION_PREFERENCES, TAB_FILES, TAB_EPORTFOLIOS,
|
|
|
|
TAB_HOME, TAB_PROFILE_SETTINGS = *0..10
|
2012-05-24 05:39:26 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def tabs_available(user=nil, opts={})
|
2011-08-24 03:44:01 +08:00
|
|
|
unless @tabs
|
|
|
|
@tabs = [
|
|
|
|
{ :id => TAB_HOME, :label => I18n.t('#tabs.home', "Home"), :css_class => 'home', :href => :dashboard_path, :no_args => true },
|
2012-08-15 00:40:56 +08:00
|
|
|
{ :id => TAB_COMMUNICATION_PREFERENCES, :label => I18n.t('#user_profile.tabs.notifications', "Notifications"), :css_class => 'notifications', :href => :communication_profile_path, :no_args => true },
|
2012-05-16 04:04:29 +08:00
|
|
|
{ :id => TAB_FILES, :label => I18n.t('#tabs.files', "Files"), :css_class => 'files', :href => :dashboard_files_path, :no_args => true },
|
2012-07-11 07:26:30 +08:00
|
|
|
{ :id => TAB_PROFILE_SETTINGS, :label => I18n.t('#user_profile.tabs.settings', 'Settings'), :css_class => 'profile_settings', :href => :settings_profile_path, :no_args => true },
|
2011-08-24 03:44:01 +08:00
|
|
|
]
|
2012-08-16 02:49:55 +08:00
|
|
|
if user && opts[:root_account] && opts[:root_account].enable_profiles?
|
2012-08-08 07:25:05 +08:00
|
|
|
@tabs.insert 1, {:id => TAB_PROFILE, :label => I18n.t('#user_profile.tabs.profile', "Profile"), :css_class => 'profile', :href => :user_profile_path, :args => [user.id]}
|
2012-07-11 05:03:14 +08:00
|
|
|
end
|
|
|
|
|
2012-07-12 07:20:39 +08:00
|
|
|
@tabs << { :id => TAB_EPORTFOLIOS, :label => I18n.t('#tabs.eportfolios', "ePortfolios"), :css_class => 'eportfolios', :href => :dashboard_eportfolios_path, :no_args => true } if user.eportfolios_enabled?
|
basic lti navigation links
By properly configuring external tools (see
/spec/models/course_spec/rb:898 for examples) they can
be added as left-side navigation links to a course,
an account, or to the user profile section of Canvas.
testing notes:
- you have to manually set options on the external tool:
- for user navigation the tool needs to be created on the root account
with the following settings:
{:user_navigation => {:url => <url>, :text => <tab label>} }
(there are also some optional language options you can set using
the :labels attribute)
- for account navigation it's the same
- for course navigation it's the same, except with :course_navigation
there's also some additional options:
:visibility => <value> // public, members, admins
:default => <value> // disabled, enabled
test plan:
- configure a user navigation tool at the root account level,
make sure it shows up in the user's profile section
- configure a course navigation tool at the account level,
make sure it shows up in the course's navigation
- configure a course navigation tool at the course level,
make sure it shows up in the course's navigation
- make sure :default => 'disabled' course navigation tools don't
appear by default in the navigation, but can be enabled on
the course settings page
- make sure :visibility => 'members' only shows up for course members
- make sure :visibility => 'admins' only shows up for course admins
- configure an account navigation tool at the account level,
make sure it shows up in the account's navigation, and
any sub-account's navigation
Change-Id: I977da3c6b89a9e32b4cff4c2b6b221f8162782ff
Reviewed-on: https://gerrit.instructure.com/5427
Reviewed-by: Brian Whitmer <brian@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2011-08-18 13:49:01 +08:00
|
|
|
if user && opts[:root_account]
|
2012-01-18 13:32:57 +08:00
|
|
|
opts[:root_account].context_external_tools.active.having_setting('user_navigation').each do |tool|
|
basic lti navigation links
By properly configuring external tools (see
/spec/models/course_spec/rb:898 for examples) they can
be added as left-side navigation links to a course,
an account, or to the user profile section of Canvas.
testing notes:
- you have to manually set options on the external tool:
- for user navigation the tool needs to be created on the root account
with the following settings:
{:user_navigation => {:url => <url>, :text => <tab label>} }
(there are also some optional language options you can set using
the :labels attribute)
- for account navigation it's the same
- for course navigation it's the same, except with :course_navigation
there's also some additional options:
:visibility => <value> // public, members, admins
:default => <value> // disabled, enabled
test plan:
- configure a user navigation tool at the root account level,
make sure it shows up in the user's profile section
- configure a course navigation tool at the account level,
make sure it shows up in the course's navigation
- configure a course navigation tool at the course level,
make sure it shows up in the course's navigation
- make sure :default => 'disabled' course navigation tools don't
appear by default in the navigation, but can be enabled on
the course settings page
- make sure :visibility => 'members' only shows up for course members
- make sure :visibility => 'admins' only shows up for course admins
- configure an account navigation tool at the account level,
make sure it shows up in the account's navigation, and
any sub-account's navigation
Change-Id: I977da3c6b89a9e32b4cff4c2b6b221f8162782ff
Reviewed-on: https://gerrit.instructure.com/5427
Reviewed-by: Brian Whitmer <brian@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2011-08-18 13:49:01 +08:00
|
|
|
@tabs << {
|
|
|
|
:id => tool.asset_string,
|
|
|
|
:label => tool.label_for(:user_navigation, opts[:language]),
|
|
|
|
:css_class => tool.asset_string,
|
|
|
|
:href => :user_external_tool_path,
|
|
|
|
:args => [user.id, tool.id]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2012-03-14 04:08:19 +08:00
|
|
|
if user && user.fake_student?
|
|
|
|
@tabs = @tabs.slice(0,2)
|
|
|
|
end
|
2011-08-24 03:44:01 +08:00
|
|
|
end
|
|
|
|
@tabs
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2011-06-23 02:20:03 +08:00
|
|
|
end
|
2012-07-26 04:33:55 +08:00
|
|
|
|