Ejemplo n.º 1
0
 public function hasTeamsAvailable()
 {
     return $this->getMaxTeams() ? Team::countAll() < $this->getMaxTeams() : true;
 }
Ejemplo n.º 2
0
 public function runAddTeam(framework\Request $request)
 {
     try {
         $mode = $request['mode'];
         if ($team_name = $request['team_name']) {
             if ($mode == 'clone') {
                 try {
                     $old_team = entities\Team::getB2DBTable()->selectById($request['team_id']);
                 } catch (\Exception $e) {
                 }
                 if (!$old_team instanceof entities\Team) {
                     throw new \Exception(framework\Context::getI18n()->__("You cannot clone this team"));
                 }
             }
             if (entities\Team::doesTeamNameExist(trim($team_name))) {
                 throw new \Exception(framework\Context::getI18n()->__("Please enter a team name that doesn't already exist"));
             }
             $team = new entities\Team();
             $team->setName($team_name);
             $team->save();
             if ($mode == 'clone') {
                 if ($request['clone_permissions']) {
                     tables\Permissions::getTable()->cloneTeamPermissions($old_team->getID(), $team->getID());
                 }
                 if ($request['clone_memberships']) {
                     tables\TeamMembers::getTable()->cloneTeamMemberships($old_team->getID(), $team->getID());
                 }
                 $message = framework\Context::getI18n()->__('The team was cloned');
             } else {
                 $message = framework\Context::getI18n()->__('The team was added');
             }
             return $this->renderJSON(array('message' => $message, 'content' => $this->getComponentHTML('configuration/teambox', array('team' => $team)), 'total_count' => entities\Team::countAll(), 'more_available' => framework\Context::getScope()->hasTeamsAvailable()));
         } else {
             throw new \Exception(framework\Context::getI18n()->__('Please enter a team name'));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Ejemplo n.º 3
0
<?php

$tbg_response->setTitle(__('Configure users, teams and clients'));
$users_text = \thebuggenie\core\framework\Context::getScope()->getMaxUsers() ? __('Users (%num/%max)', array('%num' => '<span id="current_user_num_count">' . \thebuggenie\core\entities\User::getUsersCount() . '</span>', '%max' => \thebuggenie\core\framework\Context::getScope()->getMaxUsers())) : __('Users');
$teams_text = \thebuggenie\core\framework\Context::getScope()->getMaxTeams() ? __('Teams (%num/%max)', array('%num' => '<span id="current_team_num_count">' . \thebuggenie\core\entities\Team::countAll() . '</span>', '%max' => \thebuggenie\core\framework\Context::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' => \thebuggenie\core\framework\Settings::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>