aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/user/show.rhtml
blob: a3dea619d7a74153a9d28401abf1eb479126fe2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
79
80
81
82
83
84
85
86
87
88
89
90
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
128
129
130
131
132
133
134
135
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<% if @show_requests %>
  <% @title =  _("{{user_name}} - Freedom of Information requests", :user_name => h(@display_user.name)) %>
<% else %>
  <% @title = _("{{user_name}} - user profile", :user_name => h(@display_user.name)) %>
<% end %>

<% if (@same_name_users.size >= 1) %>
    <p><%= _('There is <strong>more than one person</strong> who uses this site and has this name.
    One of them is shown below, you may mean a different one:')%> <% for @same_name_user in @same_name_users %>
        <%= user_link(@same_name_user) %>
    <% end %>
<% end%>

<% if @show_profile && @is_you && @undescribed_requests.size > 0 %>
    <div class="undescribed_requests">
        <p><%= _('Please <strong>go to the following requests</strong>, and let us
        know if there was information in the recent responses to them.')%></p>
        <ul>
        <% for undescribed_request in @undescribed_requests %>
            <li><%=request_link(undescribed_request)%></li>
        <% end %>
        </ul>
        <p>
      <%= _('Thanks very much - this will help others find useful stuff. We\'ll
            also, if you need it, give advice on what to do next about your
            requests.')%>
        </p>
    </div>
<% end %>

<% if @show_profile %>
<div id="user_profile_header">
  <div id="header_right">
     <% if !@track_thing.nil? %>
       <h2><%= _('Track this person')%></h2>
       <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %>
     <% end %>
     <% if !@xapian_requests.nil? %>
       <h2><%= _('On this page')%></h2>
       <a href="#foi_requests"><%= _('FOI requests')%></a>
       <br><a href="#annotations"><%= _('Annotations')%></a>
     <% end %>
  </div>

  <div class="header_left">
    <p id="user_photo_on_profile">
        <% if @display_user.profile_photo %>
            <% if @is_you %>
            <a href="<%= set_profile_photo_url() %>">
            <% end %>
                <img src="<%= get_profile_photo_url(:url_name => @display_user.url_name) %>" alt="">
            <% if @is_you %>
            </a>
            <% end %>
        <% else %>
            <% if @is_you %>
                <span id="set_photo">
                    <%= link_to _('Set your profile photo'), set_profile_photo_path %>
                </span>
            <% end %>
        <% end %>
    </p>

    <h1> <%= h(@display_user.name) + (@is_you ? _(" (you)") : "") %></h1>

    <p class="subtitle">
       <%= _('Joined {{site_name}} in', :site_name=>site_name) %> <%= year_from_date(@display_user.created_at) %>
        <% if !@user.nil? && @user.admin_page_links? %>
        (<%= link_to "admin", admin_user_show_path(@display_user) %>)
        <% end %>
    </p>

    <p>
        <%= link_to _('Send message to ') + h(@display_user.name), contact_user_path(:id => @display_user.id) %>
        <% if @is_you %>
            (<%= _('just to see how it works')%>)
        <% end %>
    </p>

    <% if @display_user.public_banned? %>
        <div id="user_public_banned">
            <p>
                <strong>
                  <%= _('This user has been banned from {{site_name}} ', :site_name=>site_name)%>
                </strong>
            </p>
            <p>
               <%= _('They have been given the following explanation:')%>
            </p>
            <p class="details">
                <%= @display_user.can_fail_html %>
            </p>
        </div>
    <% end %>

    <%= render :partial => 'user/show_user_info' %>

    <% if not @is_you %>
        <p id="user_not_logged_in">
           <%= raw(_('<a href="%s">Sign in</a> to change password, subscriptions and more ({{user_name}} only)',:user_name=>h(@display_user.name)) % [signin_url(:r => request.request_uri)]) %>
        </p>
    <% end %>
  </div>
</div>
<div style="clear:both"></div>
<% end %>

<% if @show_requests %>
<div id="user_profile_search">
    <% form_tag(show_user_url, :method => "get", :id=>"search_form") do %>
    <div>
        <%= text_field_tag(:user_query, params[:user_query], {:title => "type your search term here" }) %>
        <% if @is_you %>
            <%= submit_tag(_("Search your contributions")) %>
        <% else %>
            <%= submit_tag(_("Search contributions by this person")) %>
        <% end %>
    </div>
    <% end %>

    <% if !@xapian_requests.nil? %>
        <% if @xapian_requests.results.empty? %>
            <% if @page == 1 %>
                <h2 class="foi_results" id="foi_requests"><%= @is_you ? _('Freedom of Information requests made by you') : _('Freedom of Information requests made by this person') %> <%= @match_phrase %>
</h2>
                <p><%= @is_you ? _('You have made no Freedom of Information requests using this site.') : _('This person has made no Freedom of Information requests using this site.') %>
                <%= @page_desc %>
            <% end %>
        <% else %>
            <h2 class="foi_results" id="foi_requests">
                <%= @is_you ? n_('Your %d Freedom of Information request', 'Your %d Freedom of Information requests', @xapian_requests.matches_estimated) % @xapian_requests.matches_estimated.to_s : n_('This person\'s %d Freedom of Information request', 'This person\'s %d Freedom of Information requests',  @xapian_requests.matches_estimated) % @xapian_requests.matches_estimated %>
                <!-- matches_estimated <%=@xapian_requests.matches_estimated%> -->
                <%= @match_phrase %>
                <%= @page_desc %>
            </h2>


            <% for result in @xapian_requests.results %>
                <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
            <% end %>

            <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.info_requests.size) %>
        <% end %>
    <% else %>
      <% if @show_requests %>
        <h2 class="foi_results" id="foi_requests"><%= @is_you ? _('Freedom of Information requests made by you') : _('Freedom of Information requests made by this person') %> </h2>
        <p><%= _('The search index is currently offline, so we can\'t show the Freedom of Information requests this person has made.')%></p>
      <% end %>
    <% end %>

    <% if !@xapian_comments.nil? %>
        <% if @xapian_comments.results.empty? %>
            <% if @page == 1 %>
                <h2><%= @is_you ? _('Your annotations') : _('This person\'s annotations') %>
                    <%= @match_phrase %>
                </h2>
                <p><%= _('None made.')%></p>
            <% end %>
        <% else %>
            <h2 id="annotations">
                <%= @is_you ? n_('Your %d annotation', 'Your %d annotations', @display_user.visible_comments.size) % @display_user.visible_comments.size : n_('This person\'s %d annotation', 'This person\'s %d annotations', @display_user.visible_comments.size) % @display_user.visible_comments.size %>
                  <!-- matches_estimated <%=@xapian_comments.matches_estimated%> -->
                <%= @page_desc %>
            </h2>

            <% for result in @xapian_comments.results %>
                <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
            <% end %>

            <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.visible_comments.size) %>
        <% end %>
    <% end %>

</div>
<% end %>
<% if @show_profile && @is_you %>
    <h2 id="email_subscriptions"> <%= _("Things you're following")%></h2>
    <%= render :partial => 'change_receive_email' %>
    <br>
    <% if @track_things.empty? %>
        <p><%= _("You're not following anything.")%></p>
    <% else %>
        <% if @track_things_grouped.size == 1 %>
            <% form_tag({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
                <h3>
                    <%=TrackThing.track_type_description(@track_things[0].track_type)%>
                    <%= hidden_field_tag 'track_type', @track_things[0].track_type %>
                    <%= hidden_field_tag 'user', @display_user.id %>
                    <%= hidden_field_tag 'r', request.request_uri %>
                    <% if @track_things.size > 1 %>
                        <%= submit_tag _('unsubscribe all') %>
                    <% end %>
                </h3>
            <% end %>
        <% end %>
        <% for track_type, track_things in @track_things_grouped %>
            <% if @track_things_grouped.size > 1 %>
                <% form_tag({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
                    <h3>
                        <%=TrackThing.track_type_description(track_type)%>
                        <%= hidden_field_tag 'track_type', track_type %>
                        <%= hidden_field_tag 'user', @display_user.id %>
                        <%= hidden_field_tag 'r', request.request_uri %>
                        <% if track_things.size > 1 %>
                            <%= submit_tag _('unsubscribe all')%>
                        <% end %>
                    </h3>
                <% end %>
            <% end %>

            <ul>
            <% for track_thing in track_things %>
                <li>
                    <% form_tag({:controller => 'track', :action => 'update', :track_id => track_thing.id}, :class => "feed_form") do %>
                        <div>
                            <%= track_thing.params[:list_description] %>
                            <%= hidden_field_tag 'track_medium', "delete", { :id => 'track_medium_' + track_thing.id.to_s } %>
                            <%= hidden_field_tag 'r', request.request_uri, { :id => 'r_' + track_thing.id.to_s }  %>
                            <%= submit_tag _('unsubscribe') %>
                        </div>
                    <% end %>
                </li>
            <% end %>
            </ul>
        <% end %>
    <% end %>
<% end %>