Skip to content

Instantly share code, notes, and snippets.

@newism
Created April 15, 2009 06:09
Show Gist options
  • Save newism/95643 to your computer and use it in GitHub Desktop.
Save newism/95643 to your computer and use it in GitHub Desktop.
<?php
function load_settings($force_refresh = FALSE, $return_all = FALSE)
{
global $SESS, $DB, $REGX, $PREFS;
$settings = array();
$site_id = $PREFS->ini('site_id');
if(
isset($SESS->cache[$this->developer_key][$this->package]['settings']) === FALSE
|| $force_refresh === TRUE
)
{
$query = $DB->query("SELECT settings
FROM exp_extensions
WHERE class = '{$this->package}_ext'
AND settings != ''
LIMIT 1");
if ($query->num_rows > 0)
{
$settings = $REGX->array_stripslashes(unserialize($query->row['settings']));
}
$default_site_settings = $this->build_default_site_settings();
$settings[$site_id] = (isset($settings[$site_id]) === FALSE) ? $default_site_settings : array_merge($settings[$site_id], $default_site_settings);
$SESS->cache[$this->developer_key][$this->package]['settings'] = $settings;
}
if($return_all === TRUE)
{
$settings = $SESS->cache[$this->developer_key][$this->package]['settings'];
}
else
{
$settings = $SESS->cache[$this->developer_key][$this->package]['settings'][$PREFS->ini('site_id')];
}
$this->settings = $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment