/** * Return associative array with config option values by name and given * company * * @param Company $company * @return array */ function getValues($names, $company) { $result = array(); // lets get option definition instances $options = ConfigOptions::findByNames($names, COMPANY_CONFIG_OPTION); if (is_foreachable($options)) { // Now we need all company specific values we can get $values = db_execute_all('SELECT name, value FROM ' . TABLE_PREFIX . 'company_config_options WHERE name IN (?) AND company_id = ?', $names, $company->getId()); $foreachable = is_foreachable($values); // Populate result foreach ($options as $name => $option) { if ($foreachable) { foreach ($values as $record) { if ($record['name'] == $name) { $result[$name] = trim($record['value']) != '' ? unserialize($record['value']) : null; break; } // if } // foreach } // if if (!isset($result[$name])) { $result[$name] = $option->getValue(); } // if } // foreach } // if return $result; }