Extension 'yoomedia' now alpha status, some rewrites
[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  *                                                                      *
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')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 } elseif (!IS_MEMBER()) {
39         // Redirect
40         LOAD_URL(URL."/modules.php?module=index");
41 } elseif (!EXT_IS_ACTIVE("surfbar")) {
42         // Extension "surfbar" is not active
43         ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "surfbar");
44         return;
45 }
46
47 // Add description as navigation point
48 ADD_DESCR("member", __FILE__);
49
50 // Still allowed to book more URLs?
51 if (!SURFBAR_IF_USER_BOOK_MORE_URLS()) {
52         // No more URLs allowed to book!
53         LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_SURFBAR_NO_MORE_ALLOWED);
54 } elseif (isset($_POST['ok'])) {
55         // Is limitation "no" and "limit" is > 0?
56         if (($_POST['limited'] == "N") && ((isset($_POST['limit'])) && ($_POST['limit'] > 0)) || (!isset($_POST['limit']))) {
57                 // Set it to unlimited
58                 $_POST['limit'] = 0;
59         } // END - if
60
61         // Register the new URL
62         $insertId = SURFBAR_MEMBER_ADD_URL($_POST['url'], $_POST['limit']);
63
64         // Was this fine?
65         if ($insertId > 0) {
66                 // URL added and waiting for unlock
67                 $msg = MEMBER_SURFBAR_URL_ADDED;
68         } else {
69                 // Something went wrong!
70                 $msg = MEMBER_SURFBAR_URL_NOT_ADDED;
71         }
72
73         // Load message template
74         LOAD_TEMPLATE("admin_settings_saved", false, $msg);
75 } else {
76         // Prepare some content
77         $content = array(
78                 'reward'     => TRANSLATE_COMMA(SURFBAR_DETERMINE_REWARD(true)),
79                 'costs'      => TRANSLATE_COMMA(SURFBAR_DETERMINE_COSTS(true)),
80                 'max_order'  => $_CONFIG['surfbar_max_order'],
81                 'curr_order' => SURFBAR_GET_TOTAL_USER_URLS()
82         );
83
84         // Load surfbar order form
85         LOAD_TEMPLATE(sprintf("member_surfbar_book_%s", strtolower($_CONFIG['surfbar_pay_model'])), false, $content);
86 }
87
88 //
89 ?>