]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-add_points.php
Email templates added when member edits his/her URLs
[mailer.git] / inc / modules / admin / what-add_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-add_points.php                              *
8  * -------------------------------------------------------------------- *
9  * Short description : Add manually points to a user                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Manuell einem Mitglied Punkte gutschreiben       *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
42
43 // Fix a notice
44 if (!isset($_GET['u_id'])) $_GET['u_id'] = "";
45
46 if ($_GET['u_id'] == "all") {
47         // Add points to all accounts
48         if ((isset($_POST['ok'])) && ($_POST['points'] > 0)) {
49                 define('__POINTS_VALUE', $_POST['points']);
50                 $result_main = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' ORDER BY userid", __FILE__, __LINE__);
51                 while (list($uid) = SQL_FETCHROW($result_main)) {
52                         // User ID found in URL so we use this give him some credits
53                         $result = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
54                          array(bigintval($uid)), __FILE__, __LINE__);
55                         if (SQL_NUMROWS($result) == 1) {
56                                 // Selected user does exist
57                                 list($sname, $fname, $email) = SQL_FETCHROW($result);
58                                 SQL_FREERESULT($result);
59
60                                 if ((isset($_POST['ok'])) && (!empty($_POST['points']))) {
61                                         global $DEPTH;
62                                         // Remove depth to prevent booking errors. This is a bad coding
63                                         // practice, thats also why we need to write this project from
64                                         // scratch...
65                                         unset($DEPTH);
66
67                                         // Ok, add points and send an email to him...
68                                         ADD_POINTS_REFSYSTEM("admin_all", $uid, bigintval($_POST['points']), false, "0", false, "direct");
69
70                                         // Prepare content
71                                         $content = array(
72                                                 'text'   => SQL_ESCAPE($_POST['reason']),
73                                                 'points' => bigintval($_POST['points'])
74                                         );
75
76                                         // Load email template and send email away
77                                         $msg = LOAD_EMAIL_TEMPLATE("add-points", $content, bigintval($uid));
78                                         SEND_EMAIL(bigintval($uid), ADMIN_ADD_SUBJ, $msg);
79                                 }
80                         }
81                 }
82
83                 // Free memory
84                 SQL_FREERESULT($result_main);
85
86                 // Output message
87                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_ALL_POINTS_ADDED);
88         } else {
89                 // Display form add points
90                 LOAD_TEMPLATE("admin_add_points_all");
91         }
92 } elseif (!empty($_GET['u_id'])) {
93         // User ID found in URL so we use this give him some credits
94         $result = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
95          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
96         if (SQL_NUMROWS($result) == 1) {
97                 // Selected user does exist
98                 list($sname, $fname, $email) = SQL_FETCHROW($result);
99                 SQL_FREERESULT($result);
100
101                 if ((isset($_POST['ok'])) && (!empty($_POST['points']))) {
102                         global $DEPTH;
103                         // Remove depth to prevent booking errors. This is a bad coding
104                         // practice, thats also why we need to write this project from
105                         // scratch...
106                         unset($DEPTH);
107
108                         // Ok, add points and send an email to him...
109                         ADD_POINTS_REFSYSTEM("admin_single", bigintval($_GET['u_id']), bigintval($_POST['points']), false, "0", false, "direct");
110
111                         // Prepare content
112                         $content = array(
113                                 'text'   => SQL_ESCAPE($_POST['reason']),
114                                 'points' => bigintval($_POST['points'])
115                         );
116
117                         // Message laden
118                         $msg = LOAD_EMAIL_TEMPLATE("add-points", $content, bigintval($_GET['u_id']));
119
120                         SEND_EMAIL(bigintval($_GET['u_id']), ADMIN_ADD_SUBJ, $msg);
121                         LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_POINTS_ADDED);
122                 } else {
123                         // Opps, missing form here
124                         define('__USER_VALUE', "<A href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$sname." ".$fname."</A>");
125                         define('__UID'       , bigintval($_GET['u_id']));
126                         LOAD_TEMPLATE("admin_add_points");
127                 }
128         } else {
129                 // User not found!
130                 OUTPUT_HTML("<STRONG class=\"admin_failed\">".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2."</STRONG>");
131         }
132 } else {
133         // Output selection form with all confirmed user accounts listed
134         ADD_MEMBER_SELECTION_BOX("0", true);
135 }
136
137 //
138 ?>