Class Group
In: app/models/group.rb
Parent: ActiveRecord::Base

Group

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/

Group contains Users and sub Groups, and represents the unit in the organization.

Note:

  • Root Group has no records in DB, and its ID is ‘0’.

Methods

Public Class methods

self.delete

Overrides ActionRecord::Base.delete().

id:Target Group-ID.

self.delete_all

Overrides ActionRecord::Base.delete_all().

conditions:Conditions.

self.destroy

Overrides ActionRecord::Base.destroy().

id:Target Group-ID.

self.destroy_all

Overrides ActionRecord::Base.delete_all().

conditions:Conditions.

self.get_childs

Gets childs array of the specified Group.

group_id:Target Group-ID.
recursive:Specify true if recursive search is required.
ret_obj:Flag to require Group instances by return.
return:Array of child Group-IDs, or Groups if ret_obj is true.

self.get_group_folder

Gets Group Folder of specified Group-ID.

group_id:Target Group-ID.
return:Folder object of the Group.

self.get_name

Gets the name of the specified Group.

return:Group name. If not found, prearranged string.

self.get_path

Gets path-string which represents the position of this Group in the organization.

group_id:Target Group-ID.
return:Group path like "/parent_name1/parent_name2/this_name".

self.get_tree

Gets tree of Groups. Called recursive.

self.get_users

Gets Users in specified Group.

return:Users in specified Group.

Public Instance methods

count_users

Gets count of Users.

recursive:Specify true if recursive search is required.
return:Count of users.

delete

Overrides ActionRecord::Base.delete().

destroy

Overrides ActionRecord::Base.destroy().

get_childs

Gets childs array of this Group.

recursive:Specify true if recursive search is required.
ret_obj:Flag to require Group instances by return.
return:Array of child Group-IDs, or Groups if ret_obj is true.

get_parents

Gets parents array of this object.

ret_obj:Flag to require Group instances by return.
return:Array of parent Groups or Group-IDs.

get_path

Gets path-string which represents the position of this Group in the organization.

return:Group path like "/parent_name1/parent_name2/this_name".

rename

Renames Group.

new_name:New name.

[Validate]