Location: PHPKode > projects > Protoforge > protoforge_v1.2/protoforge/user_resources/index.php
<?php
require_once('../config.inc.php');

session_start();
if (require_once(PF_BASE.'connect.php'))
	$link = connect();

try {
	$currentPage = 'Personal Resources';
	$isme = false;
	if (isset($_GET['uid']) && ctype_digit($_GET['uid'])) {
		if (isset($_SESSION['user']) && $_SESSION['user']->get_user_id() == intval($_GET['uid']) ) {
			$isme = true;
			$currentPage = 'My Personal Resources';
		} else {
			$User = new User();
			$User->dbPopulate($_GET['uid'],$link);
			$currentPage = 'User Personal Resources';
		}
	}

	$pageTitle = PF_SITENAME.' '.$currentPage;
	require(PF_BASE.'Header.php');

	if ($isme) {
		include(PF_BASE.'users/user_menu.php');
	} else if (isset($User)) {
		include(PF_BASE.'users/user_menu.php');
	} else {
		unset($_GET['uid']);
		$titl = 'Personal Resources'; $timg='magnifier.png'; require(PF_BASE.'titl.php');
	}

	$s = new Search('user_resources','user_res_id');
	$s->set_maxRows(50);
	$s->set_navBarWidth(100);

	$s->add_resultField('title');
	$s->add_resultField('status');
	$s->add_resultField('type');
	$s->add_resultField('description');

	$s->add_resultFieldDisplayName('title','Resource');
	$s->add_resultFieldDisplayName('status','Status');
	$s->add_resultFieldDisplayName('type','Type');
	$s->add_resultFieldDisplayName('description','Description');

	$status_join = new Join('user_resources','resource_status','status','status_id','Status','status');
	$s->add_join('status',$status_join);
	$type_join = new Join('user_resources','resource_type','type','res_type_id','Type','type');
	$s->add_join('type',$type_join);

	$s->add_orderableField('title');
	$s->add_orderableField('type');
	$s->add_orderableField('status');

	$s->add_searchableField('title');
	$s->add_searchableField('status');
	$s->add_searchableField('type');
	$s->add_searchableField('description');

	$s->add_ownRowResult('description');

	$s->add_searchableFieldDisplayName('title','Resource');
	$s->add_searchableFieldDisplayName('status','Status');
	$s->add_searchableFieldDisplayName('type','Type');
	$s->add_searchableFieldDisplayName('description','Description');

	$r_link = new SearchLink(PF_ROOT.'user_resources/User_Resource.php?id=__user_res_id__&');
	$r_link->linkText = true;
	$r_link->add_colToReplace('user_res_id');
	$s->add_resultLink('title',$r_link);

	$s_icon = new SearchIcon(PF_ROOT.'images/package.png');
	$s_icon->set_title('');
	$s_icon->set_trailingText('&nbsp;&nbsp;');
	$s->add_resultIcon( 'title', $s_icon );

	$s->setFromGet($_GET);
	$s->executeQuery();
	echo $s->displaySearchBar();
?>
	<table width="100%" align="center" cellpadding="5" cellspacing="0" border="0">
		<tr class="action">
			<td class="action" align="right">
				<?php if ($isme || isset($User)) { ?>
					<a class="action" href="<?php echo PF_ROOT;?>user_resources/index.php">
						<img class="icon" title="" src="<?php echo PF_ROOT;?>images/magnifier.png"/>
						All Personal Resource</a>
					&nbsp;&nbsp;
					<?php if (isset($User) && isset($_SESSION['user'])) { ?>
						<a class="action" href="<?php echo PF_ROOT;?>user_resources/index.php?uid=<?php echo $_SESSION['user']->get_user_id();?>&">
							<img class="icon" title="" src="<?php echo PF_ROOT;?>images/magnifier.png"/>
							My Personal Resource</a>
						&nbsp;&nbsp;
					<?php } ?>
				<?php } else if (isset($_SESSION['user'])) { ?>
					<a class="action" href="<?php echo PF_ROOT;?>user_resources/index.php?uid=<?php echo $_SESSION['user']->get_user_id();?>&">
						<img class="icon" title="" src="<?php echo PF_ROOT;?>images/magnifier.png"/>
						My Personal Resources</a>
					&nbsp;&nbsp;
				<?php } ?>
				<a class="action" href="create_User_Resource.php?redirect=<?php echo urlencode($_SERVER['REQUEST_URI']);?>&">
					<img class="icon" title="" src="<?php echo PF_ROOT;?>images/package_add.png"/>
					Add Personal Resource</a>
				&nbsp;
			</td>
		</tr>
	</table>
<?php
	echo $s->displayNavBar();
	echo $s->displayResults();
	echo $s->displayNavBar();

} catch (Exception $e) {
	$pfutil = new PFUtil();
	$pfutil->error_page($e->getMessage());
}
?>
<?php include(PF_BASE.'Footer.php'); ?>
Return current item: Protoforge