X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/6dbcf228dba9d1175ffd0c177f0739c58ce0f199..f066e7ba4d1141bad2f50e802c0911e5f76e8ef0:/WEB-INF/lib/ttUser.class.php diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index e498cde0..3085a0d5 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -38,7 +38,9 @@ class ttUser { var $rank = null; // User role rank. var $client_id = null; // Client id for client user role. var $behalf_id = null; // User id, on behalf of whom we are working. + var $behalf_group_id = null; // Group id, on behalf of which we are working. var $behalf_name = null; // User name, on behalf of whom we are working. + var $behalf_group = null; // Group name, on behalf of which we are working. var $email = null; // User email. var $lang = null; // Language. var $decimal_mark = null; // Decimal separator. @@ -68,7 +70,7 @@ class ttUser { var $is_client = false; // Whether user is a client as determined by missing 'track_own_time' right. var $minutes_in_unit = 15; // Number of minutes in unit for Work units plugin. var $first_unit_threshold = 0;// Threshold for 1st unit for Work units plugin. - var $unit_totals_only = 0; // Totlas only option for the Work units plugin. + var $unit_totals_only = 0; // Totals only option for the Work units plugin. // Constructor. function __construct($login, $id = null) { @@ -143,11 +145,16 @@ class ttUser { $this->unit_totals_only = $config->getDefinedValue('unit_totals_only'); } - // Set "on behalf" id and name. + // Set "on behalf" id and name (user). if (isset($_SESSION['behalf_id'])) { $this->behalf_id = $_SESSION['behalf_id']; $this->behalf_name = $_SESSION['behalf_name']; } + // Set "on behalf" id and name (group). + if (isset($_SESSION['behalf_group_id'])) { + $this->behalf_group_id = $_SESSION['behalf_group_id']; + $this->behalf_group = $_SESSION['behalf_group']; + } } } @@ -156,6 +163,11 @@ class ttUser { return ($this->behalf_id ? $this->behalf_id : $this->id); } + // The getActiveGroup returns group id on behalf of which the current user is operating. + function getActiveGroup() { + return ($this->behalf_group_id ? $this->behalf_group_id : $this->group_id); + } + // can - determines whether user has a right to do something. function can($do_something) { return in_array($do_something, $this->rights); @@ -349,6 +361,22 @@ class ttUser { return $user_list; } + // getGroups obtains an array consisting of: + // - A parent group (..) of a currently selected group, if available. + // - A currently selected group (.) represented by $behalf_group_id. + // - All subgroups (only immediate children) of a currently selected group. + function getGroups() { + $mdb2 = getConnection(); + + // $sql = 'select id, parent_id, name from tt_groups where org_id = $this->org_id ...'; // TODO: parent_id is now NULL in db, fix this. + // Step 1: Get parent group (sql query). + // Step 2: Get current group from the class. + // Step 3: Get immediate subgroups (sql query). + // Populate an array and return it, + + return false; // Work in progress here... + } + // getUser function is used to manage users in group and returns user details. // At the moment, the function is used for user edits and deletes. function getUser($user_id) {