<commit_before><?php
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
	header('location: index.php');
	exit;
}

class LoginLib
{
	function activateSession($user)
	{
		global $user_cookie_site;
		$_SESSION[$user_cookie_site] = $user;
	}

	function switchUser($name)
	{
		global $user, $user_cookie_site;
		$perms = Perms::get();

		if (! $perms->admin) {
			return;
		}

		$userlib = TikiLib::lib('user');
		$username = $userlib->get_user_real_case($name);
		$this->activateSession($username);
		$_SESSION[$user_cookie_site . '_previous'] = $user;<commit_msg>[FIX] Add missing loginlib functions required for user conditions feature [partial bp/r49174]<commit_after><?php
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
	header('location: index.php');
	exit;
}

class LoginLib
{
	function getUser()
	{
		return $GLOBALS['user'];
	}

	function getUserId()
	{
		$id = TikiLib::lib('tiki')->get_user_id($this->getUser());
		if ($id === -1) {
			return false;
		} else {
			return $id;
		}
	}

	function activateSession($user)
	{
		global $user_cookie_site;
		$_SESSION[$user_cookie_site] = $user;
	}

	function switchUser($name)
	{
		global $user, $user_cookie_site;
		$perms = Perms::get();

		if (! $perms->admin) {
			return;
		}

		$userlib = TikiLib::lib('user');
		$username = $userlib->get_user_real_case($name);
		$this->activateSession($username);
		$_SESSION[$user_cookie_site . '_previous'] = $user;
{'fraction_non_alphanumeric': 0.14541176470588235, 'fraction_numerical': 0.010352941176470589, 'mean_word_length': 4.288557213930348, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5853239', 'n_tokens_mistral': 766, 'n_tokens_neox': 695, 'n_words': 198}