+// Filter for loading user data
+function FILTER_FETCH_USER_DATA ($userid = 0) {
+ // Is the userid not set? Then use member id
+ if (($userid == '0') || (is_null($userid))) $userid = getMemberId();
+
+ // Get user data
+ if (!fetchUserData($userid)) {
+ // Userid is not valid
+ debug_report_bug(__FUNCTION__, __LINE__, 'User id '.$userid . ' is invalid.');
+ } // END - if
+
+ // Set member id
+ setMemberId($userid);
+}
+
+// Filter for reseting users' last login failure, only available with latest ext-sql_patches
+function FILTER_RESET_USER_LOGIN_FAILURE () {
+ // Is the user data valid?
+ if (!isMember()) {
+ // Do only run for logged in members
+ debug_report_bug(__FUNCTION__, __LINE__, 'Please only run this filter for logged in users.');
+ } // END - if
+
+ // Remmeber login failures if available
+ if (isExtensionInstalledAndNewer('user', '0.3.7')) {
+ // Reset login failures
+ SQL_QUERY_ESC("UPDATE
+ `{?_MYSQL_PREFIX?}_user_data`
+SET
+ `login_failures`=0,
+ `last_failure`=NULL
+WHERE
+ `userid`=%s
+LIMIT 1",
+ array(getMemberId()), __FUNCTION__, __LINE__);
+
+ // Store it in session
+ setSession('mailer_member_failures' , getUserData('login_failures'));
+ setSession('mailer_member_last_failure', getUserData('last_failure'));
+ } // END - if
+}
+
+// Try to login the admin by setting some session/cookie variables
+function FILTER_DO_LOGIN_ADMIN ($data) {
+ // Now set all session variables and store the result for later processing
+ $GLOBALS['admin_login_success'] = ((
+ setAdminMd5(encodeHashForCookie($data['pass_hash']))
+ ) && (
+ setAdminId($data['id'])
+ ) && (
+ setAdminLast(time())
+ ));
+
+ // Return the data for further processing
+ return $data;
+}
+
+// Filter for loading page header, this should be ran first!
+function FILTER_LOAD_PAGE_HEADER () {
+ // Output page header code
+ $GLOBALS['page_header'] = loadTemplate('page_header', true);
+
+ // Include meta data in 'guest' module
+ if (getModule() == 'index') {
+ // Load meta data template
+ $GLOBALS['page_header'] .= loadTemplate('metadata', true);
+
+ // Add meta description to header
+ if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) {
+ // Add meta description not in admin and login module and when the script is installed
+ generateMetaDescriptionCode();
+ } // END - if
+ } // END - if
+}
+
+// Filter for adding style sheet, closing page header
+function FILTER_FINISH_PAGE_HEADER () {
+ // Include stylesheet
+ loadIncludeOnce('inc/stylesheet.php');
+
+ // Closing HEAD tag
+ $GLOBALS['page_header'] .= '</head>';
+}
+
+// Cleans up the DNS cache if sql_patches is at least 0.7.0
+function FILTER_CLEANUP_DNS_CACHE () {
+ // Is the latest version installed?
+ if (isExtensionInstalledAndNewer('sql_patches', '0.7.0')) {
+ // Load class file
+ loadIncludeOnce('inc/classes/resolver.class.php');
+
+ // Instance the resolver
+ $resolver = new HostnameResolver();
+
+ // Purge entries
+ $resolver->purgeEntries();
+
+ // Cute, isn't it? ;-)
+ } // END - if
+}
+
+// Filter for setting CURRENT_DATE, this is required after initialization of extensions
+function FILTER_SET_CURRENT_DATE () {
+ // Set current date
+ setConfigEntry('CURRENT_DATE', generateDateTime(time(), '3'));
+
+ // Epoche time for yesterday, today ... all at 00:00 am
+ setConfigEntry('START_YDAY', makeTime(0, 0, 0, time() - getOneDay()));
+ setConfigEntry('START_TDAY', makeTime(0, 0, 0, time()));
+}
+
+// Filter for marking extension as installed
+function FILTER_EXTENSION_MARK_INSTALLED ($data) {
+ // Mark it as installed
+ $GLOBALS['ext_is_installed'][$data['ext_name']] = true;
+}
+
+// Filter for generating mails links for 'pool' mails
+function FILTER_GENERATE_POOL_MAIL_LINKS ($data) {
+ // Is type 'mid'?
+ if ($data['type'] == 'mid') {
+ // Load template
+ $data['__output'] .= loadTemplate('admin_links_' . strtolower($data['mail_status']) . '_pool_mail', true, $data);
+ } // END - if
+
+ // Return data
+ return $data;
+}
+
+// Filter to activate exchange
+function FILTER_ACTIVATE_EXCHANGE () {
+ // Is the extension 'user' there?
+ if ((!isExtensionActive('user')) || (getActivateXchange() == '0')) {
+ // Silently abort here
+ return false;
+ } // END - if
+
+ // Check total amount of users
+ if (getTotalConfirmedUser() >= getActivateXchange()) {
+ // Activate System
+ addSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N', `hidden`='N', `mem_only`='Y' WHERE `module`='order' LIMIT 1");
+ addSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='order' OR `what`='unconfirmed' LIMIT 2");
+
+ // Run SQLs
+ runFilterChain('run_sqls');
+
+ // Update configuration
+ updateConfiguration('activate_xchange' ,0);
+
+ // Rebuild cache
+ rebuildCache('modules', 'modules');
+ } // END - if
+}
+