As others have remarked, the kernel provides \@ifpackageloaded and ltxcmds also \ltx@ifpackageloaded that can be used in the document.
\usepackage{ltxcmds,etoolbox}
\makeatletter
\newcommand{\IfPackagesLoaded}[1]{%
\@tempswatrue
\def\do##1{\edef\@tempa{\zap@space##1 \@empty}%
\ltx@ifpackageloaded{\@tempa}{}{\@tempswafalse}}%
\docsvlist{#1}%
\if@tempswa\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
\makeatother
Processing the list element through \zap@space ensures that no spaces around the package name remain also if the call is
\IfPackagesLoaded{ abc , xyz }
The conditional \if@tempswa is predefined by LaTeX and is used as a "scratch conditional"; it should be relied on only on immediate application, as other macros might change its truth value. The idea is that the conditional is set to true at the beginning and each "not already loaded" package in the list sets it to false. Therefore it will be still true at the end only if all packages in the list are already loaded.
The final line uses this fact and uses the code in the second or third arguments to \IfPackagesLoaded. Actually they aren't really arguments to \IfPackagesLoaded, but from the user's point of view it makes no difference. I might have defined \IfPackagesLoaded with three arguments by using as the last instruction
\if@tempswa#2\else#3\fi
but the way chosen is better as it leaves no trailing \else or \fi when the code in the second and third argument is executed.
\@firstoftwoand\@secondoftwoand why can you rename\@IfPackagesLoadedwithin the command itself? I would assume that it is not available in the second iteration in that case. So basically I do not understand most of this code... – Matthias Pospiech Nov 20 '11 at 18:52