diff --git a/core/components/com_publications/admin/controllers/items.php b/core/components/com_publications/admin/controllers/items.php index 5f1bfe5ef88..d1903bd9d8d 100644 --- a/core/components/com_publications/admin/controllers/items.php +++ b/core/components/com_publications/admin/controllers/items.php @@ -338,6 +338,13 @@ public function editauthorTask() throw new Exception(Lang::txt('COM_PUBLICATIONS_ERROR_NO_AUTHOR_RECORD'), 404); return; } + + 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'); + } // Version ID $vid = Request::getInt('vid', $this->view->author->publication_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 63b0a308d8c..1af1528e9fc 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 @@ -308,6 +308,7 @@ 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_ORGANIZATION="Organization" +COM_PUBLICATIONS_FIELD_AUTHOR_ORCID="ORCID" COM_PUBLICATIONS_REPACKAGE="Repackage" COM_PUBLICATIONS_PRODUCE_ARCHIVAL="produce archival package" 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 7200ffa9156..32f2e72353c 100644 --- a/core/components/com_publications/admin/views/items/tmpl/editauthor.php +++ b/core/components/com_publications/admin/views/items/tmpl/editauthor.php @@ -106,6 +106,12 @@ + + + + + + diff --git a/core/components/com_publications/models/blocks/authors.php b/core/components/com_publications/models/blocks/authors.php index 2d812f289d4..d13d83d58ab 100644 --- a/core/components/com_publications/models/blocks/authors.php +++ b/core/components/com_publications/models/blocks/authors.php @@ -346,6 +346,7 @@ public function addItem($manifest, $blockId, $pub, $actor = 0, $elementId = 0) $firstName = trim(Request::getString('firstName', '', 'post')); $lastName = trim(Request::getString('lastName', '', 'post')); $org = trim(Request::getString('organization', '', 'post')); + $orcid = trim(Request::getString('orcid', '', 'post')); $credit = trim(Request::getString('credit', '', 'post')); $uid = trim(Request::getInt('uid', 0, 'post')); @@ -465,6 +466,7 @@ public function addItem($manifest, $blockId, $pub, $actor = 0, $elementId = 0) $pAuthor->firstName = $firstName; $pAuthor->lastName = $lastName; $pAuthor->organization = $org; + $pAuthor->orcid = $orcid; // Get organization id on ror.org // If RoR Api is turned off because of failed API or if key doesn't exist, don't retrieve list from Api. @@ -555,6 +557,7 @@ public function saveItem($manifest, $blockId, $pub, $actor = 0, $elementId = 0, $firstName = Request::getString('firstName', '', 'post'); $lastName = Request::getString('lastName', '', 'post'); $org = Request::getString('organization', '', 'post'); + $orcid = Request::getString('orcid', '', 'post'); $credit = Request::getString('credit', '', 'post'); $sendInvite = 0; $code = \Components\Projects\Helpers\Html::generateCode(); @@ -584,6 +587,7 @@ public function saveItem($manifest, $blockId, $pub, $actor = 0, $elementId = 0, $row->credit = $credit; $row->modified_by = $actor; $row->modified = Date::toSql(); + $row->orcid = $orcid; // Check that profile exists if ($uid) diff --git a/core/components/com_publications/tables/author.php b/core/components/com_publications/tables/author.php index 043927b6eec..985a614e665 100644 --- a/core/components/com_publications/tables/author.php +++ b/core/components/com_publications/tables/author.php @@ -310,14 +310,22 @@ public function getAuthors($vid = null, $get_uids = 0, $active = 1, $return_uid_ $res->givenName = $user->get('givenName'); $res->middleName = $user->get('middleName'); $res->surname = $user->get('surname'); - $res->orcid = $user->get('orcid'); $res->p_email = $user->get('email'); - } - - if ($res->user_id) - { - $res->organization = $user->get('organization'); - $res->orgid = $user->get('orgid'); + + if (!empty($user->get('orcid'))) + { + $res->orcid = $user->get('orcid'); + } + + if (!empty($user->get('organization'))) + { + $res->organization = $user->get('organization'); + } + + if (!empty($user->get('orgid'))) + { + $res->orgid = $user->get('orgid'); + } } } } @@ -514,26 +522,38 @@ public function getAuthorByOwnerId($vid = null, $owner_id = 0) { return false; } - - $query = "SELECT A.*, po.invited_email as invited_email, po.invited_name as invited_name, "; - $query .= "x.name as p_name, x.username, x.organization as p_organization, - x.picture, x.surname, x.givenName, x.orcid, "; - $query .= " COALESCE(A.name , x.name) as name, x.username, - COALESCE(A.organization , x.organization) as organization, "; - $query .= " COALESCE(A.firstName, x.givenName) firstName, "; - $query .= " COALESCE(A.lastName, x.surname) lastName "; + $query = "SELECT A.*, po.invited_email as invited_email, po.invited_name as invited_name "; $query .= " FROM #__project_owners as po "; $query .= " LEFT JOIN $this->_tbl as A ON po.id=A.project_owner_id AND A.publication_version_id=" . $this->_db->quote($vid); - $query .= " LEFT JOIN #__xprofiles as x ON x.uidNumber=po.userid "; $query .= " AND po.status!=2 "; $query .= " WHERE po.id=" . $this->_db->quote($owner_id); $query .= " AND (A.role IS NULL OR A.role != 'submitter') "; $query .= " LIMIT 1 "; $this->_db->setQuery($query); - $result = $this->_db->loadObjectList(); - return $result ? $result[0] : false; + $result = $this->_db->loadObject(); + + 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->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'); + } + else + { + $result->p_name = $result->username = $result->p_organization = $result->picture = $result->givenName = $result->surname = $result->p_email = null; + } + + return $result; } /** diff --git a/core/migrations/Migration20240716193359ComPublications.php b/core/migrations/Migration20240716193359ComPublications.php new file mode 100644 index 00000000000..dc63928ac30 --- /dev/null +++ b/core/migrations/Migration20240716193359ComPublications.php @@ -0,0 +1,40 @@ +db->tableExists('#__publication_authors') && !$this->db->tableHasField('#__publication_authors', 'orcid')) + { + $query = "ALTER TABLE `#__publication_authors` ADD COLUMN `orcid` VARCHAR(50) NULL DEFAULT NULL"; + $this->db->setQuery($query); + $this->db->query(); + } + } + + /** + * Down + **/ + public function down() + { + if ($this->db->tableExists('#__publication_authors') && $this->db->tableHasField('#__publication_authors', 'orcid')) + { + $query = "ALTER TABLE `#__publication_authors` DROP COLUMN `orcid`"; + $this->db->setQuery($query); + $this->db->query(); + } + } +} 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 ea604fe82f8..8cbeca92af3 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 @@ -782,6 +782,7 @@ PLG_PROJECTS_PUBLICATIONS_AUTHORS_HINT_DRAG="Re-order authors by dragging" PLG_PROJECTS_PUBLICATIONS_AUTHORS_AUTHOR_FIRST_NAME="First name" PLG_PROJECTS_PUBLICATIONS_AUTHORS_AUTHOR_LAST_NAME="Last name" PLG_PROJECTS_PUBLICATIONS_AUTHORS_AUTHOR_EMAIL="Email" +PLG_PROJECTS_PUBLICATIONS_AUTHORS_ORCID_ID="ORCID" PLG_PROJECTS_PUBLICATIONS_AUTHORS_EDIT_UNCONFIRMED_TIPS="*Name and institution fields are required. You may also provide an email address and send out an invitation to register and join the publication team." PLG_PROJECTS_PUBLICATIONS_AUTHORS_NO_NAME="no name" PLG_PROJECTS_PUBLICATIONS_SUBMITTER="Submitter" diff --git a/core/plugins/projects/publications/views/edititem/tmpl/author.php b/core/plugins/projects/publications/views/edititem/tmpl/author.php index 8fbcaf105ac..419a54ac29e 100644 --- a/core/plugins/projects/publications/views/edititem/tmpl/author.php +++ b/core/plugins/projects/publications/views/edititem/tmpl/author.php @@ -98,6 +98,11 @@
+ +
+
+
+ +
+
model->isProvisioned()) { ?>