Get what ChangeSets are available for an item to be added to by this user

@return ArrayList|ChangeSet[]
557625
protected function getAvailableChangeSets()
    {
        return ChangeSet::get()
            ->filter('State', ChangeSet::STATE_OPEN)
            ->filterByCallback(function ($item) {
                /** @var ChangeSet $item */
                return $item->canView();
            });
    }
609378
public function calculateChangeSet()
    {
        $set = [];
        foreach ($this->getOriginalAll() as $key => $collection) {
            if (false === $collection->isDirty()) {
                continue;
            }
            $set[$key] = $collection->calculateChangeSet();
        }
        return $set;
    }
8968
public function getOptions()
    {
        // Loop through and figure out which values were selected.
        $options = array();
        $selectedValue = $this->getValueArray();
        foreach ($this->getSource() as $itemValue => $title) {
            $itemSelected = in_array($itemValue, $selectedValue)
                || in_array($itemValue, $this->getDefaultItems());
            $itemDisabled = $this->isDisabled()
                || in_array($itemValue, $this->getDisabledItems());
            $options[] = new ArrayData(array(
                'Title' => $title,
                'Value' => $itemValue,
                'Selected' => $itemSelected,
                'Disabled' => $itemDisabled,
            ));
        }

        $options = new ArrayList($options);
        $this->extend('updateGetOptions', $options);
        return $options;
    }
998849
public function getUpdated()
    {
        $set = new ArrayList();
        foreach ($this->updated as $arrItem) {
            $set->push(ArrayData::create($arrItem));
        }
        return $set;
    }
445458
public function allchanges()
    {
        // Check viewability of allchanges
        if (!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')
            || !SiteConfig::current_site_config()->AllChangesEnabled
        ) {
            return $this->owner->httpError(404, 'Global history not viewable');
        }

        $limit = (int)Config::inst()->get(VersionFeed::class, 'allchanges_limit');
        $latestChanges = DB::query('
			SELECT * FROM "SiteTree_Versions"
			WHERE "WasPublished" = \'1\'
			AND "CanViewType" IN (\'Anyone\', \'Inherit\')
			AND "ShowInSearch" = 1
			AND ("PublicHistory" IS NULL OR "PublicHistory" = \'1\')
			ORDER BY "LastEdited" DESC LIMIT ' . $limit);
        $lastChange = $latestChanges->record();
        $latestChanges->rewind();

        if ($lastChange) {
            // Cache the diffs to remove DOS possibility.
            $key = 'allchanges'
                . preg_replace('#[^a-zA-Z0-9_]#', '', $lastChange['LastEdited'])
                . (Security::getCurrentUser() ? Security::getCurrentUser()->ID : 'public');
            $changeList = $this->filterContent($key, function () use ($latestChanges) {
                $changeList = new ArrayList();
                $canView = array();
                foreach ($latestChanges as $record) {
                    // Check if the page should be visible.
                    // WARNING: although we are providing historical details, we check the current configuration.
                    $id = $record['RecordID'];
                    if (!isset($canView[$id])) {
                        $page = DataObject::get_by_id(SiteTree::class, $id);
                        $canView[$id] = $page && $page->canView(Security::getCurrentUser());
                    }
                    if (!$canView[$id]) {
                        continue;
                    }

                    // Get the diff to the previous version.
                    $record['ID'] = $record['RecordID'];
                    $version = SiteTree::create($record);
                    if ($diff = $version->getDiff()) {
                        $changeList->push($diff);
                    }
                }

                return $changeList;
            });
        } else {
            $changeList = new ArrayList();
        }

        // Produce output
        $url = $this->owner->getRequest()->getURL();
        $rss = new RSSFeed(
            $changeList,
            $url,
            $this->linkToAllSitesRSSFeedTitle(),
            '',
            'Title',
            '',
            null
        );
        $rss->setTemplate('Page_allchanges_rss');
        return $rss->outputToBrowser();
    }
773482
private function totalChanges(): array
    {
        return DB::table('gedcom')
            ->leftJoin('change', static function (JoinClause $join): void {
                $join
                    ->on('change.gedcom_id', '=', 'gedcom.gedcom_id')
                    ->where('change.status', '=', 'pending');
            })
            ->groupBy('gedcom.gedcom_id')
            ->pluck(DB::raw('COUNT(change_id)'), 'gedcom.gedcom_id')
            ->all();
    }
1013686
public function changes()
    {
        $changes = array();
        foreach(array_unique($this->_changed) as $key)
            $changes[$key] = $this->get($key, false);

        return $changes;
    }
593080
public function getUnchangedAttributes()
    {
        $output = array();

        foreach ($this->attributes as $name => $value) {
            if (!$this->hasChanged($name)) {
                $output[$name] = $value;
            }
        }

        return $output;
    }
60221
public function getLocalAvailableUpdates()
    {
        $app = Application::getFacadeApplication();
        $fh = $app->make('helper/file');
        $updates = [];
        $contents = @$fh->getDirectoryContents(DIR_CORE_UPDATES);
        foreach ($contents as $con) {
            if (is_dir(DIR_CORE_UPDATES . '/' . $con)) {
                $obj = ApplicationUpdate::get($con);
                if (is_object($obj)) {
                    if (version_compare($obj->getUpdateVersion(), APP_VERSION, '>')) {
                        $updates[] = $obj;
                    }
                }
            }
        }
        usort(
            $updates,
            function ($a, $b) {
                return version_compare($a->getUpdateVersion(), $b->getUpdateVersion());
            }
        );

        return $updates;
    }
1004159
public function getProcessedReplacements()
    {
        $values = $this->getReplacements();

        if (null !== ($git = $this->getGitHashPlaceholder())) {
            $values[$git] = $this->getGitHash();
        }

        if (null !== ($git = $this->getGitShortHashPlaceholder())) {
            $values[$git] = $this->getGitHash(true);
        }

        if (null !== ($git = $this->getGitTagPlaceholder())) {
            $values[$git] = $this->getGitTag();
        }

        if (null !== ($git = $this->getGitVersionPlaceholder())) {
            $values[$git] = $this->getGitVersion();
        }

        if (null !== ($date = $this->getDatetimeNowPlaceHolder())) {
            $values[$date] = $this->getDatetimeNow($this->getDatetimeFormat());
        }

        $sigil = $this->getReplacementSigil();

        foreach ($values as $key => $value) {
            unset($values[$key]);

            $values["$sigil$key$sigil"] = $value;
        }

        return $values;
    }
754390
public function getDeleted()
    {
        $set = new ArrayList();
        foreach ($this->deleted as $arrItem) {
            $set->push(ArrayData::create($arrItem));
        }
        return $set;
    }
1102968
private function getAvailableVersions()
    {
        if (!isset($this->availableVersions)) {
            $this->availableVersions = [];
            foreach ($this->getManifest() as $key => $item) {
                if ($missing = array_diff(self::$requiredKeys, array_keys($item))) {
                    throw new \RuntimeException(sprintf(
                        'Manifest item %s missing required key(s): %s',
                        $key,
                        implode(',', $missing)
                    ));
                }
                $this->availableVersions[$item['version']] = $item;
            }
        }

        return $this->availableVersions;
    }
912331
protected function obtainReplacements()
    {
        return [
            'ROUTE_LINK' => $link = $this->getReplacements()[0],
            'ROUTE_CONTROLLER' => $this->controller($this->getReplacements()[1]),
            'ROUTE_METHOD' => $this->getReplacements()[2],
            'ROUTE_NAME' => dot_path($link),
        ];
    }
196639
final private function changes()
    {
        if (null === $this->changes) {
            $lastCommittedEventSequenceNumber = $this->lastCommittedEventSequenceNumber();

            $this->changes = new DefaultEventContainer($this->identifier(), $lastCommittedEventSequenceNumber);
        }

        return $this->changes;
    }
802488
public function getAllForInsertUpdate()
    {
        $data          = parent::getAllForInsertUpdate();
        if ($this->_from !== null) {
            $data['_from'] = $this->_from;
        }
        if ($this->_to !== null) {
            $data['_to']   = $this->_to;
        }

        return $data;
    }
85118
public function getChangedFields() {
        $snapshotData = $this->getSnapshotData();
        if(!is_array($snapshotData)) {
            $fields = array_values($this->getModelsMetaData()->getColumnMap($this));
        } else {
            $snapshotData = $this->getSnapshotData();
            $databaseTypes = $this->getDatabaseTypes();
            foreach($snapshotData as $key=>$value) {
                if(array_key_exists($key, $databaseTypes)) {
                    $databaseType = $databaseTypes[$key];
                    switch($databaseType) {
                        case Column::TYPE_BOOLEAN:
                            $value = (bool)$value;
                            break;
                        case Column::TYPE_INTEGER:
                            $value = (int)$value;
                            break;
                        case Column::TYPE_FLOAT:
                        case Column::TYPE_DOUBLE:
                            $value = (float)$value;
                            break;
                    }
                    $snapshotData[$key] = $value;
                }
            }
            $fields = [];
            foreach($this->getModelsMetaData()->getColumnMap($this) as $shortName) {
                if(!array_key_exists($shortName, $snapshotData)) {
                    $fields[] = $shortName;
                    continue;
                }
                $snapData = $snapshotData[$shortName];
                $fieldValue = $this->readAttribute($shortName);
                if($snapData !== $fieldValue) {
                    $fields[] = $shortName;
                    continue;
                }
            }
        }
        return array_diff($fields, ['updatedAt', 'createdAt']);
    }
535691
public function alteredColumns(): array
    {
        $difference = [];

        $initialColumns = $this->initial->getColumns();
        foreach ($this->current->getColumns() as $name => $column) {
            if (!isset($initialColumns[$name])) {
                //Added into schema
                continue;
            }

            if (!$column->compare($initialColumns[$name])) {
                $difference[] = [$column, $initialColumns[$name]];
            }
        }

        return $difference;
    }