cvs: pear /LiveUser_Admin/Perm Complex.php Medium.php
| From: | Lukas Smith | Date: | Tue, 24 Jan 2006 13:34:31 +0000 |
| Subject: | cvs: pear /LiveUser_Admin/Perm Complex.php Medium.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-37739@lists.php.net to get a copy of this message | ||
lsmith Tue Jan 24 13:34:31 2006 UTC
Modified files:
/pear/LiveUser_Admin/Perm Complex.php Medium.php
Log:
- added "by_user" optional parameter to getRights() which determines if the userrights
table should be used or rather the grouprights and groupupsers tables
http://cvs.php.net/viewcvs.cgi/pear/LiveUser_Admin/Perm/Complex.php?r1=1.80&r2=1.81&diff_format=u
Index: pear/LiveUser_Admin/Perm/Complex.php
diff -u pear/LiveUser_Admin/Perm/Complex.php:1.80 pear/LiveUser_Admin/Perm/Complex.php:1.81
--- pear/LiveUser_Admin/Perm/Complex.php:1.80 Tue Jan 17 11:04:45 2006
+++ pear/LiveUser_Admin/Perm/Complex.php Tue Jan 24 13:34:30 2006
@@ -57,7 +57,7 @@
* @author Bjoern Kraus <krausbn@php.net>
* @copyright 2002-2005 Markus Wolff
* @license http://www.gnu.org/licenses/lgpl.txt
- * @version CVS: $Id: Complex.php,v 1.80 2006/01/17 11:04:45 lsmith Exp $
+ * @version CVS: $Id: Complex.php,v 1.81 2006/01/24 13:34:30 lsmith Exp $
* @link http://pear.php.net/LiveUser_Admin
*/
@@ -803,11 +803,13 @@
* 'select' - determines what query method to use:
* 'one' -> queryOne, 'row' -> queryRow,
* 'col' -> queryCol, 'all' ->queryAll
(default)
+ * @param bool determines if joins should be done using the 'userrights'
+ * (default) or through the 'grouprights' and 'groupusers'
tables
* @return bool|array false on failure or array with selected data
*
* @access public
*/
- function getRights($params = array())
+ function getRights($params = array(), $by_user = true)
{
// ensure optional parameters are set
!array_key_exists('inherited', $params) ? $params['inherited'] = false
: null;
@@ -840,7 +842,7 @@
}
// handle select, fields and rekey
- $rights = parent::getRights($params);
+ $rights = parent::getRights($params, $by_user);
if ($rights === false) {
return false;
}
@@ -884,7 +886,7 @@
}
// consider adding a NOT IN filter
- $implied_rights = $this->_getImpliedRights($right_id, $params);
+ $implied_rights = $this->_getImpliedRights($right_id, $params, $by_user);
if ($implied_rights === false) {
return false;
} elseif (empty($implied_rights)) {
@@ -938,7 +940,7 @@
*
* @access private
*/
- function _getImpliedRights($right_id, $params)
+ function _getImpliedRights($right_id, $params, $by_user = true)
{
$selectable_tables = array('right_implied', 'rights');
$root_table = 'right_implied';
@@ -956,7 +958,7 @@
$params['filters']['right_id'] = $result;
unset($params['inherited']);
- return $this->getRights($params);
+ return $this->getRights($params, $by_user);
}
/**
@@ -1000,7 +1002,7 @@
$params['filters']['group_id'] = $result;
unset($params['implied']);
unset($params['inherited']);
- return $this->getRights($params);
+ return $this->getRights($params, false);
}
}
?>
http://cvs.php.net/viewcvs.cgi/pear/LiveUser_Admin/Perm/Medium.php?r1=1.50&r2=1.51&diff_format=u
Index: pear/LiveUser_Admin/Perm/Medium.php
diff -u pear/LiveUser_Admin/Perm/Medium.php:1.50 pear/LiveUser_Admin/Perm/Medium.php:1.51
--- pear/LiveUser_Admin/Perm/Medium.php:1.50 Fri Dec 2 12:41:27 2005
+++ pear/LiveUser_Admin/Perm/Medium.php Tue Jan 24 13:34:30 2006
@@ -57,7 +57,7 @@
* @author Bjoern Kraus <krausbn@php.net>
* @copyright 2002-2005 Markus Wolff
* @license http://www.gnu.org/licenses/lgpl.txt
- * @version $Id: Medium.php,v 1.50 2005/12/02 12:41:27 lsmith Exp $
+ * @version $Id: Medium.php,v 1.51 2006/01/24 13:34:30 lsmith Exp $
* @link http://pear.php.net/LiveUser_Admin
*/
@@ -101,7 +101,6 @@
{
$this->LiveUser_Admin_Perm_Simple();
$this->selectable_tables['getUsers'][] = 'groupusers';
- $this->selectable_tables['getRights'][] = 'grouprights';
$this->selectable_tables['getGroups'] = array('groups',
'groupusers', 'grouprights', 'rights', 'translations');
$this->withFieldMethodMap['group_id'] = 'getGroups';
}
@@ -298,6 +297,50 @@
}
/**
+ * Fetches rights
+ *
+ * @param array containing key-value pairs for:
+ * 'fields' - ordered array containing the fields to fetch
+ * if empty all fields from the user table are fetched
+ * 'filters' - key values pairs (value may be a string or an array)
+ * 'orders' - key value pairs (values 'ASC' or
'DESC')
+ * 'rekey' - if set to true, returned array will have the
+ * first column as its first dimension
+ * 'group' - if set to true and $rekey is set to true, then
+ * all values with the same first column will be
+ * wrapped in an array
+ * 'limit' - number of rows to select
+ * 'offset' - first row to select
+ * 'select' - determines what query method to use:
+ * 'one' -> queryOne, 'row' -> queryRow,
+ * 'col' -> queryCol, 'all' ->queryAll
(default)
+ * @param bool determines if joins should be done using the 'userrights'
+ * (default) or through the 'grouprights' and 'groupusers'
tables
+ * @return bool|array false on failure or array with selected data
+ *
+ * @access public
+ */
+ function getRights($params = array(), $by_user = true)
+ {
+ $selectable_tables = $this->selectable_tables['getRights'];
+ $root_table = reset($selectable_tables);
+ if (!$by_user && !in_array('grouprights', $selectable_tables)) {
+ $key = array_search('userrights', $selectable_tables);
+ if ($key) {
+ $selectable_tables[0] = 'groupusers';
+ $selectable_tables[$key] = 'grouprights';
+ array_unshift($selectable_tables, $root_table);
+ } else {
+ $selectable_tables[0] = 'groupusers';
+ array_unshift($selectable_tables, 'grouprights');
+ array_unshift($selectable_tables, $root_table);
+ }
+ }
+
+ return $this->_makeGet($params, $root_table, $selectable_tables);
+ }
+
+ /**
* Remove rights and all their relevant relations
*
* @param array key values pairs (value may be a string or an array)