+ loadTemplate('admin_list_admins', false, $OUT);
+}
+
+// Filter for adding extra data to the query
+function FILTER_ADD_EXTRA_SQL_DATA ($add = '') {
+ // Is the admins extension updated? (should be!)
+ if (getExtensionVersion('admins') >= '0.3.0') $add .= ', `default_acl` AS def_acl';
+ if (getExtensionVersion('admins') >= '0.6.7') $add .= ', `la_mode`';
+ if (getExtensionVersion('admins') >= '0.7.2') $add .= ', `login_failures`, UNIX_TIMESTAMP(`last_failure`) AS last_failure';
+
+ // Return it
+ return $add;
+}
+
+// Sends out mail to all administrators
+// IMPORTANT: Please use SEND_ADMIN_NOTIFCATION() for now!
+function sendAdminsEmails ($subj, $template, $content, $UID) {
+ // Trim template name
+ $template = trim($template);
+
+ // Load email template
+ $message = loadEmailTemplate($template, $content, $UID);
+
+ // Check which admin shall receive this mail
+ $result = SQL_QUERY_ESC("SELECT `admin_id` FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE `mail_template`='%s' ORDER BY `admin_id` ASC",
+ array($template), __FUNCTION__, __LINE__);
+ if (SQL_NUMROWS($result) == '0') {
+ // Create new entry (to all admins)
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (`admin_id`, `mail_template`) VALUES (0, '%s')",
+ array($template), __FUNCTION__, __LINE__);
+ } else {
+ // Load admin ids...
+ // @TODO This can be, somehow, rewritten
+ $adminIds = array();
+ while ($content = SQL_FETCHARRAY($result)) {
+ $adminIds[] = $content['admin_id'];
+ } // END - while
+
+ // Free memory
+ SQL_FREERESULT($result);
+
+ // Init result
+ $result = false;
+
+ // "implode" ids and query string
+ $adminId = implode(',', $adminIds);
+ if ($adminId == '-1') {
+ if (isExtensionActive('events')) {
+ // Add line to user events
+ EVENTS_ADD_LINE($subj, $message, $UID);
+ } else {
+ // Log error for debug
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Extension 'events' missing: tpl=%s,subj=%s,UID=%s",
+ $template,
+ $subj,
+ $UID
+ ));
+ }
+ } elseif ($adminId == '0') {
+ // Select all email adresses
+ $result = SQL_QUERY("SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC",
+ __FUNCTION__, __LINE__);
+ } else {
+ // If Admin-Id is not "to-all" select
+ $result = SQL_QUERY_ESC("SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id` IN (%s) ORDER BY `id` ASC",
+ array($adminId), __FUNCTION__, __LINE__);
+ }
+ }
+
+ // Load email addresses and send away
+ while ($content = SQL_FETCHARRAY($result)) {
+ sendEmail($content['email'], $subj, $message);
+ } // END - while
+
+ // Free memory
+ SQL_FREERESULT($result);