<commit_before><?php

/**
 * Handles the retrieving and display of a users posts, attachments, stats, permissions
 * warnings and the like
 *
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * This file contains code covered by:
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
 * license:		BSD, See included LICENSE.TXT for terms and conditions.
 *
 * @version 1.1 beta 1
 *
 */

if (!defined('ELK'))
	die('No access...');

/**
 * ProfileInfo_Controller Class
 * Access all profile summary areas for a user including overall summary,
 * post listing, attachment listing, user statistics user permissions, user warnings
 */
class ProfileInfo_Controller extends Action_Controller
{
	/**
	 * Member id for the profile being worked with
	 * @var int
	 */
	private $_memID = 0;

	/**
	 * Holds the current summary tabs to load
	 * @var array
	 */
	private $_summary_areas;

	/**
	 * Called before all other methods when coming from the dispatcher or
	 * action class.
	 *
	 * - If you initiate the class outside of those methods, call this method.
	 * or setup the class yourself or fall awaits.
	 */
	public function pre_dispatch()
	{
		global $context, $user_info;

		require_once(SUBSDIR . '/Profile.subs.php');

		$this->_memID = currentMemberID();

		if (!isset($context['user']['is_owner']))
			$context['user']['is_owner'] = (int) $this->_memID === (int) $user_info['id'];

		loadLanguage('Profile');
	}

	/**
	 * Intended as entry point which delegates to methods in this class...
	 *
	 * - But here, today, for now, the methods are mainly called from other places
	 * like menu picks and the like.
	 */
	public function action_index()
	{
		global $context;

		// What do we do, do you even know what you do?
		$subActions = array(
			'buddies' => array($this, 'action_profile_buddies'),
			'recent' => array($this, 'action_profile_recent'),
			'summary' => array('file' => 'Profile.controller.php', 'dir' => CONTROLLERDIR, 'controller' => 'Profile_Controller', 'function' => 'action_index'),
		);

		// Action control
		$action = new Action('profile_info');

		// By default we want the summary
		$subAction = $action->initialize($subActions, 'summary');

		// Final bits
		$context['sub_action'] = $subAction;

		// Call the right function for this sub-action.
		$action->dispatch($subAction);
	}

	/**
	 * View the user profile summary.
	 *
	 * @uses ProfileInfo template
	 */
	public function action_summary()
	{
		global $context, $memberContext, $modSettings, $scripturl;

		// Attempt to load the member's profile data.
		if (!loadMemberContext($this->_memID) || !isset($memberContext[$this->_memID]))
			Errors::instance()->fatal_lang_error('not_a_user', false);

		loadTemplate('ProfileInfo');

		// Set a canonical URL for this page.
		$context['canonical_url'] = $scripturl . '?action=profile;u=' . $this->_memID;

		// Are there things we don't show?
		$context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();

		// Menu tab
		$context[$context['profile_menu_name']]['tab_data'] = array();

		// Profile summary tabs, like Summary, Recent, Buddies
		$this->_register_summarytabs();

		// Load in everything we know about the user to preload the summary tab
		$this->_define_user_values();
		$this->_load_summary();

		// To finish this off, custom profile fields.
		loadCustomFields($this->_memID);

		// To make tabs work, we need jQueryUI
		$modSettings['jquery_include_ui'] = true;
		addInlineJavascript('start_tabs();', true);
	}

	/**
	 * Prepares the tabs for the profile summary page
	 *
	 * What it does:
	 * - Tab information for use in the summary page
	 * - Each tab template defines a div, the value of which are the template(s) to load in that div
	 * - array(array(1, 2), array(3, 4)) <div>template 1, template 2</div><div>template 3 template 4</div>
	 * - Templates are named template_profile_block_YOURNAME
	 * - Tabs with href defined will not preload/create any page divs but instead be loaded via ajax
	 */
	private function _register_summarytabs()
	{
		global $txt, $context, $modSettings, $scripturl;

		$context['summarytabs'] = array(
			'summary' => array(
				'name' => $txt['summary'],
				'templates' => array(
					array('summary', 'user_info'),
					array('contact', 'other_info'),
					array('user_customprofileinfo', 'moderation'),
				),
				'active' => true,
			),
			'recent' => array(
				'name' => $txt['profile_recent_activity'],
				'templates' => array('posts', 'topics', 'attachments'),
				'active' => true,
				'href' => $scripturl . '?action=profileinfo&sa=recent&' . $context['session_var'] . '=' . $context['session_id'],
			),
			'buddies' => array(
				'name' => $txt['buddies'],
				'templates' => array('buddies'),
				'active' => !empty($modSettings['enable_buddylist']) && $context['user']['is_owner'],
				'href' => $scripturl . '?action=profileinfo;sa=buddies;' . $context['session_var'] . '=' . $context['session_id'],
			)
		);

		// Let addons add or remove to the tabs array
		call_integration_hook('integrate_profile_summary', array($this->_memID));

		// Go forward with whats left after integration adds or removes
		$summary_areas = '';
		foreach ($context['summarytabs'] as $id => $tab)
		{
			// If the tab is active we add it
			if ($tab['active'] !== true)
			{
				unset($context['summarytabs'][$id]);
			}
			else
			{
				// All the active templates, used to prevent processing data we don't need
				foreach ($tab['templates'] as $template)
				{
					$summary_areas .= is_array($template) ? implode(',', $template) : ',' . $template;
				}
			}
		}

		$this->_summary_areas = explode(',', $summary_areas);<commit_msg>! wrong case on the controller<commit_after><?php

/**
 * Handles the retrieving and display of a users posts, attachments, stats, permissions
 * warnings and the like
 *
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * This file contains code covered by:
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
 * license:		BSD, See included LICENSE.TXT for terms and conditions.
 *
 * @version 1.1 beta 1
 *
 */

if (!defined('ELK'))
	die('No access...');

/**
 * ProfileInfo_Controller Class
 * Access all profile summary areas for a user including overall summary,
 * post listing, attachment listing, user statistics user permissions, user warnings
 */
class ProfileInfo_Controller extends Action_Controller
{
	/**
	 * Member id for the profile being worked with
	 * @var int
	 */
	private $_memID = 0;

	/**
	 * Holds the current summary tabs to load
	 * @var array
	 */
	private $_summary_areas;

	/**
	 * Called before all other methods when coming from the dispatcher or
	 * action class.
	 *
	 * - If you initiate the class outside of those methods, call this method.
	 * or setup the class yourself or fall awaits.
	 */
	public function pre_dispatch()
	{
		global $context, $user_info;

		require_once(SUBSDIR . '/Profile.subs.php');

		$this->_memID = currentMemberID();

		if (!isset($context['user']['is_owner']))
			$context['user']['is_owner'] = (int) $this->_memID === (int) $user_info['id'];

		loadLanguage('Profile');
	}

	/**
	 * Intended as entry point which delegates to methods in this class...
	 *
	 * - But here, today, for now, the methods are mainly called from other places
	 * like menu picks and the like.
	 */
	public function action_index()
	{
		global $context;

		// What do we do, do you even know what you do?
		$subActions = array(
			'buddies' => array($this, 'action_profile_buddies'),
			'recent' => array($this, 'action_profile_recent'),
			'summary' => array('file' => 'Profile.controller.php', 'dir' => CONTROLLERDIR, 'controller' => 'Profile_Controller', 'function' => 'action_index'),
		);

		// Action control
		$action = new Action('profile_info');

		// By default we want the summary
		$subAction = $action->initialize($subActions, 'summary');

		// Final bits
		$context['sub_action'] = $subAction;

		// Call the right function for this sub-action.
		$action->dispatch($subAction);
	}

	/**
	 * View the user profile summary.
	 *
	 * @uses ProfileInfo template
	 */
	public function action_summary()
	{
		global $context, $memberContext, $modSettings, $scripturl;

		// Attempt to load the member's profile data.
		if (!loadMemberContext($this->_memID) || !isset($memberContext[$this->_memID]))
			Errors::instance()->fatal_lang_error('not_a_user', false);

		loadTemplate('ProfileInfo');

		// Set a canonical URL for this page.
		$context['canonical_url'] = $scripturl . '?action=profile;u=' . $this->_memID;

		// Are there things we don't show?
		$context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();

		// Menu tab
		$context[$context['profile_menu_name']]['tab_data'] = array();

		// Profile summary tabs, like Summary, Recent, Buddies
		$this->_register_summarytabs();

		// Load in everything we know about the user to preload the summary tab
		$this->_define_user_values();
		$this->_load_summary();

		// To finish this off, custom profile fields.
		loadCustomFields($this->_memID);

		// To make tabs work, we need jQueryUI
		$modSettings['jquery_include_ui'] = true;
		addInlineJavascript('start_tabs();', true);
	}

	/**
	 * Prepares the tabs for the profile summary page
	 *
	 * What it does:
	 * - Tab information for use in the summary page
	 * - Each tab template defines a div, the value of which are the template(s) to load in that div
	 * - array(array(1, 2), array(3, 4)) <div>template 1, template 2</div><div>template 3 template 4</div>
	 * - Templates are named template_profile_block_YOURNAME
	 * - Tabs with href defined will not preload/create any page divs but instead be loaded via ajax
	 */
	private function _register_summarytabs()
	{
		global $txt, $context, $modSettings, $scripturl;

		$context['summarytabs'] = array(
			'summary' => array(
				'name' => $txt['summary'],
				'templates' => array(
					array('summary', 'user_info'),
					array('contact', 'other_info'),
					array('user_customprofileinfo', 'moderation'),
				),
				'active' => true,
			),
			'recent' => array(
				'name' => $txt['profile_recent_activity'],
				'templates' => array('posts', 'topics', 'attachments'),
				'active' => true,
				'href' => $scripturl . '?action=profileInfo;sa=recent;xml;' . $context['session_var'] . '=' . $context['session_id'],
			),
			'buddies' => array(
				'name' => $txt['buddies'],
				'templates' => array('buddies'),
				'active' => !empty($modSettings['enable_buddylist']) && $context['user']['is_owner'],
				'href' => $scripturl . '?action=profileInfo;sa=buddies;xml;' . $context['session_var'] . '=' . $context['session_id'],
			)
		);

		// Let addons add or remove to the tabs array
		call_integration_hook('integrate_profile_summary', array($this->_memID));

		// Go forward with whats left after integration adds or removes
		$summary_areas = '';
		foreach ($context['summarytabs'] as $id => $tab)
		{
			// If the tab is active we add it
			if ($tab['active'] !== true)
			{
				unset($context['summarytabs'][$id]);
			}
			else
			{
				// All the active templates, used to prevent processing data we don't need
				foreach ($tab['templates'] as $template)
				{
					$summary_areas .= is_array($template) ? implode(',', $template) : ',' . $template;
				}
			}
		}

		$this->_summary_areas = explode(',', $summary_areas);
{'fraction_non_alphanumeric': 0.15098393056629716, 'fraction_numerical': 0.0029217152186989774, 'mean_word_length': 3.8940285954583684, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3862326', 'n_tokens_mistral': 3994, 'n_tokens_neox': 3505, 'n_words': 1060}