moving data from one module to another
Design and Skin Customization
First figure out how you want to move them. If you want to move them by you visiting a url, then you want a new view in the index file of your module.
eg:
function view_xxYourModule_somewhere($_post, $_user, $_conf)
{
fires when you visit the url
your-site.com/yourmodule/somewhere
If you want to fire the module once a day then use events and listeners to fire the module's function off when 'daily_maintenance' fires.
To do that, add the name of the function you want to fire into your modules _init() function, eg:
jrCore_register_event_listener('jrCore', 'daily_maintenance', 'jrPanel_daily_maintenance_listener');
is in the include.php file for the jrPanel module and it fires jrPanel_daily_maintenance_listener() once a day.
The next thing you need to do is to get the datastore items your interested in, so need to know which those are, then search for them.
To look for examples of searching for stuff inside a function search for '$_sp =' and that will show you other locations where modules are searching for stuff. It looks like this:
$_sp = array(
'search' => array(
"guestbook_owner_id = " . intval($_post['profile_id'])
),
'order_by' => array(
'_created' => 'DESC'
),
'limit' => 250
);
$_rt = jrCore_db_search_items('jrGuestBook', $_sp);
( example above ^ came from jrGuestBook )
That will give you all the found items inside $_rt['_items'] so then check that the array exists to make sure you have items, then itterate over them but change the prefix.
so:
if (isset($_rt) && is_array($_rt['_items'])) {
$pfx = jrCore_db_get_prefix('xxDestinationModule');
foreach($_rt['_items'] as $item){
$_sv[] = array(
$pfx.'_title' = $item['whatever_title'],
$pfx.'_description' = $item['whatever_description']
);
}
}
Then you have an array of items to either be created or updated. I think your after creating, so
jrCore_db_create_multiple_items('xxDestinationModule', $_sv);
should get the new stuff saved in the wanted datastore.