protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::PROJECT_ID, TBGProjectsTable::getTable());
     parent::_addForeignKeyColumn(self::ROLE_ID, TBGListTypesTable::getTable());
     parent::_addForeignKeyColumn(self::TEAM_ID, TBGTeamsTable::getTable());
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable());
 }
 public static function getTeamsCount()
 {
     if (self::$_num_teams === null) {
         if (self::$_teams !== null) {
             self::$_num_teams = count(self::$_teams);
         } else {
             self::$_num_teams = TBGTeamsTable::getTable()->countTeams();
         }
     }
     return self::$_num_teams;
 }
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addVarchar(self::PERMISSION_TYPE, 100);
     parent::_addVarchar(self::TARGET_ID, 200, 0);
     parent::_addBoolean(self::ALLOWED);
     parent::_addVarchar(self::MODULE, 50);
     parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable());
     parent::_addForeignKeyColumn(self::GID, TBGGroupsTable::getTable());
     parent::_addForeignKeyColumn(self::TID, TBGTeamsTable::getTable());
     parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable());
 }
 public function clearTeamsByUserID($user_id)
 {
     $team_ids = array();
     $crit = $this->getCriteria();
     $crit->addWhere(self::UID, $user_id);
     $crit->addJoin(TBGTeamsTable::getTable(), TBGTeamsTable::ID, self::TID);
     $crit->addWhere(TBGTeamsTable::ONDEMAND, false);
     if ($res = $this->doSelect($crit)) {
         while ($row = $res->getNextRow()) {
             $team_ids[$row->get(self::TID)] = true;
         }
     }
     if (!empty($team_ids)) {
         $crit = $this->getCriteria();
         $crit->addWhere(self::UID, $user_id);
         $crit->addWhere(self::TID, array_keys($team_ids), B2DBCriteria::DB_IN);
         $res = $this->doDelete($crit);
     }
 }
Example #5
0
														<?php 
        echo link_tag(make_url('project_milestone_todo_list', array('project_key' => TBGContext::getCurrentProject()->getKey())), image_tag('icon_savedsearch.png') . __('Milestone todo-list for this project'));
        ?>
														<?php 
        echo link_tag(make_url('project_most_voted_issues', array('project_key' => TBGContext::getCurrentProject()->getKey())), image_tag('icon_savedsearch.png') . __('Most voted for issues'));
        ?>
													</div>
												<?php 
    }
    ?>
											</li>
										<?php 
}
?>
										<?php 
if (!TBGContext::isProjectContext() && ($tbg_user->hasPageAccess('teamlist') || count($tbg_user->getTeams())) && !is_null(TBGTeamsTable::getTable()->getAll())) {
    ?>
											<li<?php 
    if ($tbg_response->getPage() == 'team') {
        ?>
 class="selected"<?php 
    }
    ?>
>
												<div>
													<?php 
    echo link_tag('javascript:void(0)', image_tag('tab_teams.png') . __('Teams'), array('class' => 'not_clickable'));
    ?>
													<?php 
    echo javascript_link_tag(image_tag('tabmenu_dropdown.png', array('class' => 'menu_dropdown')), array('onmouseover' => ""));
    ?>
Example #6
0
 public function runFilterFindTeams(TBGRequest $request)
 {
     $filter = $request['filter'];
     $filterkey = $request['filterkey'];
     $existing_teams = $request['existing_id'];
     if (strlen($filter) < 3) {
         return $this->renderJSON(array('results' => '<li>' . $this->getI18n()->__('Please enter 3 characters or more') . '</li>'));
     }
     $teams = TBGTeamsTable::getTable()->quickfind($filter, 10);
     foreach ($existing_teams as $id) {
         if (isset($teams[$id])) {
             unset($teams[$id]);
         }
     }
     return $this->renderJSON(array('results' => $this->getTemplateHTML('search/filterfindteams', compact('teams', 'filterkey'))));
 }
Example #7
0
 /**
  * Find users and show selection box
  *
  * @param TBGRequest $request The request object
  */
 public function runFindAssignee(TBGRequest $request)
 {
     $this->forward403unless($request->isPost());
     $this->message = false;
     if ($request['find_by']) {
         $this->selected_project = TBGContext::factory()->TBGProject($request['project_id']);
         $this->users = TBGUsersTable::getTable()->getByDetails($request['find_by'], 10);
         $this->teams = TBGTeamsTable::getTable()->quickfind($request['find_by']);
         $this->global_roles = TBGRole::getAll();
         $this->project_roles = TBGRole::getByProjectID($this->selected_project->getID());
     } else {
         $this->message = true;
     }
 }
Example #8
0
 public function runAddUser(TBGRequest $request)
 {
     try {
         if (!TBGContext::getScope()->hasUsersAvailable()) {
             throw new Exception($this->getI18n()->__('This instance of The Bug Genie cannot add more users'));
         }
         if ($username = trim($request['username'])) {
             if (!TBGUser::isUsernameAvailable($username)) {
                 if ($request->getParameter('mode') == 'import') {
                     $user = TBGUser::getByUsername($username);
                     $user->addScope(TBGContext::getScope());
                     return $this->renderJSON(array('imported' => true, 'message' => $this->getI18n()->__('The user was successfully added to this scope (pending user confirmation)')));
                 } elseif (TBGContext::getScope()->isDefault()) {
                     throw new Exception($this->getI18n()->__('This username already exists'));
                 } else {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('allow_import' => true));
                 }
             }
             $user = new TBGUser();
             $user->setUsername($username);
             $user->setRealname($request->getParameter('realname', $username));
             $user->setBuddyname($request->getParameter('buddyname', $username));
             $user->setEmail($request->getParameter('email'));
             $user->setGroup(TBGGroupsTable::getTable()->selectById((int) $request->getParameter('group_id', TBGSettings::get(TBGSettings::SETTING_USER_GROUP))));
             $user->setEnabled();
             $user->setActivated();
             if ($request->hasParameter('password') && !(empty($request['password']) && empty($request['password_repeat']))) {
                 if (empty($request['password']) || $request['password'] != $request['password_repeat']) {
                     throw new Exception($this->getI18n()->__('Please enter the same password twice'));
                 }
                 $password = $request['password'];
                 $user->setPassword($password);
             } else {
                 $password = TBGUser::createPassword();
                 $user->setPassword($password);
             }
             $user->setJoined();
             $user->save();
             foreach ((array) $request['teams'] as $team_id) {
                 $user->addToTeam(TBGTeamsTable::getTable()->selectById((int) $team_id));
             }
             TBGEvent::createNew('core', 'config.createuser.save', $user, array('password' => $password))->trigger();
         } else {
             throw new Exception($this->getI18n()->__('Please enter a username'));
         }
         $this->getResponse()->setTemplate('configuration/findusers');
         $this->too_short = false;
         $this->created_user = true;
         $this->users = array($user);
         $this->total_results = 1;
         $this->title = $this->getI18n()->__('User %username created', array('%username' => $username));
         $this->total_count = TBGUser::getUsersCount();
         $this->more_available = TBGContext::getScope()->hasUsersAvailable();
     } catch (Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Example #9
0
 /**
  * Find users and show selection links
  * 
  * @param TBGRequest $request The request object
  */
 public function runFindIdentifiable(TBGRequest $request)
 {
     $this->forward403unless($request->isPost());
     $this->users = array();
     if ($find_identifiable_by = $request['find_identifiable_by']) {
         $this->users = TBGUsersTable::getTable()->getByDetails($find_identifiable_by, 10);
         if ($request['include_teams']) {
             $this->teams = TBGTeamsTable::getTable()->quickfind($find_identifiable_by);
         } else {
             $this->teams = array();
         }
     }
     $teamup_callback = $request['teamup_callback'];
     return $this->renderComponent('identifiableselectorresults', array('users' => $this->users, 'teams' => $this->teams, 'callback' => $request['callback'], 'teamup_callback' => $teamup_callback, 'team_callback' => $request['team_callback']));
 }
                ?>
				<?php 
            } elseif (isset($user_id) && $user_id) {
                ?>
					<?php 
                $user = TBGUsersTable::getTable()->selectById($user_id);
                ?>
					<div style="float: right;"><?php 
                include_component('configuration/permissionsinfoitem', array('key' => $permission_key, 'target_id' => $current_target_id, 'type' => 'user', 'mode' => $mode, 'item_id' => $user->getID(), 'item_name' => urlencode($user->getName()), 'module' => $module, 'access_level' => $access_level));
                ?>
</div>
				<?php 
            } elseif (isset($team_id) && $team_id) {
                ?>
					<?php 
                $team = TBGTeamsTable::getTable()->selectById($team_id);
                ?>
					<div style="float: right;"><?php 
                include_component('configuration/permissionsinfoitem', array('key' => $permission_key, 'target_id' => $current_target_id, 'type' => 'team', 'mode' => $mode, 'item_id' => $team->getID(), 'item_name' => urlencode($team->getName()), 'module' => $module, 'access_level' => $access_level));
                ?>
</div>
				<?php 
            }
            ?>
				<?php 
            if (array_key_exists('details', $permission) && count($permission['details']) > 0) {
                ?>
					<a href="javascript:void(0);" onclick="TBG.Config.Permissions.getOptions('<?php 
                echo make_url('configure_permissions_get_permissions', array('base_id' => $base_id . $permission_key, 'user_id' => (int) $user_id, 'team_id' => (int) $team_id, 'permissions_list' => $permission_key, 'user_id' => $user_id, 'team_id' => $team_id, 'mode' => $mode, 'target_id' => $current_target_id, 'target_module' => $module));
                ?>
', '<?php 
Example #11
0
 protected function _saveCustomFieldValues()
 {
     foreach (TBGCustomDatatype::getAll() as $key => $customdatatype) {
         switch ($customdatatype->getType()) {
             case TBGCustomDatatype::INPUT_TEXT:
             case TBGCustomDatatype::INPUT_TEXTAREA_SMALL:
             case TBGCustomDatatype::INPUT_TEXTAREA_MAIN:
             case TBGCustomDatatype::DATE_PICKER:
                 $option_id = $this->getCustomField($key);
                 TBGIssueCustomFieldsTable::getTable()->saveIssueCustomFieldValue($option_id, $customdatatype->getID(), $this->getID());
                 break;
             case TBGCustomDatatype::EDITIONS_CHOICE:
             case TBGCustomDatatype::COMPONENTS_CHOICE:
             case TBGCustomDatatype::RELEASES_CHOICE:
             case TBGCustomDatatype::MILESTONE_CHOICE:
             case TBGCustomDatatype::STATUS_CHOICE:
             case TBGCustomDatatype::USER_CHOICE:
             case TBGCustomDatatype::TEAM_CHOICE:
                 $option_object = null;
                 try {
                     switch ($customdatatype->getType()) {
                         case TBGCustomDatatype::EDITIONS_CHOICE:
                             $option_object = TBGEditionsTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::COMPONENTS_CHOICE:
                             $option_object = TBGComponentsTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::RELEASES_CHOICE:
                             $option_object = TBGBuildsTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::MILESTONE_CHOICE:
                             $option_object = TBGMilestonesTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::STATUS_CHOICE:
                             $option_object = TBGListTypesTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::USER_CHOICE:
                             $option_object = TBGUsersTable::getTable()->selectById($this->getCustomField($key));
                             break;
                         case TBGCustomDatatype::TEAM_CHOICE:
                             $option_object = TBGTeamsTable::getTable()->selectById($this->getCustomField($key));
                             break;
                     }
                 } catch (Exception $e) {
                 }
                 $option_id = is_object($option_object) ? $option_object->getID() : null;
                 TBGIssueCustomFieldsTable::getTable()->saveIssueCustomFieldOption($option_id, $customdatatype->getID(), $this->getID());
                 break;
             default:
                 $option_id = $this->getCustomField($key) instanceof TBGCustomDatatypeOption ? $this->getCustomField($key)->getID() : null;
                 TBGIssueCustomFieldsTable::getTable()->saveIssueCustomFieldOption($option_id, $customdatatype->getID(), $this->getID());
                 break;
         }
     }
 }