<?php
/**
 * @package 	JF Login Pro
 * @author		JoomForest.com
 * @email		support@joomforest.com
 * @website		http://www.joomforest.com
 * @copyright	Copyright (C) 2011-2016 JoomForest.com, All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
**/
// no direct access
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.keepalive');
// DEFAULT VARS
	$jf_echo_name		= '';
	$jf_echo_username	= '';
	$jf_echo_email		= '';
// GET NAME, USERNAME, EMAIL
	if		($jf_l_pro_integration == 'js') {	// JOMSOCIAL
		if ($jomsocial_installed) {
				$jf_echo_name		= $js_user_Name;
				$jf_echo_username	= $js_user_Username;
				$jf_echo_email		= $js_user_Email;
		}
	} elseif($jf_l_pro_integration == 'ku') {	// KUNENA
		if ($kunena_installed) {
			if ($kunena_class) { if (KunenaForum::enabled()) {
				$jf_echo_name		= $ku_name;
				$jf_echo_username	= $user->get('username');
				$jf_echo_email		= $user->get('email');
			} }
		}
	} elseif($jf_l_pro_integration == 'es') {	// EASYSOCIAL
		if ($easysocial_installed) { 
			if (FD::exists()) {
				$jf_echo_name		= $es_name;
				$jf_echo_username	= $es_username;
				$jf_echo_email		= $user->get('email');
			}
		}
	} else {									// JOOMLA
				$jf_echo_name		= $user->get('name');
				$jf_echo_username	= $user->get('username');
				$jf_echo_email		= $user->get('email');
	}
?>
<div id="<?php echo $jf_l_pro_ID; ?>" class="jf_l_pro jf_l_pro_logged <?php echo $moduleclass_sfx; ?>">
	<div class="jf_first_sec">
		<div class="jf_greeting<?php if($jf_l_pro_btn_style == 'light') { ?> light<?php } ?>">
			<div class="jf_greeting_toggl">
				<div class="login_greeting<?php if($jf_l_pro_dr_btn_type == 'icon'){echo ' jf_as_icon';} ?>">
					<?php  	  if ($jf_l_pro_dr_btn_type == 'name') 		{  	echo '<span class="hidden-name-user-in-phone">'.$jf_echo_name.'</span>';
						} elseif ($jf_l_pro_dr_btn_type == 'username') 	{	echo $jf_echo_username;
						} elseif ($jf_l_pro_dr_btn_type == 'email') 	{	echo $jf_echo_email;
						}
					?>
					<span class="jf_imp_icon"<?php if($jf_l_pro_dr_btn_type == 'icon'){echo ' style="display:block"';} ?>></span>
				</div>
			</div>
		</div>

		<div class="jf_logged_cont">
			<div class="jf_tick"></div>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td>
						<div class="section1">
							<?php 
							// JOMSOCIAL
							if 		($jf_l_pro_integration == 'js') { if ($jomsocial_installed) { ?>
								<?php if ($jf_l_pro_api_js_avatar) { ?>
									<div class="jf_l_pro_avatar">
										<img src="<?php echo $js_user_Avatar; ?>" width="94px"/>
										<?php if($jf_l_pro_api_js_avatar_change) { ?>
											<a href="javascript:void(0)" onclick="joms.api.avatarChange('profile', '<?php echo  $js_user_Id; ?>', arguments && arguments[0]); return false;">
												<?php echo JText::sprintf('MOD_JF_LOGIN_PRO_CHANGE_AVATAR') ?>
											</a>
										<?php } ?>
									</div>
								<?php } ?>
								<?php if ($jf_l_pro_api_js_karma) { ?>
									<?php if(isset($badge->current->image)) { ?>
										<div class="jf_l_pro_karma">
											<img src="<?php echo $badge->current->image; ?>" width="98" />
										</div>
									<?php } ?>
								<?php } ?>
							<?php } } 
							// KUNENA
							elseif 	($jf_l_pro_integration == 'ku') { if ($kunena_installed) { if ($kunena_class) { if (KunenaForum::enabled()) { ?>
								<?php if ($jf_l_pro_api_ku_avatar) { ?>
									<div class="jf_l_pro_avatar">
										<?php echo $ku_avatar; ?>
									</div>
								<?php } ?>
								<?php if ($jf_l_pro_api_ku_rank) { ?>
									<div class="jf_l_pro_karma">
										<?php echo $ku_rank; ?>
									</div>
								<?php } ?>
							<?php } } } } 
							// EASYSOCIAL
							elseif	($jf_l_pro_integration == 'es') { if ($easysocial_installed) { if (FD::exists()) { ?>
								<?php if ($jf_l_pro_api_es_avatar) { ?>
									<div class="jf_l_pro_avatar">
										<img src="<?php echo $es_avatar; ?>" />
									</div>
								<?php } ?>
								<?php if ($jf_l_pro_api_es_points) { ?>
									<div class="jf_l_pro_karma">
										<?php echo $es_points; ?> <?php echo JText::_('MOD_JF_LOGIN_PRO_POINTS');?>
									</div>
								<?php } ?>
							<?php } } } ?>
						</div>
					</td>
					<td>
						<div class="section2">
							<?php if($jf_l_pro_pop_name) 		{ ?><div><?php echo $jf_echo_name; ?></div><?php } ?>
							<?php if($jf_l_pro_pop_username) 	{ ?><div><?php echo $jf_echo_username; ?></div><?php } ?>
							<?php if($jf_l_pro_pop_email) 		{ ?><div><?php echo $jf_echo_email; ?></div><?php } ?>
						
							<div class="jf_l_pro_links">
								<?php for ($jf_list = 1; $jf_list <= $jf_list_count; $jf_list += 1) { ?>
									<?php if ($link[$jf_list]) { ?>
										<a href="<?php echo JRoute::_(JFactory::getApplication()->getMenu()->getItem($link_menuid[$jf_list])->link . "&Itemid=$link_menuid[$jf_list]"); ?>" ><?php echo $link_text[$jf_list]; ?></a>
									<?php } ?>
								<?php } ?>
							</div>
						</div>								
					</td>
				</tr>
			</table>
			
			<?php echo $jf_l_pro_pop_html; ?>
			
			<form action="<?php echo JRoute::_(htmlspecialchars(JUri::getInstance()->toString()), true, $params->get('usesecure')); ?>">
				<div class="jf_logout_btn">
					<input type="submit" name="Submit" class="" value="<?php echo JText::_('JLOGOUT'); ?>" />
					<input type="hidden" name="option" value="com_users" />
					<input type="hidden" name="task" value="user.logout" />
					<input type="hidden" name="return" value="<?php echo $return; ?>" />
					<?php echo JHtml::_('form.token'); ?>
				</div>
			</form>
		</div>
	</div>
	<?php if 			($jf_l_pro_integration == 'js') { if ($jomsocial_installed) { if ($jf_l_pro_api_js_notifs) { ?>
		<div class="jf_second_sec">
			<div class="jf_l_pro_noti_c" class="grey"><div>0</div></div>
			<div class="jf_logged_cont">
				<div class="jf_tick"></div>
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<?php if($jf_l_pro_api_js_notifs_sys) { ?>
					<tr class="noti_set" onclick="joms.popup.notification.global();">
						<td class="opacity">
							<div class="name"><?php echo JText::_('MOD_JF_LOGIN_PRO_NOTIF_GLOBAL');?></div>
						</td>
						<td>
							<div class="no_notifcount jf_l_pro_noti_global"><?php echo ($newEventInviteCount) ? $newEventInviteCount : 0; ?></div>
						</td>
					</tr>
					<?php } ?>
					<?php if($jf_l_pro_api_js_notifs_fr) { ?>
					<tr class="friendreq_set" href="<?php echo CRoute::_('index.php?option=com_community&view=friends&task=pending');?>" onclick="joms.popup.notification.friend(); return false;">
						<td class="opacity">
							<div class="name"><?php echo JText::_('MOD_JF_LOGIN_PRO_NOTIF_FRIEND');?></div>
						</td>
						<td>
							<div class="no_notifcount jf_l_pro_noti_friend"><?php echo ($newFriendInviteCount) ? $newFriendInviteCount : 0; ?></div>
						</td>
					</tr>
					<?php } ?>
					<?php if($jf_l_pro_api_js_notifs_msg) { ?>
					<tr class="msg_set last" href="<?php echo CRoute::_('index.php?option=com_community&view=inbox');?>" onclick="joms.popup.notification.pm(); return false;">
						<td class="opacity">
							<div class="name"><?php echo JText::_('MOD_JF_LOGIN_PRO_NOTIF_INBOX');?></div>
						</td>
						<td>
							<div class="no_notifcount jf_l_pro_noti_message"><?php echo ($newMessageCount) ? $newMessageCount : 0; ?></div>					
						</td>
					</tr>
					<?php } ?>
				</table>
			</div>
		</div>
	<?php } } } elseif 	($jf_l_pro_integration == 'es') { if ($easysocial_installed) { if (FD::exists()) { if ($jf_l_pro_api_es_notifs) { ?>
		<div class="jf_second_sec">
			<div class="jf_l_pro_noti_c" class="grey"><div>0</div></div>
			<div class="jf_logged_cont">
				<div class="jf_tick"></div>
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<?php if ($jf_l_pro_api_es_notifs_sys) { ?>
					<tr 
						class="noti_set <?php echo $es_user->getTotalNewNotifications() > 0 ? 'has-notice' : '';?>"
						data-popbox="module://easysocial/notifications/popbox"
						data-popbox-toggle="click"
						data-module-jf_l_pro-system
						data-interval="<?php echo $jf_l_pro_api_es_notifs_sys_int; ?>"
						data-popbox-position="left"
						data-popbox-collision="flip"
						data-user-id="43">
						<td class="opacity">
							<div class="name"><?php echo JText::_('MOD_JF_LOGIN_PRO_NOTIF_GLOBAL');?></div>
						</td>
						<td>
							<div class="no_notifcount jf_l_pro_noti_global" data-notificationSystem-counter><?php echo $es_user->getTotalNewNotifications();?></div>
						</td>
					</tr>
					<?php } ?>
					<?php if ($jf_l_pro_api_es_notifs_fr) { ?>
					<tr 
						class="friendreq_set <?php echo $es_user->getTotalFriendRequests() > 0 ? 'has-notice' : '';?>"
						data-popbox="module://easysocial/friends/popbox"
						data-popbox-toggle="click"
						data-module-jf_l_pro-friends
						data-interval="<?php echo $jf_l_pro_api_es_notifs_fr_int; ?>"
						data-popbox-position="left"
						data-popbox-collision="flip"
						>
						<td class="opacity">
							<div class="name"><?php echo JText::_('MOD_JF_LOGIN_PRO_NOTIF_FRIEND');?></div>
						</td>
						<td>
							<div class="no_notifcount jf_l_pro_noti_friend" data-notificationFriends-counter><?php echo $es_user->getTotalFriendRequests();?></div>
						</td>
					</tr>
					<?php } ?>
					<?php if ($jf_l_pro_api_es_notifs_con) { ?>
					<tr 
						class="msg_set last <?php echo $es_user->getTotalNewNotifications() > 0 ? 'has-notice' : '';?>"
						data-popbox="module://easysocial/conversations/popbox"
						data-popbox-toggle="click"
						data-module-jf_l_pro-conversations
						data-interval="<?php echo $jf_l_pro_api_es_notifs_con_int; ?>"
						data-popbox-position="left"
						data-popbox-collision="flip"
						data-user-id="43">
						<td class="opacity">
							<div class="name"><?php echo JText::_('MOD_JF_LOGIN_PRO_NOTIF_INBOX');?></div>
						</td>
						<td>
							<div class="no_notifcount jf_l_pro_noti_message" data-notificationConversation-counter><?php echo $es_user->getTotalNewConversations();?></div>					
						</td>
					</tr>
					<?php } ?>
				</table>
			</div>
		</div>
	<?php } } } } ?>
</div>