Microweber\Providers\UpdateManager::save_license PHP Метод

save_license() публичный Метод

public save_license ( $params )
    public function save_license($params)
    {
        $adm = $this->app->user_manager->is_admin();
        if ($adm == false) {
            return;
        }
        $table = $this->app->modules->tables['system_licenses'];
        if ($table == false) {
            return;
        }
        if (!isset($params['rel_type']) and isset($params['rel'])) {
            $params['rel_type'] = $params['rel'];
        }
        if (!isset($params['rel_type']) and isset($params['local_key'])) {
            $prefix = explode('--', $params['local_key']);
            if (isset($prefix[1])) {
                $params['rel_type'] = $prefix[0];
            }
        }
        if (!isset($params['id']) and isset($params['rel_type'])) {
            $update = array();
            $update['rel_type'] = $params['rel_type'];
            $update['one'] = true;
            $update['table'] = $table;
            $update = $this->app->database_manager->get($update);
            if (isset($update['id'])) {
                $params['id'] = $update['id'];
            }
        } elseif (!isset($params['id']) and isset($params['local_key'])) {
            $update = array();
            $update['local_key'] = $params['local_key'];
            $update['one'] = true;
            $update['table'] = $table;
            $update = $this->app->database_manager->get($update);
            if (isset($update['id'])) {
                $params['id'] = $update['id'];
            }
        }
        $r = $this->app->database_manager->save($table, $params);
        if (isset($params['activate_on_save']) and $params['activate_on_save'] != false) {
            $this->validate_license('id=' . $r);
        }
        return array('id' => $r, 'success' => 'License key saved');
    }