root/trunk/wifidog-auth/wifidog/content/PatternLanguage/subscription.php @ 874

Revision 874, 7.2 KB (checked in by max-horvath, 7 years ago)

2005-12-28 Max Horvath <max.horvath@…>

  • Removed BASEPATH define from source - resulting in a better require-overview
  • speed improvement of 7% by optimizing Dependencies class
  • improved documentation of content classes
  • added WiFiDog skin to HTMLeditor
  • updated PhpDocumentor? documentation
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5// +-------------------------------------------------------------------+
6// | WiFiDog Authentication Server                                     |
7// | =============================                                     |
8// |                                                                   |
9// | The WiFiDog Authentication Server is part of the WiFiDog captive  |
10// | portal suite.                                                     |
11// +-------------------------------------------------------------------+
12// | PHP version 5 required.                                           |
13// +-------------------------------------------------------------------+
14// | Homepage:     http://www.wifidog.org/                             |
15// | Source Forge: http://sourceforge.net/projects/wifidog/            |
16// +-------------------------------------------------------------------+
17// | This program is free software; you can redistribute it and/or     |
18// | modify it under the terms of the GNU General Public License as    |
19// | published by the Free Software Foundation; either version 2 of    |
20// | the License, or (at your option) any later version.               |
21// |                                                                   |
22// | This program is distributed in the hope that it will be useful,   |
23// | but WITHOUT ANY WARRANTY; without even the implied warranty of    |
24// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     |
25// | GNU General Public License for more details.                      |
26// |                                                                   |
27// | You should have received a copy of the GNU General Public License |
28// | along with this program; if not, contact:                         |
29// |                                                                   |
30// | Free Software Foundation           Voice:  +1-617-542-5942        |
31// | 59 Temple Place - Suite 330        Fax:    +1-617-542-2652        |
32// | Boston, MA  02111-1307,  USA       gnu@gnu.org                    |
33// |                                                                   |
34// +-------------------------------------------------------------------+
35
36/**
37 * @package    WiFiDogAuthServer
38 * @author     Francois Proulx <francois.proulx@gmail.com>
39 * @copyright  2005 Francois Proulx <francois.proulx@gmail.com> - Technologies
40 * Coeus inc.
41 * @version    CVS: $Id$
42 * @link       http://sourceforge.net/projects/wifidog/
43 */
44
45require_once('../../include/common.php');
46
47require_once('include/common_interface.php');
48require_once('classes/User.php');
49require_once('classes/Content/PatternLanguage.php');
50require_once('classes/MainUI.php');
51
52// This trick is done to allow displaying of Pattern Language right away if there is only one available.
53if(!empty($_REQUEST['content_id']))
54{
55    $content_id = $_REQUEST['content_id'];
56    $pattern_language = PatternLanguage::getObject($content_id);
57}
58else
59{
60    $content_id = "";
61    $pattern_languages = PatternLanguage :: getAllContent();
62    if(count($pattern_languages) >= 1)
63        $pattern_language = $pattern_languages[0];
64    else
65        exit;
66}
67
68// The Pattern Language toolbar
69$tool_html = "<h1>{$pattern_language->getTitle()->__toString()}</h1>";
70$tool_html .= '<ul class="pattern_language_menu">'."\n";
71$gw_id = $session->get(SESS_GW_ID_VAR);
72if(!empty($gw_id))
73    $tool_html .= "<li><a href='/portal/?gw_id=$gw_id'>"._("Go back to this hotspot portal page")."</a></li>";
74$tool_html .= '<li><a href="'.BASE_SSL_PATH.'content/PatternLanguage/index.php?content_id='.$content_id.'">'._("About Pattern Language").'</a><br>'."\n";
75$tool_html .= '<li><a href="'.BASE_SSL_PATH.'content/PatternLanguage/narrative.php?content_id='.$content_id.'">'._("Read narrative").'</a><br>'."\n";
76$tool_html .= '<li><a href="'.BASE_SSL_PATH.'content/PatternLanguage/archives.php?content_id='.$content_id.'">'._("Archives").'</a><br>'."\n";
77$tool_html .= '<li><a href="'.BASE_SSL_PATH.'content/PatternLanguage/hotspots.php?content_id='.$content_id.'">'._("Participating hotspots").'</a><br>'."\n";
78$tool_html .= '<li><a href="'.BASE_SSL_PATH.'content/PatternLanguage/subscription.php?content_id='.$content_id.'">'._("Subscription").'</a><br>'."\n";
79$tool_html .= '</ul>'."\n";
80
81$tool_html .= "<div class='pattern_language_credits'>";
82$tool_html .=  $pattern_language->getSponsorInfo()->__toString();
83$tool_html .= "</div>";
84
85// Body
86$body_html = "<img src='header.gif'>\n";
87$body_html .= "<h1>"._("Pattern Language Subscription")."</h1>\n";
88$body_html .= "<div class='pattern_language_body'>\n";
89
90$current_user = User::getCurrentUser();
91if($current_user)
92{
93    if(!empty($_REQUEST['subscribe']) || !empty($_REQUEST['unsubscribe']))
94    {
95        if(!empty($_REQUEST['subscribe']))
96        {
97            $pattern_language = PatternLanguage::getObject($_REQUEST['content_id']);
98            if(!$pattern_language->isUserSubscribed($current_user))
99            {
100                $pattern_language->subscribe($current_user);
101                $body_html .= _("Thank you for subscribing");
102                $gw_id = $session->get(SESS_GW_ID_VAR);
103                if(!empty($gw_id))
104                    $body_html .= "<p><a href='/portal/?gw_id=$gw_id'>"._("Go back to this hotspot portal page")."</a>";
105            }
106        }
107        else if(!empty($_REQUEST['unsubscribe']))
108        {
109            $pattern_language = PatternLanguage::getObject($_REQUEST['content_id']);
110            if($pattern_language->isUserSubscribed($current_user))
111                $pattern_language->unsubscribe($current_user);
112            $body_html .= _("You are now unsubscribed");
113            $gw_id = $session->get(SESS_GW_ID_VAR);
114            if(!empty($gw_id))
115                $body_html .= "<p><a href='/portal/?gw_id=$gw_id'>"._("Go back to this hotspot portal page")."</a>";
116        }
117    }
118    else
119    {
120        if(!$pattern_language->isUserSubscribed($current_user))
121        {
122            // Subscription
123            $body_html .= _("Subscribe to Pattern Language by clicking the link below. Once you have subscribed you will receive a fragment of text each time you log in to a participating hotspot in the city of Montreal. These text fragments will accumulate to form a unique narrative for every user. You can read your narrative anytime by clicking on \"Read Narrative\", or you can read the narratives generated by other users by going to \"Archives\".");
124            $body_html .= "<br><a href='subscription.php?subscribe=true&content_id={$pattern_language->getId()}'>"._("Subscribe now")."</a>";
125        }
126        else
127        {
128            // Unsubscription
129            $body_html .= _("You are already subscribed to Pattern Language, you can terminate your participation by clicking below.");
130            $body_html .= "<br><a href='subscription.php?unsubscribe=true&content_id={$pattern_language->getId()}'>"._("Unsubscribe now")."</a>";
131        }
132    }
133}
134else
135{
136    $body_html .= _("You must be logged in to subscribe !");
137}
138
139$body_html .= "</div>\n";
140
141$ui = new MainUI();
142$ui->setToolContent($tool_html);
143$ui->setTitle(_("Pattern Language - Subscription"));
144$ui->setMainContent($body_html);
145$ui->display();
146
147/*
148 * Local variables:
149 * tab-width: 4
150 * c-basic-offset: 4
151 * c-hanging-comment-ender-p: nil
152 * End:
153 */
154
155?>
Note: See TracBrowser for help on using the browser.