<?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="770" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="180" valign="top">
			<?php
			include $templatePath . "g_menu.inc.tpl.php";
			?>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			
			<?php
			if (isset($display_confirmation_delete)) {
			?>
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td colspan="2" class="txt_title">
						<?php echo $lang['hdr_delete_membership_confirm']?><br />
						<hr />
					</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="formInput"><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" class="txt_title">
						<?php echo $lang['hdr_delete_membership']?><br />
						<hr />
					</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="formInput" /><br />
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?php
			}
			?>
			
			
			<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" class="txt_title">
						<?php echo $lang['hdr_edit_membership']?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (!empty($edit_admin)) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_membership_number'];?><br />
					</td>
			    </tr>
				<tr>
					<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>
			    </tr>
				<tr>
					<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>
			    </tr>
				<tr>
					<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>
				</tr>
				
				<tr>
					<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">
						<input type="submit" name="update_membership" value="<?php echo $lang['sub_update'];?>" class="formInput" /><br />
					</td>
				</tr>
			</table>
			<?php
			}
			?>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="52" alt="" /><br />

			<?php
			include $templatePath . "logo.inc.tpl.php";
			?>
		</td>

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

		<td width="370" valign="top">
			<?php
			if (isset($member) ) {
			?>
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
   				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php  echo $lang['txt_profile_summary'];?>
						<hr />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<?php echo $profile['profile_summary'];?><br />
					</td>
				</tr>
			</table>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_member_library'];?><br />
						<hr />
					</td>
				</tr>

				<?php
				if (isset($library)) {
				foreach($library as $key => $i):
				?>
				<tr>
					<td>
						<?php
						if (isset($i['image'])) {
						?>
							<a href="g_library.php?group_id=<?php echo $i['group_id'];?>&amp;page_id=<?php echo $i['library_id'];?>"><img align="left" src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" class="picture_left" title="<?php echo $i['image']['file_title'];?>"></a>
						<?
						}
						?>
						<a href="g_library.php?group_id=<?php echo $i['group_id'];?>&amp;page_id=<?php echo $i['library_id'];?>"><?php echo $i['library_title'];?></a><br />
						<span class="txt_footer"><?php echo dots('120', $i['library_synopsis']);?></span><br />
					</td>

				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
			<?php
				endforeach;
				} else {
				?>
				<tr>
					<td>
						<?php echo $lang['err_no_library'];?><br />
					</td>
				</tr>
			<?php }?>
			</table>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_member_blogs'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($blogs)) {
				foreach($blogs as $key => $i):
				?>
				<tr valign="top">
					<td>
						<a href="g_blog.php?group_id=<?php echo $group['group_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>"><img align="left" src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" class="picture_left" title="<?php echo $i['image']['file_title'];?>"></a>
						<a href="g_blog.php?group_id=<?php echo $group['group_id'];?>&amp;blog_id=<?php echo $i['blog_id'];?>"><?php echo $i['blog_title'];?></a><br />
						<span class="txt_footer"><?php echo $i['blog_synopsis'];?></span><br />
					</td>
			    </tr>
				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
			<?php
				endforeach;
				} else {
				?>
				<tr>
					<td>
						<?php echo $lang['err_no_blogs'];?><br />
					</td>
				</tr>
			<?php }?>
			</table>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_member_subjects'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($subjects)) {
				foreach($subjects as $key => $i):
				?>
				<tr valign="top">
					<td>
						<a href="g_forum_subject.php?group_id=<?php echo $group['group_id'];?>&amp;subject_id=<?php echo $i['subject_id'];?>"><img align="left" src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" class="picture_left" title="<?php echo $i['image']['file_title'];?>"></a>
						<a href="g_forum_subject.php?group_id=<?php echo $group['group_id'];?>&amp;subject_id=<?php echo $i['subject_id'];?>"><?php echo $i['subject_title'];?></a><br />
						<span class="txt_footer"><?php echo $i['subject_body'];?></span><br />
					</td>
			    </tr>

				<?if (isset($i['poll'])) {?>
				<tr>
					<td>
						<?php
						include $templatePath . "poll.inc.tpl";
						?>
					</td>
				</tr>
				<?php
				}
				?>
				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
			<?php
				endforeach;
				} else {
				?>
				<tr>
					<td>
						<?php echo $lang['err_no_subjects'];?><br />
					</td>
				</tr>
			<?php }?>
			</table>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td class="txt_title" align="right" colspan="2">
						<?php echo $lang['hdr_member_comments'];?><br />
						<hr />
					</td>
				</tr>
				<?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>
				<tr>
					<td colspan="2">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
			<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="2">
						<?php echo $lang['err_no_comments'];?><br />
					</td>
				</tr>
			<?php }?>
			</table>
			<?php
			}
			else {
			?>
				<?php echo $lang['err_no_member'];?><br />
			<?php
			}
			?>
		</td>

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

		<td width="180" valign="top">
			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_profile'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<table border="0" cellspacing="2" cellpadding="4" width="100%" class="picture">
							<tr>
								<td class="bg1" colspan="2">
									<?php echo $profile['profile_nic'];?><br />
								</td>
							</tr>
							<tr>
								<td colspan="2">
									<img src="get_file.php?file=<?php echo $profile['image']['file'];?>" border="0" alt="<?php echo $profile['image']['file_title'];?>" /><br />
								</td>
							</tr>
							<tr>
								<td class="bg3">
									<span class="txt_footer">
									<?php echo $lang['txt_profile_session_status'];?><br />
									</span>
								</td>
								<td class="bg4">
									<span class="txt_footer">
									<?php
									if ($profile['online_status'] == 1) {
									    echo "<span class='txt_breadcrumb_on'><b>" . $lang['arr_user_online_status'][1] . "</b></span><br />";
									}
									else {
										    echo $lang['arr_user_online_status'][$profile['online_status']] . "<br />";
									}
									?>
									</span>
								</td>
							</tr>
							<tr>
								<td class="bg3">
									<span class="txt_footer">
									<?php echo $lang['txt_profile_hometown'];?><br />
									</span>
								</td>
								<td class="bg4">
									<span class="txt_footer">
									<?php echo $profile['profile_hometown'];?><br />
									</span>
								</td>
							</tr>
							<tr>
								<td class="bg3">
									<span class="txt_footer">
									<?php echo $lang['txt_profile_create_datetime'];?><br />
									</span>
								</td>
								<td class="bg4">
									<span class="txt_footer">
									<?php echo $profile['display_profile_create_datetime'];?><br />
									</span>
								</td>
							</tr>
							<tr>
								<td class="bg3">
									<span class="txt_footer">
									<?php echo $lang['txt_membership_number'];?><br />
									</span>
								</td>
								<td class="bg4">
									<span class="txt_footer">
									<?php echo $member['membership_number'];?><br />
									</span>
								</td>
							</tr>
							<tr>
								<td class="bg3">
									<span class="txt_footer">
									<?php echo $lang['txt_group_join_date'];?><br />
									</span>
								</td>
								<td class="bg4">
									<span class="txt_footer">
									<?php echo $member['membership_create_datetime'];?><br />
									</span>
								</td>
							</tr>
							<tr>
								<td class="bg3">
									<span class="txt_footer">
									<?php echo $lang['txt_membership_role'];?><br />
									</span>
								</td>
								<td class="bg4">
									<span class="txt_footer">
									<?php echo $group['member']['role_name'];?><br />
									</span>
								</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>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			
			<?php
			if (isset($member['user_id']) ) {
			?>
			<?php
			if (isset($display) && $display == "blocked") {
			?>
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_blocked'];?><br />
						<hr />
					</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>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?
			}
			?>

			<table border="0" width="100%" cellspacing="0" cellpadding="4">
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $lang['hdr_statistics'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($gm_statistics)) {
				foreach($gm_statistics as $key => $i):
				?>
				<tr>
					<td>
						<span class="txt_footer"><?php echo $lang['arr_group_member_statistic_type_id'][$i['statistic_type_id']];?></span><br />
					</td>
					<td align="right">
						<span class="txt_footer"><?php echo $i['total'];?></span><br />
					</td>
				</tr>
				<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="2">
						<?php echo $lang['err_no_member_statistics'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>

			<?php
			}
			?>
		</td>
	</tr>
</table>
</form>
