80 lines
1.9 KiB
PHP
80 lines
1.9 KiB
PHP
|
|
<?php
|
||
|
|
/*
|
||
|
|
* @component SQL 2 Excel Component
|
||
|
|
* @copyright Copyright (C) Joomla-R-Us, joomla-r-us.com
|
||
|
|
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3
|
||
|
|
*/
|
||
|
|
|
||
|
|
// no direct access
|
||
|
|
defined( '_JEXEC' ) or die( 'Restricted access' );
|
||
|
|
|
||
|
|
class Sql2excelParms
|
||
|
|
{
|
||
|
|
function getParms()
|
||
|
|
{
|
||
|
|
$parms = new stdClass();
|
||
|
|
|
||
|
|
// Get the settings from the #__sql2excel_settings
|
||
|
|
$pdb = & JFactory::getDBO();
|
||
|
|
$query = 'SELECT param,value FROM #__sql2excel_settings';
|
||
|
|
$pdb->setQuery($query);
|
||
|
|
$res = $pdb->loadObjectList();
|
||
|
|
|
||
|
|
// Add to new Object
|
||
|
|
if ( $pdb->getErrorNum() == 0 ) {
|
||
|
|
foreach ( $res as $row ) {
|
||
|
|
$key = $row->param;
|
||
|
|
$parms->$key = $row->value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return $parms;
|
||
|
|
}
|
||
|
|
|
||
|
|
function get($cmpParms, $key, $default_value)
|
||
|
|
{
|
||
|
|
|
||
|
|
if ( !is_object($cmpParms) ) {
|
||
|
|
$cmpParms = Sql2excelParms::getParms();
|
||
|
|
}
|
||
|
|
|
||
|
|
if ( isset($cmpParms->$key) ) {
|
||
|
|
return $cmpParms->$key;
|
||
|
|
} else {
|
||
|
|
$db = & JFactory::getDBO();
|
||
|
|
$query = 'INSERT INTO #__sql2excel_settings (`param`,`value`) VALUES (' . $db->Quote($key) . ',' . $db->Quote($default_value) . ')';
|
||
|
|
$db->setQuery($query);
|
||
|
|
$db->query();
|
||
|
|
return $default_value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
function getAdmin()
|
||
|
|
{
|
||
|
|
$db = & JFactory::getDBO();
|
||
|
|
$db->setQuery( "SELECT email,name FROM `#__users` WHERE `gid` = 25 ORDER BY ID LIMIT 1" );
|
||
|
|
$admin = $db->loadObject();
|
||
|
|
return $admin;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// Get Parameter value from request - support both GET and POST
|
||
|
|
function get_parm_value($parmName, $parmType, $defaultValue) {
|
||
|
|
$parmValue = Jrequest::getVar($parmName, '-999', 'GET', $parmType);
|
||
|
|
if ( (int) $parmValue == -999 ) {
|
||
|
|
$parmValue = Jrequest::getVar($parmName, $defaultValue, 'POST', $parmType);
|
||
|
|
}
|
||
|
|
|
||
|
|
if ( $parmType == 'int' ) {
|
||
|
|
return (int) $parmValue;
|
||
|
|
} elseif ( $parmType == 'float' ) {
|
||
|
|
return (float) $parmValue;
|
||
|
|
} else {
|
||
|
|
return $parmValue;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|