OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Year based subscription access

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

Year based subscription access

Postby rke4me » Thu Apr 16, 2009 9:18 pm

Hi,
First, apology, if this is not the right place to post this issue.

When we provide a subscription based access to the reader for current year (e.g. Year 2009, Duration Jan. to Dec.), it seems that the reader can also access the previous years issues (e.g. Year 2008, 2007, 2006 ...) without any subscriptions.

Is there any possibilities in future OJS to give year-wise subscription as

1. Current Year Subscription ,

2. Previous Year Subscription

Thanks

-Rke
rke4me
 
Posts: 39
Joined: Sat Jul 14, 2007 5:19 am

Re: Year based subscription access

Postby michael » Fri Apr 17, 2009 11:53 am

Hi rke4me,

These are actually two separate things:
1) a valid subscription, which has a duration (e.g. 12 months), and
2) what a subscription provides access to

OJS has been designed in such a way that 2) enables subscription holders to access all subscription-restricted content. What you are asking for is to limit 2) to 1), the subscription duration. This is something that we could consider for future releases of OJS, but at this time there has not been much demand for this sort of limitation.

If you do require something of this sort in the short-term, you should be able to easily modify the subscription check functions (subscribedUser and subscribedDomain) in classes/issue/IssueAction.inc.php

Cheers,
Michael
michael
 
Posts: 404
Joined: Thu Mar 29, 2007 2:09 pm

Re: Year based subscription access

Postby rke4me » Fri Apr 17, 2009 8:30 pm

Dear Michael

Thanks for your reply and possible solution.

Hope that this may be included in the future OJS version.

Presently, I do not know how to modify the subscription check functions. It will be more helpful us you give a patch for this.

Thanks

-Rke
rke4me
 
Posts: 39
Joined: Sat Jul 14, 2007 5:19 am

Re: Year based subscription access

Postby michael » Mon Jun 29, 2009 10:34 am

Hi Rke and Jaik,

The subscribedUser function would need to be changed to something like the following (please note, this is not tested):

Code: Select all
    function subscribedUser(&$journal, $issueId = null, $articleId = null) {
        $user = &Request::getUser();
        $subscriptionDao = &DAORegistry::getDAO('SubscriptionDAO');
        $result = false;
        if (isset($user) && isset($journal)) {
            if (IssueAction::allowedPrePublicationAccess($journal)) {
                 $result = true;
            } else {
                if (isset($articleId)) {
                    $publishedArticleDao = &DAORegistry::getDAO('PublishedArticleDAO');
                    $publishedArticle = &$publishedArticleDao->getPublishedArticleByArticleId($articleId);
                    if (isset($publishedArticle)) {
                        import('subscription.SubscriptionDAO');
                        $result = $subscriptionDao->isValidSubscription(null, null, $user->getUserId(), $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $publishedArticle->getDatePublished());
                    }
                } else if (isset($issueId)) {
                    $issueDao = &DAORegistry::getDAO('IssueDAO');
                    $issue = &$issueDao->getIssueById($issueId);
                    if (isset($issue) && $issue->getPublished()) {
                        import('subscription.SubscriptionDAO');
                        $result = $subscriptionDao->isValidSubscription(null, null, $user->getUserId(), $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $issue->getDatePublished());
                    }
                }
            }
        }
        HookRegistry::call('IssueAction::subscribedUser', array(&$journal, &$result));
        return $result;
    }


Likewise, the subscibedDomain function would need to be changes along similar lines:

Code: Select all
    function subscribedDomain(&$journal, $issueId = null, $articleId = null) {
        $subscriptionDao = &DAORegistry::getDAO('SubscriptionDAO');
        $result = false;
        if (isset($journal)) {
            if (isset($articleId)) {
                $publishedArticleDao = &DAORegistry::getDAO('PublishedArticleDAO');
                $publishedArticle = &$publishedArticleDao->getPublishedArticleByArticleId($articleId);
                if (isset($publishedArticle)) {
                    import('subscription.SubscriptionDAO');
                    $result = $subscriptionDao->isValidSubscription(Request::getRemoteDomain(), Request::getRemoteAddr(), null, $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $publishedArticle->getDatePublished());
                }
            } else if (isset($issueId)) {
                $issueDao = &DAORegistry::getDAO('IssueDAO');
                $issue = &$issueDao->getIssueById($issueId);
                if (isset($issue) && $issue->getPublished()) {
                    import('subscription.SubscriptionDAO');
                    $result = $subscriptionDao->isValidSubscription(Request::getRemoteDomain(), Request::getRemoteAddr(), null, $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $issue->getDatePublished());
                }
            }
        }
        HookRegistry::call('IssueAction::subscribedDomain', array(&$journal, &$result));
        return $result;
    }


That is, in both cases we want to check whether the article or issue publication date falls within the subscription start and end dates.

Cheers,
Michael
michael
 
Posts: 404
Joined: Thu Mar 29, 2007 2:09 pm

Re: Year based subscription access

Postby jaik_70 » Mon Jun 29, 2009 9:30 pm

Dear Micheel

Thanks for Php script for issue access.

The output of this given below:

Parse error: parse error, unexpected T_STRING in C:\ojs-2.2.3\classes\issue\IssueAction.inc.php on line 116

-Jaik
jaik_70
 
Posts: 42
Joined: Tue Jun 02, 2009 5:49 am

Re: Year based subscription access

Postby michael » Mon Jun 29, 2009 10:45 pm

Hi Jaik,

This error is typical if there is a missing brace '{' or '}' or missing semi-colon ';' at the end of the line. Please ensure that you are copy-and-pasting the code in its entirety and/or double-check that these are in place.

Cheers,
Michael
michael
 
Posts: 404
Joined: Thu Mar 29, 2007 2:09 pm

Re: Year based subscription access

Postby jaik_70 » Tue Jun 30, 2009 8:08 pm

Dear Michael

You are right, there was a missing brace. Now we are getting following warning:

Warning: Missing argument 2 for IssueAction::allowedPrePublicationAccess(), called in C:\ojs-2.2.3\classes\issue\IssueAction.inc.php on line 120 and defined in C:\ojs-2.2.3\classes\issue\IssueAction.inc.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at C:\ojs-2.2.3\classes\issue\IssueAction.inc.php:80) in C:\ojs-2.2.3\classes\template\TemplateManager.inc.php on line 240

Warning: Cannot modify header information - headers already sent by (output started at C:\ojs-2.2.3\classes\issue\IssueAction.inc.php:80) in C:\ojs-2.2.3\classes\template\TemplateManager.inc.php on line 243



-Jaik
jaik_70
 
Posts: 42
Joined: Tue Jun 02, 2009 5:49 am

Re: Year based subscription access

Postby michael » Tue Jun 30, 2009 10:03 pm

My bad. I had pulled that code from an old working directory (pre-2.2.3). Please try the following instead:

Code: Select all
    function subscribedUser(&$journal, $issueId = null, $articleId = null) {
        $user =& Request::getUser();
        $subscriptionDao =& DAORegistry::getDAO('SubscriptionDAO');
        $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
        $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
        $result = false;
        if (isset($user) && isset($journal)) {
            if (IssueAction::allowedPrePublicationAccess($journal, $publishedArticle)) {
                 $result = true;
            } else {
                if (isset($articleId)) {
                    if (isset($publishedArticle)) {
                        import('subscription.SubscriptionDAO');
                        $result = $subscriptionDao->isValidSubscription(null, null, $user->getUserId(), $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $publishedArticle->getDatePublished());
                    }
                } else if (isset($issueId)) {
                    $issueDao = &DAORegistry::getDAO('IssueDAO');
                    $issue = &$issueDao->getIssueById($issueId);
                    if (isset($issue) && $issue->getPublished()) {
                        import('subscription.SubscriptionDAO');
                        $result = $subscriptionDao->isValidSubscription(null, null, $user->getUserId(), $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $issue->getDatePublished());
                    }
                }
            }
        }
        HookRegistry::call('IssueAction::subscribedUser', array(&$journal, &$result));
        return $result;
    }


Code: Select all
    function subscribedDomain(&$journal, $issueId = null, $articleId = null) {
        $subscriptionDao = &DAORegistry::getDAO('SubscriptionDAO');
        $result = false;
        if (isset($journal)) {
            if (isset($articleId)) {
                $publishedArticleDao = &DAORegistry::getDAO('PublishedArticleDAO');
                $publishedArticle = &$publishedArticleDao->getPublishedArticleByArticleId($articleId);
                if (isset($publishedArticle)) {
                    import('subscription.SubscriptionDAO');
                    $result = $subscriptionDao->isValidSubscription(Request::getRemoteDomain(), Request::getRemoteAddr(), null, $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $publishedArticle->getDatePublished());
                }
            } else if (isset($issueId)) {
                $issueDao = &DAORegistry::getDAO('IssueDAO');
                $issue = &$issueDao->getIssueById($issueId);
                if (isset($issue) && $issue->getPublished()) {
                    import('subscription.SubscriptionDAO');
                    $result = $subscriptionDao->isValidSubscription(Request::getRemoteDomain(), Request::getRemoteAddr(), null, $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $issue->getDatePublished());
                }
            }
        }
        HookRegistry::call('IssueAction::subscribedDomain', array(&$journal, &$result));
        return $result;
    }
michael
 
Posts: 404
Joined: Thu Mar 29, 2007 2:09 pm

Re: Year based subscription access

Postby jaik_70 » Wed Jul 01, 2009 10:22 pm

Dear Michael

Thanks for providing this yaer based facilities. This will be more helpful to other OJS users if this nice script included in next version of OJS-2.3.

Also, I have few minor questions as:
1. Is this script work with OJS-2.2.2 too ?
2. Issue(s) can be govern through
Home > User > Journal Management > Subscriptions > Edit

with Start date* and End date*
Am I right ?

Thanks again

-Jaik
jaik_70
 
Posts: 42
Joined: Tue Jun 02, 2009 5:49 am

Re: Year based subscription access

Postby michael » Fri Jul 03, 2009 11:57 am

Hi Jaik,

The above code was taken from OJS 2.2.3. It may work against OJS 2.2.2 with little or no modifications, but I would recommend testing it in either case.

Yes, you will need to set your issues as subscription-based and then grant subscriptions to individuals and institutions. There's detailed information about all of the options and settings in the OJS in an Hour guide, available here.

Cheers,
Michael
michael
 
Posts: 404
Joined: Thu Mar 29, 2007 2:09 pm

Re: Year based subscription access

Postby jaik_70 » Tue Jul 07, 2009 4:27 am

Dear Michael
Thanks for all suggestions.

-Jaik
jaik_70
 
Posts: 42
Joined: Tue Jun 02, 2009 5:49 am

Re: Year based subscription access

Postby LPaul » Thu Jul 23, 2009 4:41 am

Hello

Should one expect this feature "Year based subscription access" in OJS 2.3 ?

Thanks

-LPaul
LPaul
 
Posts: 1
Joined: Thu Jul 23, 2009 4:34 am

Re: Year based subscription access

Postby jmacgreg » Thu Jul 23, 2009 10:33 am

Hi LPaul,

Yep! Anything that's in 2.2.3 will be in 2.3.

Cheers,
James
jmacgreg
 
Posts: 4186
Joined: Tue Feb 14, 2006 10:50 am

Re: Year based subscription access

Postby michael » Thu Jul 23, 2009 2:12 pm

Hi LPaul and James,

Just to clarify, the above code is not currently in either OJS 2.2.3 or OJS 2.3, but was simply provided as an example of how something like year-based subscription access could be achieved to overrride the current subscription check for an existing OJS instance.

Cheers,
Michael
michael
 
Posts: 404
Joined: Thu Mar 29, 2007 2:09 pm

Re: Year based subscription access

Postby michael » Fri Nov 06, 2009 8:46 am

Hi Jaik,

Please find below some suggested code modifications that would be required for this to work in OJS 2.3.0.

Code: Select all
    function subscribedUser(&$journal, $issueId = null, $articleId = null) {
        $user =& Request::getUser();
        $subscriptionDao =& DAORegistry::getDAO('IndividualSubscriptionDAO');
        $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
        $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
        $result = false;
        if (isset($user) && isset($journal)) {
            if (IssueAction::allowedPrePublicationAccess($journal, $publishedArticle)) {
                 $result = true;
            } else {
                if (isset($articleId)) {
                    if (isset($publishedArticle)) {
                        import('subscription.SubscriptionDAO');
                        $result = $subscriptionDao->isValidIndividualSubscription($user->getId(), $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $publishedArticle->getDatePublished());
                    }
                } else if (isset($issueId)) {
                    $issueDao =& DAORegistry::getDAO('IssueDAO');
                    $issue =& $issueDao->getIssueById($issueId);
                    if (isset($issue) && $issue->getPublished()) {
                        import('subscription.SubscriptionDAO');
                        $result = $subscriptionDao->isValidIndividualSubscription($user->getId(), $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $issue->getDatePublished());
                    }
                }
            }
        }
        HookRegistry::call('IssueAction::subscribedUser', array(&$journal, &$result));
        return $result;
    }


Code: Select all
    function subscribedDomain(&$journal, $issueId = null, $articleId = null) {
        $subscriptionDao =& DAORegistry::getDAO('InstitutionalSubscriptionDAO');
        $result = false;
        if (isset($journal)) {
            if (isset($articleId)) {
                $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
                $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
                if (isset($publishedArticle)) {
                    import('subscription.SubscriptionDAO');
                    $result = $subscriptionDao->isValidInstitutionalSubscription(Request::getRemoteDomain(), Request::getRemoteAddr(), $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $publishedArticle->getDatePublished());
                }
            } else if (isset($issueId)) {
                $issueDao =& DAORegistry::getDAO('IssueDAO');
                $issue =& $issueDao->getIssueById($issueId);
                if (isset($issue) && $issue->getPublished()) {
                    import('subscription.SubscriptionDAO');
                    $result = $subscriptionDao->isValidInstitutionalSubscription(Request::getRemoteDomain(), Request::getRemoteAddr(), $journal->getJournalId(), SUBSCRIPTION_DATE_BOTH, $issue->getDatePublished());
                }
            }
        }
        HookRegistry::call('IssueAction::subscribedDomain', array(&$journal, &$result));
        return $result;
    }

In effect, the required changes are almost identical to that required for OJS 2.2.x. The major difference is that in OJS 2.3 individual and institutional subscriptions have been separated in the database and code such that calls to the old isValidSubscription are now differentiated between isValidIndividualSubscription and isValidInstitutionalSubscription.

Cheers,
Michael
michael
 
Posts: 404
Joined: Thu Mar 29, 2007 2:09 pm

Next

Return to OJS Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron