Class User
In: app/models/user.rb
Parent: ActiveRecord::Base

User

Original by:Sysphonic
Authors:MORITA Shintaro
Copyright:Copyright (c) 2007 MORITA Shintaro, Sysphonic. All rights reserved.
License:New BSD License (See LICENSE file)
URL:http://sysphonic.com/

User represents LOGIN-account and its personal information.

Note:

*

Methods

Included Modules

TemplatesHelper

Constants

AUTH_ALL = 'all'
AUTH_DESKTOP = 'desktop'
AUTH_ITEM = 'item'
AUTH_FOLDER = 'folder'
AUTH_USER = 'user'
AUTH_GROUP = 'group'
AUTH_TEAM = 'team'
AUTH_SCHEDULE = 'schedule'
AUTH_EQUIPMENT = 'equipment'
AUTH_LOG = 'log'
AUTH_RESEARCH = 'research'
AUTH_TEMPLATE = 'template'
AUTH_NAMES = { AUTH_ALL => _('All Authorities'), AUTH_DESKTOP => _('Desktop'), AUTH_ITEM => _('Item'), AUTH_FOLDER => _('Folder'), AUTH_USER => _('User'), AUTH_GROUP => _('Group'), AUTH_TEAM => _('Team'), AUTH_SCHEDULE => _('Schedule'), AUTH_EQUIPMENT => _('Equipment'), AUTH_LOG => _('Log'), AUTH_RESEARCH => _('Research'), AUTH_TEMPLATE => _('Template'), }
XORDER_MAX = 9999
TEL_TYPE_EXTERNAL = _('External')
TEL_TYPE_INTERNAL = _('Internal')
TEL_TYPE_HOME = _('Home')
TEL_TYPE_MOBILE = _('Mobile')
HUMANIZED_ATTRIBUTE_KEY_NAMES = { "name" => 'User name', "password" => 'Password', "email" => 'E-mail', }

Public Class methods

self.authenticate

Authenticates attributes.

attrs:Hash of the attributes to authenticate.

self.belongs_to_group?

Checks if the specified User belongs to the Group.

user_id:User-ID.
Group_id:Group-ID.
include_parents:Flag to include parent Groups.
return:true if specified User belongs to Group, false otherwise.

self.create_init_user

Creates an initial User.

self.delete

Overrides ActionRecord::Base.delete().

id:Target User-ID.

self.delete_all

Overrides ActionRecord::Base.delete_all().

conditions:Conditions.

self.destroy

Overrides ActionRecord::Base.destroy().

id:Target User-ID.

self.destroy_all

Overrides ActionRecord::Base.delete_all().

conditions:Conditions.

self.export_csv

Gets CSV description of all Users.

self.find_all

Finds all Users in order to display with specified condition.

con:Condition (String without ‘where ’). If not required, specify nil.
return:Array of Users.

self.get_admins

Gets Users who have the specified authority.

auth:Target authority. If any, specify nil.
return:Array of Users.

self.get_auth_name

Gets String which represents the specified authority.

auth:Target authority.
return:String which represents the specified authority.

self.get_config_titles

Gets titles from the configuration file.

return:Titles in the configuration file.

self.get_from_name

Gets User who has specified name.

user_name:Target User name
return:User.

self.get_my_folder

Gets ‘My Folder’ of specified User.

user_id:Target User-ID.
return:Folder object of ‘My Folder’.

self.get_name

Gets the name of specified User.

user_id:Target User-ID
return:User name. If not found, prearranged string.

self.parse_csv_row

Parses fields array of a CSV row.

row:Fields array of a CSV row.
return:User instance created from specified array.

rename_title

Updates title attributes of corresponding Users.

org_title:Original title.
new_title:New title.

self.save_config_titles

Saves official titles in the configuration file.

titles:Array of the official titles.

update_xorder

Updates xorder attributes of all Users whose titles are the same as specified one.

title:Target official title. Specifiy nil if all users are to update.
order:New order index.

Public Instance methods

add_to

Adds this User to specified Group.

return:true if modified, false otherwise.

admin?

Checks if this User has an administrative authority.

auth:Authority to verify. If called without argument, verify if User has any authority.
return:true if this User has authority, false otherwise.

check_import

Checks data to import.

mode:Mode (‘add’ or ‘update’).
user_names:Array of User names to check duplicated data.
return:Array of error messages. If no error, returns [].

create_my_folder

Creates ‘My Folder’ of this User.

return:Folder object of ‘My Folder’.

create_profile_sheet

Creates Profile-sheet of this User.

return:Profile-sheet as an Item object.

delete

Overrides ActionRecord::Base.delete().

delete_htpasswd

Deletes from htpasswd file of lighttpd for Basic Auth for RSS.

destroy

Overrides ActionRecord::Base.destroy().

exclude_from

Excludes this User from specified Group.

return:true if modified, false otherwise.

get_auth_a

Gets authorities array.

return:Authorities array without empty element. If no authorities, returns empty array.

get_groups_a

Gets Groups array to which this User belongs.

return:Array of Group-IDs. If no groups, returns empty array.

get_my_folder

Gets ‘My Folder’ of this User.

return:Folder object of ‘My Folder’.

get_name

Gets the name of the User.

return:User name.

get_profile_sheet

Gets Profile-sheet as an Item object.

return:Profile-sheet as an Item object. If no profile, returns nil.

get_project_application

Gets this User‘s Comment as an application for the project.

item_id:Item-ID of the project definition.
return:Comment if exist, nil otherwise.

get_teams_a

Gets Teams array to which this User belongs.

return:Array of Team-IDs. If no teams, returns empty array.

setup

Sets up the environment for the new User.

update_htpasswd

Updates htpasswd file of lighttpd for Basic Auth for RSS.

[Validate]