<?php $tbg_response->setTitle(__('Configure users, teams and clients')); $users_text = TBGContext::getScope()->getMaxUsers() ? __('Users (%num/%max)', array('%num' => '<span id="current_user_num_count">' . TBGUser::getUsersCount() . '</span>', '%max' => TBGContext::getScope()->getMaxUsers())) : __('Users'); $teams_text = TBGContext::getScope()->getMaxTeams() ? __('Teams (%num/%max)', array('%num' => '<span id="current_team_num_count">' . TBGTeam::countAll() . '</span>', '%max' => TBGContext::getScope()->getMaxTeams())) : __('Teams'); ?> <table style="table-layout: fixed; width: 100%" cellpadding=0 cellspacing=0 class="configuration_page"> <tr> <?php include_component('leftmenu', array('selected_section' => TBGSettings::CONFIGURATION_SECTION_USERS)); ?> <td valign="top" style="padding-left: 15px;"> <div style="width: 730px;"> <h3><?php echo __('Configure users, teams and clients'); ?> </h3> <div class="tab_menu inset"> <ul id="usersteamsgroups_menu"> <li id="tab_users" class="selected"><?php echo javascript_link_tag($users_text, array('onclick' => "TBG.Main.Helpers.tabSwitcher('tab_users', 'usersteamsgroups_menu');")); ?> </li> <li id="tab_teams"><?php echo javascript_link_tag($teams_text, array('onclick' => "TBG.Main.Helpers.tabSwitcher('tab_teams', 'usersteamsgroups_menu');")); ?> </li> <li id="tab_clients"><?php echo javascript_link_tag(__('Clients'), array('onclick' => "TBG.Main.Helpers.tabSwitcher('tab_clients', 'usersteamsgroups_menu');")); ?> </li>
public function runAddTeam(TBGRequest $request) { try { $mode = $request['mode']; if ($team_name = $request['team_name']) { if ($mode == 'clone') { try { $old_team = TBGContext::factory()->TBGTeam($request['team_id']); } catch (Exception $e) { } if (!$old_team instanceof TBGTeam) { throw new Exception(TBGContext::getI18n()->__("You cannot clone this team")); } } if (TBGTeam::doesTeamNameExist(trim($team_name))) { throw new Exception(TBGContext::getI18n()->__("Please enter a team name that doesn't already exist")); } $team = new TBGTeam(); $team->setName($team_name); $team->save(); if ($mode == 'clone') { if ($request['clone_permissions']) { TBGPermissionsTable::getTable()->cloneTeamPermissions($old_team->getID(), $team->getID()); } if ($request['clone_memberships']) { TBGTeamMembersTable::getTable()->cloneTeamMemberships($old_team->getID(), $team->getID()); } $message = TBGContext::getI18n()->__('The team was cloned'); } else { $message = TBGContext::getI18n()->__('The team was added'); } return $this->renderJSON(array('message' => $message, 'content' => $this->getTemplateHTML('configuration/teambox', array('team' => $team)), 'total_count' => TBGTeam::countAll(), 'more_available' => TBGContext::getScope()->hasTeamsAvailable())); } else { throw new Exception(TBGContext::getI18n()->__('Please enter a team name')); } } catch (Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $e->getMessage())); } }
public function hasTeamsAvailable() { return $this->getMaxTeams() ? TBGTeam::countAll() < $this->getMaxTeams() : true; }