A lot CSS classes rewritten, please update all your themes.
[mailer.git] / inc / modules / admin / what-sub_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-sub_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  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (getRequestParameter('userid') == 'all') {
49         // Is the form sent?
50         if ((isFormSent()) && (postRequestParameter('points') > 0)) {
51                 // Add points to all accounts
52                 $content['points'] = bigintval(postRequestParameter('points'));
53
54                 // Load userid
55                 $result_main = SQL_QUERY("SELECT userid, email FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' ORDER BY `userid` ASC",
56                         __FILE__, __LINE__);
57                 while ($row = SQL_FETCHARRAY($result_main)) {
58                         // Merge both arrays
59                         $content = merge_array($content, $row);
60
61                         // Ok, add points to used points and send an email to him...
62                         subtractPoints('admin_all', $content['userid'], postRequestParameter('points'));
63
64                         // Prepare content
65                         $content = array(
66                                 'reason' => SQL_ESCAPE(postRequestParameter('reason')),
67                                 'points' => bigintval(postRequestParameter('points'))
68                         );
69
70                         // Load message and send it away
71                         $message = loadEmailTemplate('sub-points', $content, bigintval($content['userid']));
72                         sendEmail($content['email'], '{--ADMIN_SUB_SUBJECT--}', $message);
73                 } // END - while
74
75                 // Free memory
76                 SQL_FREERESULT($result_main);
77
78                 // Output message
79                 loadTemplate('admin_settings_saved', false, '{--ADMIN_ALL_POINTS_SUBTRACTED--}');
80         } else {
81                 // Display form add points
82                 loadTemplate('admin_sub_points_all');
83         }
84 } elseif (isGetRequestParameterSet('userid')) {
85         // User id found in URL so we use this give him some credits
86         if (fetchUserData(getRequestParameter('userid'))) {
87                 // Selected user does exist
88                 $content = getUserDataArray();
89
90                 if ((isFormSent()) && (isPostRequestParameterSet('points'))) {
91                         // Ok, add to used points and send an email to him...
92                         subtractPoints('admin_single', bigintval(getRequestParameter('userid')), postRequestParameter('points'));
93
94                         // Prepare content
95                         $content = array(
96                                 'reason' => SQL_ESCAPE(postRequestParameter('reason')),
97                                 'points' => bigintval(postRequestParameter('points'))
98                         );
99
100                         // Load email and send it away
101                         $message = loadEmailTemplate('sub-points', $content, bigintval(getRequestParameter('userid')));
102                         sendEmail($content['email'], '{--ADMIN_SUB_SUBJECT--}', $message);
103
104                         // Output message
105                         loadTemplate('admin_settings_saved', false, '{--ADMIN_POINTS_SUBTRACTED--}');
106                 } else {
107                         // Prepare content
108                         $content['userid'] = bigintval(getRequestParameter('userid'));
109
110                         // Load form
111                         loadTemplate('admin_sub_points', false, $content);
112                 }
113         } else {
114                 // User not found!
115                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_MEMBER_404', bigintval(getRequestParameter('userid'))));
116         }
117 } else {
118         // Output selection form with all confirmed user accounts listed
119         addMemberSelectionBox(0, true);
120 }
121
122 // [EOF]
123 ?>