get_customers() public method

returns list of customers in a group as array
Author: th
public get_customers ( array $groups = null ) : array
$groups array ID of group in table groups or "all" for all groups
return array
Example #1
0
/**
 * @param Kimai_Database_Mysql $database
 * @param array $kgaUser
 * @param bool $viewOtherGroupsAllowed
 * @return array
 */
function getCustomersData(Kimai_Database_Mysql $database, $kgaUser, $viewOtherGroupsAllowed)
{
    if ($database->global_role_allows($kgaUser['globalRoleID'], 'core-customer-otherGroup-view')) {
        $customers = $database->get_customers();
    } else {
        $customers = $database->get_customers($kgaUser['groups']);
    }
    foreach ($customers as $row => $data) {
        $groupNames = array();
        $groups = $database->customer_get_groupIDs($data['customerID']);
        if ($groups !== false) {
            foreach ($groups as $groupID) {
                if (!$viewOtherGroupsAllowed && array_search($groupID, $kgaUser['groups']) === false) {
                    continue;
                }
                $data = $database->group_get_data($groupID);
                $groupNames[] = $data['name'];
            }
            $customers[$row]['groups'] = implode(", ", $groupNames);
        }
    }
    return array('customers' => $customers);
}