diff --git a/core/components/com_publications/admin/controllers/items.php b/core/components/com_publications/admin/controllers/items.php index c28dfa347c0..e17a59b5f6b 100644 --- a/core/components/com_publications/admin/controllers/items.php +++ b/core/components/com_publications/admin/controllers/items.php @@ -334,23 +334,18 @@ public function addauthorTask() public function editauthorTask() { // Incoming - $author = Request::getInt('author', 0); + $author_id = Request::getInt('author', 0); $this->view->setLayout('editauthor'); - $this->view->author = new Tables\Author($this->database); - if ($this->_task == 'editauthor' && !$this->view->author->load($author)) + $authorTblObj = new Tables\Author($this->database); + $this->view->author = $authorTblObj->getAuthorById($author_id); + + if ($this->_task == 'editauthor' && !$this->view->author) { 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 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/_selectauthors.php b/core/components/com_publications/admin/views/items/tmpl/_selectauthors.php index 7db9a2c91a6..ba9fa4ad91b 100644 --- a/core/components/com_publications/admin/views/items/tmpl/_selectauthors.php +++ b/core/components/com_publications/admin/views/items/tmpl/_selectauthors.php @@ -20,16 +20,25 @@ { $authIDs[] = $authname->id; $name = $authname->name; - - $org = ($authname->organization) - ? $this->escape($authname->organization) : ''; + $dept = $authname->department; + $org = $authname->organization ? $authname->organization : $authname->p_organization; + $email = $authname->p_email ? $authname->p_email : $authname->invited_email; $credit = ($authname->credit) ? $this->escape($authname->credit) : ''; $userid = $authname->user_id ? $authname->user_id : 'unregistered'; $html .= "\t".'
  • ' . '' . $i . '. ' . $name . ' (' . $userid . ')'; - $html .= $org ? ' - ' . $org . '' : ''; + + if ($authname->repository_contact == 1 && !empty($dept) && !empty($org) && !empty($email)) + { + $html .= ' - ' . $dept . ' - ' . $org . ' - ' . $email . ''; + } + else + { + $html .= $org ? ' - ' . $org . '' : ''; + } + $html .= ' ' . Lang::txt('COM_PUBLICATIONS_EDIT') . ' '; $html .= ' ' . Lang::txt('COM_PUBLICATIONS_DELETE') . ' '; if ($credit) 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..607ce9d3ab0 100644 --- a/core/components/com_publications/admin/views/items/tmpl/editauthor.php +++ b/core/components/com_publications/admin/views/items/tmpl/editauthor.php @@ -34,6 +34,7 @@ $firstname = $this->author->firstName ? htmlspecialchars($this->author->firstName) : $firstname; $lastname = $this->author->lastName ? htmlspecialchars($this->author->lastName) : $lastname; +$email = $this->author->p_email ? $this->author->p_email : $this->author->invited_email; ?> @@ -100,12 +101,24 @@ + + + + + + + + + + + + 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..c6c39e36b06 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,85 @@ 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_name = $user->get('name'); + $result->givenName = $user->get('givenName'); + $result->surname = $user->get('surname'); + $result->p_email = $user->get('email'); $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 + { + $result->p_name = $result->username = $result->p_organization = $result->picture = $result->givenName = $result->surname = $result->p_email = null; + } + + return $result; + } + + /** + * Get record by author ID + * + * @param integer $id Author ID + * @return mixed False if error, Object on success + */ + public function getAuthorById($id = 0) + { + if (!$id) + { + return false; + } + $query = "SELECT A.*, po.invited_email, po.invited_name"; + $query .= " FROM #__project_owners as po "; + $query .= " LEFT JOIN $this->_tbl as A ON po.id=A.project_owner_id"; + $query .= " AND A.status=1 "; + $query .= " WHERE A.id=" . $this->_db->quote($id); + $query .= " AND (A.role IS NULL OR A.role != 'submitter') "; + $query .= " LIMIT 1 "; + + $this->_db->setQuery($query); + $result = $this->_db->loadObject(); + + if (!empty($result->user_id)) + { + $user = \Components\Members\Models\Member::oneOrNew($result->user_id); + $result->username = $user->get('username'); + $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/publications/views/freeze/tmpl/authors.php b/core/plugins/projects/publications/views/freeze/tmpl/authors.php index 76ee31e4b61..952427f6ea1 100644 --- a/core/plugins/projects/publications/views/freeze/tmpl/authors.php +++ b/core/plugins/projects/publications/views/freeze/tmpl/authors.php @@ -27,7 +27,9 @@ $i= 1; foreach ($this->pub->_authors as $author) { + $dept = $author->department; $org = $author->organization ? $author->organization : $author->p_organization; + $email = $author->p_email ? $author->p_email : $author->invited_email; $name = $author->name ? $author->name : $author->p_name; $name = trim($name) ? $name : $author->invited_name; $name = trim($name) ? $name : $author->invited_email; @@ -39,7 +41,13 @@ ?>
  • - + + repository_contact == 1 && !empty($dept) && !empty($org) && !empty($email)) { ?> + + + + +
  • *: +

    +
    + +
    +
    +
    "; } ?> -