Hiya,
I am currently using JMS for some sites. All sites have seperate databases, and I need to trigger a specific custom made plugin every night to do importing into the db, using a cronjob to call a php file. But when I use the cronjob, my file of course is not aware of the site on which to call the plugin (the plugin uses site specific variables). So I was wondering: is it possible to 'manually' call the multisites class in my file which I call with the cronjob, and set the specific site on which to call the plugin?
Maybe the code beneath will explain some more about what I am trying to do:
I call a cronjob like the following (of course with proper path etc.):
Code: |
/usr/local/bin/php [path_to_php_file]/cronjob.php 'var1' 'var2' >[path_to_log_file]/log.txt 2>&1
|
the [path_to_php_file] is a filepath to the php file on the server, so there will be no site specific part in that url (the alias in the apache conf file will not trigger, thus jms will not be aware of the site on which I want to call the plugin).
The php file I call contains the following code, starting the JApplication, triggering the plugin etc:
Code: |
<?php
$joomlapath = "[local_server_file_path]/joomlamulti/administrator";
define( '_JEXEC', 1 );
define( 'JPATH_BASE', $joomlapath );
define( 'DS', DIRECTORY_SEPARATOR );
// Load the framework
require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'toolbar.php' );
JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;
require_once( JPATH_LIBRARIES.DS.'joomla'.DS.'import.php');
jimport( 'joomla.user.user' );
jimport( 'joomla.environment.uri' );
jimport( 'joomla.html.html' );
jimport( 'joomla.utilities.utility' );
jimport( 'joomla.event.event' );
jimport( 'joomla.event.dispatcher' );
jimport( 'joomla.language.language' );
jimport( 'joomla.utilities.string' );
// create the mainframe object
$mainframe = & JFactory::getApplication( 'site' );
// Initialize the framework
$mainframe->initialise();
// load system plugin group
JPluginHelper::importPlugin( 'system' );
// trigger the onAfterInitialise events
JDEBUG ? $_PROFILER->mark('afterInitialise') : null;
$mainframe->triggerEvent('onAfterInitialise');
/************************************************************
It would be nice to be able to set the specific site here, then trigger the event
Create instance of class multisites?
************************************************************/
//get the vars set in the cronjob
if( isset( $argv ) ) {
$var1 = $argv[0];
$var2 = $argv[1];
}
$option = JRequest::getCmd('option');
$mainframe->route();
$mainframe->dispatch($option);
$mainframe->render();
// Perform the Request task
$mainframe->triggerEvent('myImportPlugin');
|
Any help on this is highly appreciated. Ill be happy to explain it further if necessary.
gr
SaM