The usual asset of bugfixes/improvements:
[mailer.git] / inc / modules / admin / what-add_points.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/23/2003 *
4  * ===================                          Last change: 09/23/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-add_points.php                              *
8  * -------------------------------------------------------------------- *
9  * Short description : Add manually points to a user                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Manuell einem Mitglied Punkte gutschreiben       *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 if (getRequestParameter('userid') == 'all') {
47         // Add points to all accounts
48         if ((isFormSent()) && (postRequestParameter('points') > 0)) {
49                 // Points
50                 $content['points'] = bigintval(postRequestParameter('points'));
51
52                 // Select all users
53                 $result_main = SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' ORDER BY `userid` ASC",
54                         __FILE__, __LINE__);
55
56                 // Process all entries
57                 while ($row = SQL_FETCHARRAY($result_main)) {
58                         // Merge $row into $content
59                         $content = merge_array($content, $row);
60
61                         // Remove depth to prevent booking errors. This is a bad coding
62                         // practice, thats also why we need to write this project from
63                         // scratch...
64                         $GLOBALS['ref_level'] = -1;
65
66                         // Ok, add points and send an email to him...
67                         addPointsDirectly('admin_all', $content['userid'], bigintval(postRequestParameter('points')));
68
69                         // Prepare content
70                         $content = array(
71                                 'reason' => SQL_ESCAPE(postRequestParameter('reason')),
72                                 'points' => bigintval(postRequestParameter('points')),
73                                 'userid' => $row['userid']
74                         );
75
76                         // Load email template and send email away
77                         $message = loadEmailTemplate('add-points', $content, bigintval($content['userid']));
78                         sendEmail(bigintval($content['userid']), '{--ADMIN_ADD_SUBJECT--}', $message);
79                 } // END - while
80
81                 // Free memory
82                 SQL_FREERESULT($result_main);
83
84                 // Output message
85                 loadTemplate('admin_settings_saved', false, '{--ADMIN_ALL_POINTS_ADDED--}');
86         } else {
87                 // Display form add points
88                 loadTemplate('admin_add_points_all');
89         }
90 } elseif (isGetRequestParameterSet('userid')) {
91         // User id found in URL so we use this give him some credits
92         if (fetchUserData(getRequestParameter('userid'))) {
93                 // Selected user does exist
94                 $content = getUserDataArray();
95
96                 if ((isFormSent()) && (isPostRequestParameterSet('points'))) {
97                         // Add points and send an email to him...
98                         addPointsDirectly('admin_single', bigintval(getRequestParameter('userid')), bigintval(postRequestParameter('points')));
99
100                         // Prepare content
101                         $content = array(
102                                 'reason' => SQL_ESCAPE(postRequestParameter('reason')),
103                                 'points' => bigintval(postRequestParameter('points'))
104                         );
105
106                         // Message laden
107                         $message = loadEmailTemplate('add-points', $content, bigintval(getRequestParameter('userid')));
108
109                         sendEmail(bigintval(getRequestParameter('userid')), '{--ADMIN_ADD_SUBJECT--}', $message);
110                         loadTemplate('admin_settings_saved', false, '{--ADMIN_POINTS_ADDED--}');
111                 } else {
112                         // Prepare content
113                         $content['userid'] = bigintval(getRequestParameter('userid'));
114
115                         // Output template
116                         loadTemplate('admin_add_points', false, $content);
117                 }
118         } else {
119                 // User not found!
120                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_MEMBER_404', bigintval(getRequestParameter('userid'))));
121         }
122 } else {
123         // Output selection form with all confirmed user accounts listed
124         addMemberSelectionBox(0, true);
125 }
126
127 // [EOF]
128 ?>