Пример #1
0
 /**
  * Logs the user out
  *
  * @param \thebuggenie\core\framework\Request $request
  *
  * @return bool
  */
 public function runLogout(framework\Request $request)
 {
     if ($this->getUser() instanceof entities\User) {
         framework\Logging::log('Setting user logout state');
         $this->getUser()->setOffline();
     }
     framework\Context::logout();
     if ($request->isAjaxCall()) {
         return $this->renderJSON(array('status' => 'logout ok', 'url' => framework\Context::getRouting()->generate(framework\Settings::getLogoutReturnRoute())));
     }
     $this->forward(framework\Context::getRouting()->generate(framework\Settings::getLogoutReturnRoute()));
 }
Пример #2
0
 public function runIssueEditTimeSpent(framework\Request $request)
 {
     try {
         $entry_id = $request['entry_id'];
         $spenttime = $entry_id ? tables\IssueSpentTimes::getTable()->selectById($entry_id) : new entities\IssueSpentTime();
         if ($issue_id = $request['issue_id']) {
             $issue = entities\Issue::getB2DBTable()->selectById($issue_id);
         } else {
             throw new \Exception('no issue');
         }
         framework\Context::loadLibrary('common');
         $spenttime->editOrAdd($issue, $this->getUser(), array_only_with_default($request->getParameters(), array_merge(array('timespent_manual', 'timespent_specified_type', 'timespent_specified_value', 'timespent_activitytype', 'timespent_comment', 'edited_at'), \thebuggenie\core\entities\common\Timeable::getUnitsWithPoints())));
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('edited' => 'error', 'error' => $e->getMessage()));
     }
     $this->return_data = array('edited' => 'ok');
 }
Пример #3
0
 public function postConfigSettings(framework\Request $request)
 {
     $settings = array('hostname', 'u_type', 'g_type', 'b_dn', 'groups', 'dn_attr', 'u_attr', 'g_attr', 'e_attr', 'f_attr', 'b_attr', 'g_dn', 'control_user', 'control_pass', 'integrated_auth', 'integrated_auth_header');
     foreach ($settings as $setting) {
         if (($setting == 'u_type' || $setting == 'g_type' || $setting == 'dn_attr') && $request->getParameter($setting) == '') {
             if ($setting == 'u_type') {
                 $this->saveSetting($setting, 'person');
             } elseif ($setting == 'g_type') {
                 $this->saveSetting($setting, 'group');
             } else {
                 $this->saveSetting($setting, 'entrydn');
             }
         } elseif ($setting == 'integrated_auth') {
             $this->saveSetting($setting, (int) $request->getParameter($setting, 0));
         } else {
             if ($request->hasParameter($setting)) {
                 $this->saveSetting($setting, $request->getParameter($setting));
             }
         }
     }
 }
Пример #4
0
 /**
  * The currently selected project in actions where there is one
  *
  * @access protected
  * @property entities\Project $selected_project
  */
 public function preExecute(framework\Request $request, $action)
 {
     try {
         // Default to JSON if nothing is specified.
         $newFormat = $request->getParameter('format', 'json');
         $this->getResponse()->setTemplate(mb_strtolower($action) . '.' . $newFormat . '.php');
         $this->getResponse()->setupResponseContentType($newFormat);
         if ($project_key = $request['project_key']) {
             $this->selected_project = entities\Project::getByKey($project_key);
         } elseif ($project_id = (int) $request['project_id']) {
             $this->selected_project = entities\Project::getB2DBTable()->selectByID($project_id);
         }
         if ($this->selected_project instanceof entities\Project) {
             framework\Context::setCurrentProject($this->selected_project);
         }
         $this->render_detail = !isset($request['nodetail']);
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(500);
         return $this->renderJSON(array('error' => 'An exception occurred: ' . $e));
     }
 }
Пример #5
0
 public static function getFromRequest(\thebuggenie\core\framework\Request $request, \thebuggenie\core\entities\SavedSearch $search)
 {
     $filters = $request->getRawParameter('fs', array());
     if ($request['quicksearch']) {
         $filters['text']['o'] = '=';
     }
     if (framework\Context::isProjectContext()) {
         $filters['project_id'] = array('o' => '=', 'v' => framework\Context::getCurrentProject()->getID());
     }
     $return_filters = array();
     foreach ($filters as $key => $details) {
         if (!isset($details['o'])) {
             foreach ($details as $subdetails) {
                 $return_filters[$key][] = self::createFilter($key, $subdetails, $search);
             }
         } else {
             $return_filters[$key] = self::createFilter($key, $details, $search);
         }
     }
     return $return_filters;
 }
Пример #6
0
 public function runConfigureProjectSettings(framework\Request $request)
 {
     $this->forward403unless($request->isPost());
     if ($this->access_level != framework\Settings::ACCESS_FULL) {
         $project_id = $request['project_id'];
         $fields = array('vcs_mode', 'match_keywords', 'access_method', 'access_passkey', 'commit_url', 'log_url', 'blob_url', 'diff_url', 'browser_url', 'vcs_workflow', 'browser_type');
         foreach ($fields as $field) {
             framework\Context::getModule('vcs_integration')->saveSetting($field . '_' . $project_id, $request->getParameter($field));
         }
         switch ($request['browser_type']) {
             case 'viewvc':
                 $base_url = $request['browser_url'];
                 $link_rev = '&view=rev&revision=%revno';
                 $link_file = '&view=log';
                 $link_diff = '&r1=%revno&r2=%oldrev';
                 $link_view = '&revision=%revno&view=markup';
                 break;
             case 'viewvc_repo':
                 $base_url = $request['browser_url'];
                 $link_rev = '/?view=rev&revision=%revno';
                 $link_file = '/%file?view=log';
                 $link_diff = '/%file?r1=%revno&r2=%oldrev';
                 $link_view = '/%file?revision=%revno&view=markup';
                 break;
             case 'websvn':
                 $base_url = $request['browser_url'];
                 $link_rev = '/revision.php?repname=' . $request['repository'] . '&isdir=1&rev=%revno';
                 $link_file = '/log.php?repname=' . $request['repository'] . '&path=/%file';
                 $link_diff = '/comp.php?repname=' . $request['repository'] . '&compare[]=/%file@%revno&compare[]=/%file@%oldrev';
                 $link_view = '/filedetails.php?repname=' . $request['repository'] . '&path=/%file&rev=%revno';
                 break;
             case 'websvn_mv':
                 $base_url = $request['browser_url'];
                 $link_rev = '/' . '?repname=' . $request['repository'] . '&op=log&isdir=1&rev=%revno';
                 $link_file = '/%file?repname=' . $request['repository'];
                 $link_diff = '/%file?repname=' . $request['repository'] . '&compare[]=/%file@%revno&compare[]=/%file@%oldrev';
                 $link_view = '/%file?repname=' . $request['repository'] . '&rev=%revno';
                 break;
             case 'loggerhead':
                 $base_url = $request['browser_url'];
                 $link_rev = '/revision/%revno';
                 $link_file = '/changes';
                 $link_diff = '/revision/%revno?compare_revid=%oldrev';
                 $link_view = '/annotate/head:/%file';
                 break;
             case 'gitweb':
                 $base_url = $request['browser_url'];
                 $link_rev = ';a=commitdiff;h=%revno';
                 $link_file = ';a=history;f=%file;hb=HEAD';
                 $link_diff = ';a=blobdiff;f=%file;hb=%revno;hpb=%oldrev';
                 $link_view = ';a=blob;f=%file;hb=%revno';
                 break;
             case 'cgit':
                 $base_url = $request['browser_url'];
                 $link_rev = '/commit/?id=%revno';
                 $link_file = '/log';
                 $link_diff = '/diff/%file?id=%revno?id2=%oldrev';
                 $link_view = '/tree/%file?id=%revno';
                 break;
             case 'hgweb':
                 $base_url = $request['browser_url'];
                 $link_rev = '/rev/%revno';
                 $link_file = '/log/tip/%file';
                 $link_diff = '/diff/%revno/%file';
                 $link_view = '/file/%revno/%file';
                 break;
             case 'github':
                 $base_url = $request['browser_url'];
                 $link_rev = '/commit/%revno';
                 $link_file = '/commits/%branch/%file';
                 $link_diff = '/commit/%revno';
                 $link_view = '/blob/%revno/%file';
                 break;
             case 'gitlab':
                 $base_url = $request['browser_url'];
                 $link_rev = '/commit/%revno';
                 $link_file = '/commits/%branch/%file';
                 $link_diff = '/commit/%revno';
                 $link_view = '/blob/%revno/%file';
                 break;
             case 'bitbucket':
                 $base_url = $request['browser_url'];
                 $link_rev = '/commits/%revno';
                 $link_file = '/history/%file';
                 $link_diff = '/commits/%revno#chg-%file';
                 $link_view = '/src/%revno/%file';
                 break;
             case 'gitorious':
                 $base_url = $request['browser_url'];
                 $link_rev = '/commit/%revno';
                 $link_file = '/blobs/history/%branch/%file';
                 $link_diff = '/commit/%revno';
                 $link_view = '/blobs/%revno/%file';
                 break;
             case 'rhodecode':
                 $base_url = $request['browser_url'];
                 $link_rev = '/changeset/%revno';
                 $link_file = '/changelog/%revno/%file';
                 $link_diff = '/diff/%file?diff2=%revno&diff1=%oldrev&fulldiff=1&diff=diff';
                 $link_view = '/files/%revno/%file';
                 break;
         }
         if ($request['browser_type'] != 'other') {
             framework\Context::getModule('vcs_integration')->saveSetting('browser_url_' . $project_id, $base_url);
             framework\Context::getModule('vcs_integration')->saveSetting('log_url_' . $project_id, $link_file);
             framework\Context::getModule('vcs_integration')->saveSetting('blob_url_' . $project_id, $link_view);
             framework\Context::getModule('vcs_integration')->saveSetting('diff_url_' . $project_id, $link_diff);
             framework\Context::getModule('vcs_integration')->saveSetting('commit_url_' . $project_id, $link_rev);
         }
         return $this->renderJSON(array('failed' => false, 'message' => framework\Context::getI18n()->__('Settings saved')));
     } else {
         $this->forward403();
     }
 }
 public function isValid(\thebuggenie\core\framework\Request $request)
 {
     if ($this->_target_value) {
         return true;
     }
     switch ($this->_action_type) {
         case self::ACTION_ASSIGN_ISSUE:
             return (bool) $request['assignee_type'] && $request['assignee_id'];
             break;
         case self::ACTION_SET_MILESTONE:
             return (bool) $request->hasParameter('milestone_id');
             break;
         case self::ACTION_SET_PRIORITY:
             return (bool) $request->hasParameter('priority_id');
             break;
         case self::ACTION_SET_STATUS:
             return (bool) $request->hasParameter('status_id');
             break;
         case self::ACTION_SET_REPRODUCABILITY:
             return (bool) $request->hasParameter('reproducability_id');
             break;
         case self::ACTION_SET_RESOLUTION:
             return (bool) $request->hasParameter('resolution_id');
             break;
         default:
             return true;
     }
 }
Пример #8
0
 /**
  * Save project settings
  *
  * @Route(url="/configure/project/:project_id/mailing", name="configure_settings")
  * @Parameters(config_module="core", section=15)
  * @param \thebuggenie\core\framework\Request $request
  * @return type
  */
 public function runConfigureProjectSettings(framework\Request $request)
 {
     $this->forward403unless($request->isPost());
     if ($this->access_level != framework\Settings::ACCESS_FULL) {
         $project_id = $request['project_id'];
         if (trim($request['mailing_from_address']) != '') {
             if (filter_var(trim($request['mailing_from_address']), FILTER_VALIDATE_EMAIL) !== false) {
                 framework\Context::getModule('mailing')->saveSetting(Mailing::SETTING_PROJECT_FROM_ADDRESS . $project_id, trim(mb_strtolower($request->getParameter('mailing_from_address'))));
                 if (trim($request['mailing_from_name']) !== '') {
                     framework\Context::getModule('mailing')->saveSetting(Mailing::SETTING_PROJECT_FROM_NAME . $project_id, trim($request->getParameter('mailing_from_name')));
                 } else {
                     framework\Context::getModule('mailing')->deleteSetting(Mailing::SETTING_PROJECT_FROM_NAME . $project_id);
                 }
             } else {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array('message' => framework\Context::getI18n()->__('Please enter a valid email address')));
             }
         } elseif (trim($request['mailing_from_address']) == '') {
             framework\Context::getModule('mailing')->deleteSetting(Mailing::SETTING_PROJECT_FROM_ADDRESS . $project_id);
             framework\Context::getModule('mailing')->deleteSetting(Mailing::SETTING_PROJECT_FROM_NAME . $project_id);
         }
         return $this->renderJSON(array('failed' => false, 'message' => framework\Context::getI18n()->__('Settings saved')));
     } else {
         $this->forward403();
     }
 }
 public function isValid(\thebuggenie\core\framework\Request $request)
 {
     if ($this->_target_value) {
         return true;
     }
     switch ($this->_action_type) {
         case self::ACTION_ASSIGN_ISSUE:
             return (bool) $request['assignee_type'] && $request['assignee_id'];
             break;
         case self::ACTION_SET_MILESTONE:
             return (bool) $request->hasParameter('milestone_id');
             break;
         case self::ACTION_SET_PRIORITY:
             return (bool) $request->hasParameter('priority_id');
             break;
         case self::ACTION_SET_STATUS:
             return (bool) $request->hasParameter('status_id') && ($status = Status::getB2DBTable()->selectById((int) $request->getParameter('status_id'))) instanceof Status && $status->canUserSet(framework\Context::getUser());
             break;
         case self::ACTION_SET_REPRODUCABILITY:
             return (bool) $request->hasParameter('reproducability_id');
             break;
         case self::ACTION_SET_RESOLUTION:
             return (bool) $request->hasParameter('resolution_id');
             break;
         default:
             return true;
     }
 }
Пример #10
0
 public function runUpgrade(framework\Request $request)
 {
     $version_info = explode(',', file_get_contents(THEBUGGENIE_PATH . 'installed'));
     $this->current_version = $version_info[0];
     $this->upgrade_available = $this->current_version != framework\Settings::getVersion(false);
     if ($this->upgrade_available) {
         $scope = new \thebuggenie\core\entities\Scope();
         $scope->setID(1);
         $scope->setEnabled();
         framework\Context::setScope($scope);
         if ($this->current_version == '3.2') {
             $this->statuses = \thebuggenie\core\entities\tables\ListTypes::getTable()->getStatusListForUpgrade();
             $this->adminusername = \thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable()->getAdminUsername();
         }
     }
     $this->upgrade_complete = false;
     if ($this->upgrade_available && $request->isPost()) {
         $this->upgrade_complete = false;
         switch ($this->current_version) {
             case '3.2':
                 $this->_upgradeFrom3dot2($request);
                 break;
             default:
                 $this->upgrade_complete = true;
         }
         if ($this->upgrade_complete) {
             $existing_installed_content = file_get_contents(THEBUGGENIE_PATH . 'installed');
             file_put_contents(THEBUGGENIE_PATH . 'installed', framework\Settings::getVersion(false, false) . ', upgraded ' . date('d.m.Y H:i') . "\n" . $existing_installed_content);
             $this->current_version = framework\Settings::getVersion(false, false);
             $this->upgrade_available = false;
         }
     } elseif ($this->upgrade_available) {
         $this->permissions_ok = false;
         if (is_writable(THEBUGGENIE_PATH . 'installed') && is_writable(THEBUGGENIE_PATH . 'upgrade')) {
             $this->permissions_ok = true;
         }
     } elseif ($this->upgrade_complete) {
         $this->forward(framework\Context::getRouting()->generate('home'));
     }
 }
Пример #11
0
 /**
  * Configuration import page
  *
  * @param framework\Request $request
  */
 public function runIndex(framework\Request $request)
 {
     if ($request->isPost()) {
         if ($request['import_sample_data']) {
             $transaction = \b2db\Core::startTransaction();
             $users = array();
             $user1 = new entities\User();
             $user1->setUsername('john');
             $user1->setPassword('john');
             $user1->setBuddyname('John');
             $user1->setRealname('John');
             $user1->setActivated();
             $user1->setEnabled();
             $user1->save();
             $users[] = $user1;
             $user2 = new entities\User();
             $user2->setUsername('jane');
             $user2->setPassword('jane');
             $user2->setBuddyname('Jane');
             $user2->setRealname('Jane');
             $user2->setActivated();
             $user2->setEnabled();
             $user2->save();
             $users[] = $user2;
             $user3 = new entities\User();
             $user3->setUsername('jackdaniels');
             $user3->setPassword('jackdaniels');
             $user3->setBuddyname('Jack');
             $user3->setRealname('Jack Daniels');
             $user3->setActivated();
             $user3->setEnabled();
             $user3->save();
             $users[] = $user3;
             $project1 = new entities\Project();
             $project1->setName('Sample project 1');
             $project1->setOwner($users[rand(0, 2)]);
             $project1->setLeader($users[rand(0, 2)]);
             $project1->setQaResponsible($users[rand(0, 2)]);
             $project1->setDescription('This is a sample project that is awesome. Try it out!');
             $project1->setHomepage('http://www.google.com');
             $project1->save();
             $project2 = new entities\Project();
             $project2->setName('Sample project 2');
             $project2->setOwner($users[rand(0, 2)]);
             $project2->setLeader($users[rand(0, 2)]);
             $project2->setQaResponsible($users[rand(0, 2)]);
             $project2->setDescription('This is the second sample project. Not as awesome as the first one, but still worth a try!');
             $project2->setHomepage('http://www.bing.com');
             $project2->save();
             foreach (array($project1, $project2) as $project) {
                 for ($cc = 1; $cc <= 5; $cc++) {
                     $milestone = new entities\Milestone();
                     $milestone->setName("Milestone {$cc}");
                     $milestone->setProject($project);
                     $milestone->setType(entities\Milestone::TYPE_REGULAR);
                     if ((bool) rand(0, 1)) {
                         $milestone->setScheduledDate(NOW + 100000 * (20 * $cc));
                     }
                     $milestone->save();
                 }
             }
             $p1_milestones = $project1->getMilestones();
             $p2_milestones = $project2->getMilestones();
             $issues = array();
             $priorities = entities\Priority::getAll();
             $categories = entities\Category::getAll();
             $severities = entities\Severity::getAll();
             $statuses = entities\Status::getAll();
             $reproducabilities = entities\Reproducability::getAll();
             $lorem_ipsum = \thebuggenie\modules\publish\entities\tables\Articles::getTable()->getArticleByName('LoremIpsum');
             $lorem_words = explode(' ', $lorem_ipsum->getContent());
             foreach (array('bugreport', 'featurerequest', 'enhancement', 'idea') as $issuetype) {
                 $issuetype = entities\Issuetype::getByKeyish($issuetype);
                 for ($cc = 1; $cc <= 10; $cc++) {
                     $issue1 = new entities\Issue();
                     $issue1->setProject($project1);
                     $issue1->setPostedBy($users[rand(0, 2)]);
                     $issue1->setPosted(NOW - 86400 * rand(1, 30));
                     $title_string = '';
                     $description_string = '';
                     $rand_length = rand(4, 15);
                     $ucnext = true;
                     for ($ll = 1; $ll <= $rand_length; $ll++) {
                         $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]);
                         $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : mb_strtolower($word);
                         $title_string .= $word;
                         $ucnext = false;
                         if ($ll == $rand_length || rand(1, 15) == 5) {
                             $title_string .= '.';
                             $ucnext = true;
                         }
                         $title_string .= ' ';
                     }
                     $rand_length = rand(40, 500);
                     $ucnext = true;
                     for ($ll = 1; $ll <= $rand_length; $ll++) {
                         $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]);
                         $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : mb_strtolower($word);
                         $description_string .= $word;
                         $ucnext = false;
                         if ($ll == $rand_length || rand(1, 15) == 5) {
                             $description_string .= '.';
                             $ucnext = true;
                             $description_string .= $ll != $rand_length && rand(1, 15) == 8 ? "\n\n" : ' ';
                         } else {
                             $description_string .= ' ';
                         }
                     }
                     $issue1->setTitle(ucfirst($title_string));
                     $issue1->setDescription($description_string);
                     $issue1->setIssuetype($issuetype);
                     $issue1->setMilestone($p1_milestones[array_rand($p1_milestones)]);
                     $issue1->setPriority($priorities[array_rand($priorities)]);
                     $issue1->setCategory($categories[array_rand($categories)]);
                     $issue1->setSeverity($severities[array_rand($severities)]);
                     $issue1->setReproducability($reproducabilities[array_rand($reproducabilities)]);
                     $issue1->setPercentCompleted(rand(0, 100));
                     $issue1->save();
                     $issue1->setStatus($statuses[array_rand($statuses)]);
                     if (rand(0, 1)) {
                         $issue1->setAssignee($users[array_rand($users)]);
                     }
                     $issue1->save();
                     $issues[] = $issue1;
                     $issue2 = new entities\Issue();
                     $issue2->setProject($project2);
                     $issue2->setPostedBy($users[rand(0, 2)]);
                     $issue2->setPosted(NOW - 86400 * rand(1, 30));
                     $title_string = '';
                     $description_string = '';
                     $rand_length = rand(4, 15);
                     $ucnext = true;
                     for ($ll = 1; $ll <= $rand_length; $ll++) {
                         $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]);
                         $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : mb_strtolower($word);
                         $title_string .= $word;
                         $ucnext = false;
                         if ($ll == $rand_length || rand(1, 15) == 5) {
                             $title_string .= '.';
                             $ucnext = true;
                         }
                         $title_string .= ' ';
                     }
                     $rand_length = rand(40, 500);
                     $ucnext = true;
                     for ($ll = 1; $ll <= $rand_length; $ll++) {
                         $word = str_replace(array(',', '.', "\r", "\n"), array('', '', '', ''), $lorem_words[array_rand($lorem_words)]);
                         $word = $ucnext || rand(1, 40) == 19 ? ucfirst($word) : mb_strtolower($word);
                         $description_string .= $word;
                         $ucnext = false;
                         if ($ll == $rand_length || rand(1, 15) == 5) {
                             $description_string .= '.';
                             $ucnext = true;
                             $description_string .= $ll != $rand_length && rand(1, 15) == 8 ? "\n\n" : ' ';
                         } else {
                             $description_string .= ' ';
                         }
                     }
                     $issue2->setTitle(ucfirst($title_string));
                     $issue2->setDescription($description_string);
                     $issue2->setIssuetype($issuetype);
                     $issue2->setMilestone($p2_milestones[array_rand($p2_milestones)]);
                     $issue2->setPriority($priorities[array_rand($priorities)]);
                     $issue2->setCategory($categories[array_rand($categories)]);
                     $issue2->setSeverity($severities[array_rand($severities)]);
                     $issue2->setReproducability($reproducabilities[array_rand($reproducabilities)]);
                     $issue2->setPercentCompleted(rand(0, 100));
                     if (rand(0, 1)) {
                         $issue1->setAssignee($users[array_rand($users)]);
                     }
                     $issue2->save();
                     $issue2->setStatus($statuses[array_rand($statuses)]);
                     $issue2->save();
                     $issues[] = $issue2;
                 }
             }
             $rand_issues_to_close = rand(8, 40);
             $resolutions = entities\Resolution::getAll();
             for ($cc = 1; $cc <= $rand_issues_to_close; $cc++) {
                 $issue = array_slice($issues, array_rand($issues), 1);
                 $issue = $issue[0];
                 $issue->setResolution($resolutions[array_rand($resolutions)]);
                 $issue->close();
                 $issue->save();
             }
             $this->imported_data = true;
             $roles = entities\Role::getAll();
             foreach (array($project1, $project2) as $project) {
                 foreach ($users as $user) {
                     $project->addAssignee($user, $roles[array_rand($roles)]);
                 }
             }
             $transaction->commitAndEnd();
         }
     }
     $project1 = entities\Project::getByKey('sampleproject1');
     $project2 = entities\Project::getByKey('sampleproject2');
     $this->canimport = !$project1 instanceof entities\Project && !$project2 instanceof entities\Project;
 }
<?php

$apc_enabled = \thebuggenie\core\framework\Request::CanGetUploadStatus();
?>
<div id="backdrop_detail_content" class="backdrop_detail_content">
    <div id="upload_forms">
        <form method="post" action="<?php 
echo $form_action;
?>
" enctype="multipart/form-data" id="uploader_upload_form" style="margin: 10px 0 0 5px;<?php 
if ($apc_enabled) {
    ?>
 display: none;<?php 
}
?>
">
            <input type="hidden" name ="MAX_FILE_SIZE" value="<?php 
echo \thebuggenie\core\framework\Settings::getUploadsEffectiveMaxSize(true);
?>
">
            <input type="hidden" name="APC_UPLOAD_PROGRESS" value="" />
            <div>
                <dl>
                    <dt style="width: 120px;"><label for="uploader_file"><?php 
echo __('Select a file');
?>
</label></dt>
                    <dd style="margin-bottom: 3px;"><input type="file" name="uploader_file" id="uploader_file"></dd>
                    <?php 
$max_filesize = \thebuggenie\core\framework\Settings::getUploadsEffectiveMaxSize();
if ($max_filesize != 0) {
Пример #13
0
 /**
  * @param framework\Request $request
  * @param                   $issue
  */
 protected function _unlockIssueAfter(framework\Request $request, $issue)
 {
     tables\Permissions::getTable()->deleteByPermissionTargetIDAndModule('canviewissue', $issue->getID());
     $al_users = $request->getParameter('access_list_users', array());
     $al_teams = $request->getParameter('access_list_teams', array());
     $i_al = $issue->getAccessList();
     foreach ($i_al as $k => $item) {
         if ($item['target'] instanceof entities\Team) {
             $tid = $item['target']->getID();
             if (array_key_exists($tid, $al_teams)) {
                 unset($i_al[$k]);
             }
         } elseif ($item['target'] instanceof entities\User) {
             $uid = $item['target']->getID();
             if (array_key_exists($uid, $al_users)) {
                 unset($i_al[$k]);
             }
         }
     }
     foreach ($al_users as $uid) {
         framework\Context::setPermission('canviewissue', $issue->getID(), 'core', $uid, 0, 0, true);
     }
     foreach ($al_teams as $tid) {
         framework\Context::setPermission('canviewissue', $issue->getID(), 'core', 0, 0, $tid, true);
     }
 }
Пример #14
0
 public function runResolve(framework\Request $request)
 {
     $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName();
     if ($request->hasParameter('css')) {
         $this->getResponse()->setContentType('text/css');
         if (!$request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css');
         } else {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css');
         }
     } elseif ($request->hasParameter('js')) {
         $this->getResponse()->setContentType('text/javascript');
         if ($request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js');
         } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
             $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js');
         } else {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js');
         }
     } else {
         throw new \Exception('The expected theme Asset type is not supported.');
     }
     $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath)));
     $fileAsset->load();
     // Do not decorate the asset with the theme's header/footer
     $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE);
     return $this->renderText($fileAsset->dump());
 }
Пример #15
0
 public function runAddFilter(framework\Request $request)
 {
     if ($request['filter_name'] == 'project_id' && count(entities\Project::getAll()) == 0) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => framework\Context::getI18n()->__('No projects exist so this filter can not be added')));
     } elseif (in_array($request['filter_name'], entities\SearchFilter::getValidSearchFilters()) || entities\CustomDatatype::doesKeyExist($request['filter_name'])) {
         return $this->renderJSON(array('content' => $this->getComponentHTML('search/filter', array('filter' => $request['filter_name'], 'key' => $request->getParameter('key', 0)))));
     } else {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => framework\Context::getI18n()->__('This is not a valid search field')));
     }
 }
Пример #16
0
 /**
  * Milestone actions
  *
  * @Route(url="/:project_key/milestone/:milestone_id/actions/*", name='project_milestone')
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runMilestone(framework\Request $request)
 {
     $milestone_id = $request['milestone_id'] ? $request['milestone_id'] : null;
     $milestone = new \thebuggenie\core\entities\Milestone($milestone_id);
     $action_option = str_replace($this->selected_project->getKey() . '/milestone/' . $request['milestone_id'] . '/', '', $request['url']);
     try {
         if (!($this->getUser()->canAddScrumSprints($this->selected_project) || $this->getUser()->canManageProjectReleases($this->selected_project) && $this->getUser()->canManageProject($this->selected_project))) {
             throw new \Exception($this->getI18n()->__("You don't have access to modify milestones"));
         }
         switch (true) {
             case $request->isDelete():
                 $milestone->delete();
                 $no_milestone = new \thebuggenie\core\entities\Milestone(0);
                 $no_milestone->setProject($milestone->getProject());
                 return $this->renderJSON(array('issue_count' => $no_milestone->countIssues(), 'hours' => $no_milestone->getHoursEstimated(), 'points' => $no_milestone->getPointsEstimated()));
             case $request->isPost():
                 $this->_saveMilestoneDetails($request, $milestone);
                 if ($request->hasParameter('issues') && $request['include_selected_issues']) {
                     \thebuggenie\core\entities\tables\Issues::getTable()->assignMilestoneIDbyIssueIDs($milestone->getID(), $request['issues']);
                 }
                 $event = \thebuggenie\core\framework\Event::createNew('project', 'runMilestone::post', $milestone);
                 $event->triggerUntilProcessed();
                 if ($event->isProcessed()) {
                     $component = $event->getReturnValue();
                 } else {
                     $component = $this->getComponentHTML('project/milestonebox', array('milestone' => $milestone));
                 }
                 $message = framework\Context::getI18n()->__('Milestone saved');
                 return $this->renderJSON(array('message' => $message, 'component' => $component, 'milestone_id' => $milestone->getID()));
             case $action_option == 'details':
                 \thebuggenie\core\framework\Context::performAction(new \thebuggenie\core\modules\project\controllers\Main(), 'project', 'MilestoneDetails');
                 return true;
             default:
                 return $this->forward($this->getRouting()->generate('project_roadmap', array('project_key' => $this->selected_project->getKey())));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Пример #17
0
 /**
  * Show an article
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runEditArticle(framework\Request $request)
 {
     if (!$this->article->canEdit()) {
         framework\Context::setMessage('publish_article_error', framework\Context::getI18n()->__('You do not have permission to edit this article'));
         $this->forward(framework\Context::getRouting()->generate('publish_article', array('article_name' => $this->article_name)));
     }
     $this->article_route = $this->article->getID() ? 'publish_article_edit' : 'publish_article_new';
     $this->article_route_params = $this->article->getID() ? array('article_name' => $this->article_name) : array();
     if ($request->isPost()) {
         $this->preview = (bool) $request['preview'];
         $this->change_reason = $request['change_reason'];
         try {
             $this->article->setArticleType($request['article_type']);
             $this->article->setName($request['new_article_name']);
             $this->article->setParentArticle(Articles::getTable()->getArticleByName($request['parent_article_name']));
             $this->article->setManualName($request['manual_name']);
             if ($this->article->getArticleType() == Article::TYPE_MANUAL && !$this->article->getName()) {
                 $article_name_prefix = $this->article->getParentArticle() instanceof Article ? $this->article->getParentArticle()->getName() . ':' : $request['parent_article_name'];
                 $this->article->setName(str_replace(' ', '', $article_name_prefix . $this->article->getManualName()));
             }
             $this->article->setContentSyntax($request['article_content_syntax']);
             $this->article->setContent($request->getRawParameter('article_content'));
             if (!$this->article->getName() || trim($this->article->getName()) == '' || !preg_match('/[\\w:]+/i', $this->article->getName())) {
                 throw new \Exception(framework\Context::getI18n()->__('You need to specify a valid article name'));
             }
             if ($request['article_type'] == Article::TYPE_MANUAL && (!$this->article->getManualName() || trim($this->article->getManualName()) == '' || !preg_match('/[\\w:]+/i', $this->article->getManualName()))) {
                 throw new \Exception(framework\Context::getI18n()->__('You need to specify a valid article name'));
             }
             if (!$this->preview && framework\Context::getModule('publish')->getSetting('require_change_reason') == 1 && (!$this->change_reason || trim($this->change_reason) == '')) {
                 throw new \Exception(framework\Context::getI18n()->__('You have to provide a reason for the changes'));
             }
             if ($this->article->getLastUpdatedDate() != $request['last_modified']) {
                 throw new \Exception(framework\Context::getI18n()->__('The file has been modified since you last opened it'));
             }
             if (($article = Article::getByName($request['new_new_article_name'])) && $article instanceof Article && $article->getID() != $request['article_id']) {
                 throw new \Exception(framework\Context::getI18n()->__('An article with that name already exists. Please choose a different article name'));
             }
             if (!$this->preview) {
                 $this->article->doSave(array(), $request['change_reason']);
                 framework\Context::setMessage('publish_article_message', framework\Context::getI18n()->__('The article was saved'));
                 $this->forward(framework\Context::getRouting()->generate('publish_article', array('article_name' => $this->article->getName())));
             }
         } catch (\Exception $e) {
             $this->error = $e->getMessage();
         }
     }
 }
Пример #18
0
 /**
  * Milestone actions
  *
  * @Route(url="/milestone/:milestone_id/*")
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runMilestone(framework\Request $request)
 {
     $milestone_id = $request['milestone_id'] ? $request['milestone_id'] : null;
     $milestone = new \thebuggenie\core\entities\Milestone($milestone_id);
     try {
         if (!$this->getUser()->canManageProject($this->selected_project) || !$this->getUser()->canManageProjectReleases($this->selected_project)) {
             throw new \Exception($this->getI18n()->__("You don't have access to modify milestones"));
         }
         switch (true) {
             case $request->isDelete():
                 $milestone->delete();
                 $no_milestone = new \thebuggenie\core\entities\Milestone(0);
                 $no_milestone->setProject($milestone->getProject());
                 return $this->renderJSON(array('issue_count' => $no_milestone->countIssues(), 'hours' => $no_milestone->getHoursEstimated(), 'points' => $no_milestone->getPointsEstimated()));
             case $request->isPost():
                 $this->_saveMilestoneDetails($request, $milestone);
                 $board = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
                 if ($request->hasParameter('issues') && $request['include_selected_issues']) {
                     \thebuggenie\core\entities\tables\Issues::getTable()->assignMilestoneIDbyIssueIDs($milestone->getID(), $request['issues']);
                 }
                 $message = framework\Context::getI18n()->__('Milestone saved');
                 return $this->renderJSON(array('message' => $message, 'component' => $this->getComponentHTML('agile/milestonebox', array('milestone' => $milestone, 'board' => $board)), 'milestone_id' => $milestone->getID()));
             default:
                 return $this->renderJSON(array('content' => framework\Action::returnComponentHTML('agile/milestonebox', array('milestone' => $milestone)), 'milestone_id' => $milestone->getID(), 'milestone_name' => $milestone->getName(), 'milestone_order' => array_keys($milestone->getProject()->getMilestonesForRoadmap())));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }
Пример #19
0
 public function runSiteIcons(framework\Request $request)
 {
     if ($this->getAccessLevel($request['section'], 'core') == framework\Settings::ACCESS_FULL) {
         if ($request->isPost()) {
             switch ($request['small_icon_action']) {
                 case 'upload_file':
                     $file = $request->handleUpload('small_icon');
                     framework\Settings::saveSetting(framework\Settings::SETTING_FAVICON_TYPE, framework\Settings::APPEARANCE_FAVICON_CUSTOM);
                     framework\Settings::saveSetting(framework\Settings::SETTING_FAVICON_ID, $file->getID());
                     break;
                 case 'clear_file':
                     framework\Settings::saveSetting(framework\Settings::SETTING_FAVICON_TYPE, framework\Settings::APPEARANCE_FAVICON_THEME);
                     break;
             }
             switch ($request['large_icon_action']) {
                 case 'upload_file':
                     $file = $request->handleUpload('large_icon');
                     framework\Settings::saveSetting(framework\Settings::SETTING_HEADER_ICON_TYPE, framework\Settings::APPEARANCE_HEADER_CUSTOM);
                     framework\Settings::saveSetting(framework\Settings::SETTING_HEADER_ICON_ID, $file->getID());
                     break;
                 case 'clear_file':
                     framework\Settings::saveSetting(framework\Settings::SETTING_HEADER_ICON_TYPE, framework\Settings::APPEARANCE_HEADER_THEME);
                     break;
             }
         }
         $route = framework\Context::getRouting()->generate('configure_settings');
         if ($request->isAjaxCall()) {
             return $this->renderJSON(array('forward' => $route));
         } else {
             $this->forward($route);
         }
     }
     return $this->forward403($this->getI18n()->__("You don't have access to perform this action"));
 }
Пример #20
0
 public function runResolve(framework\Request $request)
 {
     $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName();
     $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
     if ($request->hasParameter('css')) {
         $this->getResponse()->setContentType('text/css');
         if ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'css';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'css' . DS . $request->getParameter('css');
         } elseif (!$request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css');
         } else {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css');
         }
     } elseif ($request->hasParameter('js')) {
         $this->getResponse()->setContentType('text/javascript');
         if ($request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js');
         } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js');
         } else {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js');
         }
     } elseif ($request->hasParameter('image')) {
         $basepath = THEBUGGENIE_PATH . 'themes';
         $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'images';
         if (isset($request['module_name'])) {
             $asset .= DS . "modules" . DS . $request['module_name'];
         }
         if (isset($request['folder'])) {
             $asset .= DS . $request['folder'];
         }
         $asset .= DS . $request->getParameter('image');
         if (!file_exists($asset) && isset($request['module_name']) && framework\Context::isModuleLoaded($request['module_name'])) {
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'images';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'images';
             if (isset($request['folder'])) {
                 $asset .= DS . $request['folder'];
             }
             $asset .= DS . $request->getParameter('image');
         }
         $fileinfo = finfo_open(FILEINFO_MIME_TYPE);
         $mimetype = finfo_file($fileinfo, $asset);
         finfo_close($fileinfo);
         $this->getResponse()->setContentType($mimetype);
     } else {
         throw new \Exception('The expected theme Asset type is not supported.');
     }
     $last_modified = filemtime($asset);
     $this->getResponse()->addHeader('Cache-Control: max-age=3600, must-revalidate');
     $this->getResponse()->addHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s ', $last_modified) . 'GMT');
     $this->getResponse()->addHeader('ETag: ' . md5($last_modified));
     if (!$this->getResponse()->isModified($last_modified)) {
         return $this->return304();
     }
     $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath)));
     $fileAsset->load();
     // Do not decorate the asset with the theme's header/footer
     $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE);
     return $this->renderText($fileAsset->dump());
 }
Пример #21
0
 /**
  * Returns the logged in user, or default user if not logged in
  *
  * @param \thebuggenie\core\framework\Request $request
  * @param \thebuggenie\core\framework\Action  $action
  *
  * @return \thebuggenie\core\entities\User
  */
 public static function loginCheck(framework\Request $request, framework\Action $action)
 {
     try {
         $authentication_method = $action->getAuthenticationMethodForAction(framework\Context::getRouting()->getCurrentRouteAction());
         $user = null;
         $external = false;
         switch ($authentication_method) {
             case framework\Action::AUTHENTICATION_METHOD_ELEVATED:
             case framework\Action::AUTHENTICATION_METHOD_CORE:
                 $username = $request['tbg3_username'];
                 $password = $request['tbg3_password'];
                 if ($authentication_method == framework\Action::AUTHENTICATION_METHOD_ELEVATED) {
                     $elevated_password = $request['tbg3_elevated_password'];
                 }
                 $raw = true;
                 // If no username and password specified, check if we have a session that exists already
                 if ($username === null && $password === null) {
                     if (framework\Context::getRequest()->hasCookie('tbg3_username') && framework\Context::getRequest()->hasCookie('tbg3_password')) {
                         $username = framework\Context::getRequest()->getCookie('tbg3_username');
                         $password = framework\Context::getRequest()->getCookie('tbg3_password');
                         $user = self::getB2DBTable()->getByUsername($username);
                         if ($authentication_method == framework\Action::AUTHENTICATION_METHOD_ELEVATED) {
                             $elevated_password = framework\Context::getRequest()->getCookie('tbg3_elevated_password');
                             if ($user instanceof User && !$user->hasPasswordHash($password)) {
                                 $user = null;
                             } else {
                                 if ($user instanceof User && !$user->hasPasswordHash($elevated_password)) {
                                     framework\Context::setUser($user);
                                     framework\Context::getRouting()->setCurrentRouteName('elevated_login_page');
                                     throw new framework\exceptions\ElevatedLoginException('reenter');
                                 }
                             }
                         } else {
                             if ($user instanceof User && !$user->hasPasswordHash($password)) {
                                 $user = null;
                             }
                         }
                         if (!$user instanceof User) {
                             framework\Context::logout();
                             throw new \Exception('No such login');
                         }
                     }
                 }
                 // If we have authentication details, validate them
                 if (framework\Settings::isUsingExternalAuthenticationBackend() && $username !== null && $password !== null) {
                     $external = true;
                     framework\Logging::log('Authenticating with backend: ' . framework\Settings::getAuthenticationBackend(), 'auth', framework\Logging::LEVEL_INFO);
                     try {
                         $mod = framework\Context::getModule(framework\Settings::getAuthenticationBackend());
                         if ($mod->getType() !== Module::MODULE_AUTH) {
                             framework\Logging::log('Auth module is not the right type', 'auth', framework\Logging::LEVEL_FATAL);
                         }
                         if (framework\Context::getRequest()->hasCookie('tbg3_username') && framework\Context::getRequest()->hasCookie('tbg3_password')) {
                             $user = $mod->verifyLogin($username, $password);
                         } else {
                             $user = $mod->doLogin($username, $password);
                         }
                         if (!$user instanceof User) {
                             // Invalid
                             framework\Context::logout();
                             throw new \Exception('No such login');
                             //framework\Context::getResponse()->headerRedirect(framework\Context::getRouting()->generate('login'));
                         }
                     } catch (\Exception $e) {
                         throw $e;
                     }
                 } elseif (framework\Settings::isUsingExternalAuthenticationBackend()) {
                     $external = true;
                     framework\Logging::log('Authenticating without credentials with backend: ' . framework\Settings::getAuthenticationBackend(), 'auth', framework\Logging::LEVEL_INFO);
                     try {
                         $mod = framework\Context::getModule(framework\Settings::getAuthenticationBackend());
                         if ($mod->getType() !== Module::MODULE_AUTH) {
                             framework\Logging::log('Auth module is not the right type', 'auth', framework\Logging::LEVEL_FATAL);
                         }
                         $user = $mod->doAutoLogin();
                         if ($user == false) {
                             // Invalid
                             framework\Context::logout();
                             throw new \Exception('No such login');
                             //framework\Context::getResponse()->headerRedirect(framework\Context::getRouting()->generate('login'));
                         } else {
                             if ($user == true) {
                                 $user = null;
                             }
                         }
                     } catch (\Exception $e) {
                         throw $e;
                     }
                 } elseif ($username !== null && $password !== null && !$user instanceof User) {
                     $external = false;
                     framework\Logging::log('Using internal authentication', 'auth', framework\Logging::LEVEL_INFO);
                     $user = self::getB2DBTable()->getByUsername($username);
                     if ($user instanceof User && !$user->hasPassword($password)) {
                         $user = null;
                     }
                     if (!$user instanceof User) {
                         framework\Context::logout();
                     }
                 }
                 break;
             case framework\Action::AUTHENTICATION_METHOD_DUMMY:
                 $user = self::getB2DBTable()->getByUserID(framework\Settings::getDefaultUserID());
                 break;
             case framework\Action::AUTHENTICATION_METHOD_CLI:
                 $user = self::getB2DBTable()->getByUsername(framework\Context::getCurrentCLIusername());
                 break;
             case framework\Action::AUTHENTICATION_METHOD_RSS_KEY:
                 $user = self::getB2DBTable()->getByRssKey($request['rsskey']);
                 break;
             case framework\Action::AUTHENTICATION_METHOD_APPLICATION_PASSWORD:
                 $user = self::getB2DBTable()->getByUsername($request['api_username']);
                 if (!$user->authenticateApplicationPassword($request['api_token'])) {
                     $user = null;
                 }
                 break;
         }
         if ($user === null && !framework\Settings::isLoginRequired()) {
             $user = self::getB2DBTable()->getByUserID(framework\Settings::getDefaultUserID());
         }
         if ($user instanceof User) {
             if (!$user->isActivated()) {
                 throw new \Exception('This account has not been activated yet');
             } elseif (!$user->isEnabled()) {
                 throw new \Exception('This account has been suspended');
             } elseif (!$user->isConfirmedMemberOfScope(framework\Context::getScope())) {
                 if (!framework\Settings::isRegistrationAllowed()) {
                     throw new \Exception('This account does not have access to this scope');
                 }
             }
             if ($external == false && $authentication_method == framework\Action::AUTHENTICATION_METHOD_CORE) {
                 $password = $user->getHashPassword();
                 if (!$request->hasCookie('tbg3_username') && !$user->isGuest()) {
                     if ($request->getParameter('tbg3_rememberme')) {
                         framework\Context::getResponse()->setCookie('tbg3_username', $user->getUsername());
                         framework\Context::getResponse()->setCookie('tbg3_password', $user->getPassword());
                     } else {
                         framework\Context::getResponse()->setSessionCookie('tbg3_username', $user->getUsername());
                         framework\Context::getResponse()->setSessionCookie('tbg3_password', $user->getPassword());
                     }
                 }
             }
         } elseif (framework\Settings::isLoginRequired()) {
             throw new \Exception('Login required');
         } else {
             throw new \Exception('No such login');
         }
     } catch (\Exception $e) {
         throw $e;
     }
     return $user;
 }
Пример #22
0
 public function postConfigSettings(\thebuggenie\core\framework\Request $request)
 {
     if ($request->hasParameter('import_articles')) {
         $cc = 0;
         foreach ($request['import_article'] as $article_name => $import) {
             $cc++;
             Articles::getTable()->deleteArticleByName(urldecode($article_name));
             $content = file_get_contents(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'fixtures' . DS . $article_name);
             Article::createNew(urldecode($article_name), $content, null, array('overwrite' => true, 'noauthor' => true));
         }
         framework\Context::setMessage('module_message', framework\Context::getI18n()->__('%number_of_articles articles imported successfully', array('%number_of_articles' => $cc)));
     } else {
         $settings = array('allow_camelcase_links', 'menu_title', 'hide_wiki_links', 'free_edit', 'require_change_reason');
         foreach ($settings as $setting) {
             if ($request->hasParameter($setting)) {
                 $this->saveSetting($setting, $request->getParameter($setting));
             }
         }
     }
 }
Пример #23
0
 public function postConfigSettings(framework\Request $request)
 {
     framework\Context::loadLibrary('common');
     $settings = array('smtp_host', 'smtp_port', 'smtp_user', 'smtp_pwd', 'smtp_encryption', 'timeout', 'mail_type', 'enable_outgoing_notifications', 'cli_mailing_url', 'headcharset', 'from_name', 'from_addr', 'use_queue', 'activation_needed', 'sendmail_command');
     foreach ($settings as $setting) {
         if ($request->getParameter($setting) !== null || $setting == 'no_dash_f' || $setting == 'activation_needed') {
             $value = $request->getParameter($setting);
             switch ($setting) {
                 case 'smtp_host':
                     if ($request['mail_type'] == self::MAIL_TYPE_SMTP && !tbg_check_syntax($value, "MAILSERVER")) {
                         throw new \Exception(framework\Context::getI18n()->__('Please provide a valid setting for SMTP server address'));
                     }
                     break;
                 case 'from_addr':
                     if (!tbg_check_syntax($value, "EMAIL")) {
                         throw new \Exception(framework\Context::getI18n()->__('Please provide a valid setting for email "from"-address'));
                     }
                     break;
                 case 'timeout':
                     if ($request['mail_type'] == self::MAIL_TYPE_SMTP && !is_numeric($value) || $value < 0) {
                         throw new \Exception(framework\Context::getI18n()->__('Please provide a valid setting for SMTP server timeout'));
                     }
                     break;
                 case 'smtp_port':
                     if ($request['mail_type'] == self::MAIL_TYPE_SMTP && !is_numeric($value) || $value < 1) {
                         throw new \Exception(framework\Context::getI18n()->__('Please provide a valid setting for SMTP server port'));
                     }
                     break;
                 case 'headcharset':
                     // list of supported character sets based on PHP doc : http://www.php.net/manual/en/function.htmlentities.php
                     if (!tbg_check_syntax($value, "CHARSET")) {
                         throw new \Exception(framework\Context::getI18n()->__('Please provide a valid setting for email header charset'));
                     }
                     break;
                 case 'activation_needed':
                     $value = (int) $request->getParameter($setting, 0);
                     break;
                 case 'cli_mailing_url':
                     $value = $request->getParameter($setting);
                     if (substr($value, -1) == '/') {
                         $value = substr($value, 0, strlen($value) - 1);
                     }
                     break;
             }
             $this->saveSetting($setting, $value);
         }
     }
 }
Пример #24
0
 public function runProjectWorkflowTable(framework\Request $request)
 {
     $this->selected_project = entities\Project::getB2DBTable()->selectById($request['project_id']);
     if ($request->isPost()) {
         try {
             $workflow_scheme = entities\WorkflowScheme::getB2DBTable()->selectById($request['new_workflow']);
             return $this->renderJSON(array('content' => $this->getComponentHTML('projectworkflow_table', array('project' => $this->selected_project, 'new_workflow' => $workflow_scheme))));
         } catch (\Exception $e) {
             $this->getResponse()->setHTTPStatus(400);
             return $this->renderJSON(array('error' => framework\Context::geti18n()->__('This workflow scheme is not valid')));
         }
     }
 }
Пример #25
0
 public function setValuesFromRequest(\thebuggenie\core\framework\Request $request)
 {
     if ($request->hasParameter('predefined_search')) {
         $this->setPredefinedVariables($request['predefined_search']);
     } else {
         $this->_templatename = $request->hasParameter('template') && self::isTemplateValid($request['template']) ? $request['template'] : 'results_normal';
         $this->_templateparameter = $request['template_parameter'];
         $this->_issues_per_page = $request->getParameter('issues_per_page', 50);
         $this->_offset = $request->getParameter('offset', 0);
         if ($request['quicksearch']) {
             $this->setSortFields(array(tables\Issues::LAST_UPDATED => 'asc'));
         }
         $this->_filters = SearchFilter::getFromRequest($request, $this);
         $this->_applies_to_project = framework\Context::getCurrentProject();
         $this->_columns = $request->getParameter('columns');
         $this->_sortfields = $request->getParameter('sortfields');
         $this->_groupby = $request['groupby'];
         $this->_grouporder = $request->getParameter('grouporder', 'asc');
         if (in_array($this->_templatename, array('results_userpain_singlepainthreshold', 'results_userpain_totalpainthreshold'))) {
             $this->_searchtitle = framework\Context::getI18n()->__('Showing "bug report" issues sorted by user pain, threshold set at %threshold', array('%threshold' => $this->_templateparameter));
             $this->_issues_per_page = 0;
             $this->_groupby = 'user_pain';
             $this->_grouporder = 'desc';
             $this->_filters['issuetype'] = SearchFilter::createFilter('issuetype', array('operator' => '=', 'value' => join(',', tables\IssueTypes::getTable()->getBugReportTypeIDs())));
         } elseif ($this->_templatename == 'results_votes') {
             $this->_searchtitle = framework\Context::getI18n()->__('Showing issues ordered by number of votes');
             $this->_issues_per_page = $request->getParameter('issues_per_page', 100);
             $this->_groupby = 'votes';
             $this->_grouporder = 'desc';
         }
     }
     $this->_setupGenericFilters();
 }
Пример #26
0
 public function runFindArticles(framework\Request $request)
 {
     $this->articlename = $request->getRawParameter('articlename');
     if ($this->articlename) {
         list($this->resultcount, $this->articles) = Article::findArticlesByContentAndProject($this->articlename, framework\Context::getCurrentProject(), 10);
     }
 }