# /www/master-default.tcl
#
# Set basic attributes and provide the logical defaults for variables that
# aren't provided by the slave page.
#
# Author: Kevin Scaldeferri (kevin@arsdigita.com)
# Creation Date: 14 Sept 2000
# $Id: uwc.tcl,v 1.5 2006/05/11 07:33:38 cvs Exp $
#

# fall back on defaults
ad_page_contract {

    Passion Theme
    
    @author SriHarsha Chintalapani(sriharsha.ch@azri.biz)
    @cvs-id $Id: uwc.tcl,v 1.5 2006/05/11 07:33:38 cvs Exp $
} {
    {search_p:optional}
    {help_p:optional}
    {from_cms_p:optional}
    {admin_link:optional}
} 



if { [template::util::is_nil subnavbar_link] } {
    set subnavbar_link ""
}



set skin_css [list "/resources/skin/uwc/uwc_01.css" "/resources/skin/uwc/portlets.css" ]
set package_id [ad_conn package_id]
if { ![exists_and_not_null help_p] } {
set help_p ""
}

if { $help_p == "on" } {
    set helpon [parameter::set_value -parameter help_p -value off]
} elseif { $help_p == "off" } {
    set helpon [parameter::set_value -parameter help_p -value on]
}

set package_key [apm_package_key_from_id $package_id]
#get the user_id
set user_id [ad_get_user_id]

# Context bar
if { [info exists context] } {
    set context_tmp $context
    unset context
} else {
    set context_tmp {}
}
ad_context_bar_multirow -- $context_tmp

if {![exists_and_not_null from_cms_p]} {
    set from_cms_p ""
}

ad_context_bar_multirow  -- $context_tmp


if { ![info exists active_section] } {
switch -exact -- $package_key {
    user-directory { set active_section 2 }
    photo-album { set active_section 3 }
    dotlrn { set active_section 4 }
    edit-this-page {
	if {[exists_and_not_null from_cms_p]} {
	    set active_section 1
	} else {
	    set active_section 5
	}
    } 
    bug-tracker {set active_section 7}
    sbn {set active_section 6}
    events {set active_section 10}
    mailing-lists/index {set active_section 8}    
    
    default { set active_section 1 }
}
}
 if { [template::util::is_nil title] } {
    set title [ad_conn instance_name]
}

set i 1
if {[exists_and_not_null navigation_second]} {
 foreach naventry $navigation_second {
	  set navtext [lindex $naventry 0]
	  set navlink [lindex $naventry 1]
          set class_name [lindex $naventry 2]
          set tab_id [lindex $naventry 3]

     if { ![exists_and_not_null class_name] } {
	 set class_name "link"
     }
     if { ![exists_and_not_null tab_id] } {
         set tab_id $i
     }
     if { $class_name == "activelink" } {
          append navhref "<div class=\"$class_name\" id=\"menu$tab_id\">$navtext</div>"
     } else {

         append navhref "<div class=\"$class_name\" id=\"menu$tab_id\"><a href=\"$navlink\">$navtext</a></div>"
     }
          incr i
 }
}



set system_name [ad_system_name]
set system_url [ad_url]
if { [string equal [ad_conn url] "/"] } {
    set system_url ""
}

# Get user information
set sw_admin_p 0
set user_id [ad_conn user_id]
set untrusted_user_id [ad_conn untrusted_user_id]

set community_id [dotlrn_community::get_community_id]

if {![info exists link_control_panel]} {
    set link_control_panel 1
}
if {$link_control_panel} {
    set link_control_panel 1
} else {
    set link_control_panel 0
}

if {![info exists control_panel_text]} {
    set control_panel_text "Control Panel"
}

if {![info exists link_all]} {
    set link_all 0
} 

set extra_spaces "&nbsp;&nbsp;"    
set extra_stuff_infront_p 0
set extra_stuff ""

if {![empty_string_p $community_id]} {
    set show_navbar 1
    set navbar [dotlrn::portal_navbar \
		    -user_id $user_id \
		    -link_control_panel $link_control_panel \
		    -control_panel_text $control_panel_text \
		    -pre_html "" \
		    -post_html $extra_spaces \
		    -link_all $link_all 
	       ]
} else {
    set show_navbar 0
}


if { $untrusted_user_id != 0 } {
    set user_name [person::name -person_id $untrusted_user_id]
    set pvt_home_url [ad_pvt_home]
	set pvt_home_name [_ acs-subsite.Your_Account]
    set logout_url [ad_get_logout_url]

    # Site-wide admin link
    set admin_url {}

    set sw_admin_p [acs_user::site_wide_admin_p -user_id $untrusted_user_id]

    if { $sw_admin_p } {
        set admin_url "/acs-admin/"
        set devhome_url "/acs-admin/developer"
        set locale_admin_url "/acs-lang/admin"
    } else {
        set subsite_admin_p [permission::permission_p \
                                 -object_id [subsite::get_element -element object_id] \
                                 -privilege admin \
                                 -party_id $untrusted_user_id]

        if { $subsite_admin_p  } {
            set admin_url "[subsite::get_element -element url]admin/"
        }
    }
} 

if { $untrusted_user_id == 0 } {
    set login_url [ad_get_login_url -return]
}

set n_users_online [lc_numeric [whos_online::num_users]]

set whos_online_url "[subsite::get_element -element url]shared/whos-online"

set num_of_locales [llength [lang::system::get_locales]]

    set change_locale_url   "/acs-lang/?[export_vars { { package_id "[ad_conn package_id]" } }]"


