Microweber\Providers\UpdateManager::apply_updates PHP Method

apply_updates() public method

public apply_updates ( $params )
    public function apply_updates($params)
    {
        error_reporting(E_ERROR);
        $ret = array();
        if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'ini_set')) {
            ini_set('set_time_limit', 0);
        }
        if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'set_time_limit')) {
            set_time_limit(0);
        }
        $to_be_unzipped = array();
        if (defined('MW_API_CALL')) {
            only_admin_access();
        }
        $updates = $this->check();
        if (empty($updates)) {
            return false;
        }
        $params = parse_params($params);
        $update_api = $this;
        $res = array();
        $upd_params = array();
        if (is_array($params)) {
            foreach ($params as $param_k => $param) {
                if ($param_k == 'mw_version' || $param_k == 'core_update') {
                    $ret[] = $update_api->install_version($param);
                }
                if (is_array($param) and !empty($param)) {
                    if ($param_k == 'modules') {
                        if (!empty($updates) and isset($updates['modules']) and !empty($updates['modules'])) {
                            foreach ($param as $module) {
                                foreach ($updates['modules'] as $update) {
                                    if (isset($update['module']) or $update['item_type'] == 'module') {
                                        $module_market = $update['module'];
                                        $module = str_replace('\\', '/', $module);
                                        $module_market = str_replace('\\', '/', $module_market);
                                        if ($module == $module_market) {
                                            $ret[] = $this->install_from_market($update);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($param_k == 'templates') {
                        if (!empty($updates) and isset($updates['templates']) and !empty($updates['templates'])) {
                            foreach ($param as $module) {
                                foreach ($updates['templates'] as $update) {
                                    if (isset($update['dir_name']) or $update['item_type'] == 'template') {
                                        $module_market = $update['dir_name'];
                                        $module = str_replace('\\', '/', $module);
                                        $module_market = str_replace('\\', '/', $module_market);
                                        if ($module == $module_market) {
                                            $ret[] = $this->install_from_market($update);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($param_k == 'module_templates') {
                        if (!empty($updates) and isset($updates['module_templates']) and !empty($updates['module_templates'])) {
                            foreach ($param as $module) {
                                foreach ($updates['module_templates'] as $update) {
                                    if (isset($update['item_type']) and $update['item_type'] == 'module_template') {
                                        if (isset($update['module_skin_id']) and $update['module_skin_id'] == $module) {
                                            $ret[] = $this->install_from_market($update);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($param_k == 'elements') {
                        if (!empty($updates) and isset($updates['elements']) and !empty($updates['elements'])) {
                            foreach ($param as $module) {
                                foreach ($updates['elements'] as $update) {
                                    if (isset($update['item_type']) and $update['item_type'] == 'element') {
                                        if (isset($update['element_id']) and $update['element_id'] == $module) {
                                            $ret[] = $this->install_from_market($update);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (is_array($ret) and !empty($ret)) {
            $this->post_update();
            $this->app->notifications_manager->delete_for_module('updates');
        }
        return $ret;
    }