Blame view

libraries/src/User/UserWrapper.php 8.08 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\User;

defined('JPATH_PLATFORM') or die;

/**
 * Wrapper class for UserHelper
 *
 * @since       3.4
 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
 */
class UserWrapper
{
	/**
	 * Helper wrapper method for addUserToGroup
	 *
	 * @param   integer  $userId   The id of the user.
	 * @param   integer  $groupId  The id of the group.
	 *
	 * @return  boolean  True on success
	 *
	 * @see     UserHelper::addUserToGroup()
	 * @since   3.4
	 * @throws  \RuntimeException
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function addUserToGroup($userId, $groupId)
	{
		return UserHelper::addUserToGroup($userId, $groupId);
	}

	/**
	 * Helper wrapper method for getUserGroups
	 *
	 * @param   integer  $userId  The id of the user.
	 *
	 * @return  array    List of groups
	 *
	 * @see     UserHelper::addUserToGroup()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function getUserGroups($userId)
	{
		return UserHelper::getUserGroups($userId);
	}

	/**
	 * Helper wrapper method for removeUserFromGroup
	 *
	 * @param   integer  $userId   The id of the user.
	 * @param   integer  $groupId  The id of the group.
	 *
	 * @return  boolean  True on success
	 *
	 * @see     UserHelper::removeUserFromGroup()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function removeUserFromGroup($userId, $groupId)
	{
		return UserHelper::removeUserFromGroup($userId, $groupId);
	}

	/**
	 * Helper wrapper method for setUserGroups
	 *
	 * @param   integer  $userId  The id of the user.
	 * @param   array    $groups  An array of group ids to put the user in.
	 *
	 * @return  boolean  True on success
	 *
	 * @see     UserHelper::setUserGroups()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function setUserGroups($userId, $groups)
	{
		return UserHelper::setUserGroups($userId, $groups);
	}

	/**
	 * Helper wrapper method for getProfile
	 *
	 * @param   integer  $userId  The id of the user.
	 *
	 * @return  object
	 *
	 * @see     UserHelper::getProfile()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function getProfile($userId = 0)
	{
		return UserHelper::getProfile($userId);
	}

	/**
	 * Helper wrapper method for activateUser
	 *
	 * @param   string  $activation  Activation string
	 *
	 * @return  boolean  True on success
	 *
	 * @see     UserHelper::activateUser()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function activateUser($activation)
	{
		return UserHelper::activateUser($activation);
	}

	/**
	 * Helper wrapper method for getUserId
	 *
	 * @param   string  $username  The username to search on.
	 *
	 * @return  integer  The user id or 0 if not found.
	 *
	 * @see     UserHelper::getUserId()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function getUserId($username)
	{
		return UserHelper::getUserId($username);
	}

	/**
	 * Helper wrapper method for hashPassword
	 *
	 * @param   string   $password   The plaintext password to encrypt.
	 * @param   integer  $algorithm  The hashing algorithm to use, represented by `PASSWORD_*` constants.
	 * @param   array    $options    The options for the algorithm to use.
	 *
	 * @return  string  The encrypted password.
	 *
	 * @see     UserHelper::hashPassword()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function hashPassword($password, $algorithm = PASSWORD_BCRYPT, array $options = array())
	{
		return UserHelper::hashPassword($password, $algorithm, $options);
	}

	/**
	 * Helper wrapper method for verifyPassword
	 *
	 * @param   string   $password  The plaintext password to check.
	 * @param   string   $hash      The hash to verify against.
	 * @param   integer  $user_id   ID of the user if the password hash should be updated
	 *
	 * @return  boolean  True if the password and hash match, false otherwise
	 *
	 * @see     UserHelper::verifyPassword()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function verifyPassword($password, $hash, $user_id = 0)
	{
		return UserHelper::verifyPassword($password, $hash, $user_id);
	}

	/**
	 * Helper wrapper method for getCryptedPassword
	 *
	 * @param   string   $plaintext     The plaintext password to encrypt.
	 * @param   string   $salt          The salt to use to encrypt the password. []
	 *                                  If not present, a new salt will be
	 *                                  generated.
	 * @param   string   $encryption    The kind of password encryption to use.
	 *                                  Defaults to md5-hex.
	 * @param   boolean  $show_encrypt  Some password systems prepend the kind of
	 *                                  encryption to the crypted password ({SHA},
	 *                                  etc). Defaults to false.
	 *
	 * @return  string  The encrypted password.
	 *
	 * @see     UserHelper::getCryptedPassword()
	 * @since   3.4
	 * @deprecated  4.0
	 */
	public function getCryptedPassword($plaintext, $salt = '', $encryption = 'md5-hex', $show_encrypt = false)
	{
		return UserHelper::getCryptedPassword($plaintext, $salt, $encryption, $show_encrypt);
	}

	/**
	 * Helper wrapper method for getSalt
	 *
	 * @param   string  $encryption  The kind of password encryption to use.
	 *                               Defaults to md5-hex.
	 * @param   string  $seed        The seed to get the salt from (probably a
	 *                               previously generated password). Defaults to
	 *                               generating a new seed.
	 * @param   string  $plaintext   The plaintext password that we're generating
	 *                               a salt for. Defaults to none.
	 *
	 * @return  string  The generated or extracted salt.
	 *
	 * @see     UserHelper::getSalt()
	 * @since   3.4
	 * @deprecated  4.0
	 */
	public function getSalt($encryption = 'md5-hex', $seed = '', $plaintext = '')
	{
		return UserHelper::getSalt($encryption, $seed, $plaintext);
	}

	/**
	 * Helper wrapper method for genRandomPassword
	 *
	 * @param   integer  $length  Length of the password to generate
	 *
	 * @return  string  Random Password
	 *
	 * @see     UserHelper::genRandomPassword()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function genRandomPassword($length = 8)
	{
		return UserHelper::genRandomPassword($length);
	}

	/**
	 * Helper wrapper method for invalidateCookie
	 *
	 * @param   string  $userId      User ID for this user
	 * @param   string  $cookieName  Series id (cookie name decoded)
	 *
	 * @return  boolean  True on success
	 *
	 * @see     UserHelper::invalidateCookie()
	 * @since   3.4
	 * @deprecated  4.0
	 */
	public function invalidateCookie($userId, $cookieName)
	{
		return UserHelper::invalidateCookie($userId, $cookieName);
	}

	/**
	 * Helper wrapper method for clearExpiredTokens
	 *
	 * @return  mixed  Database query result
	 *
	 * @see     UserHelper::clearExpiredTokens()
	 * @since   3.4
	 * @deprecated  4.0
	 */
	public function clearExpiredTokens()
	{
		return UserHelper::clearExpiredTokens();
	}

	/**
	 * Helper wrapper method for getRememberCookieData
	 *
	 * @return  mixed  An array of information from an authentication cookie or false if there is no cookie
	 *
	 * @see     UserHelper::getRememberCookieData()
	 * @since   3.4
	 * @deprecated  4.0
	 */
	public function getRememberCookieData()
	{
		return UserHelper::getRememberCookieData();
	}

	/**
	 * Helper wrapper method for getShortHashedUserAgent
	 *
	 * @return  string  A hashed user agent string with version replaced by 'abcd'
	 *
	 * @see     UserHelper::getShortHashedUserAgent()
	 * @since   3.4
	 * @deprecated  4.0  Use `Joomla\CMS\User\UserHelper` directly
	 */
	public function getShortHashedUserAgent()
	{
		return UserHelper::getShortHashedUserAgent();
	}
}