A lot texts rewritten and exclamation signs removed
[mailer.git] / inc / modules / admin / what-sub_points.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
41         die();
42 }
43
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
46
47 if (getRequestElement('userid') == 'all') {
48         // Add points to all accounts
49         $content['points'] = bigintval(postRequestElement('points'));
50
51         // Is the form sent?
52         if ((isFormSent()) && (postRequestElement('points') > 0)) {
53                 $result_main = SQL_QUERY("SELECT userid, email FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' ORDER BY `userid` ASC",
54                 __FILE__, __LINE__);
55                 while ($content = merge_array($content, SQL_FETCHARRAY($result_main))) {
56                         // Ok, add points to used points and send an email to him...
57                         subtractPoints('admin_all', $content['userid'], postRequestElement('points'));
58
59                         // Add more content
60                         $content['text']   = SQL_ESCAPE(postRequestElement('reason'));
61                         $content['points'] = bigintval(postRequestElement('points'));
62
63                         // Load message and send it away
64                         $message = loadEmailTemplate('sub-points', $content, bigintval($content['userid']));
65                         sendEmail($content['email'], getMessage('ADMIN_SUB_SUBJ'), $message);
66                 } // END - while
67
68                 // Free memory
69                 SQL_FREERESULT($result_main);
70
71                 // Output message
72                 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_ALL_POINTS_SUBTRACTED'));
73         } else {
74                 // Display form add points
75                 loadTemplate('admin_sub_points_all');
76         }
77 } elseif (isGetRequestElementSet('userid')) {
78         // User id found in URL so we use this give him some credits
79         $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s AND `status`='CONFIRMED' LIMIT 1",
80                 array(bigintval(getRequestElement('userid'))),__FILE__, __LINE__);
81         if (SQL_NUMROWS($result) == 1) {
82                 // Selected user does exist
83                 $content = SQL_FETCHARRAY($result);
84
85                 if ((isFormSent()) && (isPostRequestElementSet(('points')))) {
86                         // Ok, add to used points and send an email to him...
87                         subtractPoints('admin_single', bigintval(getRequestElement('userid')), postRequestElement('points'));
88
89                         // Add more content
90                         $content['text']   = SQL_ESCAPE(postRequestElement('reason'));
91                         $content['points'] = bigintval(postRequestElement('points'));
92
93                         // Load email and send it away
94                         $message = loadEmailTemplate('sub-points', $content, bigintval(getRequestElement('userid')));
95                         sendEmail($content['email'], getMessage('ADMIN_SUB_SUBJ'), $message);
96
97                         // Output message
98                         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_POINTS_SUBTRACTED'));
99                 } else {
100                         // Prepare content
101                         $content['user']   = "<a href=\"".generateEmailLink($content['email'], 'user_data')."\">".$content['surname']." ".$content['family']."</a>";
102                         $content['userid'] = bigintval(getRequestElement('userid'));
103
104                         // Load form
105                         loadTemplate('admin_sub_points', false, $content);
106                 }
107         } else {
108                 // User not found!
109                 loadTemplate('admin_settings_saved', false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), getRequestElement('userid'))."</div>");
110         }
111
112         // Free result
113         SQL_FREERESULT($result);
114 } else {
115         // Output selection form with all confirmed user accounts listed
116         addMemberSelectionBox(0, true);
117 }
118
119 // [EOF]
120 ?>