From 131729fbfb2ca9a8de7b71cb40bfb7cb7f34fe5c Mon Sep 17 00:00:00 2001 From: Jerry Kuang Date: Mon, 11 May 2026 15:05:57 +0000 Subject: [PATCH] [PURR][#2778]Update the organization setting in author profile --- .../admin/controllers/items.php | 17 +++++- .../language/en-GB/en-GB.com_publications.ini | 1 + .../admin/views/items/tmpl/editauthor.php | 6 ++ .../models/blocks/authors.php | 4 +- .../com_publications/tables/author.php | 26 ++++++--- .../en-GB/en-GB.plg_projects_publications.ini | 1 + .../projects/publications/publications.php | 4 +- .../publications/views/draft/tmpl/authors.php | 4 ++ .../projects/team/assets/js/selector.js | 58 +++++++++++++------ .../en-GB/en-GB.plg_projects_team.ini | 6 +- .../team/views/selector/tmpl/newauthor.php | 18 +++++- 11 files changed, 112 insertions(+), 33 deletions(-) diff --git a/core/components/com_publications/admin/controllers/items.php b/core/components/com_publications/admin/controllers/items.php index c28dfa347c0..d4137f36d57 100644 --- a/core/components/com_publications/admin/controllers/items.php +++ b/core/components/com_publications/admin/controllers/items.php @@ -348,8 +348,21 @@ public function editauthorTask() if (!empty($this->view->author->user_id)) { $user = \Components\Members\Models\Member::oneOrNew($this->view->author->user_id); - $this->view->author->orcid = $user->get('orcid'); - $this->view->author->organization = $user->get('organization'); + + if (empty($this->view->author->organization) && !empty($user->get('organization'))) + { + $this->view->author->organization = $user->get('organization'); + } + + if (empty($this->view->author->orgid) && !empty($user->get('orgid'))) + { + $this->view->author->orgid = $user->get('orgid'); + } + + if (empty($this->view->author->orcid) && !empty($user->get('orcid'))) + { + $this->view->author->orcid = $user->get('orcid'); + } } // Version ID diff --git a/core/components/com_publications/admin/language/en-GB/en-GB.com_publications.ini b/core/components/com_publications/admin/language/en-GB/en-GB.com_publications.ini index 80748a5df83..165f33e7f4e 100644 --- a/core/components/com_publications/admin/language/en-GB/en-GB.com_publications.ini +++ b/core/components/com_publications/admin/language/en-GB/en-GB.com_publications.ini @@ -311,6 +311,7 @@ COM_PUBLICATIONS_EDIT_AUTHOR_INFO="Edit Author Info" COM_PUBLICATIONS_FIELD_AUTHOR_NAME="Author Name" COM_PUBLICATIONS_FIELD_AUTHOR_NAME_FIRST_AND_MIDDLE="First Name (and Middle Initial)" COM_PUBLICATIONS_FIELD_AUTHOR_NAME_LAST="Last Name" +COM_PUBLICATIONS_FIELD_AUTHOR_DEPARTMENT="School or department" COM_PUBLICATIONS_FIELD_AUTHOR_ORGANIZATION="Organization" COM_PUBLICATIONS_FIELD_AUTHOR_ORCID="ORCID" COM_PUBLICATIONS_FIELD_AUTHOR_ORCID_ID_DESC="*ORCID ID is 16-digit" diff --git a/core/components/com_publications/admin/views/items/tmpl/editauthor.php b/core/components/com_publications/admin/views/items/tmpl/editauthor.php index 67dd1d26854..bd1294208c3 100644 --- a/core/components/com_publications/admin/views/items/tmpl/editauthor.php +++ b/core/components/com_publications/admin/views/items/tmpl/editauthor.php @@ -100,6 +100,12 @@ + + + + + + diff --git a/core/components/com_publications/models/blocks/authors.php b/core/components/com_publications/models/blocks/authors.php index 83c36b9ceec..880f1990589 100644 --- a/core/components/com_publications/models/blocks/authors.php +++ b/core/components/com_publications/models/blocks/authors.php @@ -342,9 +342,10 @@ public function addItem($manifest, $blockId, $pub, $actor = 0, $elementId = 0) $config = Component::params('com_publications'); $emailConfig = $config->get('email'); - $email = Request::getString('email', '', 'post'); + $email = trim(Request::getString('email', '', 'post')); $firstName = trim(Request::getString('firstName', '', 'post')); $lastName = trim(Request::getString('lastName', '', 'post')); + $dept = trim(Request::getString('department', '', 'post')); $org = trim(Request::getString('organization', '', 'post')); $orcid = trim(Request::getString('orcid', '', 'post')); $credit = trim(Request::getString('credit', '', 'post')); @@ -465,6 +466,7 @@ public function addItem($manifest, $blockId, $pub, $actor = 0, $elementId = 0) $pAuthor->name = $name; $pAuthor->firstName = $firstName; $pAuthor->lastName = $lastName; + $pAuthor->department = $dept; $pAuthor->organization = $org; $pAuthor->orcid = $orcid; diff --git a/core/components/com_publications/tables/author.php b/core/components/com_publications/tables/author.php index a88c4d4415e..317c2c06578 100644 --- a/core/components/com_publications/tables/author.php +++ b/core/components/com_publications/tables/author.php @@ -312,7 +312,7 @@ public function getAuthors($vid = null, $get_uids = 0, $active = 1, $return_uid_ $res->surname = $user->get('surname'); $res->p_email = $user->get('email'); - if (!empty($user->get('orcid'))) + if (empty($res->orcid) && !empty($user->get('orcid'))) { $res->orcid = $user->get('orcid'); } @@ -688,16 +688,28 @@ public function getAuthorByOwnerId($vid = null, $owner_id = 0) if (!empty($result->user_id)) { $user = \Components\Members\Models\Member::oneOrNew($result->user_id); - $result->p_name = $user->get('name'); $result->username = $user->get('username'); - $result->p_organization = $user->get('organization'); - $result->picture = $user->picture(0, false); + $result->p_name = $user->get('name'); $result->givenName = $user->get('givenName'); $result->surname = $user->get('surname'); - $result->orcid = $user->get('orcid'); $result->p_email = $user->get('email'); - $result->organization = $user->get('organization'); - $result->orgid = $user->get('orgid'); + $result->p_organization = $user->get('organization'); + $result->picture = $user->picture(0, false); + + if (empty($result->orcid) && !empty($user->get('orcid'))) + { + $result->orcid = $user->get('orcid'); + } + + if (empty($result->organization) && !empty($user->get('organization'))) + { + $result->organization = $user->get('organization'); + } + + if (empty($result->orgid) && !empty($user->get('orgid'))) + { + $result->orgid = $user->get('orgid'); + } } else { diff --git a/core/plugins/projects/publications/language/en-GB/en-GB.plg_projects_publications.ini b/core/plugins/projects/publications/language/en-GB/en-GB.plg_projects_publications.ini index e76d40f51e6..9257b1d4c13 100644 --- a/core/plugins/projects/publications/language/en-GB/en-GB.plg_projects_publications.ini +++ b/core/plugins/projects/publications/language/en-GB/en-GB.plg_projects_publications.ini @@ -769,6 +769,7 @@ PLG_PROJECTS_PUBLICATIONS_AUTHOR_REMOVED="Author has been removed." PLG_PROJECTS_PUBLICATIONS_AUTHORS_SELECT_AUTHORS="Select authors from your project team:" PLG_PROJECTS_PUBLICATIONS_AUTHORS_NONE_SELECTED="No authors selected. Click on names on the left to add." PLG_PROJECTS_PUBLICATIONS_PUBLICATION_AUTHORS="Publication Authors" +PLG_PROJECTS_PUBLICATIONS_PUBLICATION_AUTHORS_AS_CONTACT="Edit the author to set the department, organization and email if the author is going to be selected as the contact in the review stage" PLG_PROJECTS_PUBLICATIONS_AUTHORS_MISSING="member not active" PLG_PROJECTS_PUBLICATIONS_PUB_INFO_AUTHORS_MISSING="One or several listed authors appear to have been removed from your project team. While it is OK to proceed with publication when its authors aren't your active team members, these authors will not be able to edit or may not have access to the publication." PLG_PROJECTS_PUBLICATIONS_AUTHORS_EDIT="Edit" diff --git a/core/plugins/projects/publications/publications.php b/core/plugins/projects/publications/publications.php index 15041648c93..2cadbd012f5 100644 --- a/core/plugins/projects/publications/publications.php +++ b/core/plugins/projects/publications/publications.php @@ -2091,7 +2091,7 @@ public function publishDraft() continue; } - // Prompt error message if an invited author is chosen as contact but the email address is empty + // Prompt error message if an invited author is chosen as contact but the department, organization, or email address is empty $owner = $author->getAuthorByOwnerId($pub->version->id, $author->project_owner_id); if ((empty($owner->user_id) && empty($owner->invited_email)) || empty($owner->department) || empty($owner->organization)) @@ -2122,7 +2122,7 @@ public function publishDraft() } elseif (!(empty($owner->user_id) && empty($owner->invited_email)) && !empty($owner->department) && empty($owner->organization)) { - Notify::error(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_ERROR_CONTACT_ORGANIZATION_MISSING'), 'projects'); + Notify::error(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_ERROR_CONTACT_INSTITUTION_MISSING'), 'projects'); } App::redirect(Route::url($pub->link('editversion') . '&action=' . $this->_task)); diff --git a/core/plugins/projects/publications/views/draft/tmpl/authors.php b/core/plugins/projects/publications/views/draft/tmpl/authors.php index 113e565510d..b8cf2d16aa7 100644 --- a/core/plugins/projects/publications/views/draft/tmpl/authors.php +++ b/core/plugins/projects/publications/views/draft/tmpl/authors.php @@ -83,6 +83,10 @@ + + pub->authors()) > 0) { ?> +

*

+ pub->authors()) > 1) { ?>

*

diff --git a/core/plugins/projects/team/assets/js/selector.js b/core/plugins/projects/team/assets/js/selector.js index 522e7b33456..634d9199573 100644 --- a/core/plugins/projects/team/assets/js/selector.js +++ b/core/plugins/projects/team/assets/js/selector.js @@ -335,22 +335,46 @@ $(function(){ appendTo: '#autocomplete-organization', }); } -}); - -$('[name = "orcid"]').on('input', function(){ - var regex = /^[0-9]{4}-([0-9]{4}-){2}[0-9X]{4}/; - var orcidInput = $('[name = "orcid"]').val(); - if (!regex.test(orcidInput)) - { - $('#orcid-message').addClass("prompt"); - $('#orcid-message').text('*Invalid ORCID ID. Please enter the 16-digit ORCID ID'); - $('#orcid-message').show(); - } - else - { - $('#orcid-message').removeClass("prompt"); - $('#orcid-message').text('*You have successfully entered a valid 16-digit ORCID ID'); - $('#orcid-message').show(); + $('[name = "orcid"]').on('input', function(){ + var regex = /^[0-9]{4}-([0-9]{4}-){2}[0-9X]{4}/; + var orcidInput = $('[name = "orcid"]').val(); + + if (!regex.test(orcidInput)) + { + $('#orcid-message').addClass("prompt"); + $('#orcid-message').text('*Invalid ORCID ID. Please enter the 16-digit ORCID ID'); + $('#orcid-message').show(); + } + else + { + $('#orcid-message').removeClass("prompt"); + $('#orcid-message').text('*You have successfully entered a valid 16-digit ORCID ID'); + $('#orcid-message').show(); + } + }) + + if ($(".departmentAvailable")[0]){ + $('[name="department"]').autocomplete({ + source: function(req, resp){ + var deptURL = "index.php?option=com_publications&controller=curation&task=getDepartment&term=" + $('[name="department"]').val(); + + $.ajax({ + url:deptURL, + data: null, + dataType: "json", + success:function(result){ + resp(result); + }, + error:function(jqXHR, textStatus, errorThrown){ + console.log(textStatus); + console.log(errorThrown); + console.log(jqXHR.responseText); + } + }); + }, + + appendTo: '#autocomplete-department' + }); } -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/core/plugins/projects/team/language/en-GB/en-GB.plg_projects_team.ini b/core/plugins/projects/team/language/en-GB/en-GB.plg_projects_team.ini index 65b092e371a..f77cc565f89 100644 --- a/core/plugins/projects/team/language/en-GB/en-GB.plg_projects_team.ini +++ b/core/plugins/projects/team/language/en-GB/en-GB.plg_projects_team.ini @@ -45,14 +45,16 @@ PLG_PROJECTS_TEAM_OR="OR" PLG_PROJECTS_TEAM_SELECTOR_FIRST_NAME="First name" PLG_PROJECTS_TEAM_SELECTOR_LAST_NAME="Last name" PLG_PROJECTS_TEAM_SELECTOR_EMAIL="Email" +PLG_PROJECTS_TEAM_SELECTOR_DEPARTMENT="School or Department" PLG_PROJECTS_TEAM_SELECTOR_ORGANIZATION="Institution" PLG_PROJECTS_TEAM_SELECTOR_ORCID="ORCID" -PLG_PROJECTS_TEAM_SELECTOR_ORCID_DESC="*Please enter the 16-digit ORCID ID" +PLG_PROJECTS_TEAM_SELECTOR_ORCID_DESC="*Please enter the 16-digit ORCID ID only" PLG_PROJECTS_TEAM_SELECTOR_SAVE_NEW="add author" PLG_PROJECTS_TEAM_AUTHORS_EDIT_UNCONFIRMED_TIPS="Name and institution fields are required. You may also provide an email address for the person to send out an invitation to join the publication team." PLG_PROJECTS_TEAM_SELECTOR_AUTHOR_UNCONFIRMED="unconfirmed" PLG_PROJECTS_TEAM_SELECTOR_LOOK_UP_BY_ID="Look up author by name (optional)" -PLG_PROJECTS_TEAM_SELECTOR_HINT="*Name and organization fields are required" +PLG_PROJECTS_TEAM_SELECTOR_FIRST_NAME_REQUIRED="*First name is required" +PLG_PROJECTS_TEAM_SELECTOR_LAST_NAME_REQUIRED="*Last name is required" PLG_PROJECTS_TEAM_SELECTOR_USERID="User ID" PLG_PROJECTS_TEAM_SELECTOR_AUTHOR_NOT_PART_OF_TEAM="Author not part of project team yet?" diff --git a/core/plugins/projects/team/views/selector/tmpl/newauthor.php b/core/plugins/projects/team/views/selector/tmpl/newauthor.php index da9293a494a..548317f75c3 100644 --- a/core/plugins/projects/team/views/selector/tmpl/newauthor.php +++ b/core/plugins/projects/team/views/selector/tmpl/newauthor.php @@ -103,19 +103,34 @@
+
+ +
+
+
"; } ?> -