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

@param User $from
@param User $to

@return int
496466
public function replaceMessageUser(User $from, User $to)
    {
        $messages = $this->messageRepo->findByCreator($from);
        if (count($messages) > 0) {
            foreach ($messages as $message) {
                $message->setCreator($to);
                $message->setAuthor($to->getFirstName().' '.$to->getLastName());
            }
            $this->om->flush();
        }

        return count($messages);
    }
1120410
static public function convert($uuid, $from, $to) {
    $conv = self::$m_convert[$from][$to];
    if (!isset($conv))
      return ($uuid);

    return (self::$conv($uuid));
  }
721935
public static function move($from, $to)
    {
        return self::copy($from, $to) && self::delete($from);
    }
972449
public static function copy(string $from, string $to) {
		ref\file::path($from, true);
		if (! $from) {
			return false;
		}

		ref\file::path($to, false);
		if (! $to || ($from === $to)) {
			return false;
		}

		// Recurse directories.
		if (@\is_dir($from)) {
			ref\file::trailingslash($from);
			ref\file::trailingslash($to);

			if (! @\is_dir($to)) {
				$dir_chmod = (@\fileperms($from) & 0777 | 0755);
				if (! static::mkdir($to, $dir_chmod)) {
					return false;
				}
			}

			// Copy all files and directories within.
			if ($handle = @\opendir($from)) {
				while (false !== ($file = @\readdir($handle))) {
					// Ignore dots.
					if (('.' === $file) || ('..' === $file)) {
						continue;
					}

					// Recurse.
					static::copy("{$from}{$file}", "{$to}{$file}");
				}
				\closedir($handle);
			}

			return true;
		}
		// Let PHP handle it.
		elseif (@\is_file($from)) {
			$dir_from = \dirname($from);
			$dir_to = \dirname($to);

			// Make the TO directory if it doesn't exist.
			if (! @\is_dir($dir_to)) {
				$dir_chmod = (@\fileperms($dir_from) & 0777 | 0755);
				if (! static::mkdir($dir_to, $dir_chmod)) {
					return false;
				}
			}

			// Copy the file.
			if (! @\copy($from, $to)) {
				return false;
			}
			$file_chmod = (@\fileperms($from) & 0777 | 0644);
			@\chmod($to, $file_chmod);

			return true;
		}

		return false;
	}
571854
public function setFrom(\WobbleCode\UserBundle\Document\User $from)
    {
        $this->from = $from;
        return $this;
    }
656894
public function setFromAndTo($fromUserName, $toUserName)
    {
        $this->_from = $toUserName;
        $this->_to = $fromUserName;
        return $this;
    }
297928
public function relPath($from,$to) {
		$expFrom = explode('/',$from);
		$expTo = explode('/',$to);
		$max=max(count($expFrom),count($expTo));
		$rel = [];
		$base=TRUE;
		for ($i=0;$i<$max;$i++) {
			if ($base && isset($expTo[$i]) && isset($expFrom[$i])
				&& $expTo[$i] === $expFrom[$i])
				continue;
			else
				$base=FALSE;
			if (!empty($expFrom[$i]))
				array_unshift($rel,'..');
			if (!empty($expTo[$i]))
				array_push($rel,$expTo[$i]);
		}
		return implode('/',$rel);
	}
376857
public function rename($from, $to) {
		$path1 = $this->escapePath($from);
		$path2 = $this->escapePath($to);
		$output = $this->execute('rename ' . $path1 . ' ' . $path2);
		return $this->parseOutput($output, $to);
	}
109707
public function replaceDropUser(User $from, User $to)
    {
        $drops = $this->dropRepo->findByUser($from);

        if (count($drops) > 0) {
            foreach ($drops as $drop) {
                $drop->setUser($to);
            }

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

        return count($drops);
    }
953509
public function replaceMemberAuthor(User $from, User $to)
    {
        $fromIsMember = false;
        $froms = $this->memberRepo->findByUser($from);
        if (count($froms) > 0) {
            $fromIsMember = true;
        }

        $toIsMember = false;
        $tos = $this->memberRepo->findByUser($to);
        if (count($tos) > 0) {
            $toIsMember = true;
        }

        if ($toIsMember && $fromIsMember) {
            //user kept already have its member entry, delete the old one
            foreach ($froms as $member) {
                $this->objectManager->remove($member);
            }
            $this->objectManager->flush();
        } elseif (!$toIsMember && $fromIsMember) {
            //update entry for kept user
            foreach ($froms as $member) {
                $member->setUser($to);
            }
            $this->objectManager->flush();
        }
    }
862546
public function replaceCasUserUser(User $from, User $to)
    {
        $casUsers = $this->om->getRepository("Claroline\AuthenticationBundle\Entity\Cas\CasUser")->findByUser($from);

        if (count($casUsers) > 0) {
            foreach ($casUsers as $casUser) {
                $casUser->setUser($to);
            }

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

        return count($casUsers);
    }
72799
public function replaceEventInvitationUser(User $from, User $to)
    {
        $eventInvitations = $this->om->getRepository('ClarolineAgendaBundle:EventInvitation')->findByUser($from);

        if (count($eventInvitations) > 0) {
            foreach ($eventInvitations as $eventInvitation) {
                $eventInvitation->setUser($to);
            }

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

        return count($eventInvitations);
    }
1277513
public function replaceUser(User $from, User $to)
    {
        $portfolioComments = $this->entityManager->getRepository('IcapPortfolioBundle:PortfolioComment')->findBySender($from);

        if (count($portfolioComments) > 0) {
            foreach ($portfolioComments as $portfolioComment) {
                $portfolioComment->setSender($to);
            }

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

        return count($portfolioComments);
    }
20781
public function replaceCommentAuthor(User $from, User $to)
    {
        $comments = $this->repo->findByAuthor($from);

        if (count($comments) > 0) {
            foreach ($comments as $comment) {
                $comment->setAuthor($to);
            }

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

        return count($comments);
    }
891514
public function replaceUser(User $from, User $to)
    {
        $marks = $this->repo->findByUser($from);

        if (count($marks) > 0) {
            foreach ($marks as $mark) {
                $mark->setUser($to);
            }

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

        return count($marks);
    }
292167
public function replaceUser(User $from, User $to)
    {
        $drops = $this->em->getRepository('IcapDropzoneBundle:Drop')->findByUser($from);

        if (count($drops) > 0) {
            foreach ($drops as $drop) {
                $drop->setUser($to);
            }

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

        return count($drops);
    }
849545
public function moveFile( $from, $to )
	{
		$this->connection->checkConnection();
		return @ftp_rename( $this->connection->getResource(), $from, $to );
	}