newVersion(self::$pid, dcCore::app()->plugins->moduleInfo(self::$pid, 'version')); return self::$init; } public static function process(): ?bool { if (!self::$init) { return false; } try { // Upgrade self::growUp(); // Set module settings foreach (self::$mod_conf as $v) { dcCore::app()->blog->settings->__get(self::$pid)->put( $v[0], $v[1], $v[2], $v[3], false, true ); } return true; } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); return false; } } public static function growUp(): void { $current = dcCore::app()->getVersion(self::$pid); // Update settings id, ns if ($current && version_compare($current, '1.0', '<')) { $record = dcCore::app()->con->select( 'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' . "WHERE setting_ns = 'whiteListCom' " ); while ($record->fetch()) { if (preg_match('/^whiteListCom(.*?)$/', $record->setting_id, $match)) { $value = @unserialize(@base64_decode($x)); $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME); $cur->setting_id = $match[1]; $cur->setting_ns = self::$pid; $cur->setting_value = is_array($value) ? json_encode($value) : '[]'; $cur->update( "WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'whiteListCom' " . 'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' ")) ); } } } } }