cvs: pear /LiveUser_Admin Admin.php
| From: | Lukas Smith | Date: | Tue, 11 Apr 2006 14:50:52 +0000 |
| Subject: | cvs: pear /LiveUser_Admin Admin.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-39547@lists.php.net to get a copy of this message | ||
lsmith Tue Apr 11 14:50:52 2006 UTC
Modified files:
/pear/LiveUser_Admin Admin.php
Log:
- changed the getUsers(), addUser() and updateUser() API to be more in line with the container
APIs *BC break* (req #7025)
http://cvs.php.net/viewcvs.cgi/pear/LiveUser_Admin/Admin.php?r1=1.63&r2=1.64&diff_format=u
Index: pear/LiveUser_Admin/Admin.php
diff -u pear/LiveUser_Admin/Admin.php:1.63 pear/LiveUser_Admin/Admin.php:1.64
--- pear/LiveUser_Admin/Admin.php:1.63 Fri Apr 7 22:23:02 2006
+++ pear/LiveUser_Admin/Admin.php Tue Apr 11 14:50:52 2006
@@ -57,7 +57,7 @@
* @author Bjoern Kraus <krausbn@php.net>
* @copyright 2002-2006 Markus Wolff
* @license http://www.gnu.org/licenses/lgpl.txt
- * @version CVS: $Id: Admin.php,v 1.63 2006/04/07 22:23:02 lsmith Exp $
+ * @version CVS: $Id: Admin.php,v 1.64 2006/04/11 14:50:52 lsmith Exp $
* @link http://pear.php.net/LiveUser_Admin
*/
@@ -391,13 +391,12 @@
/**
* Add a user to both containers.
*
- * @param array authentication user data
- * @param int permission user type
+ * @param array auth user data and perm type
* @return int|bool perm user id or false
*
* @access public
*/
- function addUser($data, $type = LIVEUSER_USER_TYPE_ID)
+ function addUser($data)
{
if (!is_object($this->auth) || !is_object($this->perm)) {
$this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception',
@@ -405,6 +404,13 @@
return false;
}
+ if (array_key_exists('perm_type', $data)) {
+ $type = $data['perm_type'];
+ unset($data['perm_type']);
+ } else {
+ $type = LIVEUSER_USER_TYPE_ID;
+ }
+
$authUserId = $this->auth->addUser($data);
if (!$authUserId) {
return false;
@@ -421,14 +427,13 @@
/**
* Changes user data for both containers.
*
+ * @param array auth user data and perm type
* @param int permission user id
- * @param array authentication user data
- * @param int permission user type
* @return int|bool affected rows on success or false otherwise
*
* @access public
*/
- function updateUser($permUserId, $data, $type = null)
+ function updateUser($data, $permUserId)
{
if (!is_object($this->auth) || !is_object($this->perm)) {
$this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception',
@@ -450,6 +455,13 @@
return false;
}
+ if (array_key_exists('perm_type', $data)) {
+ $type = $data['perm_type'];
+ unset($data['perm_type']);
+ } else {
+ $type = null;
+ }
+
$this->setAdminAuthContainer($permData['auth_container_name']);
$filters = array('auth_user_id' => $permData['auth_user_id']);
$result = $this->auth->updateUser($data, $filters);
@@ -462,9 +474,7 @@
return true;
}
- $data = array(
- 'perm_type' => $type
- );
+ $data = array('perm_type' => $type);
$filters = array('perm_user_id' => $permUserId);
return $this->perm->updateUser($data, $filters);
}
@@ -513,15 +523,20 @@
/**
* Finds and gets full userinfo by filtering inside the given container
+ * Note that this method is not particularily efficient, as it fetches
+ * the data in the primary container in a single call, but requires one call
+ * to the secondary container for every user returned from the primary container
*
- * @param string either 'auth' or 'perm' to determine if users should
first
- * be searched in the 'auth' or 'perm' container
* @param array params (as for getUsers()
+ * with an additional optional key 'container' 'perm' (default) or
+ 'auth' to determine the primary and secondary container.
+ data is first fetched from the primary container and then
+ combined with data from the secondary container if available
* @return array|bool array with userinfo if found on success or false otherwise
*
* @access public
*/
- function getUsers($container = 'perm', $param = array())
+ function getUsers($param = array())
{
if (array_key_exists('select', $param)) {
if ($param['select'] != 'row' && $param['select']
!= 'all') {
@@ -533,10 +548,12 @@
$param['select'] = 'all';
}
- if ($container == 'perm') {
- return $this->_getUsersByPerm($param);
+ if (array_key_exists('container', $param)
+ && $param['container'] == 'auth'
+ ) {
+ return $this->_getUsersByAuth($param);
}
- return $this->_getUsersByAuth($param);
+ return $this->_getUsersByPerm($param);
}
/**