<?php
require_once 'modules/admin/models/ServicePlugin.php';
require_once 'newedge/classes/NE_PluginCollection.php';

/**
* @package Plugins
*/
class PluginCurrencyrates extends ServicePlugin
{
    function getVariables()
    {
        $variables = array(
            /*T*/'Plugin Name'/*/T*/   => array(
                'type'          => 'hidden',
                'description'   => /*T*/''/*/T*/,
                'value'         => /*T*/'Currency Rates'/*/T*/,
            ),
            /*T*/'Enabled'/*/T*/       => array(
                'type'          => 'yesno',
                'description'   => /*T*/'When enabled, currency rates are updated based on the Currency Pluging selected when this service is triggered.'/*/T*/,
                'value'         => '0',
            ),
            /*T*/'Run schedule - Minute'/*/T*/  => array(
                'type'          => 'text',
                'description'   => /*T*/'Enter number, range, list or steps'/*/T*/,
                'value'         => '30',
                'helpid'        => '8',
            ),
            /*T*/'Run schedule - Hour'/*/T*/  => array(
                'type'          => 'text',
                'description'   => /*T*/'Enter number, range, list or steps'/*/T*/,
                'value'         => '*',
            ),
            /*T*/'Run schedule - Day'/*/T*/  => array(
                'type'          => 'text',
                'description'   => /*T*/'Enter number, range, list or steps'/*/T*/,
                'value'         => '*',
            ),
            /*T*/'Run schedule - Month'/*/T*/  => array(
                'type'          => 'text',
                'description'   => /*T*/'Enter number, range, list or steps'/*/T*/,
                'value'         => '*',
            ),
            /*T*/'Run schedule - Day of the week'/*/T*/  => array(
                'type'          => 'text',
                'description'   => /*T*/'Enter number in range 0-6 (0 is Sunday) or a 3 letter shortcut (e.g. sun)'/*/T*/,
                'value'         => '*',
            ),
        );
    
        return $variables;
    }
    
    function execute($defaultCurrency = '')
    {
        $plugins = new NE_PluginCollection("currencies", $this->user);

        // service execution can take a while
        @set_time_limit(0);

        while ($plugin = $plugins->getNext()) {
            if ($plugin->getInternalName() == $this->settings->get('Selected Currency Plugin')) {
                return $plugin->execute($defaultCurrency);
            }
        }
    }
    
    function output()
    {
    }
    
    function dashboard()
    {
    }
}
?>
