Updated copyright notice as there are changes in this year
[mailer.git] / inc / modules / member / what-earning.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 07/31/2011 *
4  * ===================                          Last change: 07/31/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-earnings.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Extra earnings for the user                      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Zusatzverdienst fuer die Mitglieder              *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         exit();
41 } elseif (!isMember()) {
42         redirectToIndexMemberOnlyModule();
43 }
44
45 // Add description as navigation point
46 addYouAreHereLink('member', __FILE__);
47
48 // Is the form sent?
49 if (isFormSent()) {
50         // Then handle the extra earning request
51         doMemberEarning(
52                 postRequestElement('earning_id'),
53                 postRequestElement('earning_daily_amount'),
54                 postRequestElement('earning_active')
55         );
56 } // END - if
57
58 // Check for all earnings
59 $result = SQL_QUERY('SELECT
60         `d`.`earning_id`,
61         `d`.`earning_group`,
62         `d`.`earning_provider`
63 FROM
64         `{?_MYSQL_PREFIX?}_earning_data` AS `d`
65 ORDER BY
66         `d`.`earning_sorting` ASC', __FILE__, __LINE__);
67
68 // Are there entries?
69 if (!SQL_HASZERONUMS($result)) {
70         // Init output
71         $OUT = '';
72
73         // List all entries
74         while ($content = SQL_FETCHARRAY($result)) {
75                 // Load user_earning data
76                 $result2 = SQL_QUERY_ESC('SELECT
77         `u`.`earning_active`,
78         UNIX_TIMESTAMP(`u`.`earning_added`) AS `earning_added`,
79         UNIX_TIMESTAMP(`u`.`earning_canceled`) AS `earning_canceled`,
80         `u`.`earning_daily_amount`,
81         `u`.`earning_points`
82 FROM
83         `{?_MYSQL_PREFIX?}_user_earning` AS `u`
84 WHERE
85         `u`.`earning_id`=%s AND
86         `u`.`earning_userid`=%s
87 LIMIT 1',
88                         array(
89                                 bigintval($content['earning_id']),
90                                 getMemberId()
91                         ), __FILE__, __LINE__);
92
93                 // Is there an entry?
94                 if (SQL_NUMROWS($result2) == 1) {
95                         // Load it
96                         $content = merge_array($content, SQL_FETCHARRAY($result2));
97                 } // END - if
98
99                 // Free result
100                 SQL_FREERESULT($result2);
101
102                 // Is there user_earning data available?
103                 if (!isset($content['earning_active'])) {
104                         // Load row template "open subscription"
105                         $OUT .= loadTemplate('member_earning_' . strtolower($content['earning_group']) . '_form_row', TRUE, $content);
106                 } else {
107                         // Load row template "already subscribed"
108                         $OUT .= loadTemplate('member_earning_' . strtolower($content['earning_group']) . '_row', TRUE, $content);
109                 }
110         } // END - while
111
112         // Load main template
113         loadTemplate('member_earning', FALSE, $OUT);
114 } else {
115         // Display message
116         displayMessage('{--MEMBER_EARNINGS_404--}');
117 }
118
119 // Free result
120 SQL_FREERESULT($result);
121
122 // [EOF]
123 ?>