summaryrefslogtreecommitdiff
path: root/index.php
blob: b91fdf419ad7e700ffb248c56334d2c59d5914a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
 * $Header: /cvsroot/bitweaver/_bit_users/index.php,v 1.20 2007/01/24 09:46:34 squareing Exp $
 *
 * Copyright (c) 2004 bitweaver.org
 * Copyright (c) 2003 tikwiki.org
 * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
 * All Rights Reserved. See copyright.txt for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
 *
 * $Id: index.php,v 1.20 2007/01/24 09:46:34 squareing Exp $
 * @package users
 * @subpackage functions
 */
global $gQueryUserId, $gBitSystem;

/**
 * required setup
 */
define('ACTIVE_PACKAGE', 'users');	// Todo: use a different $_SERVER variable to properly determine the active package
require_once( '../bit_setup_inc.php' );
global $gBitSystem;
require_once( LIBERTY_PKG_PATH."LibertyStructure.php" );

// custom userfields
if( $gBitSystem->getConfig( 'custom_user_fields' ) ) {
	$customFields= explode( ',', $gBitSystem->getConfig( 'custom_user_fields' )  );
	$gBitSmarty->assign('customFields', $customFields);
}
// lookup may be via content_id which will then return user_id for search request
require_once( USERS_PKG_PATH.'lookup_user_inc.php' );
$search_request = '';
if (!empty($_REQUEST['home'])) {
	$search_request = $_REQUEST['home'];
}
if( !empty( $_REQUEST['home'] ) && ($gBitUser->hasPermission( 'p_users_view_user_homepage' ) || $gBitUser->hasPermission( 'p_users_admin' ) ) ) {
	$gBitSystem->verifyPermission( 'p_users_view_user_homepage' );
	$gBitSmarty->assign( 'home', $_REQUEST['home'] );
	$gQueryUserId = $_REQUEST['home'];
	if( $gQueryUser->isValid() ) {
		$gBitSmarty->assign( 'gQueryUserId', $gQueryUserId );
	}
	if ($gBitSystem->isPackageActive('stars') && $gBitSystem->isFeatureActive('stars_user_ratings')) {
		require(STARS_PKG_PATH."templates/user_ratings.php");
	}

	if( $gQueryUser->canCustomizeTheme() ) {
		$userHomeStyle = $gQueryUser->getPreference( 'theme' );
		if( isset( $userHomeStyle ) ) {
			$gBitSystem->setStyle($userHomeStyle );
			$gBitSystem->mStyles['styleSheet'] = $gBitSystem->getStyleCss( $userHomeStyle, $_REQUEST['home'] );
			$gBitSmarty->assign( 'userStyle', $userHomeStyle );
		}
	}
	$userHomeTitle = $gQueryUser->getPreference( 'homepage_title' );
	if (!$userHomeTitle) {
		$userHomeTitle = $gQueryUser->getDisplayName()."'s Homepage";
	}
	$browserTitle = $userHomeTitle;
	//$_REQUEST['page'] = $userHomeTitle; // $_REQUEST['page'] should be used for requesting a page #! - drewslater

// need to loadLayout prematurely (usually happens in modules_inc.php) so we can see if we have any center pieces
	if( $gQueryUser->canCustomizeLayout() ) {
		$homeName = $_REQUEST['home'];
	} else {
		$homeName = ROOT_USER_ID;
	}
	$layout = HOMEPAGE_LAYOUT;
	if( isset( $layout ) ) {
		$gBitSystem->loadLayout( $homeName, $layout, ACTIVE_PACKAGE, TRUE );
	}
	global $gCenterPieces;
	$centerDisplay = ( count( $gCenterPieces ) ? 'bitpackage:kernel/dynamic.tpl' : 'bitpackage:users/center_user_wiki_page.tpl' );
} elseif( empty( $search_request ) ) {
	$gBitSystem->verifyPermission( 'p_users_view_user_list' );
	$gQueryUser->getList( $_REQUEST );
	$gBitSmarty->assign('search_request',$search_request);
	$gBitSmarty->assign_by_ref('users', $_REQUEST["data"]);
	$gBitSmarty->assign_by_ref('usercount', $_REQUEST["cant"]);
	if (isset($_REQUEST["numrows"]))
		$_REQUEST['listInfo']["numrows"] = $_REQUEST["numrows"];
	else
		$_REQUEST['listInfo']["numrows"] = 50;
	$_REQUEST['listInfo']["URL"] = USERS_PKG_URL."index.php";
	$gBitSmarty->assign_by_ref('control', $_REQUEST['listInfo']);
	$centerDisplay = 'bitpackage:users/index_list.tpl';
	$browserTitle = $gBitSystem->getConfig( 'site_title' ).' '.tra( 'Members' );
	$gBitSmarty->assign_by_ref( 'listInfo', $_REQUEST['listInfo'] );
} elseif( !$gBitSystem->isFeatureActive( 'users_homepages' ) ) {
	$gBitSystem->verifyPermission( 'p_users_view_user_list' );
	$gQueryUser->getList( $_REQUEST );
	$gBitSmarty->assign_by_ref('users', $_REQUEST["data"]);
	$gBitSmarty->assign_by_ref('usercount', $_REQUEST["cant"]);
	if (isset($_REQUEST["numrows"]))
		$_REQUEST['listInfo']["numrows"] = $_REQUEST["numrows"];
	else
		$_REQUEST['listInfo']["numrows"] = 50;
	$_REQUEST['listInfo']["URL"] = USERS_PKG_URL."index.php";
	$gBitSmarty->assign_by_ref('control', $_REQUEST['listInfo']);
	$centerDisplay = 'bitpackage:users/index_list.tpl';
	$browserTitle = $gBitSystem->getConfig( 'site_title' ).' '.tra( 'Members' );
} else {
	$gBitSmarty->assign('msg',tra('User not found'));
	$centerDisplay = 'bitpackage:kernel/error.tpl';
	$browserTitle = $gBitSystem->getConfig( 'site_title' ).' '.tra( 'Members' );
}

$gBitSmarty->assign( 'gBitLanguage', $gBitLanguage );

$gBitSystem->display( $centerDisplay, $browserTitle );
?>