Smoother navigation and restricted iconbar for guest mode
authorArt Cancro <ajc@citadel.org>
Tue, 28 Dec 2010 22:20:27 +0000 (17:20 -0500)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 13:31:00 +0000 (13:31 +0000)
webcit/iconbar.c
webcit/roomops.c
webcit/static/t/iconbar.html
webcit/webcit.c

index a8c7b69c5051737d3a668c9843aa0aada191605b..5519100dc0de27c93c19379621ab93395225ee1c 100644 (file)
@@ -197,12 +197,20 @@ void commit_iconbar(void) {
 }
 
 
+/*
+ * Display the icon bar as long as we have an active session,
+ * and either the user is logged in or the server allows guest mode.
+ */
 void tmplput_iconbar(StrBuf *Target, WCTemplputParams *TP)
 {
        wcsession *WCC = WC;
        
-       if ((WCC != NULL) && (WCC->logged_in)) {
-         DoTemplate(HKEY("iconbar"), NULL, &NoCtx);
+        if (   (WCC != NULL)
+               && (    (WCC->logged_in)
+                       || (WCC->serv_info->serv_supports_guest)
+               )
+       ) {
+               DoTemplate(HKEY("iconbar"), NULL, &NoCtx);
        }
 }
 
index 8a3b4dfa4fe3f619d8d838e976bf95e78bf7e882..ace2559624a4c346f1960ab00d8d395be7ff19bb 100644 (file)
@@ -117,8 +117,8 @@ void smart_goto(const StrBuf *next_room) {
        readloop(readnew, eUseDefault);
 }
 
-/**
- * \brief goto a private room
+/*
+ * goto a private room
  */
 void goto_private(void)
 {
@@ -944,8 +944,8 @@ void entroom(void)
 
 
 
-/**
- * \brief Change the view for this room
+/*
+ * Change the view for this room
  */
 void change_view(void) {
        int newview;
index 4a84bef3eb535e47a9aca557937363217ea8d1ae..b63f2b407deeb9e6a0dcf02df78b1a5ce874f3cc 100644 (file)
@@ -12,6 +12,7 @@
         <?_("Summary")>
     </span></a>
 </li>
+<??("COND:LOGGEDIN",3)>
 <li id="ib_inbox" class="ib_button">
     <a class="ib_button_link" href="dotgoto?room=_MAIL_" title="<?_("Go to your email inbox")>"><span>
        <?_("Mail")></span>
@@ -37,6 +38,7 @@
 <?_("Tasks")></span>
 </a>
 </li>
+<??("X",3)>
 <li id="ib_rooms" class="ib_button">
 <a class="ib_button_link" href="knrooms?template=knrooms?SortBy=byfloorroom?SortOrder=1" title="<?_("List all your accessible rooms")>"><span>
 <?_("Rooms")></span>
@@ -51,6 +53,7 @@
 <li><?_("Loading")></li>
 </ul>
 </li>
+<??("COND:LOGGEDIN",5)>
 <li id="ib_chat" class="ib_button">
 <a class="ib_button_link" href="chat"><span>
 <?_("Chat")>
@@ -63,6 +66,7 @@
 </span>
 </a>
 </li>
+<??("X",5)>
 <??("COND:AIDE", 1)>
 <li id="ib_admin" class="ib_button">
 <a class="ib_button_link" href="do_template?template=aide_display_menu" title="<?_("Room and system administration functions")>"><span><?_("Administration")></span></a>
   <span><a href="do_template?template=iconbar_edit"><?_("customize this menu")></a></span>
 </div>
 <??("X",2)>
+<?!("COND:LOGGEDIN",4)>
+<div id="ib_logoff" class="ib_button">
+<a class="ib_button_link" href="login" title="<?_("Login")>"><span><?_("Login")></span></a>
+</div>
+<?!("X",4)>
 <div class="ctdlTemplate">
 <span id="rmlist_template"><?_("switch to room list")></span>
 <span id="mnlist_template"><?_("switch to menu")></span>
index 8f51833deb32a180f9ebced1bc9ddc3177a9c016..5a0eec7441eea738b929c802d45a3d70a742e7db 100644 (file)
@@ -250,15 +250,10 @@ void http_redirect(const char *whichpage) {
 /*
  * Output a piece of content to the web browser using conformant HTTP and MIME semantics
  */
-void http_transmit_thing(const char *content_type,
-                        int is_static) {
+void http_transmit_thing(const char *content_type, int is_static)
+{
 
-#ifndef TECH_PREVIEW
-       lprintf(9, "http_transmit_thing(%s)%s\n",
-               content_type,
-               ((is_static > 0) ? " (static)" : "")
-       );
-#endif
+       lprintf(9, "http_transmit_thing(%s)%s\n", content_type, ((is_static > 0) ? " (static)" : ""));
        output_headers(0, 0, 0, 0, 0, is_static);
 
        hprintf("Content-type: %s\r\n"
@@ -326,8 +321,7 @@ void display_success(char *successmessage)
 
 
 /*
- * Authorization required page 
- * This is probably temporary and should be revisited 
+ * Authorization required page (sends a 401, causing the browser to request login credentials)
  */
 void authorization_required(void)
 {
@@ -740,7 +734,10 @@ void session_loop(void)
        }
 
        if (WCC->Hdr->HR.Handler != NULL) {
-               if (!WCC->logged_in && ((WCC->Hdr->HR.Handler->Flags & ANONYMOUS) == 0)) {
+               if (    (!WCC->logged_in)
+                       && ((WCC->Hdr->HR.Handler->Flags & ANONYMOUS) == 0)
+                       && (WCC->serv_info->serv_supports_guest == 0)
+               ) {
                        display_login();
                }
                else {
@@ -755,17 +752,25 @@ void session_loop(void)
                                end_ajax_response();
                }
        }
-       /* When all else fais, display the main menu. */
+       /* When all else fails, display the main menu. */
        else {
                /* 
                 * ordinary browser users get a nice login screen, DAV etc. requsets
                 * are given a 401 so they can handle it appropriate.
                 */
                if (!WCC->logged_in)  {
-                       if (xhttp)
+                       if (xhttp) {
                                authorization_required();
-                       else 
+                       }
+                       else if (WCC->serv_info->serv_supports_guest) {
+                               /* default action.  probably revisit this. */
+                               StrBuf *teh_lobby = NewStrBufPlain(HKEY("_BASEROOM_"));
+                               smart_goto(teh_lobby);
+                               FreeStrBuf(&teh_lobby);
+                       }
+                       else {
                                display_login();
+                       }
                }
                /*
                 * Toplevel dav requests? or just a flat browser request?