2 /************************************************************************
3 * MXChange v0.2.1 Start: 11/23/2003 *
4 * =============== Last change: 09/23/2004 *
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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
45 // Add description as navigation point
46 ADD_DESCR('admin', __FILE__);
49 if (!REQUEST_ISSET_GET('uid')) REQUEST_SET_GET('uid', '');
51 if (REQUEST_GET('uid') == "all") {
52 // Add points to all accounts
53 // @TODO Rewrite this constant
54 define('__POINTS_VALUE', REQUEST_POST('points'));
57 if ((isFormSent()) && (REQUEST_POST('points') > 0)) {
58 $result_main = SQL_QUERY("SELECT userid, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED' ORDER BY `userid` ASC",
60 while ($content = SQL_FETCHARRAY($result_main)) {
61 // Ok, add points to used points and send an email to him...
62 SUB_POINTS("admin_all", $content['userid'], REQUEST_POST('points'));
65 $content['text'] = SQL_ESCAPE(REQUEST_POST('reason'));
66 $content['points'] = bigintval(REQUEST_POST('points'));
68 // Load message and send it away
69 $msg = LOAD_EMAIL_TEMPLATE("sub-points", $content, bigintval($content['userid']));
70 sendEmail($content['email'], getMessage('ADMIN_SUB_SUBJ'), $msg);
74 SQL_FREERESULT($result_main);
77 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_ALL_POINTS_SUBTRACTED'));
79 // Display form add points
80 LOAD_TEMPLATE("admin_sub_points_all");
82 } elseif (REQUEST_ISSET_GET('uid')) {
83 // User ID found in URL so we use this give him some credits
84 $result = SQL_QUERY_ESC("SELECT surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1",
85 array(bigintval(REQUEST_GET('uid'))),__FILE__, __LINE__);
86 if (SQL_NUMROWS($result) == 1) {
87 // Selected user does exist
88 $content = SQL_FETCHARRAY($result);
90 if ((isFormSent()) && (REQUEST_ISSET_POST(('points')))) {
91 // Ok, add to used points and send an email to him...
92 SUB_POINTS("admin_single", bigintval(REQUEST_GET('uid')), REQUEST_POST('points'));
95 $content['text'] = SQL_ESCAPE(REQUEST_POST('reason'));
96 $content['points'] = bigintval(REQUEST_POST('points'));
98 // Load email and send it away
99 $msg = LOAD_EMAIL_TEMPLATE("sub-points", $content, bigintval(REQUEST_GET('uid')));
100 sendEmail($content['email'], getMessage('ADMIN_SUB_SUBJ'), $msg);
103 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_POINTS_SUBTRACTED'));
105 // @TODO Rewrite these constants
106 define('__USER_VALUE', "<a href=\"".generateMemberEmailLink($content['email'], "user_data")."\">".$content['surname']." ".$content['family']."</a>");
107 define('__UID', bigintval(REQUEST_GET('uid')));
110 LOAD_TEMPLATE("admin_sub_points");
114 LOAD_TEMPLATE('admin_settings_saved', false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), REQUEST_GET('uid'))."</div>");
118 SQL_FREERESULT($result);
120 // Output selection form with all confirmed user accounts listed
121 ADD_MEMBER_SELECTION_BOX('0', true);