Skip to content

Commit

Permalink
show message in the profile that role in not active
Browse files Browse the repository at this point in the history
  • Loading branch information
ipula committed Feb 11, 2025
1 parent 2ee7e50 commit 911d1b9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
8 changes: 8 additions & 0 deletions classes/userGroup/relationships/UserUserGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,12 @@ public function scopeSortBy(Builder $query, string $column, ?string $direction =
{
return $query->orderBy('user_user_groups.' . $column, $direction);
}

public function scopeWithActiveInFuture(Builder $query): Builder
{
$currentDateTime = Core::getCurrentDate();
return $query->whereNotNull('user_user_groups.date_start')
->where('user_user_groups.date_start', '>', $currentDateTime)
->orderBy('user_user_groups.date_start', 'asc');
}
}
6 changes: 6 additions & 0 deletions locale/en/user.po
Original file line number Diff line number Diff line change
Expand Up @@ -801,3 +801,9 @@ msgstr "This ORCID has not been verified. Please remove this unverified ORCID an

msgid "user.removeRole.message"
msgstr "Are you sure want remove this role permanently?"

msgid "user.futureRole.notification.message"
msgstr "Your role is scheduled to begin on "

msgid "user.futureRole.notification.description"
msgstr "Until then, you can review and update your profile. If you believe this is an error, please contact journal administrator."
13 changes: 12 additions & 1 deletion pages/user/ProfileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use PKP\core\PKPRequest;
use PKP\security\authorization\PKPSiteAccessPolicy;
use PKP\security\authorization\UserRequiredPolicy;
use PKP\userGroup\relationships\UserUserGroup;

class ProfileHandler extends UserHandler
{
Expand Down Expand Up @@ -58,8 +59,9 @@ public function authorize($request, &$args, $roleAssignments)
public function profile($args, $request)
{
$context = $request->getContext();
$user = $request->getUser();
$date_start = null;
if (!$context) {
$user = $request->getUser();
$contextDao = Application::getContextDAO();
$workingContexts = $contextDao->getAvailable($user ? $user->getId() : null);
[$firstContext, $secondContext] = [$workingContexts->next(), $workingContexts->next()];
Expand All @@ -74,11 +76,20 @@ public function profile($args, $request)
$request->redirect(null, null, null, null, null, $anchor);
}

if(count($user->getRoles($context->getId())) === 0){
$userFutureRoleStartDate = UserUserGroup::withUserId($user->getId())
->withActiveInFuture()
->pluck('date_start')
->first();
$date_start = new \DateTime($userFutureRoleStartDate);
}

$this->setupTemplate($request);

$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign([
'pageTitle' => __('user.profile'),
'userFutureRoleStartDate'=> $date_start?->format('Y-m-d'),
]);
$templateMgr->display('user/profile.tpl');
}
Expand Down
6 changes: 6 additions & 0 deletions templates/user/profile.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
{extends file="layouts/backend.tpl"}

{block name="page"}
{if $userFutureRoleStartDate}
<Notification>
<h2 class="text-3xl-bold text-heading"> {translate key="user.futureRole.notification.message"} {$userFutureRoleStartDate}</h2>
<p> {translate key="user.futureRole.notification.description"}</p>
</Notification>
{/if}
<h1 class="app__pageHeading">
{translate key="user.profile"}
</h1>
Expand Down

0 comments on commit 911d1b9

Please sign in to comment.