function myModule_live_button()
{
global $_post, $_conf;
if ($_conf['myModule_live'] == 'on') {
$button_text = 'turn off';
} else {
$button_text = 'go live';
}
return jrCore_page_button('live', $button_text, "window.location='{$_conf['jrCore_base_url']}/{$_post['module_url']}/live'");
}
function view_myModule_live()
{
global $_conf;
jrUser_master_only();
// live/not live switch
if ($_conf['myModule_live'] == 'off') {
$onoff = 'on';
jrCore_set_form_notice('success', 'Your setting is now on');
} else {
$onoff = 'off';
jrCore_set_form_notice('success', 'Your setting is now off');
}
$_field = array(
'name' => "live",
'type' => 'hidden',
'validate' => 'onoff',
'value' => $onoff
);
jrCore_update_setting('myModule',$_field);
jrCore_form_result();
}
jrCore_page_banner('my module control panel',myModule_live_button());
$dat[3]['title'] = myModule_live_button();
// live/not live
$_tmp = array(
'name' => 'live',
'default' => 'off',
'type' => 'checkbox',
'validate' => 'onoff',
'required' => 'on',
'label' => 'go live',
'help' => 'switches the setting on and off'
);
jrCore_register_setting('myModule',$_tmp);
function smarty_function_myModule_onoff_button($params,$smarty)
{
global $_mods, $_conf;
// Check that it is admin, check module and check setting exists
if (!jrUser_is_master() || !jrCore_module_is_active('myModule') || !isset($_conf['myModule_live'])) {
return '';
}
$out = myModule_live_button();
// standard smarty assign
if (isset($params['assign']) && $params['assign'] != '') {
$smarty->assign($params['assign'],$out);
return '';
}
return $out;
}
{myModule_onoff_button}