/usr/share/php/tests/Horde_Group/Horde/Group/Stub/Api.php is in php-horde-group 2.0.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <?php
/**
* Copyright 2011-2013 Horde LLC (http://www.horde.org/)
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @package Group
* @subpackage UnitTests
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
*/
class Horde_Group_Stub_Api
{
protected $_groups = array(
'localsql:79ad3f08f267d15056650ee642a90b82' => array(
'id' => '79ad3f08f267d15056650ee642a90b82',
'members' => 'a:1:{i:0;s:3:"joe";}',
'email' => 'me@example.com',
'name' => 'My Group'),
'localsql:f44d8744352d9d3b6a5a1a72831e4cf4' => array(
'id' => 'f44d8744352d9d3b6a5a1a72831e4cf4',
'members' => 'a:2:{i:0;s:3:"joe";i:1;s:4:"jane";}',
'email' => null,
'name' => 'My Other Group'),
'localsql:43959c113d25605fbce585a46ff495d6' => array(
'id' => '43959c113d25605fbce585a46ff495d6',
'members' => 'b:0;',
'email' => null,
'name' => 'Not My Group'));
/**
* Returns all contact groups.
*
* @return array A list of group hashes.
* @throws Horde_Exception
*/
public function getGroupObjects()
{
return $this->_groups;
}
/**
* Returns all contact groups that the specified user is a member of.
*
* @param string $user The user
* @param boolean $parentGroups Include user as a member of the any
* parent group as well.
*
* @return array An array of group identifiers that the specified user is a
* member of.
* @throws Horde_Exception
*/
public function getGroupMemberships($user, $parentGroups = false)
{
$groups = array();
foreach ($this->_groups as $id => $group) {
$members = unserialize($group['members']);
if (is_array($members) && in_array($user, $members)) {
$groups[$id] = $group['name'];
}
}
return $groups;
}
/**
* Returns a contact group hash.
*
* @param string $gid The group identifier.
*
* @return array A hash defining the group.
* @throws Horde_Exception
*/
public function getGroupObject($gid)
{
if (!isset($this->_groups[$gid])) {
return array();
}
$group = $this->_groups[$gid];
unset($group['id']);
return $group;
}
/**
* Returns a list of all members belonging to a contact group.
*
* @param string $gid The group identifier
* @param boolean $subGroups Also include members of any subgroups?
*
* @return array An array of group members (identified by email address).
* @throws Horde_Exception
*/
public function getGroupMembers($gid, $subGroups = false)
{
if (!isset($this->_groups[$gid])) {
return array();
}
return unserialize($this->_groups[$gid]['members']);
}
}
|