Class: SakaiInfo::SiteMembership
Instance Attribute Summary collapse
Attributes inherited from SakaiObject
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from SakaiObject
all_serializations, #dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml
Constructor Details
#initialize(site_id, user_id, role) ⇒ SiteMembership
Returns a new instance of SiteMembership.
532
533
534
535
536
|
# File 'lib/sakai-info/site.rb', line 532
def initialize(site_id, user_id, role)
@site = Site.find(site_id)
@user = User.find(user_id)
@role = AuthzRole.find(role)
end
|
Instance Attribute Details
#role ⇒ Object
Returns the value of attribute role.
530
531
532
|
# File 'lib/sakai-info/site.rb', line 530
def role
@role
end
|
#site ⇒ Object
Returns the value of attribute site.
530
531
532
|
# File 'lib/sakai-info/site.rb', line 530
def site
@site
end
|
#user ⇒ Object
Returns the value of attribute user.
530
531
532
|
# File 'lib/sakai-info/site.rb', line 530
def user
@user
end
|
Class Method Details
.find_by_site_id(site_id) ⇒ Object
538
539
540
541
542
543
544
545
546
547
548
|
# File 'lib/sakai-info/site.rb', line 538
def self.find_by_site_id(site_id)
results = []
DB.connect.fetch("select srrg.user_id, srr.role_name " +
"from sakai_realm_rl_gr srrg, sakai_realm_role srr, sakai_realm sr " +
"where srrg.role_key = srr.role_key " +
"and srrg.realm_key = sr.realm_key " +
"and sr.realm_id = '/site/' || ? ", site_id) do |row|
results << SiteMembership.new(site_id, row[:user_id], row[:role_name])
end
results
end
|
.find_by_user_id(user_id) ⇒ Object
550
551
552
553
554
555
556
557
558
559
560
561
562
|
# File 'lib/sakai-info/site.rb', line 550
def self.find_by_user_id(user_id)
results = []
DB.connect.fetch("select substr(sr.realm_id,7) as site_id, srr.role_name as role_name " +
"from sakai_realm_rl_gr srrg, sakai_realm_role srr, sakai_realm sr " +
"where srrg.role_key = srr.role_key " +
"and srrg.realm_key = sr.realm_key " +
"and srrg.user_id = ? " +
"and sr.realm_id like '/site/%' " +
"and sr.realm_id not like '%/group/%'", user_id) do |row|
results << SiteMembership.new(row[:site_id], user_id, row[:role_name])
end
results
end
|
Instance Method Details
#default_serialization ⇒ Object
564
565
566
567
568
569
570
|
# File 'lib/sakai-info/site.rb', line 564
def default_serialization
{
"site" => self.site.serialize(:summary),
"user" => self.user.serialize(:summary),
"role" => self.role.name
}
end
|
#site_summary_serialization ⇒ Object
591
592
593
594
595
596
597
598
|
# File 'lib/sakai-info/site.rb', line 591
def site_summary_serialization
{
"user_id" => self.user.id,
"user_eid" => self.user.eid,
"user_type" => self.user.type,
"role" => self.role.name
}
end
|
#summary_serialization ⇒ Object
572
573
574
575
576
577
578
579
580
581
|
# File 'lib/sakai-info/site.rb', line 572
def summary_serialization
{
"site_id" => self.site.id,
"site_title" => self.site.title,
"user_id" => self.user.id,
"user_eid" => self.user.eid,
"user_type" => self.user.type,
"role" => self.role.name
}
end
|
#user_summary_serialization ⇒ Object
583
584
585
586
587
588
589
|
# File 'lib/sakai-info/site.rb', line 583
def user_summary_serialization
{
"site_id" => self.site.id,
"site_title" => self.site.title,
"role" => self.role.name
}
end
|