/** * Initialize all enabled addons * * @return array INIT_STATUS_OK */ function fn_init_addons() { Registry::registerCache('addons', array('addons', 'settings_objects', 'settings_vendor_values', 'settings_descriptions', 'settings_sections', 'settings_variants'), Registry::cacheLevel('static')); if (Registry::isExist('addons') == false) { $init_addons = Registry::get('settings.init_addons'); $allowed_addons = null; if ($init_addons == 'none') { $allowed_addons = array(); } elseif ($init_addons == 'core') { $allowed_addons = Snapshot::getCoreAddons(); } $_addons = db_get_hash_array("SELECT addon, priority, status, unmanaged FROM ?:addons WHERE 1 ORDER BY priority", 'addon'); foreach ($_addons as $k => $v) { $_addons[$k] = Settings::instance()->getValues($v['addon'], Settings::ADDON_SECTION, false); if (fn_check_addon_snapshot($k)) { $_addons[$k]['status'] = $v['status']; } else { $_addons[$k]['status'] = 'D'; } if ($allowed_addons !== null && !in_array($v['addon'], $allowed_addons)) { $_addons[$k]['status'] = 'D'; } $_addons[$k]['priority'] = $v['priority']; $_addons[$k]['unmanaged'] = $v['unmanaged']; } // Some addons could be disabled for vendors. if (fn_allowed_for('MULTIVENDOR') && Registry::get('runtime.company_id')) { Registry::set('addons', $_addons); // So, we have to parse it one more time foreach ($_addons as $k => $v) { // and check permissions schema. // We couldn't make it in the previous cycle because the fn_get_scheme func works only with full list of addons. if (!fn_check_addon_permission($k)) { unset($_addons[$k]); } } } Registry::set('addons', $_addons); } foreach ((array) Registry::get('addons') as $addon_name => $data) { if (empty($data['status'])) { // FIX ME: Remove me error_log("ERROR: Addons initialization: Bad '{$addon_name}' addon data:" . serialize($data) . " Addons Registry:" . serialize(Registry::get('addons'))); } if (!empty($data['status']) && $data['status'] == 'A') { fn_load_addon($addon_name); } } Registry::set('addons_initiated', true, true); return array(INIT_STATUS_OK); }
/** * Initialize all enabled addons * * @return boolean always true */ function fn_init_addons() { Registry::register_cache('addons', array('addons'), CACHE_LEVEL_STATIC); // Get settings if (Registry::is_exist('addons') == false) { $_addons = db_get_hash_array("SELECT addon, priority, IF(status = 'A', options, '') as options, status FROM ?:addons ORDER BY priority", 'addon'); foreach ($_addons as $k => $v) { if (defined('COMPANY_ID') && !fn_check_addon_permission($k)) { unset($_addons[$k]); continue; } $_addons[$k] = $v['status'] == 'A' && !empty($v['options']) ? fn_parse_addon_options($v['options']) : array(); $_addons[$k]['status'] = $v['status']; $_addons[$k]['priority'] = $v['priority']; } Registry::set('addons', $_addons); } foreach ((array) Registry::get('addons') as $addon_name => $data) { if ($data['status'] == 'A') { if (is_file(DIR_ADDONS . $addon_name . '/init.php')) { include DIR_ADDONS . $addon_name . '/init.php'; } } } return true; }