1 <?php
  2 /**
  3  * @package     Joomla.Platform
  4  * @subpackage  User
  5  *
  6  * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
  7  * @license     GNU General Public License version 2 or later; see LICENSE
  8  */
  9 
 10 defined('JPATH_PLATFORM') or die;
 11 
 12 /**
 13  * Wrapper class for JUserHelper
 14  *
 15  * @package     Joomla.Platform
 16  * @subpackage  User
 17  * @since       3.4
 18  */
 19 class JUserWrapperHelper
 20 {
 21     /**
 22      * Helper wrapper method for addUserToGroup
 23      *
 24      * @param   integer  $userId   The id of the user.
 25      * @param   integer  $groupId  The id of the group.
 26      *
 27      * @return  boolean  True on success
 28      *
 29      * @see     JUserHelper::addUserToGroup()
 30      * @since   3.4
 31      * @throws  RuntimeException
 32      */
 33     public function addUserToGroup($userId, $groupId)
 34     {
 35         return JUserHelper::addUserToGroup($userId, $groupId);
 36     }
 37 
 38     /**
 39      * Helper wrapper method for getUserGroups
 40      *
 41      * @param   integer  $userId  The id of the user.
 42      *
 43      * @return  array    List of groups
 44      *
 45      * @see     JUserHelper::addUserToGroup()
 46      * @since   3.4
 47      */
 48     public function getUserGroups($userId)
 49     {
 50         return JUserHelper::getUserGroups($userId);
 51     }
 52 
 53     /**
 54      * Helper wrapper method for removeUserFromGroup
 55      *
 56      * @param   integer  $userId   The id of the user.
 57      * @param   integer  $groupId  The id of the group.
 58      *
 59      * @return  boolean  True on success
 60      *
 61      * @see     JUserHelper::removeUserFromGroup()
 62      * @since   3.4
 63      */
 64     public function removeUserFromGroup($userId, $groupId)
 65     {
 66         return JUserHelper::removeUserFromGroup($userId, $groupId);
 67     }
 68 
 69     /**
 70      * Helper wrapper method for setUserGroups
 71      *
 72      * @param   integer  $userId  The id of the user.
 73      * @param   array    $groups  An array of group ids to put the user in.
 74      *
 75      * @return  boolean  True on success
 76      *
 77      * @see     JUserHelper::setUserGroups()
 78      * @since   3.4
 79      */
 80     public function setUserGroups($userId, $groups)
 81     {
 82         return JUserHelper::setUserGroups($userId, $groups);
 83     }
 84 
 85     /**
 86      * Helper wrapper method for getProfile
 87      *
 88      * @param   integer  $userId  The id of the user.
 89      *
 90      * @return  object
 91      *
 92      * @see     JUserHelper::getProfile()
 93      * @since   3.4
 94      */
 95     public function getProfile($userId = 0)
 96     {
 97         return JUserHelper::getProfile($userId);
 98     }
 99 
100     /**
101      * Helper wrapper method for activateUser
102      *
103      * @param   string  $activation  Activation string
104      *
105      * @return  boolean  True on success
106      *
107      * @see     JUserHelper::activateUser()
108      * @since   3.4
109      */
110     public function activateUser($activation)
111     {
112         return JUserHelper::activateUser($activation);
113     }
114 
115     /**
116      * Helper wrapper method for getUserId
117      *
118      * @param   string  $username  The username to search on.
119      *
120      * @return  integer  The user id or 0 if not found.
121      *
122      * @see     JUserHelper::getUserId()
123      * @since   3.4
124      */
125     public function getUserId($username)
126     {
127         return JUserHelper::getUserId($username);
128     }
129 
130     /**
131      * Helper wrapper method for hashPassword
132      *
133      * @param   string  $password  The plaintext password to encrypt.
134      *
135      * @return  string  The encrypted password.
136      *
137      * @see     JUserHelper::hashPassword()
138      * @since   3.4
139      */
140     public function hashPassword($password)
141     {
142         return JUserHelper::hashPassword($password);
143     }
144 
145     /**
146      * Helper wrapper method for verifyPassword
147      *
148      * @param   string   $password  The plaintext password to check.
149      * @param   string   $hash      The hash to verify against.
150      * @param   integer  $user_id   ID of the user if the password hash should be updated
151      *
152      * @return  boolean  True if the password and hash match, false otherwise
153      *
154      * @see     JUserHelper::verifyPassword()
155      * @since   3.4
156      */
157     public function verifyPassword($password, $hash, $user_id = 0)
158     {
159         return JUserHelper::verifyPassword($password, $hash, $user_id);
160     }
161 
162     /**
163      * Helper wrapper method for getCryptedPassword
164      *
165      * @param   string   $plaintext     The plaintext password to encrypt.
166      * @param   string   $salt          The salt to use to encrypt the password. []
167      *                                  If not present, a new salt will be
168      *                                  generated.
169      * @param   string   $encryption    The kind of password encryption to use.
170      *                                  Defaults to md5-hex.
171      * @param   boolean  $show_encrypt  Some password systems prepend the kind of
172      *                                  encryption to the crypted password ({SHA},
173      *                                  etc). Defaults to false.
174      *
175      * @return  string  The encrypted password.
176      *
177      * @see     JUserHelper::getCryptedPassword()
178      * @since   3.4
179      * @deprecated  4.0
180      */
181     public function getCryptedPassword($plaintext, $salt = '', $encryption = 'md5-hex', $show_encrypt = false)
182     {
183         return JUserHelper::getCryptedPassword($plaintext, $salt, $encryption, $show_encrypt);
184     }
185 
186     /**
187      * Helper wrapper method for getSalt
188      *
189      * @param   string  $encryption  The kind of password encryption to use.
190      *                               Defaults to md5-hex.
191      * @param   string  $seed        The seed to get the salt from (probably a
192      *                               previously generated password). Defaults to
193      *                               generating a new seed.
194      * @param   string  $plaintext   The plaintext password that we're generating
195      *                               a salt for. Defaults to none.
196      *
197      * @return  string  The generated or extracted salt.
198      *
199      * @see     JUserHelper::getSalt()
200      * @since   3.4
201      * @deprecated  4.0
202      */
203     public function getSalt($encryption = 'md5-hex', $seed = '', $plaintext = '')
204     {
205         return JUserHelper::getSalt($encryption, $seed, $plaintext);
206     }
207 
208     /**
209      * Helper wrapper method for genRandomPassword
210      *
211      * @param   integer  $length  Length of the password to generate
212      *
213      * @return  string  Random Password
214      *
215      * @see     JUserHelper::genRandomPassword()
216      * @since   3.4
217      */
218     public function genRandomPassword($length = 8)
219     {
220         return JUserHelper::genRandomPassword($length);
221     }
222 
223     /**
224      * Helper wrapper method for invalidateCookie
225      *
226      * @param   string  $userId      User ID for this user
227      * @param   string  $cookieName  Series id (cookie name decoded)
228      *
229      * @return  boolean  True on success
230      *
231      * @see     JUserHelper::invalidateCookie()
232      * @since   3.4
233      * @deprecated  4.0
234      */
235     public function invalidateCookie($userId, $cookieName)
236     {
237         return JUserHelper::invalidateCookie($userId, $cookieName);
238     }
239 
240     /**
241      * Helper wrapper method for clearExpiredTokens
242      *
243      * @return  mixed  Database query result
244      *
245      * @see     JUserHelper::clearExpiredTokens()
246      * @since   3.4
247      * @deprecated  4.0
248      */
249     public function clearExpiredTokens()
250     {
251         return JUserHelper::clearExpiredTokens();
252     }
253 
254     /**
255      * Helper wrapper method for getRememberCookieData
256      *
257      * @return  mixed  An array of information from an authentication cookie or false if there is no cookie
258      *
259      * @see     JUserHelper::getRememberCookieData()
260      * @since   3.4
261      * @deprecated  4.0
262      */
263     public function getRememberCookieData()
264     {
265         return JUserHelper::getRememberCookieData();
266     }
267 
268     /**
269      * Helper wrapper method for getShortHashedUserAgent
270      *
271      * @return  string  A hashed user agent string with version replaced by 'abcd'
272      *
273      * @see     JUserHelper::getShortHashedUserAgent()
274      * @since   3.4
275      */
276     public function getShortHashedUserAgent()
277     {
278         return JUserHelper::getShortHashedUserAgent();
279     }
280 }
281