<commit_before><?php
/*	Project:	EQdkp-Plus
 *	Package:	EQdkp-plus
 *	Link:		http://eqdkp-plus.eu
 *
 *	Copyright (C) 2006-2015 EQdkp-Plus Developer Team
 *
 *	This program is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU Affero General Public License as published
 *	by the Free Software Foundation, either version 3 of the License, 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 Affero General Public License for more details.
 *
 *	You should have received a copy of the GNU Affero General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

class user_pageobject extends pageobject {
	public static $shortcuts = array('crypt'=>'encrypt');
	
	public function __construct() {
		$handler = array(
			'u'					=> array('process' => 'viewuser'),
		);
		$this->user->check_auth('u_userlist');
		parent::__construct(false, $handler, array());
		$this->process();
	}

	public function viewuser(){
		include_once($this->root_path.'core/country_states.php');

		$user_id 	= $this->in->get('u');
		$row		= $this->pdh->get('user', 'data', array($user_id));
		if (!$row){
			$this->display();
			return;
		}

		$arrUserCustomFieldsData = $this->pdh->get('user', 'custom_fields', array($user_id));
		
		//Gender
		switch($row['gender']){
			case '1' : $strGender = $this->user->lang('gender_m').', ';
			break;
			case '2' : $strGender = $this->user->lang('gender_f').', ';
			break;
			default: $strGender = "";
		}
		
		$this->jquery->Tab_header('userprofile_tabs', true);
		
		$this->tpl->assign_vars(array(
			'USER_PROFILE_ID' => $user_id,
			'USER_PROFILE_AVATAR' => ($this->pdh->get('user', 'avatarimglink', array($user_id))) ? $this->pfh->FileLink($this->pdh->get('user', 'avatarimglink', array($user_id)), false, 'absolute') : $this->server_path.'images/global/avatar-default.svg',
			'USER_PROFILE_USERNAME'	=> sanitize($row['username']),
			'USER_PROFILE_GENDER' => $strGender,
			'USER_PROFILE_REGISTERED'	=> $this->pdh->geth('user', 'regdate', array($user_id)),
			'USER_PROFILE_LAST_ACTIVITY' => $this->pdh->geth('user', 'last_visit', array($user_id)),
			'USER_PROFILE_USERGROUPS' => str_replace(', ', '', $this->pdh->geth('user', 'groups', array($user_id, true))),
		));
		
		//Wall Permissions
		$blnWallRead = $this->pdh->get('user', 'check_privacy', array($user_id, 'priv_wall_posts_read'));
		$blnWallWrite = $this->pdh->get('user', 'check_privacy', array($user_id, 'priv_wall_posts_write'));

		//Wall
		$this->comments->SetVars(array(
			'attach_id'	=> $user_id,
			'page'		=> 'userwall',
			'auth'		=> 'a_users_man',
			'userauth' 	=> (($blnWallWrite) ? 'u_userlist' : 'a_something'),
			'replies'	=> true,
		));
		$this->tpl->assign_vars(array(
			'USER_WALL'			=> $this->comments->Show(),
			'S_SHOW_WALL'		=> $blnWallRead,
		));
		
		//Personal Profile Information
		$blnPersonal = $blnContact = false;
		
		if($this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_age'))){
			$age = ($this->time->age($row['birthday']) !== 0) ? $this->time->age($row['birthday']) : '';
			if (strlen($age)) {
				$val = ($this->pdh->get('user', 'check_privacy', array($user_id, 'priv_bday'))) ? $this->time->user_date($row['birthday']).' ('.$age.')': $age;
				$this->tpl->assign_block_vars('profile_personal_row', array(
					'NAME' => $this->user->lang("user_sett_f_priv_userprofile_age"),
					'TEXT' => $val,
				));
				$this->tpl->assign_var('USER_PROFILE_AGE', $val);
				$blnPersonal = true;
			}
		}
		
		if($this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_country'))){

			if (strlen($row['country'])) {
				$val = '<img src="'.$this->server_path.'images/flags/'.strtolower($row['country']).'.svg" alt="'.$row['country'].'" /> '.sanitize(ucfirst(strtolower($country_array[$row['country']])));
				$this->tpl->assign_block_vars('profile_personal_row', array(
						'NAME' => $this->user->lang("user_sett_f_priv_userprofile_country"),
						'TEXT' => $val,
				));
				$this->tpl->assign_var('USER_PROFILE_COUNTRY', $val);
				$blnPersonal = true;
			}
		}

		
		$arrProfileFields = $this->pdh->get('user_profilefields', 'usersettings_fields', array(true));
		foreach($arrProfileFields as $intFieldID){
			$blnPerm = $this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_'.$intFieldID));
			if (!$blnPerm) continue;
			
			$val = $this->pdh->geth('user_profilefields', 'display_field', array($intFieldID, $user_id));

			if ($val == "") continue;
			
			$this->tpl->assign_block_vars('profile_personal_row', array(
					'NAME' => $this->pdh->geth('user_profilefields', 'name', array($intFieldID)),
					'TEXT' => $val,
			));
			$blnPersonal = true;
			$this->tpl->assign_var('USER_PROFILE_'.strtoupper($intFieldID), $val);
		}
		
		
		
		//Contact Information
		if ($this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_email'))){
			$strEmail = $this->pdh->geth('user', 'email', array($user_id, true));
			if ($strEmail != ""){	
				$this->tpl->assign_block_vars('profile_contact_row', array(
						'NAME' => $this->user->lang("email_address"),
						'TEXT' => $strEmail,
				));
				$blnContact = true;
			}
		}
		
		$arrContactFields = $this->pdh->get('user_profilefields', 'contact_fields', array(true));
		foreach($arrContactFields as $intFieldID){
			$blnPerm = $this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_'.$intFieldID));
			if (!$blnPerm) continue;
				
			$val = $this->pdh->geth('user_profilefields', 'display_field', array($intFieldID, $user_id));
		
			if ($val == "") continue;
				
			$this->tpl->assign_block_vars('profile_contact_row', array(
					'NAME' => $this->pdh->geth('user_profilefields', 'name', array($intFieldID)),
					'TEXT' => $val,
			));
			$blnPersonal = true;
			$this->tpl->assign_var('USER_PROFILE_'.strtoupper($intFieldID), $val);
		}
								
		$hptt_page_settings = $this->pdh->get_page_settings('userprofile', 'hptt_userprofile_memberlist_overview');

		$arrMemberList = ($this->pdh->get('member', 'mainchar', array($user_id))) ? array($this->pdh->get('member', 'mainchar', array($user_id))) : array();

		$hptt = $this->get_hptt($hptt_page_settings, $arrMemberList, $arrMemberList, array('%link_url%' => $this->routing->simpleBuild('character'), '%link_url_suffix%' => '', '%with_twink%' => false, '%use_controller%' => true), 'userprofile_'.$user_id);
		$hptt->setPageRef($this->strPath);
		$this->tpl->assign_vars(array(
			'S_PROFILE_PERSONAL_ROW' => $blnPersonal,
			'S_PROFILE_CONTACT_ROW' => $blnContact,

			'PROFILE_CHARS' 		=> $hptt->get_html_table($this->in->get('sort'), '', null, 1, sprintf($this->user->lang('listmembers_footcount'), count( $this->pdh->get('member', 'connection_id', array($user_id))))),
			'S_PROFILE_CHARACTERS'	=> count($arrMemberList),
		));
		
		//Custom Tabs
		$arrHooks = $this->hooks->process('userprofile_customtabs', array('user_id' => $user_id));<commit_msg>Fixed display of contact fields<commit_after><?php
/*	Project:	EQdkp-Plus
 *	Package:	EQdkp-plus
 *	Link:		http://eqdkp-plus.eu
 *
 *	Copyright (C) 2006-2015 EQdkp-Plus Developer Team
 *
 *	This program is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU Affero General Public License as published
 *	by the Free Software Foundation, either version 3 of the License, 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 Affero General Public License for more details.
 *
 *	You should have received a copy of the GNU Affero General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

class user_pageobject extends pageobject {
	public static $shortcuts = array('crypt'=>'encrypt');
	
	public function __construct() {
		$handler = array(
			'u'					=> array('process' => 'viewuser'),
		);
		$this->user->check_auth('u_userlist');
		parent::__construct(false, $handler, array());
		$this->process();
	}

	public function viewuser(){
		include_once($this->root_path.'core/country_states.php');

		$user_id 	= $this->in->get('u');
		$row		= $this->pdh->get('user', 'data', array($user_id));
		if (!$row){
			$this->display();
			return;
		}

		$arrUserCustomFieldsData = $this->pdh->get('user', 'custom_fields', array($user_id));
		
		//Gender
		switch($row['gender']){
			case '1' : $strGender = $this->user->lang('gender_m').', ';
			break;
			case '2' : $strGender = $this->user->lang('gender_f').', ';
			break;
			default: $strGender = "";
		}
		
		$this->jquery->Tab_header('userprofile_tabs', true);
		
		$this->tpl->assign_vars(array(
			'USER_PROFILE_ID' => $user_id,
			'USER_PROFILE_AVATAR' => ($this->pdh->get('user', 'avatarimglink', array($user_id))) ? $this->pfh->FileLink($this->pdh->get('user', 'avatarimglink', array($user_id)), false, 'absolute') : $this->server_path.'images/global/avatar-default.svg',
			'USER_PROFILE_USERNAME'	=> sanitize($row['username']),
			'USER_PROFILE_GENDER' => $strGender,
			'USER_PROFILE_REGISTERED'	=> $this->pdh->geth('user', 'regdate', array($user_id)),
			'USER_PROFILE_LAST_ACTIVITY' => $this->pdh->geth('user', 'last_visit', array($user_id)),
			'USER_PROFILE_USERGROUPS' => str_replace(', ', '', $this->pdh->geth('user', 'groups', array($user_id, true))),
		));
		
		//Wall Permissions
		$blnWallRead = $this->pdh->get('user', 'check_privacy', array($user_id, 'priv_wall_posts_read'));
		$blnWallWrite = $this->pdh->get('user', 'check_privacy', array($user_id, 'priv_wall_posts_write'));

		//Wall
		$this->comments->SetVars(array(
			'attach_id'	=> $user_id,
			'page'		=> 'userwall',
			'auth'		=> 'a_users_man',
			'userauth' 	=> (($blnWallWrite) ? 'u_userlist' : 'a_something'),
			'replies'	=> true,
		));
		$this->tpl->assign_vars(array(
			'USER_WALL'			=> $this->comments->Show(),
			'S_SHOW_WALL'		=> $blnWallRead,
		));
		
		//Personal Profile Information
		$blnPersonal = $blnContact = false;
		
		if($this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_age'))){
			$age = ($this->time->age($row['birthday']) !== 0) ? $this->time->age($row['birthday']) : '';
			if (strlen($age)) {
				$val = ($this->pdh->get('user', 'check_privacy', array($user_id, 'priv_bday'))) ? $this->time->user_date($row['birthday']).' ('.$age.')': $age;
				$this->tpl->assign_block_vars('profile_personal_row', array(
					'NAME' => $this->user->lang("user_sett_f_priv_userprofile_age"),
					'TEXT' => $val,
				));
				$this->tpl->assign_var('USER_PROFILE_AGE', $val);
				$blnPersonal = true;
			}
		}
		
		if($this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_country'))){

			if (strlen($row['country'])) {
				$val = '<img src="'.$this->server_path.'images/flags/'.strtolower($row['country']).'.svg" alt="'.$row['country'].'" /> '.sanitize(ucfirst(strtolower($country_array[$row['country']])));
				$this->tpl->assign_block_vars('profile_personal_row', array(
						'NAME' => $this->user->lang("user_sett_f_priv_userprofile_country"),
						'TEXT' => $val,
				));
				$this->tpl->assign_var('USER_PROFILE_COUNTRY', $val);
				$blnPersonal = true;
			}
		}

		
		$arrProfileFields = $this->pdh->get('user_profilefields', 'usersettings_fields', array(true));
		foreach($arrProfileFields as $intFieldID){
			$blnPerm = $this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_'.$intFieldID));
			if (!$blnPerm) continue;
			
			$val = $this->pdh->geth('user_profilefields', 'display_field', array($intFieldID, $user_id));

			if ($val == "") continue;
			
			$this->tpl->assign_block_vars('profile_personal_row', array(
					'NAME' => $this->pdh->geth('user_profilefields', 'name', array($intFieldID)),
					'TEXT' => $val,
			));
			$blnPersonal = true;
			$this->tpl->assign_var('USER_PROFILE_'.strtoupper($intFieldID), $val);
		}
		
		
		
		//Contact Information
		if ($this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_email'))){
			$strEmail = $this->pdh->geth('user', 'email', array($user_id, true));
			if ($strEmail != ""){	
				$this->tpl->assign_block_vars('profile_contact_row', array(
						'NAME' => $this->user->lang("email_address"),
						'TEXT' => $strEmail,
				));
				$blnContact = true;
			}
		}
		
		$arrContactFields = $this->pdh->get('user_profilefields', 'contact_fields', array(true));
		foreach($arrContactFields as $intFieldID){
			$blnPerm = $this->pdh->get('user', 'check_privacy', array($user_id, 'priv_userprofile_'.$intFieldID));
			if (!$blnPerm) continue;
				
			$val = $this->pdh->geth('user_profilefields', 'display_field', array($intFieldID, $user_id));
		
			if ($val == "") continue;
				
			$this->tpl->assign_block_vars('profile_contact_row', array(
					'NAME' => $this->pdh->geth('user_profilefields', 'name', array($intFieldID)),
					'TEXT' => $val,
			));
			if($this->pdh->get('user_profilefields', 'is_contact', array($intFieldID))) {
				$blnContact = true;
			} else {
				$blnPersonal = true;
			}
			$this->tpl->assign_var('USER_PROFILE_'.strtoupper($intFieldID), $val);
		}
								
		$hptt_page_settings = $this->pdh->get_page_settings('userprofile', 'hptt_userprofile_memberlist_overview');

		$arrMemberList = ($this->pdh->get('member', 'mainchar', array($user_id))) ? array($this->pdh->get('member', 'mainchar', array($user_id))) : array();

		$hptt = $this->get_hptt($hptt_page_settings, $arrMemberList, $arrMemberList, array('%link_url%' => $this->routing->simpleBuild('character'), '%link_url_suffix%' => '', '%with_twink%' => false, '%use_controller%' => true), 'userprofile_'.$user_id);
		$hptt->setPageRef($this->strPath);
		$this->tpl->assign_vars(array(
			'S_PROFILE_PERSONAL_ROW'	=> $blnPersonal,
			'S_PROFILE_CONTACT_ROW'		=> $blnContact,

			'PROFILE_CHARS' 		=> $hptt->get_html_table($this->in->get('sort'), '', null, 1, sprintf($this->user->lang('listmembers_footcount'), count( $this->pdh->get('member', 'connection_id', array($user_id))))),
			'S_PROFILE_CHARACTERS'	=> count($arrMemberList),
		));
		
		//Custom Tabs
		$arrHooks = $this->hooks->process('userprofile_customtabs', array('user_id' => $user_id));
{'fraction_non_alphanumeric': 0.20663159352069776, 'fraction_numerical': 0.0017998061747196456, 'mean_word_length': 4.846620801295022, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 323, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1447760', 'n_tokens_mistral': 5849, 'n_tokens_neox': 5210, 'n_words': 859}