<?php

// -----------------------------------------------------------------------
// This file is part of aroundme
// 
// Copyright (C) 2003, 2005 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., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// -----------------------------------------------------------------------

?>


<form action="g_member_profile.php" method="post">
<input type="hidden" name="group_id" value="<?php echo $group['group_id'];?>" />



<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="180" valign="top" rowspan="2">
			<?php
			include $templatePath . "g_menu.inc.tpl.php";
			?>
		</td>

		<td width="20" rowspan="2">&nbsp;</td>

		<td width="560" valign="top" colspan="3">
			<?php
			if (isset($member) ) {
			?>
			<div class="box_top">
				<?php echo $lang['hdr_profile'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<?php
			if (isset($display) && $display == "blocked") {
			?>
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td>
						<b><?php echo $lang['hdr_blocked'];?></b><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_blocked_help'];?><br />
					</td>
				</tr>
				<tr>
					<td align="right">
						<a href="my_profile.php?blocked=1"><?php echo $lang['href_blocked_list'];?></a><br />
					</td>
				</tr>
			</table>
			
			<hr />
			<?php }?>
			
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td valign="top">
						<?php echo $profile['profile_summary'];?><br />
					</td>
				</tr>
			</table>
			
			<hr />
			
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td valign="top">
						<img src="get_file.php?file=<?php echo $profile['image']['file'];?>" class="picture" border="0" alt="<?php echo $profile['image']['file_title'];?>" /><br />
					
					</td>
					<td valign="top">
						<table border="0" cellspacing="2" cellpadding="4" width="100%">
							<tr>
								<td colspan="2">
									<?php echo $profile['profile_nic'];?><br />
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $lang['txt_profile_session_status'];?><br />
								</td>
								<td>
									<?php
									if ($profile['online_status'] == 1) {
									    echo "<b>" . $lang['arr_user_online_status'][1] . "</b><br />";
									}
									else {
										    echo $lang['arr_user_online_status'][$profile['online_status']] . "<br />";
									}
									?>
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $lang['txt_profile_hometown'];?><br />
								</td>
								<td>
									<?php echo $profile['profile_hometown'];?><br />
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $lang['txt_profile_create_datetime'];?><br />
								</td>
								<td>
									<?php echo $profile['display_profile_create_datetime'];?><br />
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $lang['txt_membership_number'];?><br />
								</td>
								<td>
									<?php echo $member['membership_number'];?><br />
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $lang['txt_group_join_date'];?><br />
								</td>
								<td>
									<?php echo $member['membership_create_datetime'];?><br />
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $lang['txt_membership_role'];?><br />
								</td>
								<td>
									<?php echo $group['member']['role_name'];?><br />
								</td>
							</tr>
							<tr>
								<td colspan="2" align="right">
									<a href="msg_compose.php?to_user_id=<?php echo $member['user_id'];?>"><img src="<?php echo $templatePath;?>img/unopenned_mail.png" alt="<?php echo $lang['ttl_send_message'];?>" border="0" /></a><br />
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td valign="top">
						<b><?php echo $lang['hdr_statistics'];?></b><br />
					</td>
				</tr>
				<tr>
					
					<td valign="top">
						<table border="0" width="100%" cellspacing="0" cellpadding="2">
							<?php
							if (isset($gm_statistics)) {
							foreach($gm_statistics as $key => $i):
							if (isset($lang['arr_group_member_statistic_type_id'][$i['statistic_type_id']])) {
							?>
							<tr>
								<td>
									<?php echo $lang['arr_group_member_statistic_type_id'][$i['statistic_type_id']];?><br />
								</td>
								<td align="right">
									<?php echo $i['total'];?><br />
								</td>
							</tr>
							<?php
							}
							endforeach;
							} else {
							?>
							<tr>
								<td colspan="2">
									<?php echo $lang['err_no_member_statistics'];?><br />
								</td>
							</tr>
							<?php }?>
						</table>
					</td>
				</tr>
			</table>
			
			<div class="box_edit">
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td valign="top" width="60%">
						<input type="hidden" name="user_id" value="<?php echo $member['user_id'];?>" />
						<?php
						if ($this->group_acs->checkPermission($resource_ids['group_membership'], $privilege_ids['allow_edit'])) { //resourece_id, Priv_id
							$edit_admin = 1;
						}
						else {
						?>
						<input type="hidden" name="data[membership_number]" value="<?php echo $member['membership_number'];?>" />
						<input type="hidden" name="data[role_id]" value="<?php echo $member['role_id'];?>" />
						<input type="hidden" name="data[status_id]" value="<?php echo $member['status_id'];?>" />
						<?php
						}
						?>
						
						<?php
						if ($me['user_id'] == $member['user_id']) {
							$edit_profile = 1;
						}
						else {
						?>
						<input type="hidden" name="data[profile_id]" value="<?php echo $member['profile_id'];?>" />
						<?php
						}
						?>
						
						<?php
						if (!empty($edit_admin) || !empty($edit_profile)) {
						?>
						<table width="100%" cellpadding="4" cellspacing="0" border="0">
							<tr>
								<td colspan="2">
									<b><?php echo $lang['hdr_edit_membership']?></b><br />
								</td>
							</tr>
							<?php
							if (!empty($edit_admin)) {
							?>
							<tr>
								<td>
									<?php echo $lang['txt_membership_number'];?><br />
								</td>
								<td>
									<input type="text" name="data[membership_number]" value="<?php echo $member['membership_number'];?>" size="20" class="formInput" /><br />
								</td>
						    </tr>
							<tr>
								<td>
									<?php echo $lang['txt_member_role'];?><br />
								</td>
								<td>
									<select name="data[role_id]" class="formInput">
										<?php
										foreach($group_roles as $key => $i):
											$selected = "";
											if($member['role_id'] == $i['role_id']) {
												$selected = " selected=\"selected\"";
											}
											print "<option value='" . $i['role_id'] . "'" . $selected . ">" . $i['role_name'] . "</option>";
										endforeach;
										?>
									</select>
								</td>
						    </tr>
							<tr>
								<td>
									<?php echo $lang['txt_member_status'];?><br />
								</td>
								<td>
									<select name="data[status_id]" class="formInput">
										<?php
										foreach($group_member_status_ids as $key => $i):
											$selected = "";
											if($member['status_id'] == $i) {
												$selected = " selected";
											}
											print "<option value='" . $i . "'" . $selected . ">" . $lang['arr_group_member_status'][$i] . "</option>";
										endforeach;
										?>
									</select>
								</td>
						    </tr>
							<?php
							}
							
							if (!empty($edit_profile)) {
							?>
							<tr>
								<td>
									<?php echo $lang['txt_profile'];?><br />
								</td>
								<td>
									<select name="data[profile_id]" class="formInput">
										<?php
										foreach($profiles as $key => $i):
											$selected = "";
											if (isset($member['profile_id']) && $member['profile_id'] == $i['profile_id']) {
											    $selected = "selected=\"selected\"";
											}
											print "<option value='" . $i['profile_id'] . "' " . $selected . ">" . $i['profile_name'] . "</option>";
										endforeach;
										?>
									</select>
									<br />
								</td>
							</tr>
							<?php
							}
							?>
						    <tr>
								<td align="right" colspan="2">
									<input type="submit" name="update_membership" value="<?php echo $lang['sub_update'];?>" class="button_urgent" /><br />
								</td>
							</tr>
						</table>
						<?php }?>
					</td>
					
					<td width="20">&nbsp;</td>
					
					<td valign="top" width="40%">
						<?php
						if (isset($display_confirmation_delete)) {
						?>
						<table width="100%" cellpadding="4" cellspacing="0" border="0">
							<tr>
								<td colspan="2">
									<b><?php echo $lang['hdr_delete_membership_confirm']?></b><br />
								</td>
							</tr>
			
							<tr>
								<td>
									<?php echo $lang['txt_delete_membership_confirm'];?><br />
								</td>
						    </tr>
						    <tr>
								<td align="right">
									<input type="submit" name="delete_membership_confirm" value="<?php echo $lang['sub_confirm_delete'];?>" class="button_urgent"><br /><br />
								</td>
							</tr>
						</table>
						<?php
						}
						elseif ($member['user_id'] == $group['member']['user_id']) {
						?>
						<table width="100%" cellpadding="4" cellspacing="0" border="0">
							<tr>
								<td colspan="2">
									<b><?php echo $lang['hdr_delete_membership']?></b><br />
								</td>
							</tr>
			
							<tr>
								<td>
									<?php echo $lang['txt_delete_membership'];?><br />
								</td>
						    </tr>
						    <tr>
								<td align="right">
									<input type="submit" name="delete_membership" value="<?php echo $lang['sub_delete'];?>" class="button_urgent" /><br />
								</td>
							</tr>
						</table>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
						<?php }?>
					</td>
				</tr>
			</table>
			</div>
			</div>
			
			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
		</td>
	</tr>
	<tr>
		<td width="270" valign="top">
			<?php
			if ($this->group_acs->checkPermission($resource_ids['group_blog'], $privilege_ids['allow_access'])) { //resourece_id, Priv_id
			?>
			<div class="box_top">
				<?php echo $lang['hdr_member_blogs'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<?php
				if (isset($blogs)) {
				foreach($blogs as $key => $i):
				?>
				<tr>
					<td valign="top" width="1%">
						<a href="blg_item.php?group_id=<?php echo $group['group_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>"><img align="right" src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" class="picture" title="<?php echo $i['image']['file_title'];?>"></a><br />
					</td>
					<td valign="top">
						<a href="blg_item.php?group_id=<?php echo $group['group_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>"><?php echo $i['blog_create_datetime'];?></a><br />
						<b><?php echo $i['blog_title'];?></b><br />
						<span class="txt_footer"><?php echo $i['blog_synopsis'];?></span><br />
					</td>
			    </tr>
				<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="2">
						<?php echo $lang['err_no_blogs'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
			</div>
			
			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?php }?>
			
			
			<?php
			if ($this->group_acs->checkPermission($resource_ids['group_library'], $privilege_ids['allow_access'])) { //resourece_id, Priv_id
			?>
			<div class="box_top">
				<?php echo $lang['hdr_member_library'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<?php
				if (isset($library)) {
				foreach($library as $key => $i):
				?>
				<tr>
					<td valign="top" width="1%">
						<a href="lib_item.php?group_id=<?php echo $group['group_id'];?>&amp;page=<?php echo $i['library_page_name'];?>"><img align="right" src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" class="picture" title="<?php echo $i['image']['file_title'];?>"></a><br />
					</td>
					<td valign="top">
						<a href="lib_item.php?group_id=<?php echo $group['group_id'];?>&amp;page=<?php echo $i['library_page_name'];?>"><?php echo $i['library_title'];?></a><br />
						<b><?php echo $i['library_title'];?></b><br />
						<span class="txt_footer"><?php echo dots('180', $i['library_synopsis']);?></span><br />
					</td>
				</tr>
			<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="2">
						<?php echo $lang['err_no_library'];?><br />
					</td>
				</tr>
			<?php }?>
			</table>
			</div>
			
			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>
			<?php }?>
		</td>

		<td width="20">&nbsp;</td>

		<td width="270" valign="top">
			<?php
			if ($this->group_acs->checkPermission($resource_ids['group_forum'], $privilege_ids['allow_access'])) { //resourece_id, Priv_id
			?>
			<div class="box_top">
				<?php echo $lang['hdr_member_subjects'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<?php
				if (isset($subjects)) {
				foreach($subjects as $key => $i):
				?>
				<tr valign="top">
					<td valign="top" width="1%">
						<a href="frm_item.php?group_id=<?php echo $group['group_id'];?>&amp;subject_id=<?php echo $i['subject_id'];?>"><img align="right" src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" class="picture" title="<?php echo $i['image']['file_title'];?>"></a><br />
					</td>
					<td valign="top">
						<a href="frm_item.php?group_id=<?php echo $group['group_id'];?>&amp;subject_id=<?php echo $i['subject_id'];?>"><?php echo $i['subject_create_datetime'];?></a><br />
						<b><?php echo $i['subject_title'];?></b><br />
						<span class="txt_footer"><?php echo dots(200,$i['subject_body']);?></span><br />
		 			</td>
				</tr>
				<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="2">
						<?php echo $lang['err_no_subjects'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
			</div>
			
			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?php }?>
			
			
			<div class="box_top">
				<?php echo $lang['hdr_member_comments'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<?php
				if (isset($comments)) {
				foreach($comments as $key => $i):
				?>
			    <tr>
					<td width="3" valign="top">
						<img src="<?php echo $templatePath;?>img/green_dot.png" width="3" height="9" alt="" /><br />
					</td>
					<td valign="top">
						<?php echo $i['comment_body'];?><br />
					</td>
				</tr>
			<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="2">
						<?php echo $lang['err_no_comments'];?><br />
					</td>
				</tr>
			<?php }?>
			</table>
			</div>
			
			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			
			<?php 
			}
			else {
			?>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td>
						<?php echo $lang['err_no_member'];?><br />
					</td>
				</tr>
			</table>
			<?php }?>
		</td>
	</tr>
</table>
</form>
