X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/c2b4a52bc12c6ee6204fd03d1d1b2534b7249554..95356f167c97ca1a70fc78d91a9dbc7b1d258b31:/WEB-INF/lib/ttUser.class.php diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 2511ecfb..dfcd1a6b 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -57,7 +57,7 @@ class ttUser { var $currency = null; // Currency. var $plugins = null; // Comma-separated list of enabled plugins. var $config = null; // Comma-separated list of miscellaneous config options. - var $team = null; // Team name. + var $group = null; // Group name. var $custom_logo = 0; // Whether to use a custom logo for team. var $lock_spec = null; // Cron specification for record locking. var $workday_minutes = 480; // Number of work minutes in a regular day. @@ -113,7 +113,7 @@ class ttUser { $this->record_type = $val['record_type']; $this->bcc_email = $val['bcc_email']; $this->allow_ip = $val['allow_ip']; - $this->team = $val['group_name']; + $this->group = $val['group_name']; $this->currency = $val['currency']; $this->plugins = $val['plugins']; $this->lock_spec = $val['lock_spec']; @@ -236,6 +236,33 @@ class ttUser { return $result; } + // getAssignedClients - returns an array of clients assigned to own projects. + function getAssignedClients() + { + // Start with projects; + $projects = $this->getAssignedProjects(); + if (!$projects) return false; + $assigned_project_ids = array(); + foreach($projects as $project) { + $assigned_project_ids[] = $project['id']; + } + + $mdb2 = getConnection(); + + // Get active clients for group. + $clients = array(); + $sql = "select id, name, address, projects from tt_clients where group_id = $this->group_id and status = 1"; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $client_project_ids = $val['projects'] ? explode(',', $val['projects']) : array(); + if (array_intersect($assigned_project_ids, $client_project_ids)) + $clients[] = $val; // Add client if one of user projects is a client project, too. + } + } + return $clients; + } + // isDateLocked checks whether a specifc date is locked for modifications. function isDateLocked($date) {