/**
  * Retrieve and cache all settings for a plugin.
  * @param $contextId int Context ID
  * @param $pluginName string Plugin symbolic name
  * @return array
  */
 function getPluginSettings($contextId, $pluginName)
 {
     // Normalize plug-in name to lower case.
     $pluginName = strtolower_codesafe($pluginName);
     $contextColumn = Application::getPluginSettingsContextColumnName();
     $result = $this->retrieve('SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ? AND ' . $contextColumn . ' = ?', array($pluginName, (int) $contextId));
     $pluginSettings = array();
     while (!$result->EOF) {
         $row = $result->getRowAssoc(false);
         $pluginSettings[$row['setting_name']] = $this->convertFromDB($row['setting_value'], $row['setting_type']);
         $result->MoveNext();
     }
     $result->Close();
     $cache = $this->_getCache($contextId, $pluginName);
     $cache->setEntireCache($pluginSettings);
     return $pluginSettings;
 }
Example #2
0
    /**
     * Retrieve all currently enabled products within the
     * given context as a two dimensional array with the
     * first key representing the product type, the second
     * key the product name and the value the product version.
     *
     * @param $context array the application context, only
     *  products enabled in that context will be returned.
     * @return array
     */
    function &getCurrentProducts($context)
    {
        $contextColumn = Application::getPluginSettingsContextColumnName();
        if (count($context)) {
            assert(count($context) == 1);
            // Context depth > 1 no longer supported here.
            $contextWhereClause = 'AND (' . $contextColumn . ' = ? OR v.sitewide = 1)';
        } else {
            $contextWhereClause = '';
        }
        $result = $this->retrieve('SELECT v.*
			FROM versions v LEFT JOIN plugin_settings ps ON
				lower(v.product_class_name) = ps.plugin_name
				AND ps.setting_name = \'enabled\' ' . $contextWhereClause . '
			WHERE v.current = 1 AND (ps.setting_value = \'1\' OR v.lazy_load <> 1)', $context, false);
        $productArray = array();
        while (!$result->EOF) {
            $row = $result->getRowAssoc(false);
            $productArray[$row['product_type']][$row['product']] =& $this->_returnVersionFromRow($row);
            $result->MoveNext();
        }
        $result->_close();
        return $productArray;
    }