OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Delete db table record when disable plugin

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.

Delete db table record when disable plugin

Postby fivos » Thu May 08, 2014 3:37 pm

Hi everybody,

i have implemented a generic plugin that displays article metadata in the corresponding article view page.During the installation of the plugin, there is created a table in the ojs database that contains some fields of
the plugin settings. When the plugin is enabled for an article, there is created a new record in that table for the corresponding article.

I would like the corresponding record to be deleted from the table when the user chooses 'DISABLE' management verb of the plugin for an article.

I have created a 'delete' function in the Dao and i want it to be called when DISABLE is clicked but occurs an error that the 'DAO is unrecognized'. Obviously this happens because the plugin is disabled.

How could i achieve this?

Here is the code if it helps
Code: Select all
function getManagementVerbs() {
      $verbs = array();
                $journal =& Request::getJournal();
                $journalId = $journal->getId();
      if ($this->getEnabled()) {                                              
         $verbs[] = array(
            'disable',
            Locale::translate('manager.plugins.disable')
         );
                        $verbs[] = array('views', __('plugins.generic.customView.views'));
                        .
                        .
                       
                        }
      } else {
         $verbs[] = array(
            'enable',
            Locale::translate('manager.plugins.enable')
         );
                       
                        if($journalId!=null){
                            $this->import('CustomViewDAO');
                            $customViewDao =& DAORegistry::getDAO('CustomViewDAO');
                            $customViewDao->deleteViewById($journalId);
                        }
      }
      return $verbs;            
   }


Thank you in advance!
Last edited by fivos on Thu May 08, 2014 3:46 pm, edited 1 time in total.
fivos
 
Posts: 19
Joined: Thu Mar 06, 2014 4:12 am

Re: Delete db table record before disable plugin

Postby asmecher » Thu May 08, 2014 3:42 pm

Hi fivos,

Is the entire plugin source online somewhere? Best would be a github repository, which allows commenting and revision.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8910
Joined: Wed Aug 10, 2005 12:56 pm

Re: Delete db table record when disable plugin

Postby fivos » Thu May 08, 2014 4:00 pm

Would you mind if i uploaded the source code in this post because i don't have a github account and i don't know how ti works?

Thank you
fivos
 
Posts: 19
Joined: Thu Mar 06, 2014 4:12 am

Re: Delete db table record when disable plugin

Postby asmecher » Thu May 08, 2014 5:44 pm

Hi fivos,

I encourage you to experiment with github -- it's much easier for us and it's a useful skill -- but if not, you can upload the code here.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8910
Joined: Wed Aug 10, 2005 12:56 pm

Re: Delete db table record when disable plugin

Postby fivos » Fri May 09, 2014 6:45 am

Hi Alec,

i uploaded the plugin source code in the following github repository: https://github.com/icsd/ojsViews
I hope the code to be editable. If not let me know because i just made a github account and i am not familiar with it.

Thank you!
fivos
 
Posts: 19
Joined: Thu Mar 06, 2014 4:12 am

Re: Delete db table record when disable plugin

Postby asmecher » Fri May 09, 2014 9:47 am

Hi fivos,

Looks good -- and much easier to make specific suggestions on. I've added a suggestion here.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8910
Joined: Wed Aug 10, 2005 12:56 pm

Re: Delete db table record when disable plugin

Postby fivos » Sun May 11, 2014 2:38 pm

Hi Alec,

Thank you so much for your help! Now it works fine!!
I just had to move the DAO registration outside of the getEnabled() block, as you suggested!
fivos
 
Posts: 19
Joined: Thu Mar 06, 2014 4:12 am


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 3 guests