mailer project continued:
[mailer.git] / inc / filter / user_filter.php
index a98c45be3f6c55194fa47519830bab9be3ca28f8..95f91b3df5aa24147397046fa5f009637200faec 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -42,8 +42,9 @@ if (!defined('__SECURITY')) {
 
 // Filter for returning given user's points
 function FILTER_USER_POINTS ($filterData) {
-       // Get the points and add them to the existing
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+
+       // Get the points and add them to the existing
        $filterData['points'] += countSumTotalData($filterData['userid'], 'user_points', 'points');
 
        // Return the data for next filter
@@ -51,5 +52,100 @@ function FILTER_USER_POINTS ($filterData) {
        return $filterData;
 }
 
+// Filter for returning given user's locked points
+function FILTER_LOCKED_USER_POINTS ($filterData) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+
+       // Get the points and add them to the existing
+       $filterData['points'] += countSumTotalData($filterData['userid'], 'user_points', 'locked_points');
+
+       // Return the data for next filter
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
+       return $filterData;
+}
+
+// Filter for returning all user points column names
+function FILTER_GET_ALL_USER_POINTS_COLUMN_NAMES ($filterData) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+       // Add 'points' and 'locked_points'
+       $filterData['columns'] .= $filterData['alias'] . 'points' . $filterData['separator'] . $filterData['alias'] . 'locked_points' . $filterData['separator'];
+
+       // Return the data for next filter
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
+       return $filterData;
+}
+
+// Filter for excluding tester users in WHERE statements
+function FILTER_TESTER_USER_EXCLUSION_SQL ($sql) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called! - sql(' . strlen($sql) . ')=' . $sql);
+
+       /*
+        * Allow testers to be included? Do only this when you only want to test
+        * it, normally you don't want these accounts being included everywhere.
+        */
+       if (ifTesterAccountsAllowed()) {
+               // Do not exclude tester accounts
+               return $sql;
+       } // END - if
+
+       // Add it, as of this filter is registered only with ext-user >= 0.5.0
+       if (empty($sql)) {
+               // Add WHERE
+               $sql = " WHERE `surname` NOT LIKE '{?tester_user_surname_prefix?}%%'";
+       } else {
+               // Add AND
+               $sql .= " AND `surname` NOT LIKE '{?tester_user_surname_prefix?}%%'";
+       }
+
+       // Return the data for next filter
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done! - sql(' . strlen($sql) . ')=' . $sql);
+       return $sql;
+}
+
+// Filter for including tester users in WHERE statements
+function FILTER_TESTER_USER_INCLUSION_SQL ($sql) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called! - sql(' . strlen($sql) . ')=' . $sql);
+       // Add it, as of this filter is registered only with ext-user >= 0.5.0
+       if (empty($sql)) {
+               // Add WHERE
+               $sql = " WHERE `surname` LIKE '{?tester_user_surname_prefix?}%%'";
+       } else {
+               // Add AND
+               $sql .= " AND `surname` LIKE '{?tester_user_surname_prefix?}%%'";
+       }
+
+       // Return the data for next filter
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done! - sql(' . strlen($sql) . ')=' . $sql);
+       return $sql;
+}
+
+// Filter to add SQL columns to user registration
+function FILTER_TESTER_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+
+       // Does the admin create a tester account?
+       if ((isAdmin()) && (isTesterUserName(postRequestElement('surname')))) {
+               // Yes, these accounts never needs confirmation (you can still test it by creating a usual account).
+               setPostRequestElement('status', 'CONFIRMED');
+       } // END - if
+
+       // Return filter data
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
+       //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=<pre>'.print_r($filterData,true).'</pre>';
+       return $filterData;
+}
+
+// Filter to add 'converting' SQL statements
+function FILTER_ADD_USER_DATA_CONVERT_SQL_COLUMNS ($sql) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called! - sql(' . strlen($sql) . ')=' . $sql);
+
+       // Add it
+       $sql .= ', UNIX_TIMESTAMP(`lock_timestamp`) AS `lock_timestamp`';
+
+       // Return the data for next filter
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done! - sql(' . strlen($sql) . ')=' . $sql);
+       return $sql;
+}
+
 // [EOF]
 ?>