Find all content for a given user and replace him by another.

@param User $from
@param User $to

@return int
170592
public function replaceObjectiveProgressUser(User $from, User $to)
    {
        $objectiveProgresses = $this->objectiveProgressRepo->findByUser($from);

        if (count($objectiveProgresses) > 0) {
            foreach ($objectiveProgresses as $objectiveProgress) {
                $objectiveProgress->setUser($to);
            }

            $this->om->flush();
        }

        return count($objectiveProgresses);
    }
1063841
public function replace($from, $to) : ArrayList
    {
        $values = $this->_replace($from, $to);
        $this->setValues($values);
        return $this;
    }
80929
function copyAsUser($from, $to)
    {
        copy($from, $to);

        $this->chown($to, user());
    }
799820
public function replaceCreator(User $from, User $to)
    {
        /** @var ResourceNode[] $nodes */
        $nodes = $this->resourceNodeRepo->findBy([
            'creator' => $from,
        ]);

        if (count($nodes) > 0) {
            foreach ($nodes as $node) {
                $node->setCreator($to);
            }

            $this->om->flush();
        }

        return count($nodes);
    }
992026
public function move($from, $to)
    {
        return $this->filesystem->move(
            $this->path($from),
            $this->path($to)
        );
    }
673746
public function replaceCorrectionUser(User $from, User $to)
    {
        $corrections = $this->correctionRepo->findByUser($from);

        if (count($corrections) > 0) {
            foreach ($corrections as $correction) {
                $correction->setUser($to);
            }

            $this->om->flush();
        }

        return count($corrections);
    }
177926
public function rename($from, $to) {
		return $this->getState()->rename($this->buildUrl($from), $this->buildUrl($to));
	}
765510
protected function deleteRelationData($from, $to)
    {
        $config  = Config::table($from);
        $content = $config->get();
        unset($content->relations->{$to});
        $config->put($content);
    }
1126960
private function recipientUsers(string $to): Collection
    {
        switch ($to) {
            default:
            case 'all':
                return $this->user_service->all();
            case 'never_logged':
                return $this->user_service->all()->filter(static function (UserInterface $user): bool {
                    return $user->getPreference('verified_by_admin') && $user->getPreference('reg_timestamp') > $user->getPreference('sessiontime');
                });
            case 'last_6mo':
                $six_months_ago = Carbon::now()->subMonths(6)->unix();

                return $this->user_service->all()->filter(static function (UserInterface $user) use ($six_months_ago): bool {
                    $session_time = (int) $user->getPreference('sessiontime');

                    return $session_time > 0 && $session_time < $six_months_ago;
                });
        }
    }
1117648
protected function copy($from, $to = null)
    {
        if (is_array($from) && is_null($to)) {
            foreach ($from as $key => $value) {
                $this->copy($key, $value);
            }

            return;
        }

        if (!file_exists($from)) {
            return;
        }

        $to = $this->extensionPath($to);

        $this->filesystem->copy($from, $to);
    }
151768
public function humanizedChanges($from, $to)
    {
        if (!$from) {
            return _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.UPLOADEDFILE', "Uploaded file");
        }

        $fromRecord = Versioned::get_version(get_class($this->owner), $this->owner->ID, $from);
        $toRecord = Versioned::get_version(get_class($this->owner), $this->owner->ID, $to);

        $diff = new DataDifferencer($fromRecord, $toRecord);
        $changes = $diff->changedFieldNames();

        $k = array_search('LastEdited', $changes);

        if ($k !== false) {
            unset($changes[$k]);
        }

        $output = array();

        foreach ($changes as $change) {
            $human = $change;

            if ($change == "ParentID") {
                // updated folder ID
                $human = _t(
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdminFile.MOVEDFOLDER',
                    "Moved file"
                );
            } elseif ($change == 'Title') {
                $human = _t(
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdminFile.RENAMEDTITLE',
                    "Updated title to "
                ) . $fromRecord->Title;
            } elseif ($change == 'Name') {
                $human = _t(
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdminFile.RENAMEDFILE',
                    "Renamed file to "
                ) . $fromRecord->Filename;
            } elseif ($change == 'File') {
                // check to make sure the files are actually different
                if ($fromRecord->getHash() != $toRecord->getHash()) {
                    $human = _t(
                        'SilverStripe\\AssetAdmin\\Controller\\AssetAdminFile.RENAMEDFILE',
                        "Replaced file"
                    );
                } else {
                    $human = false;
                }
            } else {
                $human = false;
            }

            if ($human) {
                $output[] = $human;
            }
        }

        return implode(", ", $output);
    }
564080
protected function status($from, $to)
    {
        $from = str_replace(base_path(), '', realpath($from));
        $to = str_replace(base_path(), '', realpath($to));
        $this->line("<info>Copied File</info> <comment>[{$from}]</comment> <info>To</info> <comment>[{$to}]</comment>");
    }
357201
public function replaceEntryUserUser(User $from, User $to)
    {
        $entryUsers = $this->entryUserRepo->findByUser($from);

        if (count($entryUsers) > 0) {
            foreach ($entryUsers as $entryUser) {
                $entryUser->setUser($to);
            }

            $this->om->flush();
        }

        return count($entryUsers);
    }
166628
public function ipInRange($ip, $from, $to)
    {
        $ip = $this->getIpNumberFromAddress($ip);
        $from = $this->getIpNumberFromAddress($from);
        $to = $this->getIpNumberFromAddress($to);

        return (!$ip || !$from || !$to) ? false : ($ip <= $to && $from <= $ip);
    }
168144
public function rename($from, $to)
    {
        $from = trim($from, '.');
        $to = trim($to, '.');
        if ($this->has($from)) {
            $value = $this->get($from);
            $this->remove($from);
            $this->set($to, $value);
            return true;
        }
        return false;
    }
534493
public function diff($from, $to)
    {
        $buffer = $this->header;
        $diff   = $this->diffToArray($from,$to);

        $inOld = FALSE;
        $i     = 0;
        $old   = array();

        foreach ($diff as $line) {
            if ($line[1] ===  0 /* OLD */) {
                if ($inOld === FALSE) {
                    $inOld = $i;
                }
            }

            else if ($inOld !== FALSE) {
                if (($i - $inOld) > 5) {
                    $old[$inOld] = $i - 1;
                }

                $inOld = FALSE;
            }

            ++$i;
        }

        $start = isset($old[0]) ? $old[0] : 0;
        $end   = count($diff);

        if ($tmp = array_search($end, $old)) {
            $end = $tmp;
        }

        $newChunk = TRUE;

        for ($i = $start; $i < $end; $i++) {
            if (isset($old[$i])) {
                $buffer  .= "\n";
                $newChunk = TRUE;
                $i        = $old[$i];
            }

            if ($newChunk) {
                $buffer  .= "@@ @@\n";
                $newChunk = FALSE;
            }

            if ($diff[$i][1] === 1 /* ADDED */) {
                $buffer .= '+' . $diff[$i][0] . "\n";
            }

            else if ($diff[$i][1] === 2 /* REMOVED */) {
                $buffer .= '-' . $diff[$i][0] . "\n";
            }

            else {
                $buffer .= ' ' . $diff[$i][0] . "\n";
            }
        }

        return $buffer;
    }
353383
public function replaceUser(User $from, User $to)
    {
        $objectives = $this->objectiveRepo->findAllByUser($from);

        if (count($objectives) > 0) {
            foreach ($objectives as $objective) {
                $objective->removeUser($from);
                $objectives->addUser($to);
            }

            $this->om->flush();
        }

        return count($objectives);
    }