Microweber\Providers\Modules::set_installed PHP Method

set_installed() public method

public set_installed ( $params )
    public function set_installed($params)
    {
        if ($this->app->user_manager->is_admin() == false) {
            return false;
        }
        if (isset($params['for_module'])) {
            $this_module = $this->get('ui=any&one=1&module=' . $params['for_module']);
            if (isset($this_module['id'])) {
                $params['id'] = $this_module['id'];
            }
        }
        if (isset($params['id'])) {
            $id = intval($params['id']);
            $this_module = $this->get('ui=any&one=1&id=' . $id);
            if ($this_module != false and is_array($this_module) and isset($this_module['id'])) {
                $module_name = $this_module['module'];
                if (trim($module_name) == '') {
                    return false;
                }
                $loc_of_config = $this->locate($module_name, 'config');
                $res = array();
                $loc_of_functions = $this->locate($module_name, 'functions');
                $cfg = false;
                if (is_file($loc_of_config)) {
                    include $loc_of_config;
                    if (isset($config)) {
                        $cfg = $config;
                    }
                    if (is_array($cfg) and !empty($cfg)) {
                        if (isset($cfg['on_install'])) {
                            $func = $cfg['on_install'];
                            if (!function_exists($func)) {
                                if (is_file($loc_of_functions)) {
                                    include_once $loc_of_functions;
                                }
                            }
                            if (function_exists($func)) {
                                $res = $func();
                            }
                        }
                    }
                }
                $to_save = array();
                $to_save['id'] = $id;
                $to_save['installed'] = 1;
                $this->save($to_save);
            }
        }
        $this->app->cache_manager->delete('modules' . DIRECTORY_SEPARATOR . '');
    }