OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Reload Default Email Templates Tool

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.

Reload Default Email Templates Tool

Postby vlilloh » Wed Oct 26, 2011 11:10 am

Please,

I'm trying to create a small script in tools folder to install the default email templates in the empty tables 'email_templates_default' and 'email_templates_default_data' for all installed languages.

I'm trying with the next code:

Code: Select all
<?php
require(dirname(__FILE__) . '/bootstrap.inc.php');
$emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
$emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
foreach ($this->installedLocales as $locale) {
     $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
}
?>

or

Code: Select all
<?php
require(dirname(__FILE__) . '/bootstrap.inc.php');
$emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
foreach ($emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename(), true) as $sql) {
     $this->executeSQL($sql);
}
foreach ($this->installedLocales as $locale) {
     foreach ($emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale), true) as $sql) {
          $this->executeSQL($sql);
     }
}
?>

but when I run the script (i.e. "php tools/reloadEmailTemplates.php") nothing happens. Still empty tables.

How would you fix it? Have you thought to include something like this in OJS? It would be very useful!

On the other hand, how to make the script clear tables before without having to do it manually?

Thanks,
Cheers.
vlilloh
 
Posts: 285
Joined: Thu Feb 07, 2008 3:35 am
Location: Murcia, Spain

Re: Reload Default Email Templates Tool

Postby jmacgreg » Thu Nov 03, 2011 4:36 pm

Hi Vicente,

I'm going to ask another developer to get back to you regarding why the script may not be working -- but in the meantime, have you tried the "Reset all templates" link at the bottom of the Prepared Emails journal management page? It should reset all prepared emails for that locale; I'm not sure if it does so for all locales on the system or not, so you may have to press it for each locale.

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

Re: Reload Default Email Templates Tool

Postby vlilloh » Fri Nov 04, 2011 2:18 am

Hi James,

"Reset all templates" button, reset from "locale/xx_XX/emailTemplates.xml" to the table "email_templates_default_data"? if so, it is not working for me.

That is my wish in the script, or add a feature en OJS for that. Actually, "locale/xx_XX/emailTemplates.xml" is forgotten after an installation, and there is no way to modify the default templates in OJS after an installation.

I thought that "Reset all templates" button in a journal delete all entries in the "email_templates_data" table for that journal, and so again back to capture from "email_templates_default_data" table.

Thanks,
Cheers.
vlilloh
 
Posts: 285
Joined: Thu Feb 07, 2008 3:35 am
Location: Murcia, Spain

Re: Reload Default Email Templates Tool

Postby mcrider » Mon Nov 07, 2011 11:18 am

Hi Vicente,

I think you'll have to declare your code in the scope of a custom class, and have that class inherit from the 'CommandLineTool' class. This will set up everything needed for your script to interface with OJS. As an example, the rest of the scripts in the tools/ directory do this.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 4 guests