Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Able to view the list of users associated with an Organization #8511

Merged
merged 12 commits into from
Jun 14, 2023
8 changes: 8 additions & 0 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3898,6 +3898,14 @@ HTML
$user_template_data_ref->{edit_profile} = 1;
$user_template_data_ref->{orgid} = $orgid;
}
if (defined $User{pro_moderator}) {
my @org_members;
foreach my $member_id (keys %{$user_or_org_ref->{members}}) {
MonalikaPatnaik marked this conversation as resolved.
Show resolved Hide resolved
my $member_details = retrieve_user($member_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a convention, when a variable is an object reference, we suffix it with _ref. Coul you rename $member_details to $member_user_ref or similar?

push @org_members, $member_details;
}
$user_template_data_ref->{org_members} = \@org_members;
}

process_template('web/pages/org_profile/org_profile.tt.html',
$user_template_data_ref, \$profile_html)
Expand Down
10 changes: 10 additions & 0 deletions lib/ProductOpener/Users.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ BEGIN {
&is_admin_user
&create_password_hash
&check_password_hash
&retrieve_user

&check_session

Expand Down Expand Up @@ -921,6 +922,15 @@ sub open_user_session ($user_ref, $request_ref) {
return;
}

sub retrieve_user ($user_id) {
my $user_file = "$data_root/users/" . get_string_id_for_lang("no_language", $user_id) . ".sto";
my $user_ref;
if (-e $user_file) {
$user_ref = retrieve($user_file);
}
return $user_ref;
}

sub init_user ($request_ref) {

my $user_id = undef;
Expand Down
32 changes: 32 additions & 0 deletions po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5039,6 +5039,38 @@ msgctxt "official_site"
msgid "Official site"
msgstr "Official site"

msgctxt "organization_members"
msgid "Organization Members"
msgstr "Organization Members"

msgctxt "number_of_members"
msgid "Number of Members"
msgstr "Number of Members"

msgctxt "serial_no"
msgid "S.No"
msgstr "S.No"

msgctxt "member_userid"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have strings for "Name", "Email", "Country", "Language" etc. in the .po file, so we can reuse them without adding new translation strings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okayy..will make the changes👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "member_userid" can you use the existing "username" string?

msgid "UserId"
msgstr "UserId"

msgctxt "member_name"
msgid "Name"
msgstr "Name"

msgctxt "email"
msgid "Email"
msgstr "Email"

msgctxt "member_language"
msgid "Language"
msgstr "Language"

msgctxt "member_country"
msgid "Country"
msgstr "Country"

msgctxt "contact_form"
msgid "Contact form"
msgstr "Contact form"
Expand Down
32 changes: 32 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -5076,6 +5076,38 @@ msgctxt "official_site"
msgid "Official site"
msgstr "Official site"

msgctxt "organization_members"
msgid "Organization Members"
msgstr "Organization Members"

msgctxt "number_of_members"
msgid "Number of Members"
msgstr "Number of Members"

msgctxt "serial_no"
msgid "S.No"
msgstr "S.No"

msgctxt "member_userid"
msgid "UserId"
msgstr "UserId"

msgctxt "member_name"
msgid "Name"
msgstr "Name"

msgctxt "email"
msgid "Email"
msgstr "Email"

msgctxt "member_language"
msgid "Language"
msgstr "Language"

msgctxt "member_country"
msgid "Country"
msgstr "Country"

msgctxt "contact_form"
msgid "Contact form"
msgstr "Contact form"
Expand Down
31 changes: 31 additions & 0 deletions templates/web/pages/org_profile/org_profile.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@
<p>&rarr; <a href="[% link %]">[% lang("official_site") %]</a></p>
[% END %]

[% IF org_members.size %]
<h2>[% lang("organization_members") %]</h2>
<p>[% lang("number_of_members") %]: [% org_members.size %]</p>
MonalikaPatnaik marked this conversation as resolved.
Show resolved Hide resolved
<div style="position:relative">
<table id="org_member_table" class="data_table" style="[% tablestyle %];">
<tr>
<th>[% lang("serial_no") %]</th>
<th>[% lang("member_userid") %]</th>
<th>[% lang("member_name") %]</th>
<th>[% lang("email") %]</th>
<th>[% lang("member_language") %]</th>
<th>[% lang("member_country") %]</th>

</tr>
[% SET count = 1 %]
[% FOREACH users IN org_members %]
<tr>
<td>[% count %]</td>
<td>[% users.userid %]</td>
<td>[% users.name %]</td>
<td>[% users.email %]</td>
<td>[% users.initial_lc %]</td>
<td>[% users.initial_cc %]</td>
</tr>
[% SET count = count + 1 %]
[% END %]
</table>
</div>
[% END %]


<div class="row">

[% FOREACH contact IN ['customer_service', 'commercial_service'] %]
Expand Down