2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 - 2009 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')) || (!isAdmin())) {
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
47 if (getRequestElement('userid') == 'all') {
48 // Add points to all accounts
49 $content['points'] = bigintval(postRequestElement('points'));
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",
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'));
60 $content['text'] = SQL_ESCAPE(postRequestElement('reason'));
61 $content['points'] = bigintval(postRequestElement('points'));
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);
69 SQL_FREERESULT($result_main);
72 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_ALL_POINTS_SUBTRACTED'));
74 // Display form add points
75 loadTemplate('admin_sub_points_all');
77 } elseif (isGetRequestElementSet('userid')) {
78 // User id found in URL so we use this give him some credits
79 if (fetchUserData(getRequestElement('userid'))) {
80 // Selected user does exist
81 $content = getUserDataArray();
83 if ((isFormSent()) && (isPostRequestElementSet(('points')))) {
84 // Ok, add to used points and send an email to him...
85 subtractPoints('admin_single', bigintval(getRequestElement('userid')), postRequestElement('points'));
88 $content['text'] = SQL_ESCAPE(postRequestElement('reason'));
89 $content['points'] = bigintval(postRequestElement('points'));
91 // Load email and send it away
92 $message = loadEmailTemplate('sub-points', $content, bigintval(getRequestElement('userid')));
93 sendEmail($content['email'], getMessage('ADMIN_SUB_SUBJ'), $message);
96 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_POINTS_SUBTRACTED'));
99 $content['user'] = "<a href=\"".generateEmailLink($content['email'], 'user_data')."\">".$content['surname']." ".$content['family']."</a>";
100 $content['userid'] = bigintval(getRequestElement('userid'));
103 loadTemplate('admin_sub_points', false, $content);
107 loadTemplate('admin_settings_saved', false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), getRequestElement('userid'))."</div>");
110 // Output selection form with all confirmed user accounts listed
111 addMemberSelectionBox(0, true);