Beispiel #1
0
 /**
  * Forgotten password logic (AJAX call)
  *
  * @Route(url="/mailing/forgot")
  * @AnonymousRoute
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runForgot(framework\Request $request)
 {
     $i18n = framework\Context::getI18n();
     try {
         $username = str_replace('%2E', '.', $request['forgot_password_username']);
         if (!empty($username)) {
             if (($user = \thebuggenie\core\entities\User::getByUsername($username)) instanceof \thebuggenie\core\entities\User) {
                 if ($user->isActivated() && $user->isEnabled() && !$user->isDeleted()) {
                     if ($user->getEmail()) {
                         framework\Context::getModule('mailing')->sendForgottenPasswordEmail($user);
                         return $this->renderJSON(array('message' => $i18n->__('Please use the link in the email you received')));
                     } else {
                         throw new \Exception($i18n->__('Cannot find an email address for this user'));
                     }
                 } else {
                     throw new \Exception($i18n->__('Forbidden for this username, please contact your administrator'));
                 }
             } else {
                 throw new \Exception($i18n->__('This username does not exist'));
             }
         } else {
             throw new \Exception($i18n->__('Please enter an username'));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Beispiel #2
0
 /**
  * Load the user object into the user property
  *
  * @return \thebuggenie\core\entities\User
  */
 public static function loadUser($user = null)
 {
     try {
         self::$_user = $user === null ? User::loginCheck(self::getRequest(), self::getCurrentAction()) : $user;
         if (self::$_user->isAuthenticated()) {
             if (self::$_user->isOffline() || self::$_user->isAway()) {
                 self::$_user->setOnline();
             }
             if (!self::getRequest()->hasCookie('tbg3_original_username')) {
                 self::$_user->updateLastSeen();
             }
             if (!self::getScope()->isDefault() && !self::getRequest()->isAjaxCall() && !in_array(self::getRouting()->getCurrentRouteName(), array('add_scope', 'debugger', 'logout')) && !self::$_user->isGuest() && !self::$_user->isConfirmedMemberOfScope(self::getScope())) {
                 self::getResponse()->headerRedirect(self::getRouting()->generate('add_scope'));
             }
             self::$_user->save();
             if (!self::$_user->getGroup() instanceof \thebuggenie\core\entities\Group) {
                 throw new \Exception('This user account belongs to a group that does not exist anymore. <br>Please contact the system administrator.');
             }
         }
     } catch (exceptions\ElevatedLoginException $e) {
         throw $e;
     } catch (\Exception $e) {
         self::$_user = new User();
         throw $e;
     }
     return self::$_user;
 }
Beispiel #3
0
 public function do_execute()
 {
     $hostname = $this->getProvidedArgument('hostname');
     $this->cliEcho('Checking scope availability ...');
     if (tables\ScopeHostnames::getTable()->getScopeIDForHostname($hostname) === null) {
         $this->cliEcho("available!\n");
         $this->cliEcho("Creating scope ...");
         $scope = new entities\Scope();
         $scope->addHostname($hostname);
         $scope->setName($this->getProvidedArgument('shortname'));
         $uploads_enabled = $this->getProvidedArgument('enable_uploads', 'yes') == 'yes';
         $scope->setUploadsEnabled((bool) $uploads_enabled);
         $scope->setMaxUploadLimit($this->getProvidedArgument('upload_limit', 0));
         $scope->setMaxProjects($this->getProvidedArgument('projects', 0));
         $scope->setMaxUsers($this->getProvidedArgument('users', 0));
         $scope->setMaxTeams($this->getProvidedArgument('teams', 0));
         $scope->setMaxWorkflowsLimit($this->getProvidedArgument('workflows', 0));
         $scope->setEnabled();
         $this->cliEcho(".");
         $scope->save();
         $this->cliEcho(".done!\n");
         $admin_user = $this->getProvidedArgument('scope_admin');
         if ($admin_user) {
             $user = entities\User::getByUsername($admin_user);
             if ($user instanceof entities\User) {
                 $this->cliEcho("Adding user {$admin_user} to scope\n");
                 $admin_group_id = (int) framework\Settings::get(framework\Settings::SETTING_ADMIN_GROUP, 'core', $scope->getID());
                 tables\UserScopes::getTable()->addUserToScope($user->getID(), $scope->getID(), $admin_group_id, true);
             } else {
                 $this->cliEcho("Could not add user {$admin_user} to scope (username not found)\n");
             }
         }
         if ($this->getProvidedArgument('remove_admin', 'no') == 'yes') {
             $this->cliEcho("Removing administrator user from scope\n");
             tables\UserScopes::getTable()->removeUserFromScope(1, $scope->getID());
         }
         foreach (framework\Context::getModules() as $module) {
             $module_name = $module->getName();
             if ($module_name == 'publish') {
                 continue;
             }
             if ($this->getProvidedArgument("install_module_{$module_name}", "no") == 'yes') {
                 $this->cliEcho("Installing module {$module_name}\n");
                 entities\Module::installModule($module_name, $scope);
             }
         }
     } else {
         $this->cliEcho("not available\n", 'red');
     }
     $this->cliEcho("\n");
 }
 public function addIdentity($identity, $user_id)
 {
     $user = \thebuggenie\core\entities\User::getB2DBTable()->selectById($user_id);
     $crit = $this->getCriteria();
     $crit->addInsert(self::IDENTITY, $identity);
     $crit->addInsert(self::IDENTITY_HASH, User::hashPassword($identity, $user->getSalt()));
     $crit->addInsert(self::UID, $user_id);
     $type = 'openid';
     foreach (self::getProviders() as $provider => $string) {
         if (stripos($identity, $string) !== false) {
             $type = $provider;
             break;
         }
     }
     $crit->addInsert(self::TYPE, $type);
     $this->doInsert($crit);
 }
Beispiel #5
0
 public function runAuthenticate(framework\Request $request)
 {
     $username = trim($request['username']);
     $password = trim($request['password']);
     if ($username) {
         $user = tables\Users::getTable()->getByUsername($username);
         if ($password && $user instanceof entities\User) {
             foreach ($user->getApplicationPasswords() as $app_password) {
                 if (!$app_password->isUsed()) {
                     if ($app_password->getHashPassword() == entities\User::hashPassword($password, $user->getSalt())) {
                         $app_password->useOnce();
                         $app_password->save();
                         return $this->renderJSON(array('token' => $app_password->getHashPassword()));
                     }
                 }
             }
         }
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array('error' => 'Incorrect username or application password'));
 }
Beispiel #6
0
 public function findInConfig($details, $limit = 50, $allow_keywords = true)
 {
     $crit = $this->getCriteria();
     switch ($details) {
         case 'unactivated':
             if ($allow_keywords) {
                 $crit->addWhere(self::ACTIVATED, false);
                 $limit = 500;
                 break;
             }
         case 'newusers':
             if ($allow_keywords) {
                 $crit->addWhere(self::JOINED, NOW - 1814400, Criteria::DB_GREATER_THAN_EQUAL);
                 $limit = 500;
                 break;
             }
         case '0-9':
             if ($allow_keywords) {
                 $ctn = $crit->returnCriterion(self::UNAME, array('0%', '1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%'), Criteria::DB_IN);
                 $ctn->addOr(self::BUDDYNAME, array('0%', '1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%'), Criteria::DB_IN);
                 $ctn->addOr(self::REALNAME, array('0%', '1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%'), Criteria::DB_IN);
                 $crit->addWhere($ctn);
                 $limit = 500;
                 break;
             }
         case 'all':
             if ($allow_keywords) {
                 $limit = 500;
                 break;
             }
         default:
             if (mb_strlen($details) == 1) {
                 $limit = 500;
             }
             $details = mb_strlen($details) == 1 ? mb_strtolower("{$details}%") : mb_strtolower("%{$details}%");
             $ctn = $crit->returnCriterion(self::UNAME, $details, Criteria::DB_LIKE);
             $ctn->addOr(self::BUDDYNAME, $details, Criteria::DB_LIKE);
             $ctn->addOr(self::REALNAME, $details, Criteria::DB_LIKE);
             $ctn->addOr(self::EMAIL, $details, Criteria::DB_LIKE);
             $crit->addWhere($ctn);
             break;
     }
     $crit->addJoin(UserScopes::getTable(), UserScopes::USER_ID, self::ID, array(), Criteria::DB_INNER_JOIN);
     $crit->addWhere(UserScopes::SCOPE, framework\Context::getScope()->getID());
     $crit->addWhere(self::DELETED, false);
     $users = array();
     $res = null;
     if ($details != '' && ($res = $this->doSelect($crit))) {
         while (($row = $res->getNextRow()) && count($users) < $limit) {
             $user_id = (int) $row->get(self::ID);
             $details = UserScopes::getTable()->getUserDetailsByScope($user_id, framework\Context::getScope()->getID());
             if (!$details) {
                 continue;
             }
             $users[$user_id] = \thebuggenie\core\entities\User::getB2DBTable()->selectById($user_id);
             $users[$user_id]->setScopeConfirmed($details['confirmed']);
         }
     }
     return $users;
 }
 /**
  * Toggle favourite article (starring)
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runToggleFavouriteArticle(framework\Request $request)
 {
     if ($article_id = $request['article_id']) {
         try {
             $article = Articles::getTable()->selectById($article_id);
             $user = \thebuggenie\core\entities\User::getB2DBTable()->selectById($request['user_id']);
         } catch (\Exception $e) {
             return $this->renderText('fail');
         }
     } else {
         return $this->renderText('no article');
     }
     if ($user->isArticleStarred($article_id)) {
         $retval = !$user->removeStarredArticle($article_id);
     } else {
         $retval = $user->addStarredArticle($article_id);
         if ($user->getID() != $this->getUser()->getID()) {
             framework\Event::createNew('core', 'article_subscribe_user', $article, compact('user'))->trigger();
         }
     }
     return $this->renderText(json_encode(array('starred' => $retval, 'subscriber' => $this->getComponentHTML('publish/articlesubscriber', array('user' => $user, 'article' => $article)))));
 }
Beispiel #8
0
 /**
  * Populate the array of starred articles
  */
 protected function User__populateStarredArticles(User $user)
 {
     if ($user->_isset('publish', 'starredarticles') === null) {
         $articles = UserArticles::getTable()->getUserStarredArticles($user->getID());
         $user->_store('publish', 'starredarticles', $articles);
     }
 }
Beispiel #9
0
         <?php 
 if (!isset($include_issue_title) || $include_issue_title) {
     ?>
             <?php 
     echo link_tag(make_url('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo())), $issue_title, array('class' => $log_action['change_type'] == \thebuggenie\core\entities\tables\Log::LOG_ISSUE_CLOSE ? 'issue_closed' : 'issue_open', 'style' => 'margin-top: 7px;'));
     ?>
         <?php 
 }
 ?>
         <?php 
 if ((!isset($include_issue_title) || $include_issue_title) && (isset($include_user) && $include_user == true)) {
     ?>
             <br>
             <span class="user">
                 <?php 
     if (($user = \thebuggenie\core\entities\User::getB2DBTable()->selectById($log_action['user_id'])) instanceof \thebuggenie\core\entities\User) {
         ?>
                     <?php 
         if ($log_action['change_type'] != \thebuggenie\core\entities\tables\Log::LOG_COMMENT) {
             ?>
                         <?php 
             echo $user->getNameWithUsername() . ':';
             ?>
                     <?php 
         } else {
             ?>
                         <?php 
             echo __('%user said', array('%user' => $user->getNameWithUsername())) . ':';
             ?>
                     <?php 
         }
Beispiel #10
0
 /**
  * Return the default user
  *
  * @return \thebuggenie\core\entities\User
  */
 public static function getDefaultUser()
 {
     try {
         return \thebuggenie\core\entities\User::getB2DBTable()->selectByID((int) self::get(self::SETTING_DEFAULT_USER_ID));
     } catch (\Exception $e) {
         return null;
     }
 }
Beispiel #11
0
 public function getOrCreateUserFromEmailString($email_string)
 {
     $email = $this->getEmailAdressFromSenderString($email_string);
     if (!($user = User::findUser($email))) {
         $name = $email;
         if (($q_pos = strpos($email_string, "<")) !== false) {
             $name = trim(substr($email_string, 0, $q_pos - 1));
         }
         $user = new User();
         try {
             $user->setBuddyname($name);
             $user->setEmail($email);
             $user->setUsername($email);
             $user->setValidated();
             $user->setActivated();
             $user->setEnabled();
             $user->save();
         } catch (\Exception $e) {
             return null;
         }
     }
     return $user;
 }
                 <?php 
     echo __('Set resolution to %resolution', array('%resolution' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\Resolution::getB2DBTable()->selectById((int) $action->getTargetValue())->getName() : __('Resolution provided by user')) . '</span>'));
     ?>
             <?php 
 } elseif ($action->getActionType() == \thebuggenie\core\entities\WorkflowTransitionAction::ACTION_SET_REPRODUCABILITY) {
     ?>
                 <?php 
     echo __('Set reproducability to %reproducability', array('%reproducability' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ? \thebuggenie\core\entities\Reproducability::getB2DBTable()->selectById((int) $action->getTargetValue())->getName() : __('Reproducability provided by user')) . '</span>'));
     ?>
             <?php 
 } elseif ($action->getActionType() == \thebuggenie\core\entities\WorkflowTransitionAction::ACTION_ASSIGN_ISSUE) {
     ?>
                 <?php 
     if ($action->hasTargetValue()) {
         $target_details = explode('_', $action->getTargetValue());
         echo __('Assign issue to %assignee', array('%assignee' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($target_details[0] == 'user' ? \thebuggenie\core\entities\User::getB2DBTable()->selectById((int) $target_details[1])->getNameWithUsername() : \thebuggenie\core\entities\Team::getB2DBTable()->selectById((int) $target_details[1])->getName()) . '</span>'));
     } else {
         echo __('Assign issue to %assignee', array('%assignee' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . __('User or team specified during transition') . '</span>'));
     }
     ?>
             <?php 
 } elseif ($action->isCustomSetAction()) {
     ?>
                 <?php 
     $tbg_response->addJavascript('calendarview.js');
     switch (\thebuggenie\core\entities\CustomDatatype::getByKey($action->getCustomActionType())->getType()) {
         case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_MAIN:
         case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXTAREA_SMALL:
         case \thebuggenie\core\entities\CustomDatatype::INPUT_TEXT:
         case \thebuggenie\core\entities\CustomDatatype::CALCULATED_FIELD:
             echo __('Set issue field %key to %value', array('%key' => $action->getCustomActionType(), '%value' => '<span id="workflowtransitionaction_' . $action->getID() . '_value" style="font-weight: bold;">' . ($action->getTargetValue() ?: __('Value provided by user')) . '</span>'));
Beispiel #13
0
 /**
  * Check if the given user is a friend of this user
  *
  * @param \thebuggenie\core\entities\User $user The user to check
  *
  * @return boolean
  */
 public function isFriend($user)
 {
     $this->_setupFriends();
     if (empty($this->_friends)) {
         return false;
     }
     return array_key_exists($user->getID(), $this->_friends);
 }
Beispiel #14
0
function tbg_get_userstate_image(\thebuggenie\core\entities\User $user)
{
    switch (true) {
        case $user->getState()->isInMeeting():
            return fa_image_tag('circle', array('class' => 'userstate in-meeting', 'title' => __($user->getState()->getName())));
            break;
        case $user->getState()->isBusy():
            return fa_image_tag('minus-circle', array('class' => 'userstate busy', 'title' => __($user->getState()->getName())));
            break;
        case $user->isOffline():
            return fa_image_tag('times-circle', array('class' => 'userstate offline', 'title' => __($user->getState()->getName())));
            break;
        case $user->getState()->isAbsent():
            return fa_image_tag('circle', array('class' => 'userstate absent', 'title' => __($user->getState()->getName())));
            break;
        case $user->getState()->isUnavailable():
            return fa_image_tag('circle-thin', array('class' => 'userstate unavailable', 'title' => __($user->getState()->getName())));
            break;
        default:
            return fa_image_tag('check-circle', array('class' => 'userstate online', 'title' => __($user->getState()->getName())));
            break;
    }
}
Beispiel #15
0
 public function removeMember(\thebuggenie\core\entities\User $user)
 {
     if ($this->_members !== null) {
         unset($this->_members[$user->getID()]);
     }
     if ($this->_num_members !== null) {
         $this->_num_members--;
     }
     tables\TeamMembers::getTable()->removeUserFromTeam($user->getID(), $this->getID());
 }
Beispiel #16
0
 /**
  * Configure project leaders
  *
  * @param framework\Request $request The request object
  */
 public function runSetItemLead(framework\Request $request)
 {
     try {
         switch ($request['item_type']) {
             case 'project':
                 $item = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 break;
             case 'edition':
                 $item = entities\Edition::getB2DBTable()->selectById($request['edition_id']);
                 break;
             case 'component':
                 $item = entities\Component::getB2DBTable()->selectById($request['component_id']);
                 break;
         }
     } catch (\Exception $e) {
     }
     $this->forward403unless(isset($item) && $item instanceof entities\common\Identifiable);
     if ($request->hasParameter('value')) {
         $this->forward403unless($request['item_type'] == 'project' && $this->getUser()->canEditProjectDetails($this->selected_project) || $request['item_type'] != 'project' && $this->getUser()->canManageProjectReleases($this->selected_project));
         if ($request->hasParameter('identifiable_type')) {
             if (in_array($request['identifiable_type'], array('team', 'user')) && $request['value']) {
                 switch ($request['identifiable_type']) {
                     case 'user':
                         $identified = entities\User::getB2DBTable()->selectById($request['value']);
                         break;
                     case 'team':
                         $identified = entities\Team::getB2DBTable()->selectById($request['value']);
                         break;
                 }
                 if ($identified instanceof entities\common\Identifiable) {
                     if ($request['field'] == 'owned_by') {
                         $item->setOwner($identified);
                     } elseif ($request['field'] == 'qa_by') {
                         $item->setQaResponsible($identified);
                     } elseif ($request['field'] == 'lead_by') {
                         $item->setLeader($identified);
                     }
                     $item->save();
                 }
             } else {
                 if ($request['field'] == 'owned_by') {
                     $item->clearOwner();
                 } elseif ($request['field'] == 'qa_by') {
                     $item->clearQaResponsible();
                 } elseif ($request['field'] == 'lead_by') {
                     $item->clearLeader();
                 }
                 $item->save();
             }
         }
         if ($request['field'] == 'owned_by') {
             return $this->renderJSON(array('field' => $item->hasOwner() ? array('id' => $item->getOwner()->getID(), 'name' => $item->getOwner() instanceof entities\User ? $this->getComponentHTML('main/userdropdown', array('user' => $item->getOwner())) : $this->getComponentHTML('main/teamdropdown', array('team' => $item->getOwner()))) : array('id' => 0)));
         } elseif ($request['field'] == 'lead_by') {
             return $this->renderJSON(array('field' => $item->hasLeader() ? array('id' => $item->getLeader()->getID(), 'name' => $item->getLeader() instanceof entities\User ? $this->getComponentHTML('main/userdropdown', array('user' => $item->getLeader())) : $this->getComponentHTML('main/teamdropdown', array('team' => $item->getLeader()))) : array('id' => 0)));
         } elseif ($request['field'] == 'qa_by') {
             return $this->renderJSON(array('field' => $item->hasQaResponsible() ? array('id' => $item->getQaResponsible()->getID(), 'name' => $item->getQaResponsible() instanceof entities\User ? $this->getComponentHTML('main/userdropdown', array('user' => $item->getQaResponsible())) : $this->getComponentHTML('main/teamdropdown', array('team' => $item->getQaResponsible()))) : array('id' => 0)));
         }
     }
 }
Beispiel #17
0
 public function doLogin($username, $password, $mode = 1)
 {
     $validgroups = $this->getSetting('groups');
     $base_dn = $this->getSetting('b_dn');
     $dn_attr = $this->escape($this->getSetting('dn_attr'));
     $username_attr = $this->escape($this->getSetting('u_attr'));
     $fullname_attr = $this->escape($this->getSetting('f_attr'));
     $buddyname_attr = $this->escape($this->getSetting('b_attr'));
     $email_attr = $this->escape($this->getSetting('e_attr'));
     $groups_members_attr = $this->escape($this->getSetting('g_attr'));
     $user_class = framework\Context::getModule('auth_ldap')->getSetting('u_type');
     $group_class = framework\Context::getModule('auth_ldap')->getSetting('g_type');
     $email = null;
     $integrated_auth = $this->getSetting('integrated_auth');
     /*
      * Do the LDAP check here.
      *
      * If a connection error or something, throw an exception and log
      *
      * If we can, set $mail and $realname to correct values from LDAP
      * otherwise don't touch those variables.
      *
      * To log do:
      * framework\Logging::log('error goes here', 'ldap', framework\Logging::LEVEL_FATAL);
      */
     try {
         /*
          * First job is to connect to our control user (may be an anonymous bind)
          * so we can find the user we want to log in as/validate.
          */
         $connection = $this->connect();
         $control_user = $this->getSetting('control_user');
         $control_password = $this->getSetting('control_pass');
         $this->bind($connection, $control_user, $control_password);
         // Assume bind successful, otherwise we would have had an exception
         /*
          * Search for a user with the username specified. We search in the base_dn, so we can
          * find users in multiple parts of the directory, and only return users of a specific
          * class (default person).
          *
          * We want exactly 1 user to be returned. We get the user's full name, email, cn
          * and dn.
          */
         $fields = array($fullname_attr, $buddyname_attr, $email_attr, 'cn', $dn_attr);
         $filter = '(&(objectClass=' . $this->escape($user_class) . ')(' . $username_attr . '=' . $this->escape($username) . '))';
         $results = ldap_search($connection, $base_dn, $filter, $fields);
         if (!$results) {
             framework\Logging::log('failed to search for user: '******'ldap', framework\Logging::LEVEL_FATAL);
             throw new \Exception(framework\Context::geti18n()->__('Search failed: ') . ldap_error($connection));
         }
         $data = ldap_get_entries($connection, $results);
         // User does not exist
         if ($data['count'] == 0) {
             framework\Logging::log('could not find user ' . $username . ', class ' . $user_class . ', attribute ' . $username_attr, 'ldap', framework\Logging::LEVEL_FATAL);
             throw new \Exception(framework\Context::geti18n()->__('User does not exist in the directory'));
         }
         // If we have more than 1 user, something is seriously messed up...
         if ($data['count'] > 1) {
             framework\Logging::log('too many users for ' . $username . ', class ' . $user_class . ', attribute ' . $username_attr, 'ldap', framework\Logging::LEVEL_FATAL);
             throw new \Exception(framework\Context::geti18n()->__('This user was found multiple times in the directory, please contact your administrator'));
         }
         /*
          * If groups are specified, perform group restriction tests
          */
         if ($validgroups != '') {
             /*
              * We will repeat this for every group, but groups are supplied as a comma-separated list
              */
             if (strstr($validgroups, ',')) {
                 $groups = explode(',', $validgroups);
             } else {
                 $groups = array();
                 $groups[] = $validgroups;
             }
             // Assumed we are initially banned
             $allowed = false;
             foreach ($groups as $group) {
                 // No need to carry on looking if we have access
                 if ($allowed == true) {
                     continue;
                 }
                 /*
                  * Find the group we are looking for, we search the entire directory as per users (See that stuff)
                  * We want to find 1 group, if we don't get 1, silently ignore this group.
                  */
                 $fields2 = array($groups_members_attr);
                 $filter2 = '(&(objectClass=' . $this->escape($group_class) . ')(cn=' . $this->escape($group) . '))';
                 $results2 = ldap_search($connection, $base_dn, $filter2, $fields2);
                 if (!$results2) {
                     framework\Logging::log('failed to search for user after binding: ' . ldap_error($connection), 'ldap', framework\Logging::LEVEL_FATAL);
                     throw new \Exception(framework\Context::geti18n()->__('Search failed ') . ldap_error($connection));
                 }
                 $data2 = ldap_get_entries($connection, $results2);
                 if ($data2['count'] != 1) {
                     continue;
                 }
                 /*
                  * Look through the group's member list. If we are found, grant access.
                  */
                 foreach ($data2[0][strtolower($groups_members_attr)] as $member) {
                     $member = preg_replace('/(?<=,) +(?=[a-zA-Z])/', '', $member);
                     $user_dn = preg_replace('/(?<=,) +(?=[a-zA-Z])/', '', $data[0][strtolower($dn_attr)][0]);
                     if (!is_numeric($member) && strtolower($member) == strtolower($user_dn)) {
                         $allowed = true;
                     }
                 }
             }
             if ($allowed == false) {
                 throw new \Exception(framework\Context::getI18n()->__('You are not a member of a group allowed to log in'));
             }
         }
         /*
          * Set user's properties.
          * Realname is obtained from directory, if not found we set it to the username
          * Email is obtained from directory, if not found we set it to blank
          */
         if (!array_key_exists(strtolower($fullname_attr), $data[0])) {
             $realname = $username;
         } else {
             $realname = $data[0][strtolower($fullname_attr)][0];
         }
         if (!array_key_exists(strtolower($buddyname_attr), $data[0])) {
             $buddyname = $username;
         } else {
             $buddyname = $data[0][strtolower($buddyname_attr)][0];
         }
         if (!array_key_exists(strtolower($email_attr), $data[0])) {
             $email = '';
         } else {
             $email = $data[0][strtolower($email_attr)][0];
         }
         /*
          * If we are performing a non integrated authentication login,
          * now bind to the user and see if the credentials
          * are valid. We bind using the full DN of the user, so no need for DOMAIN\ stuff
          * on Windows, and more importantly it fixes other servers.
          *
          * If the bind fails (exception), we throw a nicer exception and don't continue.
          */
         if ($mode == 1 && !$integrated_auth) {
             try {
                 if (!is_array($data[0][strtolower($dn_attr)])) {
                     $dn = $data[0][strtolower($dn_attr)];
                 } else {
                     $dn = $data[0][strtolower($dn_attr)][0];
                 }
                 $bind = $this->bind($connection, $this->escape($dn), $password);
             } catch (\Exception $e) {
                 throw new \Exception(framework\Context::geti18n()->__('Your password was not accepted by the server'));
             }
         } elseif ($mode == 1) {
             if (!isset($_SERVER[$this->getSetting('integrated_auth_header')]) || $_SERVER[$this->getSetting('integrated_auth_header')] != $username) {
                 throw new \Exception(framework\Context::geti18n()->__('HTTP authentication internal error.'));
             }
         }
     } catch (\Exception $e) {
         ldap_unbind($connection);
         throw $e;
     }
     try {
         /*
          * Get the user object. If the user exists, update the user's
          * data from the directory.
          */
         $user = \thebuggenie\core\entities\User::getByUsername($username);
         if ($user instanceof \thebuggenie\core\entities\User) {
             $user->setBuddyname($buddyname);
             $user->setRealname($realname);
             $user->setPassword($user->getJoinedDate() . $username);
             // update password
             $user->setEmail($email);
             // update email address
             $user->save();
         } else {
             /*
              * If not, and we are performing an initial login, create the user object
              * if we are validating a log in, kick the user out as the session is invalid.
              */
             if ($mode == 1) {
                 // create user
                 $user = new \thebuggenie\core\entities\User();
                 $user->setUsername($username);
                 $user->setRealname('temporary');
                 $user->setBuddyname($username);
                 $user->setEmail('temporary');
                 $user->setEnabled();
                 $user->setActivated();
                 $user->setJoined();
                 $user->setPassword($user->getJoinedDate() . $username);
                 $user->save();
             } else {
                 throw new \Exception('User does not exist in TBG');
             }
         }
     } catch (\Exception $e) {
         ldap_unbind($connection);
         throw $e;
     }
     ldap_unbind($connection);
     /*
      * Set cookies and return user row for general operations.
      */
     framework\Context::getResponse()->setCookie('tbg3_username', $username);
     framework\Context::getResponse()->setCookie('tbg3_password', \thebuggenie\core\entities\User::hashPassword($user->getJoinedDate() . $username, $user->getSalt()));
     return \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($username);
 }
Beispiel #18
0
 /**
  * Register a user as working on the issue
  *
  * @param \thebuggenie\core\entities\User $user
  */
 public function startWorkingOnIssue(User $user)
 {
     $this->_addChangedProperty('_being_worked_on_by_user', $user->getID());
     $this->_being_worked_on_by_user_since = NOW;
 }
function tbg_get_userstate_image(\thebuggenie\core\entities\User $user)
{
    switch (true) {
        case $user->isOffline():
            return image_tag('user-offline.png', array('class' => 'userstate', 'title' => __($user->getState()->getName())));
            break;
        case $user->getState()->isBusy():
        case $user->getState()->isUnavailable():
            return image_tag('user-busy.png', array('class' => 'userstate', 'title' => __($user->getState()->getName())));
            break;
        case $user->getState()->isAbsent():
            return image_tag('user-invisible.png', array('class' => 'userstate', 'title' => __($user->getState()->getName())));
            break;
        case $user->getState()->isInMeeting():
            return image_tag('user-away-extended.png', array('class' => 'userstate', 'title' => __($user->getState()->getName())));
            break;
        case $user->getState()->isUnavailable():
            return image_tag('user-away.png', array('class' => 'userstate', 'title' => __($user->getState()->getName())));
            break;
        default:
            return image_tag('user-online.png', array('class' => 'userstate', 'title' => __($user->getState()->getName())));
            break;
    }
}
         $previous_value = $item->getPreviousValue() ? \thebuggenie\core\entities\Issue::getPainTypesOrLabel('pain_likelihood', $item->getPreviousValue()) : __('Not determined');
         $new_value = $item->getCurrentValue() ? \thebuggenie\core\entities\Issue::getPainTypesOrLabel('pain_likelihood', $item->getCurrentValue()) : __('Not determined');
         echo __("Likelihood on issue changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>'));
     }
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_PAIN_CALCULATED:
     echo image_tag('icon_percent.png');
     if ($item->hasChangeDetails()) {
         echo __("Calculated pain on issue changed: %value", array('%value' => '<strong>' . $item->getText() . '</strong>'));
     }
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_USERS:
     echo image_tag('icon_user.png');
     if ($item->hasChangeDetails()) {
         $previous_value = $item->getPreviousValue() ? ($old_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getPreviousValue())) ? __($old_item->getNameWithUsername()) : __('Unknown') : __('Not determined');
         $new_value = $item->getCurrentValue() ? ($new_item = \thebuggenie\core\entities\User::getB2DBTable()->selectById($item->getCurrentValue())) ? __($new_item->getNameWithUsername()) : __('Unknown') : __('Not determined');
         echo __("User working on issue changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . $previous_value . '</strong>', '%new_value' => '<strong>' . $new_value . '</strong>'));
     }
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_ASSIGNED:
     echo image_tag('icon_user.png');
     echo __("Assignee changed to %new_value", array('%new_value' => '<strong>' . $item->getText() . '</strong>'));
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_TIME_SPENT:
     echo image_tag('icon_time.png');
     echo __("Time spent changed: %value", array('%value' => '<strong>' . $item->getText() . '</strong>'));
     break;
 case \thebuggenie\core\entities\tables\Log::LOG_ISSUE_PERCENT:
     echo image_tag('icon_percent.png');
     if ($item->hasChangeDetails()) {
         echo __("Percent complete changed: %previous_value => %new_value", array('%previous_value' => '<strong>' . (int) $item->getPreviousValue() . '</strong>', '%new_value' => '<strong>' . (int) $item->getCurrentValue() . '</strong>'));
Beispiel #21
0
 /**
  * @param \thebuggenie\core\entities\User $user
  * @return array
  */
 public function getPlanningColumns(\thebuggenie\core\entities\User $user)
 {
     $columns = framework\Settings::get('planning_columns_' . $this->getID(), 'project', framework\Context::getScope()->getID(), $user->getID());
     $columns = explode(',', $columns);
     if (empty($columns) || isset($columns[0]) && empty($columns[0])) {
         // Default values
         $columns = array('priority', 'estimated_time', 'spent_time');
     }
     // Set array keys to equal array values
     $columns = array_combine($columns, $columns);
     return $columns;
 }
Beispiel #22
0
 public function removeMember(\thebuggenie\core\entities\User $user)
 {
     if ($this->_members !== null) {
         unset($this->_members[$user->getID()]);
     }
     if ($this->_num_members !== null) {
         $this->_num_members--;
     }
 }
Beispiel #23
0
 /**
  * Load user fixtures for a specified scope
  *
  * @param Scope $scope
  * @param Group $admin_group
  * @param Group $user_group
  * @param Group $guest_group
  */
 public static function loadFixtures(Scope $scope, Group $admin_group, Group $user_group, Group $guest_group)
 {
     $adminuser = new User();
     $adminuser->setUsername('administrator');
     $adminuser->setRealname('Administrator');
     $adminuser->setBuddyname('Admin');
     $adminuser->setGroup($admin_group);
     $adminuser->setPassword('admin');
     $adminuser->setActivated();
     $adminuser->setEnabled();
     $adminuser->setAvatar('admin');
     $adminuser->save();
     $guestuser = new User();
     $guestuser->setUsername('guest');
     $guestuser->setRealname('Guest user');
     $guestuser->setBuddyname('Guest user');
     $guestuser->setGroup($guest_group);
     $guestuser->setPassword('password');
     // Settings not active yet
     $guestuser->setActivated();
     $guestuser->setEnabled();
     $guestuser->save();
     framework\Settings::saveSetting('defaultuserid', $guestuser->getID(), 'core', $scope->getID());
     return array($guestuser->getID(), $adminuser->getID());
 }
Beispiel #24
0
 protected function _processChanges()
 {
     $related_issues_to_save = array();
     $changed_properties = $this->_getChangedProperties();
     if (count($changed_properties)) {
         $is_saved_estimated = false;
         $is_saved_spent = false;
         $is_saved_assignee = false;
         $is_saved_owner = false;
         foreach ($changed_properties as $property => $value) {
             $compare_value = is_object($this->{$property}) ? $this->{$property}->getID() : $this->{$property};
             $original_value = $value['original_value'];
             if ($original_value != $compare_value) {
                 switch ($property) {
                     case '_title':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_TITLE, framework\Context::getI18n()->__("Title updated"), $original_value, $compare_value);
                         break;
                     case '_shortname':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_SHORTNAME, framework\Context::getI18n()->__("Issue label updated"), $original_value, $compare_value);
                         break;
                     case '_description':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_DESCRIPTION, framework\Context::getI18n()->__("Description updated"), $original_value, $compare_value);
                         break;
                     case '_reproduction_steps':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_UPDATE_REPRODUCTIONSTEPS, framework\Context::getI18n()->__("Reproduction steps updated"), $original_value, $compare_value);
                         break;
                     case '_category':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Category::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getCategory() instanceof Datatype ? $this->getCategory()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_CATEGORY, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_pain_bug_type':
                         if ($original_value != 0) {
                             $old_name = ($old_item = self::getPainTypesOrLabel('pain_bug_type', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = ($new_item = self::getPainTypesOrLabel('pain_bug_type', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_BUG_TYPE, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_pain_effect':
                         if ($original_value != 0) {
                             $old_name = ($old_item = self::getPainTypesOrLabel('pain_effect', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = ($new_item = self::getPainTypesOrLabel('pain_effect', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_EFFECT, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_pain_likelihood':
                         if ($original_value != 0) {
                             $old_name = ($old_item = self::getPainTypesOrLabel('pain_likelihood', $original_value)) ? $old_item : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = ($new_item = self::getPainTypesOrLabel('pain_likelihood', $value['current_value'])) ? $new_item : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_LIKELIHOOD, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_user_pain':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PAIN_CALCULATED, $original_value . ' &rArr; ' . $value['current_value']);
                         break;
                     case '_status':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Status::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getStatus() instanceof Datatype ? $this->getStatus()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_STATUS, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_reproducability':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Reproducability::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getReproducability() instanceof Datatype ? $this->getReproducability()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_REPRODUCABILITY, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_priority':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Priority::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getPriority() instanceof Datatype ? $this->getPriority()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PRIORITY, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_assignee_team':
                     case '_assignee_user':
                         if (!$is_saved_assignee) {
                             $new_name = $this->getAssignee() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getAssignee()->getName() : framework\Context::getI18n()->__('Not assigned');
                             if ($this->getAssignee() instanceof \thebuggenie\core\entities\User) {
                                 $this->startWorkingOnIssue($this->getAssignee());
                             }
                             $this->addLogEntry(tables\Log::LOG_ISSUE_ASSIGNED, $new_name);
                             $is_saved_assignee = true;
                         }
                         break;
                     case '_posted_by':
                         $old_identifiable = $original_value ? \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value) : framework\Context::getI18n()->__('Unknown');
                         $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown');
                         $new_name = $this->getPostedBy()->getName();
                         $this->addLogEntry(tables\Log::LOG_ISSUE_POSTED, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_being_worked_on_by_user':
                         if ($original_value != 0) {
                             $old_identifiable = \thebuggenie\core\entities\User::getB2DBTable()->selectById($original_value);
                             $old_name = $old_identifiable instanceof \thebuggenie\core\entities\User ? $old_identifiable->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not being worked on');
                         }
                         $new_name = $this->getUserWorkingOnIssue() instanceof \thebuggenie\core\entities\User ? $this->getUserWorkingOnIssue()->getName() : framework\Context::getI18n()->__('Not being worked on');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_USERS, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_owner_team':
                     case '_owner_user':
                         if (!$is_saved_owner) {
                             $new_name = $this->getOwner() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getOwner()->getName() : framework\Context::getI18n()->__('Not owned by anyone');
                             $this->addLogEntry(tables\Log::LOG_ISSUE_OWNED, $new_name);
                             $is_saved_owner = true;
                         }
                         break;
                     case '_percent_complete':
                         $this->addLogEntry(tables\Log::LOG_ISSUE_PERCENT, $original_value . '% &rArr; ' . $this->getPercentCompleted() . '', $original_value, $compare_value);
                         break;
                     case '_resolution':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Resolution::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getResolution() instanceof Datatype ? $this->getResolution()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_RESOLUTION, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_severity':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Severity::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getSeverity() instanceof Datatype ? $this->getSeverity()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_SEVERITY, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_milestone':
                         if ($original_value != 0) {
                             $old_name = ($old_item = \thebuggenie\core\entities\Milestone::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Not determined');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Not determined');
                         }
                         $new_name = $this->getMilestone() instanceof \thebuggenie\core\entities\Milestone ? $this->getMilestone()->getName() : framework\Context::getI18n()->__('Not determined');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_MILESTONE, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         $this->_milestone_order = 0;
                         break;
                     case '_issuetype':
                         if ($original_value != 0) {
                             $old_name = ($old_item = Issuetype::getB2DBTable()->selectById($original_value)) ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                         } else {
                             $old_name = framework\Context::getI18n()->__('Unknown');
                         }
                         $new_name = $this->getIssuetype() instanceof \thebuggenie\core\entities\Issuetype ? $this->getIssuetype()->getName() : framework\Context::getI18n()->__('Unknown');
                         $this->addLogEntry(tables\Log::LOG_ISSUE_ISSUETYPE, $old_name . ' &rArr; ' . $new_name, $original_value, $compare_value);
                         break;
                     case '_estimated_months':
                     case '_estimated_weeks':
                     case '_estimated_days':
                     case '_estimated_hours':
                     case '_estimated_points':
                         if (!$is_saved_estimated) {
                             $old_time = array('months' => $this->getChangedPropertyOriginal('_estimated_months'), 'weeks' => $this->getChangedPropertyOriginal('_estimated_weeks'), 'days' => $this->getChangedPropertyOriginal('_estimated_days'), 'hours' => $this->getChangedPropertyOriginal('_estimated_hours'), 'points' => $this->getChangedPropertyOriginal('_estimated_points'));
                             $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('Not estimated');
                             $new_formatted_time = $this->hasEstimatedTime() ? Issue::getFormattedTime($this->getEstimatedTime()) : framework\Context::getI18n()->__('Not estimated');
                             $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_ESTIMATED, $old_formatted_time . ' &rArr; ' . $new_formatted_time, serialize($old_time), serialize($this->getEstimatedTime()));
                             $is_saved_estimated = true;
                         }
                         break;
                     case '_spent_months':
                     case '_spent_weeks':
                     case '_spent_days':
                     case '_spent_hours':
                     case '_spent_points':
                         if (!$is_saved_spent) {
                             $old_time = array('months' => $this->getChangedPropertyOriginal('_spent_months'), 'weeks' => $this->getChangedPropertyOriginal('_spent_weeks'), 'days' => $this->getChangedPropertyOriginal('_spent_days'), 'hours' => round($this->getChangedPropertyOriginal('_spent_hours') / 100, 2), 'points' => $this->getChangedPropertyOriginal('_spent_points'));
                             $old_formatted_time = array_sum($old_time) > 0 ? Issue::getFormattedTime($old_time) : framework\Context::getI18n()->__('No time spent');
                             $new_formatted_time = $this->hasSpentTime() ? Issue::getFormattedTime($this->getSpentTime()) : framework\Context::getI18n()->__('No time spent');
                             $this->addLogEntry(tables\Log::LOG_ISSUE_TIME_SPENT, $old_formatted_time . ' &rArr; ' . $new_formatted_time, serialize($old_time), serialize($this->getSpentTime()));
                             $is_saved_spent = true;
                         }
                         break;
                     case '_state':
                         if ($this->isClosed()) {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_CLOSE);
                             if ($this->getMilestone() instanceof \thebuggenie\core\entities\Milestone) {
                                 if ($this->getMilestone()->isSprint()) {
                                     if (!$this->getIssueType()->isTask()) {
                                         $this->setSpentPoints($this->getEstimatedPoints());
                                     } else {
                                         if ($this->getSpentHours() < $this->getEstimatedHours()) {
                                             $this->setSpentHours($this->getEstimatedHours());
                                         }
                                         foreach ($this->getParentIssues() as $parent_issue) {
                                             if ($parent_issue->checkTaskStates()) {
                                                 $related_issues_to_save[$parent_issue->getID()] = true;
                                             }
                                         }
                                     }
                                 }
                                 $this->getMilestone()->updateStatus();
                                 $this->getMilestone()->save();
                             }
                         } else {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_REOPEN);
                         }
                         break;
                     case '_blocking':
                         if ($this->isBlocking()) {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_BLOCKED);
                         } else {
                             $this->addLogEntry(tables\Log::LOG_ISSUE_UNBLOCKED);
                         }
                         break;
                     default:
                         if (mb_substr($property, 0, 12) == '_customfield') {
                             $key = mb_substr($property, 12);
                             $customdatatype = CustomDatatype::getByKey($key);
                             switch ($customdatatype->getType()) {
                                 case CustomDatatype::INPUT_TEXT:
                                     $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value);
                                     break;
                                 case CustomDatatype::INPUT_TEXTAREA_SMALL:
                                 case CustomDatatype::INPUT_TEXTAREA_MAIN:
                                     $new_value = $this->getCustomField($key) != '' ? $this->getCustomField($key) : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $new_value, $original_value, $compare_value);
                                     break;
                                 case CustomDatatype::EDITIONS_CHOICE:
                                 case CustomDatatype::COMPONENTS_CHOICE:
                                 case CustomDatatype::RELEASES_CHOICE:
                                 case CustomDatatype::MILESTONE_CHOICE:
                                 case CustomDatatype::STATUS_CHOICE:
                                 case CustomDatatype::TEAM_CHOICE:
                                 case CustomDatatype::USER_CHOICE:
                                 case CustomDatatype::CLIENT_CHOICE:
                                     $old_object = null;
                                     $new_object = null;
                                     try {
                                         switch ($customdatatype->getType()) {
                                             case CustomDatatype::EDITIONS_CHOICE:
                                                 $old_object = Edition::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::COMPONENTS_CHOICE:
                                                 $old_object = Component::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::RELEASES_CHOICE:
                                                 $old_object = Build::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::MILESTONE_CHOICE:
                                                 $old_object = Milestone::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::STATUS_CHOICE:
                                                 $old_object = Status::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::TEAM_CHOICE:
                                                 $old_object = Team::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::USER_CHOICE:
                                                 $old_object = User::getB2DBTable()->selectById($original_value);
                                                 break;
                                             case CustomDatatype::CLIENT_CHOICE:
                                                 $old_object = Client::getB2DBTable()->selectById($original_value);
                                                 break;
                                         }
                                     } catch (\Exception $e) {
                                     }
                                     try {
                                         switch ($customdatatype->getType()) {
                                             case CustomDatatype::EDITIONS_CHOICE:
                                             case CustomDatatype::COMPONENTS_CHOICE:
                                             case CustomDatatype::RELEASES_CHOICE:
                                             case CustomDatatype::MILESTONE_CHOICE:
                                             case CustomDatatype::STATUS_CHOICE:
                                             case CustomDatatype::TEAM_CHOICE:
                                             case CustomDatatype::USER_CHOICE:
                                             case CustomDatatype::CLIENT_CHOICE:
                                                 $new_object = $this->getCustomField($key);
                                                 break;
                                         }
                                     } catch (\Exception $e) {
                                     }
                                     $old_value = is_object($old_object) ? $old_object->getName() : framework\Context::getI18n()->__('Unknown');
                                     $new_value = is_object($new_object) ? $new_object->getName() : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' &rArr; ' . $new_value, $original_value, $compare_value);
                                     break;
                                 default:
                                     $old_item = null;
                                     try {
                                         $old_item = $original_value ? new CustomDatatypeOption($original_value) : null;
                                     } catch (\Exception $e) {
                                     }
                                     $old_value = $old_item instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $old_item->getName() : framework\Context::getI18n()->__('Unknown');
                                     $new_value = $this->getCustomField($key) instanceof \thebuggenie\core\entities\CustomDatatypeOption ? $this->getCustomField($key)->getName() : framework\Context::getI18n()->__('Unknown');
                                     $this->addLogEntry(tables\Log::LOG_ISSUE_CUSTOMFIELD_CHANGED, $key . ': ' . $old_value . ' &rArr; ' . $new_value, $original_value, $compare_value);
                                     break;
                             }
                         }
                         break;
                 }
             }
         }
         if ($is_saved_estimated) {
             tables\IssueEstimates::getTable()->saveEstimate($this->getID(), $this->_estimated_months, $this->_estimated_weeks, $this->_estimated_days, $this->_estimated_hours, $this->_estimated_points);
         }
     }
     return $related_issues_to_save;
 }
</li>
        <?php 
if (\thebuggenie\core\framework\Context::getScope()->isDefault()) {
    ?>
            <li><a href="javascript:void(0);" onclick="TBG.Main.Helpers.Backdrop.show('<?php 
    echo make_url('get_partial_for_backdrop', array('key' => 'userscopes', 'user_id' => $user->getID()));
    ?>
');"><?php 
    echo __('Edit available scopes for this user');
    ?>
</a></li>
        <?php 
}
?>
        <?php 
if (\thebuggenie\core\entities\User::isThisGuest() == false && $user->getID() != $tbg_user->getID()) {
    ?>
            <li style="<?php 
    if ($tbg_user->isFriend($user)) {
        ?>
 display: none;<?php 
    }
    ?>
" id="add_friend_<?php 
    echo $user->getID();
    ?>
_12">
                <?php 
    echo javascript_link_tag(__('Become friends'), array('onclick' => "TBG.Main.Profile.addFriend('" . make_url('toggle_friend', array('mode' => 'add', 'user_id' => $user->getID())) . "', {$user->getID()}, 12);"));
    ?>
            </li>
    $tbg_response->addFeed(make_url('project_open_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Open issues for %project_name', array('%project_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getName())));
    $tbg_response->addFeed(make_url('project_allopen_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Open issues for %project_name (including subprojects)', array('%project_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getName())));
    $tbg_response->addFeed(make_url('project_closed_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Closed issues for %project_name', array('%project_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getName())));
    $tbg_response->addFeed(make_url('project_allclosed_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Closed issues for %project_name (including subprojects)', array('%project_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getName())));
    $tbg_response->addFeed(make_url('project_wishlist_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Wishlist for %project_name', array('%project_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getName())));
    $tbg_response->addFeed(make_url('project_milestone_todo_list', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Milestone todo-list for %project_name', array('%project_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getName())));
    $tbg_response->addFeed(make_url('project_month_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Issues reported for %project_name this month', array('%project_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getName())));
    $tbg_response->addFeed(make_url('project_last_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss', 'units' => 30, 'time_unit' => 'days')), __('Issues reported for %project_name last 30 days', array('%project_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getName())));
    if (!\thebuggenie\core\entities\User::isThisGuest()) {
        $tbg_response->addFeed(make_url('project_my_reported_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Issues reported by me') . ' (' . \thebuggenie\core\framework\Context::getCurrentProject()->getName() . ')');
        $tbg_response->addFeed(make_url('project_my_assigned_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Open issues assigned to me') . ' (' . \thebuggenie\core\framework\Context::getCurrentProject()->getName() . ')');
        $tbg_response->addFeed(make_url('project_my_teams_assigned_issues', array('project_key' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')), __('Open issues assigned to my teams') . ' (' . \thebuggenie\core\framework\Context::getCurrentProject()->getName() . ')');
    }
} else {
    $tbg_response->addBreadcrumb(__('Issues'), make_url('search'), tbg_get_breadcrumblinks('main_links'));
    if (!\thebuggenie\core\entities\User::isThisGuest()) {
        $tbg_response->addFeed(make_url('my_reported_issues', array('format' => 'rss')), __('Issues reported by me'));
        $tbg_response->addFeed(make_url('my_assigned_issues', array('format' => 'rss')), __('Open issues assigned to you'));
        $tbg_response->addFeed(make_url('my_teams_assigned_issues', array('format' => 'rss')), __('Open issues assigned to your teams'));
    }
}
?>
<table style="width: 100%; height: 100;" cellpadding="0" cellspacing="0">
    <tr>
        <?php 
include_component('search/sidebar', array('hide' => $show_results && $resultcount));
?>
        <td id="find_issues">
            <?php 
if ($search_error !== null) {
    ?>
Beispiel #27
0
 public function canUserSet(\thebuggenie\core\entities\User $user)
 {
     $retval = $user->hasPermission($this->getPermissionsKey(), $this->getID(), 'core');
     $retval = $retval === null ? $user->hasPermission($this->getPermissionsKey(), 0, 'core') : $retval;
     return $retval !== null ? $retval : \thebuggenie\core\framework\Settings::isPermissive();
 }
Beispiel #28
0
 public function runAddClientMember(framework\Request $request)
 {
     try {
         $user_id = (int) $request['user_id'];
         $client = tables\Clients::getTable()->selectById((int) $request['client_id']);
         $user = entities\User::getB2DBTable()->selectByID($user_id);
         $client->addMember($user);
         return $this->renderJSON(array('clientlistitem' => $this->getComponentHTML('configuration/clientuserlistitem', compact('client', 'user_id', 'user')), 'update_clients' => array('ids' => array($client->getID()), 'membercounts' => array($client->getID() => $client->getNumberOfMembers()))));
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Beispiel #29
0
 protected function _upgradeFrom3dot2(framework\Request $request)
 {
     set_time_limit(0);
     \thebuggenie\core\entities\tables\Milestones::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGMilestone::getB2DBTable());
     \thebuggenie\core\entities\tables\Projects::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGProjectsTable::getTable());
     \thebuggenie\core\entities\tables\Log::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGLogTable::getTable());
     \thebuggenie\core\entities\tables\Users::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable());
     \thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssuesTable::getTable());
     \thebuggenie\core\entities\tables\Workflows::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGWorkflowsTable::getTable());
     \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssueSpentTimesTable::getTable());
     \thebuggenie\core\entities\tables\Comments::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGCommentsTable::getTable());
     \thebuggenie\core\entities\tables\SavedSearches::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSavedSearchesTable::getTable());
     \thebuggenie\core\entities\tables\Settings::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSettingsTable::getTable());
     \thebuggenie\core\entities\tables\Notifications::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGNotificationsTable::getTable());
     \thebuggenie\core\entities\tables\Permissions::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGPermissionsTable::getTable());
     \thebuggenie\core\entities\Dashboard::getB2DBTable()->create();
     \thebuggenie\core\entities\DashboardView::getB2DBTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGDashboardViewsTable::getTable());
     \thebuggenie\core\entities\ApplicationPassword::getB2DBTable()->create();
     \thebuggenie\core\entities\NotificationSetting::getB2DBTable()->create();
     $transaction = \b2db\Core::startTransaction();
     // Upgrade user passwords
     switch ($request['upgrade_passwords']) {
         case 'manual':
             $password = $request['manual_password'];
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 $user->setPassword($password);
                 $user->save();
             }
             break;
         case 'auto':
             $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email';
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 if ($field == 'username' && trim($user->getUsername())) {
                     $user->setPassword(trim($user->getUsername()));
                     $user->save();
                 } elseif ($field == 'email' && trim($user->getEmail())) {
                     $user->setPassword(trim($user->getEmail()));
                     $user->save();
                 }
             }
             break;
     }
     $adminuser = \thebuggenie\core\entities\User::getB2DBTable()->selectById(1);
     $adminuser->setPassword($request['admin_password']);
     $adminuser->save();
     // Add new settings
     framework\Settings::saveSetting(framework\Settings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1);
     foreach ($request->getParameter('status') as $scope_id => $status_id) {
         $scope = \thebuggenie\core\entities\tables\Scopes::getTable()->selectById((int) $scope_id);
         if ($scope instanceof \thebuggenie\core\entities\Scope) {
             $epic = new \thebuggenie\core\entities\Issuetype();
             $epic->setName('Epic');
             $epic->setIcon('epic');
             $epic->setDescription('Issue type suited for entering epics');
             $epic->setScope($scope_id);
             $epic->save();
             framework\Settings::saveSetting('issuetype_epic', $epic->getID(), 'core', $scope_id);
             foreach (\thebuggenie\core\entities\tables\Workflows::getTable()->getAll((int) $scope_id) as $workflow) {
                 $transition = new \thebuggenie\core\entities\WorkflowTransition();
                 $steps = $workflow->getSteps();
                 $step = array_shift($steps);
                 $step->setLinkedStatusID((int) $status_id);
                 $step->save();
                 $transition->setOutgoingStep($step);
                 $transition->setName('Issue created');
                 $transition->setWorkflow($workflow);
                 $transition->setScope($scope);
                 $transition->setDescription('This is the initial transition for issues using this workflow');
                 $transition->save();
                 $workflow->setInitialTransition($transition);
                 $workflow->save();
             }
             \thebuggenie\core\entities\ActivityType::loadFixtures($scope);
         }
     }
     $transaction->commitAndEnd();
     framework\Context::finishUpgrading();
     foreach (framework\Context::getModules() as $module) {
         $module->upgrade();
     }
     $this->upgrade_complete = true;
 }
 public function hasValidTarget()
 {
     if (!$this->_target_value) {
         return true;
     }
     switch ($this->_action_type) {
         case self::ACTION_ASSIGN_ISSUE:
             $target_details = explode('_', $this->_target_value);
             return (bool) ($target_details[0] == 'user') ? \thebuggenie\core\entities\User::doesIDExist($target_details[1]) : Team::doesIDExist($target_details[1]);
             break;
         case self::ACTION_SET_PERCENT:
             return (bool) ($this->_target_value > -1);
             break;
         case self::ACTION_SET_MILESTONE:
             return (bool) Milestone::doesIDExist($this->_target_value);
             break;
         case self::ACTION_SET_PRIORITY:
             return (bool) Priority::has($this->_target_value);
             break;
         case self::ACTION_SET_STATUS:
             return (bool) Status::has($this->_target_value);
             break;
         case self::ACTION_SET_REPRODUCABILITY:
             return (bool) Reproducability::has($this->_target_value);
             break;
         case self::ACTION_SET_RESOLUTION:
             return (bool) Resolution::has($this->_target_value);
             break;
         default:
             return true;
     }
 }