What is the function that gets the list of articles of an issue?

I am working on an email notification that contains the list of contents of the article.

I have somewhat worked backwards through the databases, so I could use simple PHP requests, but then if OJS changes the database structure, I would need to do everything again.

I am going through the code to see which php function is used to get the list of articles - I have found the smarty template, but not the DAO

Could someone help?

Thanks

Stephen

Hi @ssciberras

What OJS version are you using?
For OJS 3.1.1:
Maybe you can take a look into the function _setupIssueTemplate here: ojs/IssueHandler.inc.php at ojs-stable-3_1_1 · pkp/ojs · GitHub.
Roughly: you would use

$publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
$publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true);

to get the published articles for that issue and organized in sections.
Ans you can take a look in this template to see how they are presented in OJS, in the issue TOC: ojs/issue_toc.tpl at ojs-stable-3_1_1 · pkp/ojs · GitHub.

Let me know if you would need any further help


Best,
Bozana

Thanks

I was just looking into those sections.

Now I need to see how to integrate everything so far


I wish to call a modal window, which would contain a smarty template, with the table of contents. I would like to incorporate this as a plugin, but first i will try with direct modification of the system.

thanks

stephen

I am quite close to achieving what I wanted.

One step is eluding me: what is $request, and how do I obtain it to pass it to a function.

Thanks

sTephen

Hi @ssciberras

It depends where/how you use it, but maybe also $request = Application::getRequest(); can help

Best,
Bozana

Thanks

I have just tried that, and it works. Now I’ll see what is the next step.

But now again stuck, this time on
PHP Fatal error: Call to a member function getAuthorizedContextObject() on null in
l/lib/pkp/classes/handler/PKPHandler.inc.php on line 140

My code is as follows:

import(‘classes.article.PublishedArticleDAO’);
import (‘classes.issue.IssueAction’);
import(‘classes.handler.Handler’);
//define(‘ASSOC_TYPE_ISSUE’, 0x0000103);

$publishedArticles = array();
$publishedArticleDao = DAORegistry::getDAO(‘PublishedArticleDAO’);

$publishedArticles = $publishedArticleDao->getPublishedArticlesInSections(4 );
echo “test”;

$request = Application::getRequest();
class IssueHandler extends Handler {
function current($args, $request) {
echo " trial3";
$issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
echo " trial3";
$this->setupTemplate($request);
$templateMgr = TemplateManager::getManager($request);
$journal = $request->getJournal();

	$this->setupTemplate($request);
	$templateMgr = TemplateManager::getManager($request);
	$templateMgr->assign('issueId', 4);
	
	$templateMgr->display('frontend/pages/issue_toc.tpl');
}

$test = new IssueHandler;
$args = array (“4”);
$test->current( $args, $request);
?>

I am definitely missing a step


Stephen

Hi @ssciberras

Hmmm
 What exactly are you trying to do? – I see you are changing the function current, correct?

Best,
Bozana

Well, my aim is to prepare a plugin that sends an email TOC in HTML format, using a smarty template.

For now, I am trying to get a preview in a tab in the issues section. Then add a button, that will inititiate the sending of the email.

I am currently stuck at the first step. I have added the tab, with load_url_div in the smarty template for the page. This tries to load the above page, but it is not working.

I am also trying to see how emails are being sent by the system, but that is another story

Stephen

1 Like

This is much needed thing. Currently, OJS can only send an email saying that there is a notification. So this shall be great to port in OJS.

Hi @ssciberras

Where exactly is your tab? Parallel to the Future Issues and Back Issues, or when you edit an issue?

Your load_url_div should call a component handler function. You could use an existing handler and implement the function there. That function should best call a form (similar to the other cases in the system), that will provide you the email preview and “submit” button.
From above it seems that you are trying to use the IssueHandler which is not the right choice, I think – it is a page handler used for the frontend display. If you tell me where you tab is, I can see further
 how to point you to a few examples you could see as an example


Best,
Bozana

Thanks

You are correct, I am trying to load a component handler, but used controllers/grid/toc/TocGridHandler.inc.php as a basis. The previous code was the contents of my TestTocGridHandler

The tab is just next to the Future / Back issues:

templates/manageIssues/issues.tpl

< div id=“issuesTabs”>

<ul>
	<li><a name="futureIssues" href="#futureIssuesDiv">{translate key="editor.navigation.futureIssues"}</a></li>
	<li><a name="backIssues" href="#backIssuesDiv">{translate key="editor.navigation.issueArchive"}</a></li>
<li><a name="test" href="#testDiv">{translate key="eTOC"}</a></li>
</ul>
<div id="futureIssuesDiv">
	{help file="issue-management.md" class="pkp_help_tab"}
	{url|assign:futureIssuesGridUrl router=$smarty.const.ROUTE_COMPONENT component="grid.issues.FutureIssueGridHandler" op="fetchGrid" escape=false}
	{load_url_in_div id="futureIssuesGridContainer" url=$futureIssuesGridUrl}
</div>
<div id="backIssuesDiv">
	{help file="issue-management.md" class="pkp_help_tab"}
	{url|assign:backIssuesGridUrl router=$smarty.const.ROUTE_COMPONENT component="grid.issues.BackIssueGridHandler" op="fetchGrid" escape=false}
	{load_url_in_div id="backIssuesGridContainer" url=$backIssuesGridUrl}
</div>
{help file="issue-management.md" class="pkp_help_tab"} {url|assign:testGridUrl router=$smarty.const.ROUTE_COMPONENT component="test.TestTocGridHandler" op="fetchGrid" issueId=4 escape=false} {$testGridUrl} {load_url_in_div id="testGridContainer" url=$testGridUrl}

I did not find documentation on how plugins are. written - if there is anything, please do let me know. I have had to try to figure out by searching through github.

Thanks

Stephen

Hi @ssciberras

Hmm
 What do you think about having your extra tab in the model that opens when you edit an issue? – You would like to email only TOC of one issue, correct?
For that, for example, you would add a new line here ojs/issue.tpl at ojs-3_1_1-2 · pkp/ojs · GitHub, something like:
<li><a href="{url router=$smarty.const.ROUTE_COMPONENT op="editEmailTOC" issueId=$issueId}">{translate key="..."}</a></li>

Then you would need to implement that function editEmailTOC in controllers/grid/issues/IssueGridHandler.inc.php. It should call a form, similar how the functions editIssueData or identifiers are doing it there.
Then you would need to implement that form class and template, that would display the e-mail content and have a button “Send to all users” or so. The form action would be the function sendEmailTOC, that you would also have to implement in controllers/grid/issues/IssueGridHandler.inc.php.

Then, maybe when it works like this, hard coded, we can see how to best write a plugin for that.
What do you think?

Best,
Bozana

That is not a bad idea. I had thought about that, but first started with an easy route.

I will try this later on this week, and report back.

Stephen

OK so I am going through this.

So far, I have created the extra tab, and edited IssueHandler - although I think that in the future, I will see if this can be limited only to back issues, to avoid accidents. This calls the function emailTOC - which so far is just a duplicate of editIssueData, just renamed.

However, whenever. Iclick on the tab, I keep getting the alert:

The current role does not have access to this operation.

Any ideas how to move on?

Stephen

EIDT: OK - am slowly getting the idea - i had to add the name of my function to the rolemanager at the start of the Issuehandler.

Hi @ssciberras

Glad you are coming forward!
Yes, later you can provide the function only for the back issues


Best,
Bozana

I am very close to finishing off a test of this function, but am stuck at the final stages.

I need to call an external page to send the email, but of course, it does not go through all the initialization process of OJS. That means that even simple functions like ‘import ()’ do not work. I have replaced as much as I can and made it simple, but each import() means more and more work.

Any idea how I call this page through OJS and get it part of the OJS? I know it has got to do with routers, but this is still a concept that I need to grasp.

Thanks

Stephen