function mailsystem_get_classes in Mail System 6.2
Same name and namespace in other branches
- 8 mailsystem.admin.inc \mailsystem_get_classes()
- 8.2 mailsystem.module \mailsystem_get_classes()
- 6 mailsystem.admin.inc \mailsystem_get_classes()
- 7.3 mailsystem.module \mailsystem_get_classes()
- 7 mailsystem.admin.inc \mailsystem_get_classes()
- 7.2 mailsystem.module \mailsystem_get_classes()
Returns a list of classes which implement MailSystemInterface.
3 calls to mailsystem_get_classes()
- mailsystem_admin_settings in ./
mailsystem.admin.inc - @file Administrative form for setting the mail_system variable.
- mailsystem_create_class in ./
mailsystem.module - Creates and registers a new MailSystemInterface class.
- mailsystem_init in ./
mailsystem.module - Implements hook_init().
File
- ./
mailsystem.module, line 245 - Provide UI for controlling the mail_system variable.
Code
function &mailsystem_get_classes($reset = FALSE) {
static $mailsystem_classes;
if ($reset || !isset($mailsystem_classes)) {
$mailsystem_classes = array();
// @todo Is there a better way to find all mail-related classes?
$declared_classes = get_declared_classes();
$all_classes = array_combine($declared_classes, array_fill(0, count($declared_classes), 0));
$result = db_query("SELECT name, filename " . "FROM {autoload_registry} " . "WHERE type='%s' AND " . "( filename like '%s' OR name like '%s' )", array(
'class',
'%.mail.%',
'%MailSystem',
));
if ($result) {
while ($row = db_fetch_array($result)) {
$classname = $row['name'];
if (file_exists($row['filename']) && autoload_class($classname)) {
$all_classes[$classname] = 1;
}
}
}
foreach ($all_classes as $classname => $autoload) {
if (($autoload || preg_match('/MailSystem/', $classname)) && ($object = new $classname()) && $object instanceof MailSystemInterface) {
$mailsystem_classes[$classname] = $classname;
}
elseif ($autoload) {
// Clear classes that are no longer available.
db_query("DELETE FROM {autoload_registry} " . "WHERE name = '%s'", array(
$classname,
));
}
}
foreach (array_unique(mailsystem_get()) as $classname) {
if (class_exists($classname)) {
$mailsystem_classes[$classname] = $classname;
}
else {
mailsystem_clear(array(
mailsystem_default_id() => $classname,
));
}
}
ksort($mailsystem_classes);
}
return $mailsystem_classes;
}