Example #1
0
 /**
  * Return the default user group
  *
  * @return \thebuggenie\core\entities\Group
  */
 public static function getDefaultGroup()
 {
     try {
         return \thebuggenie\core\entities\Group::getB2DBTable()->selectByID(self::get(self::SETTING_USER_GROUP));
     } catch (\Exception $e) {
         return null;
     }
 }
    ?>
</td>
                        <td><label for="user_<?php 
    echo $user->getID();
    ?>
_group"><?php 
    echo __('In group');
    ?>
</label></td>
                        <td>
                            <select name="group" id="user_<?php 
    echo $user->getID();
    ?>
_group">
                                <?php 
    foreach (\thebuggenie\core\entities\Group::getAll() as $group) {
        ?>
                                    <option value="<?php 
        echo $group->getID();
        ?>
"<?php 
        if ($user->getGroupID() == $group->getID()) {
            ?>
 selected<?php 
        }
        ?>
><?php 
        echo $group->getName();
        ?>
</option>
                                <?php 
Example #3
0
 public function runUpdateUser(framework\Request $request)
 {
     try {
         $user = entities\User::getB2DBTable()->selectByID($request['user_id']);
         if ($user instanceof entities\User) {
             if (!$user->isConfirmedMemberOfScope(framework\Context::getScope())) {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array('error' => $this->getI18n()->__('This user is not a confirmed member of this scope')));
             }
             if (!empty($request['username'])) {
                 $testuser = entities\User::getByUsername($request['username']);
                 if (!$testuser instanceof entities\User || $testuser->getID() == $user->getID()) {
                     $user->setUsername($request['username']);
                 } else {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => $this->getI18n()->__('This username is already taken')));
                 }
             }
             $password_changed = false;
             if ($request['password_action'] == 'change' && $request['new_password_1'] && $request['new_password_2']) {
                 if ($request['new_password_1'] == $request['new_password_2']) {
                     $user->setPassword($request['new_password_1']);
                     $password_changed = true;
                 } else {
                     $this->getResponse()->setHttpStatus(400);
                     return $this->renderJSON(array('error' => $this->getI18n()->__('Please enter the new password twice')));
                 }
             } elseif ($request['password_action'] == 'random') {
                 $random_password = entities\User::createPassword();
                 $user->setPassword($random_password);
                 $password_changed = true;
             }
             if (isset($request['realname'])) {
                 $user->setRealname($request['realname']);
             }
             $return_options = array();
             try {
                 if ($group = entities\Group::getB2DBTable()->selectById($request['group'])) {
                     if ($user->getGroupID() != $group->getID()) {
                         $groups = array($user->getGroupID(), $group->getID());
                         $return_options['update_groups'] = array('ids' => array(), 'membercounts' => array());
                     }
                     $user->setGroup($group);
                 }
             } catch (\Exception $e) {
                 throw new \Exception($this->getI18n()->__('Invalid user group'));
             }
             $existing_teams = array_keys($user->getTeams());
             $new_teams = array();
             $new_clients = array();
             $user->clearTeams();
             try {
                 foreach ($request->getParameter('teams', array()) as $team_id => $team) {
                     if ($team = entities\Team::getB2DBTable()->selectById($team_id)) {
                         $new_teams[] = $team_id;
                         $user->addToTeam($team);
                     }
                 }
             } catch (\Exception $e) {
                 throw new \Exception($this->getI18n()->__('One or more teams were invalid'));
             }
             try {
                 $user->clearClients();
                 foreach ($request->getParameter('clients', array()) as $client_id => $client) {
                     if ($client = entities\Client::getB2DBTable()->selectById($client_id)) {
                         $new_clients[] = $client_id;
                         $user->addToClient($client);
                     }
                 }
             } catch (\Exception $e) {
                 throw new \Exception($this->getI18n()->__('One or more clients were invalid'));
             }
             if (isset($request['nickname'])) {
                 $user->setBuddyname($request['nickname']);
             }
             if (isset($request['email'])) {
                 $user->setEmail($request['email']);
             }
             if (isset($request['homepage'])) {
                 $user->setHomepage($request['homepage']);
             }
             if (framework\Context::getScope()->isDefault()) {
                 $user->setActivated((bool) $request['activated']);
                 $user->setEnabled((bool) $request['enabled']);
             }
             $user->save();
             if (isset($groups)) {
                 foreach ($groups as $group_id) {
                     if (!$group_id) {
                         continue;
                     }
                     $return_options['update_groups']['ids'][] = $group_id;
                     $return_options['update_groups']['membercounts'][$group_id] = entities\Group::getB2DBTable()->selectById($group_id)->getNumberOfMembers();
                 }
             }
             if ($new_teams != $existing_teams) {
                 $new_team_ids = array_diff($new_teams, $existing_teams);
                 $existing_team_ids = array_diff($existing_teams, $new_teams);
                 $teams_to_update = array_merge($new_team_ids, $existing_team_ids);
                 $return_options['update_teams'] = array('ids' => array(), 'membercounts' => array());
                 foreach ($teams_to_update as $team_id) {
                     $return_options['update_teams']['ids'][] = $team_id;
                     $return_options['update_teams']['membercounts'][$team_id] = entities\Team::getB2DBTable()->selectById($team_id)->getNumberOfMembers();
                 }
             }
             $template_options = array('user' => $user);
             if (isset($random_password)) {
                 $template_options['random_password'] = $random_password;
             }
             $return_options['content'] = $this->getComponentHTML('configuration/finduser_row', $template_options);
             $return_options['title'] = $this->getI18n()->__('User updated!');
             if ($password_changed) {
                 $return_options['message'] = $this->getI18n()->__('The password was changed');
             }
             return $this->renderJSON($return_options);
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $this->getI18n()->__('This user could not be updated: %message', array('%message' => $e->getMessage()))));
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array('error' => $this->getI18n()->__('This user could not be updated')));
 }
        </tr>
    </thead>
    <tbody>
        <tr class="hover_highlight">
            <td style="padding: 2px; border-bottom: 1px solid #EAEAEA;"><?php 
echo __('<b>Global </b>(Everyone with access)', array(), true);
?>
</td>
            <td style="padding: 2px; border-bottom: 1px solid #EAEAEA; text-align: center;">
                <?php 
include_component('configuration/permissionsinfoitem', array('key' => $key, 'target_id' => $target_id, 'type' => 'everyone', 'mode' => $mode, 'item_id' => 0, 'module' => $module, 'access_level' => $access_level));
?>
            </td>
        </tr>
        <?php 
$groups = \thebuggenie\core\entities\Group::getAll();
?>
        <?php 
$gcount = count($groups);
$cc = 1;
?>
        <?php 
foreach ($groups as $group) {
    ?>
            <tr class="hover_highlight">
                <td style="padding: 2px;<?php 
    if ($cc == $gcount) {
        ?>
 border-bottom: 1px solid #EAEAEA;<?php 
    }
    ?>
Example #5
0
 public function loadFixtures()
 {
     // Load initial settings
     tables\Settings::getTable()->loadFixtures($this);
     \thebuggenie\core\framework\Settings::loadSettings();
     // Load group, users and permissions fixtures
     Group::loadFixtures($this);
     // Load initial teams
     Team::loadFixtures($this);
     // Set up user states, like "available", "away", etc
     Userstate::loadFixtures($this);
     // Set up data types
     list($b_id, $f_id, $e_id, $t_id, $u_id, $i_id, $ep_id) = Issuetype::loadFixtures($this);
     $scheme = IssuetypeScheme::loadFixtures($this);
     tables\IssueFields::getTable()->loadFixtures($this, $scheme, $b_id, $f_id, $e_id, $t_id, $u_id, $i_id, $ep_id);
     Datatype::loadFixtures($this);
     // Set up workflows
     Workflow::loadFixtures($this);
     WorkflowScheme::loadFixtures($this);
     tables\WorkflowIssuetype::getTable()->loadFixtures($this);
     // Set up left menu links
     tables\Links::getTable()->loadFixtures($this);
 }
Example #6
0
 public function getByPermissionTargetIDAndModule($permission, $target_id, $module = 'core')
 {
     $crit = $this->getCriteria();
     $crit->addWhere(self::PERMISSION_TYPE, $permission);
     $crit->addWhere(self::TARGET_ID, $target_id);
     $crit->addWhere(self::MODULE, $module);
     $permissions = array();
     if ($res = $this->doSelect($crit)) {
         while ($row = $res->getNextRow()) {
             $target = null;
             if ($uid = $row->get(self::UID)) {
                 $target = \thebuggenie\core\entities\User::getB2DBTable()->selectById($uid);
             }
             if ($tid = $row->get(self::TID)) {
                 $target = \thebuggenie\core\entities\Team::getB2DBTable()->selectById($tid);
             }
             if ($gid = $row->get(self::GID)) {
                 $target = \thebuggenie\core\entities\Group::getB2DBTable()->selectById($gid);
             }
             if ($target instanceof \thebuggenie\core\entities\common\Identifiable) {
                 $permissions[] = array('target' => $target, 'allowed' => (bool) $row->get(self::ALLOWED), 'user_id' => $row->get(self::UID), 'team_id' => $row->get(self::TID), 'group_id' => $row->get(self::GID));
             }
         }
     }
     return $permissions;
 }