Fixes for broken order page and themes
[mailer.git] / inc / modules / member / what-surfbar_book.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 09/08/2008 *
4  * ================                             Last change: 09/08/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-surfbar_book.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Members can book new URLs here                   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Mitglieder koennen URLs buchen                   *
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')) {
41         die();
42 } elseif (!isMember()) {
43         // Redirect
44         redirectToIndexMemberOnlyModule();
45 }
46
47 // Add description as navigation point
48 addMenuDescription('member', __FILE__);
49
50 if ((!isExtensionActive('surfbar')) && (!isAdmin())) {
51         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('surfbar'));
52         return;
53 } // END - if
54
55 // Still allowed to book more URLs?
56 if (!SURFBAR_IF_USER_BOOK_MORE_URLS()) {
57         // No more URLs allowed to book!
58         loadTemplate('admin_settings_saved', false, getMessage('MEMBER_SURFBAR_NO_MORE_ALLOWED'));
59 } elseif ((isFormSent()) && (isPostRequestElementSet(('limited')))) {
60         // Is limitation "no" and "limit" is > 0?
61         if ((postRequestElement('limited') != 'Y') && ((isPostRequestElementSet(('limit'))) && (postRequestElement('limit') > 0)) || (!isPostRequestElementSet(('limit')))) {
62                 // Set it to unlimited
63                 setRequestPostElement('limit', 0);
64         } // END - if
65
66         // Register the new URL
67         $insertId = SURFBAR_MEMBER_ADD_URL(postRequestElement('url'), postRequestElement('limit'));
68
69         // By default something went wrong
70         $message = getMessage('MEMBER_SURFBAR_URL_NOT_ADDED');
71
72         // Was this fine?
73         if ($insertId > 0) {
74                 // URL added and waiting for unlock
75                 $message = getMessage('MEMBER_SURFBAR_URL_ADDED');
76         } // END - if
77
78         // Load message template
79         loadTemplate('admin_settings_saved', false, $message);
80 } else {
81         // Prepare some content
82         $content = array(
83                 'reward'     => translateComma(SURFBAR_DETERMINE_REWARD(true)),
84                 'costs'      => translateComma(SURFBAR_DETERMINE_COSTS(true)),
85                 'max_order'  => getConfig('surfbar_max_order'),
86                 'curr_order' => SURFBAR_GET_TOTAL_USER_URLS()
87         );
88
89         // Load surfbar order form
90         loadTemplate(sprintf("member_surfbar_book_%s", strtolower(getConfig('surfbar_pay_model'))), false, $content);
91 }
92
93 //
94 ?>