- $team_id = ttTeamHelper::insert(array(
- 'name' => $this->teamData['NAME'],
- 'currency' => $this->teamData['CURRENCY'],
- 'decimal_mark' => $this->teamData['DECIMAL_MARK'],
- 'lang' => $this->teamData['LANG'],
- 'date_format' => $this->teamData['DATE_FORMAT'],
- 'time_format' => $this->teamData['TIME_FORMAT'],
- 'week_start' => $this->teamData['WEEK_START'],
- 'tracking_mode' => $this->teamData['TRACKING_MODE'],
- 'project_required' => $this->teamData['PROJECT_REQUIRED'],
- 'task_required' => $this->teamData['TASK_REQUIRED'],
- 'record_type' => $this->teamData['RECORD_TYPE'],
- 'uncompleted_indicators' => $this->teamData['UNCOMPLETED_INDICATORS'],
- 'bcc_email' => $this->teamData['BCC_EMAIL'],
- 'plugins' => $this->teamData['PLUGINS'],
- 'lock_spec' => $this->teamData['LOCK_SPEC'],
- 'workday_hours' => $this->teamData['WORKDAY_HOURS']));
- if ($team_id) {
- $this->team_id = $team_id;
+ $this->top_role_id = ttRoleHelper::getRoleByRank(512, 0);
+ $group_id = ttTeamHelper::insert(array(
+ 'name' => $this->groupData['NAME'],
+ 'currency' => $this->groupData['CURRENCY'],
+ 'decimal_mark' => $this->groupData['DECIMAL_MARK'],
+ 'lang' => $this->groupData['LANG'],
+ 'date_format' => $this->groupData['DATE_FORMAT'],
+ 'time_format' => $this->groupData['TIME_FORMAT'],
+ 'week_start' => $this->groupData['WEEK_START'],
+ 'tracking_mode' => $this->groupData['TRACKING_MODE'],
+ 'project_required' => $this->groupData['PROJECT_REQUIRED'],
+ 'task_required' => $this->groupData['TASK_REQUIRED'],
+ 'record_type' => $this->groupData['RECORD_TYPE'],
+ 'bcc_email' => $this->groupData['BCC_EMAIL'],
+ 'plugins' => $this->groupData['PLUGINS'],
+ 'lock_spec' => $this->groupData['LOCK_SPEC'],
+ 'workday_minutes' => $this->groupData['WORKDAY_MINUTES'],
+ 'config' => $this->groupData['CONFIG']));
+ if ($group_id) {
+ $this->group_id = $group_id;
+
+ // Create roles.
+ foreach ($this->roles as $key=>$role_item) {
+ $role_id = ttRoleHelper::insert(array(
+ 'group_id' => $this->group_id,
+ 'name' => $role_item['NAME'],
+ 'rank' => $role_item['RANK'],
+ 'rights' => $role_item['RIGHTS'],
+ 'status' => $role_item['STATUS']));
+ $this->roleMap[$role_item['ID']] = $role_id;
+ }
+