Skip to content

Commit

Permalink
[PURR][#2549]Add ORCID text field for co-author of publications (#1726)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuang5 authored Jul 20, 2024
1 parent 647caf0 commit b769812
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 18 deletions.
7 changes: 7 additions & 0 deletions core/components/com_publications/admin/controllers/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
<input type="text" name="organization" value="<?php echo $this->escape($this->author->organization); ?>" size="25" />
</td>
</tr>
<tr>
<td class="key"><label><?php echo Lang::txt('COM_PUBLICATIONS_FIELD_AUTHOR_ORCID'); ?>:</label></td>
<td>
<input type="text" name="orcid" value="<?php echo $this->escape($this->author->orcid); ?>" size="25" />
</td>
</tr>
<tr>
<td class="key"><label><?php echo Lang::txt('COM_PUBLICATIONS_FIELD_AUTHOR_CREDIT'); ?>:</label></td>
<td>
Expand Down
4 changes: 4 additions & 0 deletions core/components/com_publications/models/blocks/authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down
56 changes: 38 additions & 18 deletions core/components/com_publications/tables/author.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
}
Expand Down Expand Up @@ -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;
}

/**
Expand Down
40 changes: 40 additions & 0 deletions core/migrations/Migration20240716193359ComPublications.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @package hubzero-cms
* @copyright Copyright (c) 2005-2020 The Regents of the University of California.
* @license http://opensource.org/licenses/MIT MIT
*/

use Hubzero\Content\Migration\Base;

/**
* Migration script for ...
**/
class Migration20240716193359ComPublications extends Base
{
/**
* Up
**/
public function up()
{
if ($this->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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@
</label>
<div class="clear"></div>
<?php } ?>
<label for="orcid">
<span class="leftshift faded"><?php echo Lang::txt('PLG_PROJECTS_PUBLICATIONS_AUTHORS_ORCID_ID'); ?>:</span>
<input type="text" name="orcid" class="long" value="<?php echo $author->orcid; ?>" maxlength="255"/><span class="optional"><?php echo Lang::txt('OPTIONAL'); ?></span>
</label>
<div class="clear"></div>
<label for="credit">
<span class="leftshift faded"><?php echo ucfirst(Lang::txt('PLG_PROJECTS_PUBLICATIONS_AUTHORS_AUTHOR_CREDIT')); ?>:</span>
<input type="text" name="credit" class="long" value="<?php echo htmlspecialchars($author->credit); ?>" maxlength="255" /><span class="optional"><?php echo Lang::txt('OPTIONAL'); ?></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ 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_ORGANIZATION="Institution"
PLG_PROJECTS_TEAM_SELECTOR_ORCID="ORCID"
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"
Expand Down
8 changes: 8 additions & 0 deletions core/plugins/projects/team/views/selector/tmpl/newauthor.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@
</label>
</div>
</div>
<div class="block">
<div class="block-liner">
<label for="orcid">
<span class="formlabel"><?php echo Lang::txt('PLG_PROJECTS_TEAM_SELECTOR_ORCID'); ?></span>
<input type="text" name="orcid" id="orcid" value="" maxlength="255" /><span class="optional"><?php echo Lang::txt('OPTIONAL'); ?></span>
</label>
</div>
</div>
<?php if (!$this->model->isProvisioned()) { ?>
<div class="block">
<p class="invite-question"><?php echo ucfirst(Lang::txt('PLG_PROJECTS_TEAM_SELECTOR_INVITE_TO_TEAM')); ?></p>
Expand Down

0 comments on commit b769812

Please sign in to comment.