<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
// 
// Copyright (C) 2003 - 2007 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>

<style type="text/css">
<!--
@import url(<?php echo $template_path_core;?>css/aroundme_form.css);
-->
</style>


<form action="index.php?amn=core_profile" method="post" name="frm" id="id_frm">
<input type="hidden" name="identity_id" value="<?php echo $identity['identity_id'];?>" />

<div class="col_main">
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_identity'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php
				if (isset($common_ties) || isset($identity['testimonial_count'])) {
				?>
				<p style="float:right;white-space:nowrap;">
					<?php
					if (isset($common_ties)) {
					?>
					<span class="icon_frame">
					<span class="icon_title"><a href="index.php?amn=core_tie_matrix&amp;identity_id=<?php echo $common_ties['identity_id']; ?>&amp;identity_id_relation=<?php echo $common_ties['identity_id_relation'];?>">matrix</a></span>
					<span class="icon_value"><?php if (isset($common_ties)) echo $common_ties['count_strong'];?></span>
					<span class="icon_value"><?php if (isset($common_ties)) echo $common_ties['count_weak'];?></span>
					</span>
					&nbsp; 
					<?php }?>
					
					<?php
					if (isset($identity['testimonial_count'])) {
					?>
					<span class="icon_frame">
						<span class="icon_title">&nbsp;<?php echo $lang['txt_vouched'];?>&nbsp;</span>
						<span class="icon_value">&nbsp;<?php echo $identity['testimonial_count'];?>&nbsp;</span>
					</span>
					<?php }?>
				</p>
				<?php }?>
				
				<p>	
					<?php
					if (!empty($identity['blocking'])) {
					?>
					<a href="index.php?amn=core_blocked" title="<?php echo $lang['txt_block_warning'];?>"><img src="<?php echo $template_path;?>img/warning.png" alt="" border="0" /></a>
					<?php }?>
					
					<?php
					if (!empty($identity['identity_allow_msg'])) {
					?>
					<a href="index.php?amn=core_msg_edit&amp;to_identity_id=<?php echo $identity['identity_id'];?>" title="send message"><img src="<?php echo $template_path;?>img/unopenned_mail.png" alt="" border="0" /></a>
					<?php }?>
					
					<?php
					if (!empty($identity['identity_allow_export'])) {
					?>
					<a href="#" title="export as vcard"><img src="<?php echo $template_path_core;?>img/export.png" alt="" border="0" /></a>
					<?php }?>
					
					<a href="index.php?amn=core_profile&identity_id=<?php echo $identity['identity_id'];?>"><b><?php echo $identity['identity_nic'];?></b></a><br />	
				</p>
				
				
				<table cellspacing="2" cellpadding="2" border="0" width="100%">
					<tr>
						<?php
						if(isset($identity['image'])) {
						?>
						<td rowspan="2" valign="top" width="1">
							<a href="index.php?amn=core_profile&identity_id=<?php echo $identity['identity_id'];?>"><img src="get_file.php?file=<?php echo $identity['image']['file_md5_name_view']; ?>" border="0" class="picture" alt="" /></a><br />
						</td>
						<td width="10">
							<br />
						</td>
						<?php }?>
						<td valign="top">
							<?php echo $identity['location_name'];?><br />
							<?php echo $this->date->formatDate($identity['user_create_datetime'],1);?><br />
							<?php echo $lang['user_online_status'][$identity['online_status']];?><br />
							<?php
							if (isset($identity['invitee'])) {
							?>
							<?php echo $lang['txt_invitee'];?>: 
							<a href="index.php?amn=core_profile&identity_id=<?php echo $identity['invitee']['identity_id'];?>"><?php echo $identity['invitee']['identity_nic'];?></a><br />
							<?php }?>
							
							<?php
							if (!empty($identity['tags'])) {
							?>
								<p>
									<?php echo $lang['txt_tagged'];?>: 
									<?php
									$prnt = "";
									foreach($identity['tags'] as $key => $i):
										$prnt .= $i['tag_body'] . ", ";
									endforeach;
									$prnt = substr($prnt, 0, -2);
									echo $prnt;
									?>
									<br />
								</p>
							<?php }?>
							
							<?php
							if (!empty($identity['identity_signature'])) {
							?>
							<p>
								<i>"<?php echo $identity['identity_signature'];?>"</i><br />
							</p>
							<?php }?>
							
						</td>
					</tr>
				</table>
				
				<?php
				if (!empty($identity['custom_fields'])) {
				?>
				<p>
					<?php
					$prnt = "";
					foreach ($identity['custom_fields'] as $idckey => $idc):
					if (!empty($idc['custom_item_body'])) {
						$prnt .= $lang['identity']['custom'][$idc['custom_item_id']] . ":";
						$prnt .= $idc['custom_item_body'];
						$prnt .= ",&nbsp; ";
					}
					endforeach;
					$prnt = substr($prnt, 0, -8);
					echo $prnt;
					?>
					<br />
				</p>
				<?php }?>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<?php
	if (isset($ties)) {
	?>
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_network'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<table cellspacing="2" cellpadding="0" border="0" width="100%">
					<?php
					foreach ($ties as $key => $i):
					?>
					<tr>
						<td width="32">
							<a href="index.php?amn=core_profile&amp;module_id=<?php echo $i['module_id'];?>&amp;item_id=<?php echo $i['item_id'];?>&amp;identity_id=<?php echo $i['identity_id_relation'];?>"><img src="get_file.php?file=<?php echo $i['identity']['image']['file_md5_name_view'];?>" border="0" alt="<?php echo $i['identity']['image']['file_title'];?>" /></a><br />
						</td>
						<td valign="top">
							<a href="index.php?amn=core_profile&amp;module_id=<?php echo $i['module_id'];?>&amp;item_id=<?php echo $i['item_id'];?>&amp;identity_id=<?php echo $i['identity_id_relation'];?>"><?php echo $i['identity']['identity_nic'];?></a><br />
						</td>
						<td valign="top">
							<?php
							if (!empty($i['item'])) {
							?>
							<a href="<?php echo $i['item']['item_url'];?>"><?php echo $i['item']['item_title'];?></a><br />			
							<?php }?>
							<br />
						</td>
						<td valign="top" align="right">
							<?php
							if (isset($i['common_ties'])) {
							?>
							<span class="icon_frame">
							<span class="icon_title"><a href="index.php?amn=core_tie_matrix&amp;identity_id=<?php echo $i['identity_id']; ?>&amp;identity_id_relation=<?php echo $i['identity_id_relation'];?>">matrix</a></span>
							<span class="icon_value"><?php echo $i['common_ties']['count_strong'];?></span>
							<span class="icon_value"><?php echo $i['common_ties']['count_weak'];?></span>
							</span>
							&nbsp; 
							<?php }?>
						</td>
						<td valign="top" align="right">
							<?php
							if (!empty($i['common_ties']['is_mutual'])) {
								echo $lang['txt_mutual'];
							}
							
							if (!empty($i['relation_portable'])) {
								echo "<sup>*</sup>";
							}
							?><br />
						</td>
					</tr>
					<?php
					endforeach;
					?>
				</table>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	<?php }?>
	
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_statistics'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php
				if (isset($statistics)) {
				?>
				<table border="0" cellspacing="0" cellpadding="4" width="100%">
					<?php
					foreach($statistics as $keystattype => $st):
					foreach($st as $key => $i):
					if (isset($lang['statistic'][$keystattype][$i['statistic_type_id']])) {
					?>
					<tr>
						<td>
							<?php echo $lang['statistic'][$keystattype][$i['statistic_type_id']];?><br />
						</td>
						<td align="right">
							<?php echo $i['total'];?><br />
						</td>
					</tr>
					<?php
					}
					endforeach;
					endforeach;
					?>
				</table>
				<?php }?>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<?php
	if (is_file($template_path . "inc/profile.tpl.inc.php")) {
		include $template_path . "inc/profile.tpl.inc.php";
	}
	?>
</div>

<div class="col_side">
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_options'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
				<?php 
				if (!isset($identity['blocking'])) {
				?>
					<a href="index.php?amn=core_blocked&amp;identity_id=<?php echo $identity['identity_id'];?>"><?php echo $lang['href_block_user']; ?></a><br />
				<?php }?>
				</p>
				
				<?php
				if (isset($_SESSION['user_id']) && $_SESSION['user_id'] != $identity['user_id']) {
				?>
				<p>
					<?php
					if (isset($relationship)) {
						echo "respected";
						
						if (isset($relationship['mutual'])) {
							echo "<sup>m</sup>";
						}
						
						if (!empty($relationship['relation_portable'])) {
							echo "<sup>*</sup>";
						}
					}
					else {
					?>
						<a href="index.php?amn=core_profile&amp;respect=1&amp;identity_id=<?php echo $identity['identity_id'];?>&amp;module_id=<?php if(isset($module_id)) { echo $module_id;}?>&amp;item_id=<?php if (isset($item_id)) { echo $item_id;}?>"><?php echo $lang['href_respect'];?></a><br />
						<a href="index.php?amn=core_profile&amp;respect=1&amp;identity_id=<?php echo $identity['identity_id'];?>&amp;module_id=<?php if(isset($module_id)) { echo $module_id;}?>&amp;item_id=<?php if (isset($item_id)) { echo $item_id;}?>&amp;portable=1"><?php echo $lang['href_respect_portable'];?></a><br />
					<?php }?>
					<?php }?>
				</p>
				
				<hr />
				
				<p>
					<b><?php echo $lang['txt_tags'];?></b><br />
					<?php
					if (isset($tags)) {
					$prnt = "";
					foreach($tags as $key => $i):
						$prnt .= $i['tag_body'] . "<sup><a href='index.php?amn=core_profile&amp;edit_tag=" . $i['tag_id'] . "&amp;identity_id=" . $i['item_id'] . "' style='text-decoration:none;'>&#43;</a></sup> ";
					endforeach;
					echo $prnt;
					}
					?>
				</p>
				
				<table cellspacing="1" cellpadding="0" border="0" width="100%">
					<tr>
						<td>
							<input type="hidden" name="tag_id" value="<?php if (isset($tag)) { echo $tag['tag_id'];}?>" />
							<input type="text" class="input1" name="tag_body" size="10" value="<?php if (isset($tag)) { echo $tag['tag_body'];}?>" /><br />
						</td>	
						<td nowrap="nowrap" align="right">
							<input type="submit" name="insert_tag" class="input_submit" style="font-size:60%;" value="OK" /> 
							<input type="submit" name="delete_tag" class="input_submit" style="font-size:60%;" value="DEL" /><br />
						</td>					
					</tr>				
				</table>
				
				<?php
				if (isset($identity_metadata))  {
				?>
				
				<hr />
				
				<p>
					<b><?php echo $lang['txt_metadata'];?></b><br />
					<?php
					$prnt = "";
					foreach($identity_metadata as $key => $i):
						$i = trim($i);
						$prnt .= "<a href='index.php?amn=core_search&amp;meta=" . $i . "'>" . $i . "</a>, ";
					endforeach;
					$prnt = substr($prnt, 0 ,-2);
					echo $prnt;
					?>
					<br />
				</p>
				<?php }?>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_testimonials'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php
				if (isset($invitee_identity)) {
				?>
				<b><?php echo $lang['txt_invited_by'];?></b><br />
				<?php
				$id_card = $invitee_identity;
				$id_card_layout = "portrait";
				include("inc/identity.inc.php");
				
				if (!empty($invitee_identity['testimonial']['testimonial_body'])) {
				?>
				<p>
					<i><?php echo $invitee_identity['testimonial']['testimonial_body'];?></i><br />
				</p>
				
				<hr />
				<?php }?>
				<?php }?>
				
				<?php if (isset($testimonials) && !empty($testimonials)) { ?>
				<?php foreach($testimonials as $t):?>
				<p>
					<a href="index.php?amn=core_profile&amp;user_id=<?php echo $t['testifier_identity_id']; ?>"><b><?php echo $t['identity_nic']; ?></b></a><br />
					<p><i><?php echo $t['testimonial_body']; ?></i></p><hr /><br />
				</p>
				<?php endforeach; ?>
				<?php } else { ?>
				<p>
				<?php echo $lang['txt_no_testimonials']; ?>
				</p>
				<?php }?>
			
				<p align="right">
					<a href="index.php?amn=core_testimonial&amp;identity_id=<?php echo $_REQUEST['identity_id']; ?>">write a testimonial</a><br />
				</p>
				
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
</div>
</form>
