Wiki source code of ユーザープロフィール

Version 1.1 by Super Admin on 2026/03/05 22:05

Show last authors
1 {{velocity}}
2 ## ===== ユーザー公開プロフィール =====
3 ## 他ユーザーが閲覧するための公開プロフィールページ。
4 ## 本名・メールアドレス・警告状態は非公開。displayNameのみ表示。
5 ##
6 ## 使い方: SeitokaiCode.UserProfile?user=XWiki.Username でアクセス
7 ## または各投稿の作者名リンクから遷移。
8
9 #set($targetUser = $request.user)
10 #if(!$targetUser || $targetUser == '')
11 {{warning}}ユーザーが指定されていません。{{/warning}}
12 #else
13
14 #set($targetDoc = $xwiki.getDocument($targetUser))
15 #if(!$targetDoc || !$targetDoc.exists())
16 {{error}}指定されたユーザーが見つかりません。{{/error}}
17 #else
18
19 #set($profileDisplayName = $!targetDoc.getValue('displayName'))
20 #if(!$profileDisplayName || $profileDisplayName == '')
21 #set($profileDisplayName = $xwiki.getUserName($targetUser))
22 #end
23 #set($profileAccountType = $!targetDoc.getValue('accountType'))
24 #set($profileUserRole = $!targetDoc.getValue('userRole'))
25 #set($profileUserStatus = $!targetDoc.getValue('userStatus'))
26 #set($profileSchoolCode = $!targetDoc.getValue('schoolCode'))
27 #set($profileSchoolName = $!targetDoc.getValue('schoolName'))
28 #set($profileEnrollmentYear = $!targetDoc.getValue('enrollmentYear'))
29
30 ## --- 学年の動的計算(学校種別対応) ---
31 #set($profileGrade = '')
32 #if($profileEnrollmentYear && $profileEnrollmentYear != '' && $profileUserRole == 'student')
33 #set($now = $datetool.date)
34 #set($currentYear = $datetool.format('yyyy', $now))
35 #set($currentMonth = $datetool.format('MM', $now))
36 #set($currentYearInt = $mathtool.toInteger($currentYear))
37 #set($currentMonthInt = $mathtool.toInteger($currentMonth))
38 #set($enrollYearInt = $mathtool.toInteger($profileEnrollmentYear))
39 #if($currentMonthInt >= 4)
40 #set($schoolYear = $currentYearInt)
41 #else
42 #set($schoolYear = $mathtool.sub($currentYearInt, 1))
43 #end
44 ## 学校種別から在学年数を判定
45 #set($profileMaxYears = 3)
46 #if($profileSchoolCode && $profileSchoolCode.length() >= 2)
47 #set($profileSchoolType = $profileSchoolCode.substring(0, 2))
48 #if($profileSchoolType == 'C2')
49 #set($profileMaxYears = 9)
50 #elseif($profileSchoolType == 'D2')
51 #set($profileMaxYears = 6)
52 #end
53 #end
54 #set($gradeNum = $mathtool.add($mathtool.sub($schoolYear, $enrollYearInt), 1))
55 #if($gradeNum >= 1 && $gradeNum <= $profileMaxYears)
56 #set($profileGrade = "${gradeNum}年生")
57 #elseif($gradeNum > $profileMaxYears)
58 #set($profileGrade = "卒業生")
59 #end
60 #end
61
62 ## --- 自分自身のプロフィールならマイページにリダイレクト ---
63 #if($targetUser == $xcontext.user)
64 $response.sendRedirect($xwiki.getURL("SeitokaiCode.MyPage", "view"))
65 #end
66
67 = <svg class="ico" style="width:1.1em;height:1.1em;vertical-align:-0.15em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg> $profileDisplayName =
68
69 {{html clean="false"}}
70 <div class="seitokai-badge-container">
71 #if($profileAccountType == 'admin')
72 <span class="badge badge-admin"><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 管理者</span>
73 #elseif($profileAccountType == 'verified')
74 <span class="badge badge-verified"><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg> 承認済み</span>
75 #elseif($profileAccountType == 'referred')
76 <span class="badge badge-referred"><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg> 紹介</span>
77 #else
78 <span class="badge badge-general">一般</span>
79 #end
80 #if($profileUserRole == 'student')
81 <span class="badge badge-role-student"><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 10l-10-5L2 10l10 5 10-5z"/><path d="M6 12v5c0 1.66 2.69 3 6 3s6-1.34 6-3v-5"/></svg> 生徒</span>
82 #elseif($profileUserRole == 'teacher')
83 <span class="badge badge-role-teacher"><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5A2.5 2.5 0 016.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z"/></svg> 教員</span>
84 #elseif($profileUserRole == 'graduate')
85 <span class="badge badge-role-graduate"><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 10l-10-5L2 10l10 5 10-5z"/><path d="M6 12v5c0 1.66 2.69 3 6 3s6-1.34 6-3v-5"/></svg> 卒業生</span>
86 #end
87 #if($profileGrade && $profileGrade != '')
88 <span class="badge badge-grade">$profileGrade</span>
89 #end
90 #if($profileUserStatus == 'graduated')
91 <span class="badge badge-status-graduated"><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 10l-10-5L2 10l10 5 10-5z"/><path d="M6 12v5c0 1.66 2.69 3 6 3s6-1.34 6-3v-5"/></svg> 卒業済み</span>
92 #elseif($profileUserStatus == 'on_leave')
93 <span class="badge badge-status-onleave"><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg> 休学中</span>
94 #elseif($profileUserStatus == 'transferred')
95 <span class="badge badge-status-transferred"><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"/></svg> 転校済み</span>
96 #end
97 </div>
98 {{/html}}
99
100 == プロフィール ==
101
102 {{html clean="false"}}
103 <div class="school-info-card">
104 <h2><svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg> 公開情報</h2>
105 <table class="wiki-table school-info-table">
106 <tr><th>表示名</th><td><strong>$profileDisplayName</strong></td></tr>
107 <tr><th>アカウント種別</th><td>
108 #if($profileAccountType == 'admin')管理者
109 #elseif($profileAccountType == 'verified')承認済み
110 #elseif($profileAccountType == 'referred')紹介
111 #else一般#end
112 </td></tr>
113 <tr><th>役割</th><td>
114 #if($profileUserRole == 'student')生徒
115 #elseif($profileUserRole == 'teacher')教員
116 #elseif($profileUserRole == 'graduate')卒業生
117 #else$!profileUserRole#end
118 </td></tr>
119 <tr><th>所属校</th><td>
120 #if($profileSchoolCode && $profileSchoolCode != '')
121 <a href="/xwiki/bin/view/Schools/${profileSchoolCode}/WebHome">$!profileSchoolName</a>
122 #else
123 未公開
124 #end
125 </td></tr>
126 #if($profileUserRole == 'student' && $profileGrade != '')
127 <tr><th>学年</th><td>$profileGrade</td></tr>
128 #end
129 <tr><th>在籍状態</th><td>
130 #if($profileUserStatus == 'active')在籍中
131 #elseif($profileUserStatus == 'graduated')卒業済み
132 #elseif($profileUserStatus == 'on_leave')休学中
133 #elseif($profileUserStatus == 'transferred')転校済み
134 #else$!profileUserStatus#end
135 </td></tr>
136 </table>
137 </div>
138 {{/html}}
139
140 == このユーザーの投稿・編集履歴 ==
141
142 {{velocity}}
143 #set($query = $services.query.xwql("where doc.author = '${targetUser}' order by doc.date desc"))
144 #set($query = $query.setLimit(20))
145 #set($results = $query.execute())
146
147 #if($results.size() > 0)
148 |=ページ|=日時
149 #foreach($docName in $results)
150 #set($actDoc = $xwiki.getDocument($docName))
151 |[[$actDoc.title>>$docName]]|$xwiki.formatDate($actDoc.date, "yyyy/MM/dd HH:mm")
152 #end
153 #else
154 //このユーザーの公開投稿はまだありません。//
155 #end
156 {{/velocity}}
157
158 {{html clean="false"}}
159 <div style="margin-top:24px; padding:14px 18px; background:#f4f5fb; border-radius:8px; font-size:0.85em; color:#4a4e6a; text-align:center;">
160 <svg class="ico" style="width:1em;height:1em;vertical-align:-0.125em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg> 本名・メールアドレス・警告状態などの個人情報は非公開です
161 </div>
162 {{/html}}
163
164 #end
165 #end
166 {{/velocity}}