Module: People::CommunitiesHelper

Defined in:
app/helpers/people/communities_helper.rb

Overview

COPYRIGHT:

Copyright (c) 2005-2009 North Carolina State University
Developed with funding for the National eXtension Initiative.

LICENSE:

BSD(-compatible)
see LICENSE file or view at http://about.extension.org/wiki/LICENSE

Instance Method Summary (collapse)

Instance Method Details



18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/people/communities_helper.rb', line 18

def change_community_connection_link(container,community,label,connectaction,linkoptions = {})
  url = {:controller => '/people/communities', :action => :change_my_connection, :id => community.id, :connectaction => connectaction}
  if(container == 'nointerest')
    color = 'white'
  else
    color = 'ffe2c8'
  end
  progress = "<p><img src='/images/common/ajax-loader-#{color}.gif' /> Saving... </p>"
  return link_to_remote(label, {:url => url, :loading => update_page{|p| p.replace_html(container,progress)}}, linkoptions)
end

- (Object) community_class(community)



10
11
12
13
14
15
16
# File 'app/helpers/people/communities_helper.rb', line 10

def community_class(community)
  if community.is_institution? 
    "institution"
  else 
    "community"
  end
end


80
81
82
83
84
85
86
87
88
89
# File 'app/helpers/people/communities_helper.rb', line 80

def community_connection_link(container,community,showuser,label,connectaction,title,confirm = nil)
  urloptions = {:controller => '/people/communities', :action => :modify_user_connection, :id => community.id, :userid => showuser.id }
  urloptions.merge!({:connectaction => connectaction})
  progress = "<img src='/images/common/ajax-loader-white.gif' /> Saving..."
  loading = update_page{|p| p.replace_html(container,progress)}
  options = {:url => urloptions, :loading => loading}
  options.merge!({:confirm => confirm}) if(!confirm.nil?)
  htmloptions = {:title => title}
  return link_to_remote(label,options,htmloptions)
end


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'app/helpers/people/communities_helper.rb', line 91

def community_connection_links(container,community,showuser,connectaction)
  remove_leader_link = community_connection_link(container,community,showuser,(community.is_institution? ? 'remove from inst. team' : 'remove leadership'),'removeleader',(community.is_institution? ? 'Remove from the Institutional Team' : 'Remove user from leadership'))
  remove_member_link = community_connection_link(container,community,showuser,'remove','removemember',"Remove user from this community","Are you sure you want to remove this person from the community?")
  add_member_link = community_connection_link(container,community,showuser,'make member','addmember',"Make user a member")
  add_leader_link = community_connection_link(container,community,showuser,(community.is_institution? ? 'add to inst. team' : 'make leader'),'addleader',(community.is_institution? ? 'Add to Institutional Team' : 'Make user a community leader'))
  sendagain_invite_link = community_connection_link(container,community,showuser,'send again','invitereminder',"Send an invitation reminder")
  rescind_invite_link = community_connection_link(container,community,showuser,'rescind','rescindinvitation',"Rescind community invitation","Are you sure you want rescind this invitation?")
  invite_member_link = community_connection_link(container,community,showuser,'invite as member','invitemember',"Invite user to be a community member")

  # special cases
  if(connectaction == 'invitereminder')
    returnstring = 'Sent Reminder'
  else
    connection = showuser.connection_with_community(community)
    case connection

    when 'invitedleader'
      returnstring = "#{rescind_invite_link} #{sendagain_invite_link} #{add_leader_link}"
    when 'invitedmember'
      returnstring = "#{rescind_invite_link} #{sendagain_invite_link} #{add_member_link}"
    when 'wantstojoin'
      returnstring = "#{add_member_link}"
    when 'interest'
      returnstring = "#{invite_member_link}"
    when 'leader'
      returnstring = "#{remove_leader_link}"
    when 'member'
      returnstring = "#{add_leader_link} #{remove_member_link}"
    when 'none'
      returnstring = ''
    else
      returnstring = ''
    end
  end

  returnstring
end

- (Object) get_communitytypes_for_select



29
30
31
32
33
34
35
36
37
# File 'app/helpers/people/communities_helper.rb', line 29

def get_communitytypes_for_select
  returnarray = []
  Community::ENTRYTYPES.keys.sort.each do |key|
    if(Community::ENTRYTYPES[key][:allowadmincreate])
      returnarray << [I18n.translate("communities.#{Community::ENTRYTYPES[key][:locale_key]}"),key]
    end
  end
  returnarray
end


129
130
131
132
133
# File 'app/helpers/people/communities_helper.rb', line 129

def link_shared_tags(shared_tag_list_names)
  shared_tag_list_names.map{|tagname|
    link_to(tagname,:controller=>:communities,:action=> :tags,:taglist=>tagname)
  }.join(Tag::JOINER)
end

- (Object) make_community_userlist_filter_line(community, options = {})



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'app/helpers/people/communities_helper.rb', line 136

def make_community_userlist_filter_line(community,options = {})
  filteredparameters = ParamsFilter.new(User.filteredparameters,params)    
  returntext = '<ul id="usertypes">'
  displayfilter = params[:connectiontype].nil? ? 'all' : params[:connectiontype]
  

  # joined
  if(User.filtered_count(options.merge({:community => community, :connectiontype => 'joined'})) > 0)
    if(displayfilter == 'joined')
      returntext += "<li class='filtered'>Joined</li>"
    else
      returntext += "<li>#{link_to('Joined',userlist_people_community_url(community.id, filteredparameters.option_values_hash.merge({:connectiontype => 'joined'})))}</li>"
    end
  end
  
  # leaders
  if(User.filtered_count(options.merge({:community => community, :connectiontype => 'leaders'})) > 0)
    if(displayfilter == 'leaders')
      returntext += "<li class='filtered'>Leaders</li>"
    else
      returntext += "<li>#{link_to('Leaders',userlist_people_community_url(community.id, filteredparameters.option_values_hash.merge({:connectiontype => 'leaders'})))}</li>"
    end
  end
      
  # members
  if(User.filtered_count(options.merge({:community => community, :connectiontype => 'members'})) > 0)
    if(displayfilter == 'members')
      returntext += "<li class='filtered'>Members</li>"
    else
      returntext += "<li>#{link_to('Members',userlist_people_community_url(community.id, filteredparameters.option_values_hash.merge({:connectiontype => 'members'})))}</li>"
    end
  end
  
  # wantstojoin
  if(community.memberfilter == Community::MODERATED and User.filtered_count(options.merge({:community => community, :connectiontype => 'wantstojoin'})) > 0)
    if(displayfilter == 'wantstojoin')
      returntext += "<li class='filtered'>Wants to Join</li>"
    else
      returntext += "<li>#{link_to('Wants to Join',userlist_people_community_url(community.id, filteredparameters.option_values_hash.merge({:connectiontype => 'wantstojoin'})))}</li>"
    end
  end
  
  # interest
  if(User.filtered_count(options.merge({:community => community, :connectiontype => 'interest'})) > 0)
    if(displayfilter == 'interest')
      returntext += "<li class='filtered'>Interest</li>"
    else
      returntext += "<li>#{link_to('Interest',userlist_people_community_url(community.id, filteredparameters.option_values_hash.merge({:connectiontype => 'interest'})))}</li>"
    end
  end
  
  # invited
  if(User.filtered_count(options.merge({:community => community, :connectiontype => 'invited'})) > 0)
    if(displayfilter == 'invited')
      returntext += "<li class='filtered'>Invited</li>"
    else
      returntext += "<li>#{link_to('Invited',userlist_people_community_url(community.id, filteredparameters.option_values_hash.merge({:connectiontype => 'invited'})))}</li>"
    end
  end
  returntext += '</ul>'
  returntext
end

- (Object) makecommunityusercsvstring(user, community)



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/helpers/people/communities_helper.rb', line 40

def makecommunityusercsvstring(user,community)
   #eXtensionID,First Name,Last Name,Email,Title,Position,Institution,Affiliation,Location,County,Agreement Status,Connection,Account Created,Connection Created,Connection Updated
   csvstring = user.+','
   csvstring += user.first_name.tr(',',' ')+','
   csvstring += user.last_name.tr(',',' ')+','
   csvstring += user.email+','
   csvstring += ((user.phonenumber.nil? or user.phonenumber == '') ? 'not specified' : number_to_phone(user.phonenumber,:area_code => true))+','
   csvstring += ((user.title.nil? or user.title == '') ? 'not specified' : user.title.tr(',',' '))+','
   csvstring += ((user.position.nil? or user.position == '') ? 'not specified' : user.position.name.tr(',',' '))+','
   csvstring += user.primary_institution_name.tr(',',' ')+','
   csvstring += ((user.affiliation.blank?) ? 'not specified' : user.affiliation.tr(',',' '))+','
   csvstring += ((user.location.nil? or user.location == '') ? 'not specified' : user.location.name.tr(',',' '))+','
   csvstring += ((user.county.nil? or user.county == '') ? 'not specified' : user.county.name.tr(',',' '))+','

 	if !user.contributor_agreement.nil?
 	  if user.contributor_agreement 
 	    csvstring += 'Accepted'
 	  else
 	    csvstring += 'Did Not Accept'
 	  end
 	else
    csvstring += 'Not Yet Reviewed'
  end
  
  csvstring += ','
  csvstring += user.connection_display(community)
  
  csvstring += ','
  csvstring += user.created_at.strftime("%Y/%m/%d %H:%M:%S")

  csvstring += ','
  csvstring += user.community_connect_date(community,"created").strftime("%Y/%m/%d %H:%M:%S")
  csvstring += ','
  csvstring += user.community_connect_date(community,"updated").strftime("%Y/%m/%d %H:%M:%S")
  csvstring += ','
  csvstring += community.name
  
  return csvstring
end