<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Optimise get_company_pref()]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=6998</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=6998&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Optimise get_company_pref().]]></description>
		<lastBuildDate>Mon, 02 Oct 2017 03:38:48 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Optimise get_company_pref()]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=28803#p28803</link>
			<description><![CDATA[<p>@joe: can commit this.<br /><a href="https://github.com/FrontAccountingERP/FA/commit/b4c00f88c87e776a7700879adb15a2b013d48045">Committed</a>.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Mon, 02 Oct 2017 03:38:48 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=28803#p28803</guid>
		</item>
		<item>
			<title><![CDATA[Optimise get_company_pref()]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=28795#p28795</link>
			<description><![CDATA[<p>The file <strong>admin/db/company_db.inc</strong> has the <strong><em>function</em> get_company_pref($prefs = null)</strong>:</p><div class="codebox"><pre><code>function get_company_pref($prefs = null)
{
    global $SysPrefs, $db_version;

    if (!isset($SysPrefs-&gt;prefs))     // just after first login or reset
        $SysPrefs-&gt;refresh();

    $all = $SysPrefs-&gt;prefs;

    if (!$prefs)
        return $all;
    elseif (is_string($prefs))
        return @$all[$prefs];

    $ret = array();
    foreach($prefs as $name)
        $ret[$name] = $all[$name];

    return $ret;
}</code></pre></div><p>This can be simplified and made efficient by replacing it with:</p><div class="codebox"><pre><code>function get_company_pref($prefs = null){
    global $SysPrefs, $db_version;

    if (!isset($SysPrefs-&gt;prefs))     // just after first login or reset
        $SysPrefs-&gt;refresh();

    $all = $SysPrefs-&gt;prefs;
    if ($prefs &amp;&amp; is_string($prefs))
        return @$all[$prefs];     // silent on absent array element

    if (!is_array($all))
        $all = array();

    return $all;}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 01 Oct 2017 04:14:59 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=28795#p28795</guid>
		</item>
	</channel>
</rss>
