Exemplo n.º 1
0
 public static function loadFixtures(TBGScope $scope)
 {
     $scope_id = $scope->getID();
     $admin_group = new TBGGroup();
     $admin_group->setName('Administrators');
     $admin_group->setScope($scope);
     $admin_group->save();
     TBGSettings::saveSetting('admingroup', $admin_group->getID(), 'core', $scope_id);
     $user_group = new TBGGroup();
     $user_group->setName('Regular users');
     $user_group->setScope($scope);
     $user_group->save();
     TBGSettings::saveSetting('defaultgroup', $user_group->getID(), 'core', $scope_id);
     $guest_group = new TBGGroup();
     $guest_group->setName('Guests');
     $guest_group->setScope($scope);
     $guest_group->save();
     // Set up initial users, and their permissions
     if ($scope->isDefault()) {
         list($guestuser_id, $adminuser_id) = TBGUser::loadFixtures($scope, $admin_group, $user_group, $guest_group);
         TBGUserScopesTable::getTable()->addUserToScope($guestuser_id, $scope->getID(), $guest_group->getID(), true);
         TBGUserScopesTable::getTable()->addUserToScope($adminuser_id, $scope->getID(), $admin_group->getID(), true);
     } else {
         $default_scope_id = TBGSettings::getDefaultScopeID();
         $default_user_id = (int) TBGSettings::get(TBGSettings::SETTING_DEFAULT_USER_ID, 'core', $default_scope_id);
         TBGUserScopesTable::getTable()->addUserToScope($default_user_id, $scope->getID(), $user_group->getID(), true);
         TBGUserScopesTable::getTable()->addUserToScope(1, $scope->getID(), $admin_group->getID());
         TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_USER_ID, $default_user_id, 'core', $scope->getID());
     }
     TBGPermissionsTable::getTable()->loadFixtures($scope, $admin_group->getID(), $guest_group->getID());
 }
 public function loadFixtures(TBGScope $scope)
 {
     $i18n = TBGContext::getI18n();
     $crit = $this->getCriteria();
     $crit->addInsert(self::SCOPE, $scope->getID());
     $crit->addInsert(self::NAME, "Default workflow scheme");
     $crit->addInsert(self::DESCRIPTION, "This is the default workflow scheme. It is used by all projects with no specific workflow scheme selected. This scheme cannot be edited or removed.");
     $this->doInsert($crit);
 }
 public function loadFixtures(TBGScope $scope)
 {
     foreach (TBGIssueTypesTable::getTable()->getAllIDsByScopeID($scope->getID()) as $issuetype_id) {
         $crit = $this->getCriteria();
         $crit->addInsert(self::SCOPE, $scope->getID());
         $crit->addInsert(self::WORKFLOW_ID, TBGSettings::getCoreWorkflow()->getID());
         $crit->addInsert(self::WORKFLOW_SCHEME_ID, TBGSettings::getCoreWorkflowScheme()->getID());
         $crit->addInsert(self::ISSUETYPE_ID, $issuetype_id);
         $this->doInsert($crit);
     }
 }
Exemplo n.º 4
0
 public static function loadFixtures(TBGScope $scope)
 {
     $scope_id = $scope->getID();
     $bug_report = new TBGIssuetype();
     $bug_report->setName('Bug report');
     $bug_report->setIcon('bug_report');
     $bug_report->setScope($scope_id);
     $bug_report->setDescription('Have you discovered a bug in the application, or is something not working as expected?');
     $bug_report->save();
     TBGSettings::saveSetting('defaultissuetypefornewissues', $bug_report->getID(), 'core', $scope_id);
     TBGSettings::saveSetting('issuetype_bug_report', $bug_report->getID(), 'core', $scope_id);
     $feature_request = new TBGIssuetype();
     $feature_request->setName('Feature request');
     $feature_request->setIcon('feature_request');
     $feature_request->setDescription('Are you missing some specific feature, or is your favourite part of the application a bit lacking?');
     $feature_request->setScope($scope_id);
     $feature_request->save();
     TBGSettings::saveSetting('issuetype_feature_request', $feature_request->getID(), 'core', $scope_id);
     $enhancement = new TBGIssuetype();
     $enhancement->setName('Enhancement');
     $enhancement->setIcon('enhancement');
     $enhancement->setDescription('Have you found something that is working in a way that could be improved?');
     $enhancement->setScope($scope_id);
     $enhancement->save();
     TBGSettings::saveSetting('issuetype_enhancement', $enhancement->getID(), 'core', $scope_id);
     $task = new TBGIssuetype();
     $task->setName('Task');
     $task->setIcon('task');
     $task->setIsTask();
     $task->setScope($scope_id);
     $task->save();
     TBGSettings::saveSetting('issuetype_task', $task->getID(), 'core', $scope_id);
     $user_story = new TBGIssuetype();
     $user_story->setName('User story');
     $user_story->setIcon('developer_report');
     $user_story->setDescription('Doing it Agile-style. Issue type perfectly suited for entering user stories');
     $user_story->setScope($scope_id);
     $user_story->save();
     TBGSettings::saveSetting('issuetype_user_story', $user_story->getID(), 'core', $scope_id);
     $idea = new TBGIssuetype();
     $idea->setName('Idea');
     $idea->setIcon('idea');
     $idea->setDescription('Express yourself - share your ideas with the rest of the team!');
     $idea->setScope($scope_id);
     $idea->save();
     TBGSettings::saveSetting('issuetype_idea', $idea->getID(), 'core', $scope_id);
     return array($bug_report->getID(), $feature_request->getID(), $enhancement->getID(), $task->getID(), $user_story->getID(), $idea->getID());
 }
 public static function loadFixtures(TBGScope $scope)
 {
     $scheme = new TBGIssuetypeScheme();
     $scheme->setScope($scope->getID());
     $scheme->setName("Default issuetype scheme");
     $scheme->setDescription("This is the default issuetype scheme. It is used by all projects with no specific issuetype scheme selected. This scheme cannot be edited or removed.");
     $scheme->save();
     foreach (TBGIssuetype::getAll() as $issuetype) {
         $scheme->setIssuetypeEnabled($issuetype);
         if ($issuetype->getIcon() == 'developer_report') {
             $scheme->setIssuetypeRedirectedAfterReporting($issuetype, false);
         }
         if (in_array($issuetype->getIcon(), array('task', 'developer_report', 'idea'))) {
             $scheme->setIssuetypeReportable($issuetype, false);
         }
     }
     return $scheme;
 }
Exemplo n.º 6
0
 public static function loadFixtures(TBGScope $scope)
 {
     $available = new TBGUserstate();
     $available->setIsOnline();
     $available->setName('Available');
     $available->save();
     $offline = new TBGUserstate();
     $offline->setIsUnavailable();
     $offline->setName('Offline');
     $offline->save();
     $busy = new TBGUserstate();
     $busy->setIsUnavailable();
     $busy->setIsOnline();
     $busy->setName('Busy');
     $busy->save();
     $unavailable = new TBGUserstate();
     $unavailable->setIsUnavailable();
     $unavailable->setIsOnline();
     $unavailable->setName('Unavailable');
     $unavailable->save();
     $in_a_meeting = new TBGUserstate();
     $in_a_meeting->setIsUnavailable();
     $in_a_meeting->setIsInMeeting();
     $in_a_meeting->setName('In a meeting');
     $in_a_meeting->save();
     $coding = new TBGUserstate();
     $coding->setIsUnavailable();
     $coding->setIsBusy();
     $coding->setIsOnline();
     $coding->setName('Coding');
     $coding->save();
     $coffee = new TBGUserstate();
     $coffee->setIsUnavailable();
     $coffee->setIsBusy();
     $coffee->setIsOnline();
     $coffee->setName('On coffee break');
     $away = new TBGUserstate();
     $away->setIsUnavailable();
     $away->setIsOnline();
     $away->setIsBusy();
     $away->setIsAbsent();
     $away->setName('Away');
     $away->save();
     $vacation = new TBGUserstate();
     $vacation->setIsUnavailable();
     $vacation->setIsBusy();
     $vacation->setIsAbsent();
     $vacation->setName('On vacation');
     $vacation->save();
     TBGSettings::saveSetting(TBGSettings::SETTING_ONLINESTATE, $available->getID(), 'core', $scope->getID());
     TBGSettings::saveSetting(TBGSettings::SETTING_OFFLINESTATE, $offline->getID(), 'core', $scope->getID());
     TBGSettings::saveSetting(TBGSettings::SETTING_AWAYSTATE, $away->getID(), 'core', $scope->getID());
 }
Exemplo n.º 7
0
 public static function loadFixtures(TBGScope $scope)
 {
     $scope_id = $scope->getID();
     $admin_group = new TBGGroup();
     $admin_group->setName('Administrators');
     $admin_group->setScope($scope);
     $admin_group->save();
     TBGSettings::saveSetting('admingroup', $admin_group->getID(), 'core', $scope_id);
     $user_group = new TBGGroup();
     $user_group->setName('Regular users');
     $user_group->setScope($scope);
     $user_group->save();
     TBGSettings::saveSetting('defaultgroup', $user_group->getID(), 'core', $scope_id);
     $guest_group = new TBGGroup();
     $guest_group->setName('Guests');
     $guest_group->setScope($scope);
     $guest_group->save();
     // Set up initial users, and their permissions
     TBGUser::loadFixtures($scope, $admin_group, $user_group, $guest_group);
     TBGPermissionsTable::getTable()->loadFixtures($scope, $admin_group->getID(), $guest_group->getID());
 }
Exemplo n.º 8
0
 static function getAll()
 {
     if (self::$_scopes === null) {
         $res = TBGScopesTable::getTable()->doSelectAll();
         $scopes = array();
         while ($row = $res->getNextRow()) {
             $scope = TBGContext::factory()->TBGScope($row->get(TBGScopesTable::ID), $row);
             $scopes[$scope->getID()] = $scope;
         }
         self::$_scopes = $scopes;
     }
     return self::$_scopes;
 }
 public function loadFixtures(TBGScope $scope)
 {
     $steps = array();
     $steps[] = array('name' => 'New', 'description' => 'A new issue, not yet handled', 'status_id' => TBGStatus::getStatusByKeyish('new')->getID(), 'editable' => true, 'is_closed' => false);
     $steps[] = array('name' => 'Investigating', 'description' => 'An issue that is being investigated, looked into or is by other means between new and unconfirmed state', 'status_id' => TBGStatus::getStatusByKeyish('investigating')->getID(), 'editable' => true, 'is_closed' => false);
     $steps[] = array('name' => 'Confirmed', 'description' => 'An issue that has been confirmed', 'status_id' => TBGStatus::getStatusByKeyish('confirmed')->getID(), 'editable' => false, 'is_closed' => false);
     $steps[] = array('name' => 'In progress', 'description' => 'An issue that is being adressed', 'status_id' => TBGStatus::getStatusByKeyish('beingworkedon')->getID(), 'editable' => false, 'is_closed' => false);
     $steps[] = array('name' => 'Ready for testing', 'description' => 'An issue that has been marked fixed and is ready for testing', 'status_id' => TBGStatus::getStatusByKeyish('readyfortesting/qa')->getID(), 'editable' => false, 'is_closed' => false);
     $steps[] = array('name' => 'Testing', 'description' => 'An issue where the proposed or implemented solution is currently being tested or approved', 'status_id' => TBGStatus::getStatusByKeyish('testing/qa')->getID(), 'editable' => false, 'is_closed' => false);
     $steps[] = array('name' => 'Rejected', 'description' => 'A closed issue that has been rejected', 'status_id' => TBGStatus::getStatusByKeyish('notabug')->getID(), 'editable' => false, 'is_closed' => true);
     $steps[] = array('name' => 'Closed', 'description' => 'A closed issue', 'status_id' => null, 'editable' => false, 'is_closed' => true);
     foreach ($steps as $step) {
         $crit = $this->getCriteria();
         $crit->addInsert(self::WORKFLOW_ID, 1);
         $crit->addInsert(self::SCOPE, $scope->getID());
         $crit->addInsert(self::NAME, $step['name']);
         $crit->addInsert(self::DESCRIPTION, $step['description']);
         $crit->addInsert(self::STATUS_ID, $step['status_id']);
         $crit->addInsert(self::CLOSED, $step['is_closed']);
         $crit->addInsert(self::EDITABLE, $step['editable']);
         $this->doInsert($crit);
     }
 }
Exemplo n.º 10
0
 public function do_execute()
 {
     $scopes = TBGScope::getAll();
     $this->cliEcho("The ID for the default scope has an asterisk next to it\n\n");
     $this->cliEcho("ID", 'white', 'bold');
     $this->cliEcho(" - hostname(s)\n", 'white', 'bold');
     foreach ($scopes as $scope_id => $scope) {
         $this->cliEcho($scope_id, 'white', 'bold');
         if ($scope->isDefault()) {
             $this->cliEcho('*', 'white', 'bold');
             $this->cliEcho(" - all unspecified hostnames\n");
         } else {
             $this->cliEcho(" - " . join(', ', $scope->getHostnames()) . "\n");
         }
     }
     $this->cliEcho("\n");
 }
Exemplo n.º 11
0
 public function runScopes(TBGRequest $request)
 {
     if ($request->isMethod(TBGRequest::POST)) {
         $hostname = $request->getParameter('hostname');
         $scopename = $request->getParameter('name');
         if (!$hostname || TBGScopesTable::getTable()->getByHostname($hostname) instanceof TBGScope) {
             $this->scope_hostname_error = true;
         } elseif (!$scopename) {
             $this->scope_name_error = true;
         } else {
             $scope = new TBGScope();
             $scope->addHostname($hostname);
             $scope->setName($scopename);
             $scope->setEnabled();
             $scope->save();
             $this->forward(TBGContext::getRouting()->generate('configure_scopes'));
         }
     }
     $this->scope_deleted = TBGContext::getMessageAndClear('scope_deleted');
     $this->scopes = TBGScope::getAll();
 }
Exemplo n.º 12
0
 public function runScopes(TBGRequest $request)
 {
     if ($request->isPost()) {
         $hostname = $request['hostname'];
         $hostname = str_replace(array('http://', 'https://'), array('', ''), $hostname);
         $scopename = $request['name'];
         if (!$hostname || TBGScopesTable::getTable()->getByHostname($hostname) instanceof TBGScope) {
             $this->scope_hostname_error = true;
         } elseif (!$scopename) {
             $this->scope_name_error = true;
         } else {
             $scope = new TBGScope();
             $scope->addHostname($hostname);
             $scope->setName($scopename);
             $scope->setEnabled();
             $scope->save();
             $this->forward(TBGContext::getRouting()->generate('configure_scopes'));
         }
     }
     $this->scope_deleted = TBGContext::getMessageAndClear('scope_deleted');
     $this->scopes = TBGScope::getAll();
 }
 public function loadFixtures(TBGScope $scope)
 {
     $i18n = TBGContext::getI18n();
     $settings = array();
     $settings[TBGSettings::SETTING_THEME_NAME] = 'oxygen';
     $settings[TBGSettings::SETTING_REQUIRE_LOGIN] = 0;
     $settings[TBGSettings::SETTING_DEFAULT_USER_IS_GUEST] = 1;
     $settings[TBGSettings::SETTING_ALLOW_REGISTRATION] = 1;
     $settings[TBGSettings::SETTING_RETURN_FROM_LOGIN] = 'referer';
     $settings[TBGSettings::SETTING_RETURN_FROM_LOGOUT] = 'home';
     $settings[TBGSettings::SETTING_SHOW_PROJECTS_OVERVIEW] = 1;
     $settings[TBGSettings::SETTING_ALLOW_USER_THEMES] = 0;
     $settings[TBGSettings::SETTING_ENABLE_UPLOADS] = 0;
     $settings[TBGSettings::SETTING_ENABLE_GRAVATARS] = 1;
     $settings[TBGSettings::SETTING_UPLOAD_RESTRICTION_MODE] = 'blacklist';
     $settings[TBGSettings::SETTING_UPLOAD_EXTENSIONS_LIST] = 'exe,bat,php,asp,jsp';
     $settings[TBGSettings::SETTING_UPLOAD_STORAGE] = 'files';
     $settings[TBGSettings::SETTING_UPLOAD_LOCAL_PATH] = THEBUGGENIE_PATH . 'files/';
     $settings[TBGSettings::SETTING_TBG_NAME] = 'The Bug Genie';
     $settings[TBGSettings::SETTING_TBG_TAGLINE] = '<b>Friendly</b> issue tracking and project management';
     $settings[TBGSettings::SETTING_SYNTAX_HIGHLIGHT_DEFAULT_LANGUAGE] = 'html4strict';
     $settings[TBGSettings::SETTING_SYNTAX_HIGHLIGHT_DEFAULT_NUMBERING] = '3';
     $settings[TBGSettings::SETTING_SYNTAX_HIGHLIGHT_DEFAULT_INTERVAL] = '10';
     $settings[TBGSettings::SETTING_SALT] = sha1(time() . mt_rand(1000, 10000));
     $scope_id = $scope->getID();
     foreach ($settings as $settings_name => $settings_val) {
         $this->saveSetting($settings_name, 'core', $settings_val, 0, $scope_id);
     }
 }
Exemplo n.º 14
0
 /**
  * Return all available scopes
  * 
  * @return array|TBGScope
  */
 static function getAll()
 {
     if (self::$_scopes === null) {
         self::$_scopes = TBGScopesTable::getTable()->selectAll();
     }
     return self::$_scopes;
 }
Exemplo n.º 15
0
 public function isMemberOfScope(TBGScope $scope)
 {
     return array_key_exists($scope->getID(), $this->getScopes());
 }
Exemplo n.º 16
0
 public function runUpgrade(TBGRequest $request)
 {
     $version_info = explode(',', file_get_contents(THEBUGGENIE_PATH . 'installed'));
     $this->current_version = $version_info[0];
     $this->upgrade_available = $this->current_version != '3.1';
     if ($this->upgrade_available) {
         $scope = new TBGScope();
         $scope->setID(1);
         $scope->setEnabled();
         TBGContext::setScope($scope);
     }
     $this->upgrade_complete = false;
     if ($this->upgrade_available && $request->isMethod(TBGRequest::POST)) {
         $this->upgrade_complete = false;
         switch ($this->current_version) {
             case '3.0':
                 $this->_upgradeFrom3dot0();
                 break;
         }
         if ($this->upgrade_complete) {
             $existing_installed_content = file_get_contents(THEBUGGENIE_PATH . 'installed');
             file_put_contents(THEBUGGENIE_PATH . 'installed', TBGSettings::getVersion(false, false) . ', upgraded ' . date('d.m.Y H:i') . "\n" . $existing_installed_content);
             unlink(THEBUGGENIE_PATH . 'upgrade');
             $this->current_version = '3.1';
             $this->upgrade_available = false;
         }
     } elseif ($this->current_version != '3.1') {
         $this->permissions_ok = false;
         if (is_writable(THEBUGGENIE_PATH . 'installed') && is_writable(THEBUGGENIE_PATH . 'upgrade')) {
             $this->permissions_ok = true;
         }
     } else {
         $this->forward(TBGContext::getRouting()->generate('home'));
     }
 }
Exemplo n.º 17
0
 public function componentUserscopes()
 {
     $this->scopes = TBGScope::getAll();
 }
Exemplo n.º 18
0
 public function loadFixtures(TBGScope $scope)
 {
     $scope_id = $scope->getID();
     $this->addMainMenuLink('http://www.thebuggenie.com', 'The Bug Genie homepage', 1, $scope_id);
     $this->addMainMenuLink('http://forum.thebuggenie.com', 'The Bug Genie forums', 2, $scope_id);
     $this->addMainMenuLink(null, null, 3, $scope_id);
     $this->addMainMenuLink('http://issues.thebuggenie.com', 'Online issue tracker', 4, $scope_id);
     $this->addMainMenuLink('', "''This is the issue tracker for The Bug Genie''", 5, $scope_id);
     $this->addMainMenuLink(null, null, 6, $scope_id);
     $this->addMainMenuLink('http://thebuggenie.wordpress.com/', 'The Bug Genie team blog', 7, $scope_id);
     $this->addMainMenuLink('', "''Stay up to date on the latest development''", 8, $scope_id);
 }
 public function do_execute()
 {
     if (file_exists(THEBUGGENIE_PATH . 'installed')) {
         $this->cliEcho("The Bug Genie seems to already be installed.\n", 'red', 'bold');
         $this->cliEcho('Please remove the file ');
         $this->cliEcho(THEBUGGENIE_PATH . 'installed', 'white', 'bold');
         $this->cliEcho(' and try again.');
         $this->cliEcho("\n");
         return;
     }
     $this->cliEcho("\nWelcome to the \"The Bug Genie\" installation wizard!\n", 'white', 'bold');
     $this->cliEcho("This wizard will take you through the installation of The Bug Genie.\nRemember that you can also install The Bug Genie from your web-browser.\n");
     $this->cliEcho("Simply point your web-browser to the The Bug Genie subdirectory on your web server,\nand the installation will start.\n\n");
     $this->cliEcho("Press ENTER to continue with the installation: ");
     $this->pressEnterToContinue();
     $this->cliEcho("\n");
     $this->cliEcho("How to support future development\n", 'green', 'bold');
     $this->cliEcho("Even though this software has been provided to you free of charge,\ndeveloping it would not have been possible without support from our users.\n");
     $this->cliEcho("By making a donation, or buying a support contract you can help us continue development.\n\n");
     $this->cliEcho("If this software is valuable to you - please consider supporting it.\n\n");
     $this->cliEcho("More information about supporting The Bug Genie's development can be found here:\n");
     $this->cliEcho("http://www.thebuggenie.com/giving_back.php\n\n", 'blue', 'underline');
     $this->cliEcho("Press ENTER to continue: ");
     $this->pressEnterToContinue();
     $this->cliEcho("\n");
     try {
         $this->cliEcho("License information\n", 'green', 'bold');
         $this->cliEcho("This software is Open Source Initiative approved Open Source Software.\nOpen Source Initiative Approved is a trademark of the Open Source Initiative.\n\n");
         $this->cliEcho("True to the the Open Source Definition, The Bug Genie is released\nunder the MPL 1.1 only. You can read the full license here:\n");
         $this->cliEcho("http://www.opensource.org/licenses/mozilla1.1.php\n\n", 'blue', 'underline');
         if ($this->getProvidedArgument('accept_license') != 'yes') {
             $this->cliEcho("Before you can continue the installation, you need to confirm that you \nagree to be bound by the terms in this license.\n\n");
             $this->cliEcho("Do you agree to be bound by the terms in the MPL 1.1 license?\n(type \"yes\" to agree, anything else aborts the installation): ");
             if (!$this->askToAccept()) {
                 throw new Exception($this->cliEcho('You need to accept the license to continue', 'red', 'bold'));
             }
         } else {
             $this->cliEcho('You have accepted the license', 'yellow', 'bold');
             $this->cliEcho("\n\n");
         }
         $not_well = array();
         if (!is_writable('core/B2DB/')) {
             $not_well[] = 'b2db_perm';
         }
         if (!is_writable(THEBUGGENIE_PATH)) {
             $not_well[] = 'root';
         }
         if (count($not_well) > 0) {
             $this->cliEcho("\n");
             foreach ($not_well as $afail) {
                 switch ($afail) {
                     case 'b2db_perm':
                         $this->cliEcho("Could not write to the B2DB directory\n", 'red', 'bold');
                         $this->cliEcho('The folder ');
                         $this->cliEcho('include/B2DB', 'white', 'bold');
                         $this->cliEcho(' folder needs to be writable');
                         break;
                     case 'root':
                         $this->cliEcho("Could not write to the main directory\n", 'red', 'bold');
                         $this->cliEcho('The top level folder must be writable during installation');
                         break;
                 }
             }
             throw new Exception("\n\nYou need to correct the above errors before the installation can continue.");
         } else {
             $this->cliEcho("Step 1 - database information\n");
             if (file_exists('core/b2db_bootstrap.inc.php')) {
                 $this->cliEcho("You seem to already have completed this step successfully.\n");
                 if ($this->getProvidedArgument('use_existing_db_info') == 'yes') {
                     $this->cliEcho("\n");
                     $this->cliEcho("Using existing database information\n", 'yellow', 'bold');
                     $use_existing_db_info = true;
                 } else {
                     $this->cliEcho("Do you want to use the stored settings?\n", 'white', 'bold');
                     $this->cliEcho("\nType \"no\" to enter new settings, press ENTER to use existing: ", 'white', 'bold');
                     $use_existing_db_info = $this->askToDecline();
                 }
                 $this->cliEcho("\n");
             } else {
                 $use_existing_db_info = false;
             }
             if (!$use_existing_db_info) {
                 $this->cliEcho("The Bug Genie uses a database to store information. To be able to connect\nto your database, The Bug Genie needs some information, such as\ndatabase type, username, password, etc.\n\n");
                 $this->cliEcho("Please select what kind of database you are installing The Bug Genie on:\n");
                 B2DB::setHTMLException(false);
                 $db_types = array();
                 foreach (B2DB::getDBtypes() as $db_type => $db_desc) {
                     $db_types[] = $db_type;
                     $this->cliEcho(count($db_types) . ': ' . $db_desc . "\n", 'white', 'bold');
                 }
                 do {
                     $this->cliEcho('Enter the corresponding number for the database (1-' . count($db_types) . '): ');
                     $db_selection = $this->getInput();
                     if (!isset($db_types[(int) $db_selection - 1])) {
                         throw new Exception($db_selection . ' is not a valid database type selection');
                     }
                     $db_type = $db_types[(int) $db_selection - 1];
                     $this->cliEcho("Selected database type: ");
                     $this->cliEcho($db_type . "\n\n");
                     $this->cliEcho("Please enter the database hostname: \n");
                     $this->cliEcho('Database hostname [localhost]: ', 'white', 'bold');
                     $db_hostname = $this->getInput();
                     $db_hostname = $db_hostname == '' ? 'localhost' : $db_hostname;
                     $this->cliEcho("\nPlease enter the username The Bug Genie will use to connect to the database: \n");
                     $this->cliEcho('Database username: '******'white', 'bold');
                     $db_username = $this->getInput();
                     $this->cliEcho("Database password (press ENTER if blank): ", 'white', 'bold');
                     $db_password = $this->getInput();
                     $this->cliEcho("\nPlease enter the database The Bug Genie will use.\nIf it does not exist, The Bug Genie will create it for you.\n(the default database name is ");
                     $this->cliEcho("thebuggenie_db", 'white', 'bold');
                     $this->cliEcho(" - press ENTER to use that):\n");
                     $this->cliEcho('Database name: ', 'white', 'bold');
                     $db_name = $this->getInput('thebuggenie_db');
                     $this->cliEcho("\n");
                     $this->cliEcho("The following settings will be used:\n");
                     $this->cliEcho("Database type: \t\t", 'white', 'bold');
                     $this->cliEcho($db_type . "\n");
                     $this->cliEcho("Database hostname: \t", 'white', 'bold');
                     $this->cliEcho($db_hostname . "\n");
                     $this->cliEcho("Database username: \t", 'white', 'bold');
                     $this->cliEcho($db_username . "\n");
                     $this->cliEcho("Database password: \t", 'white', 'bold');
                     $this->cliEcho($db_password . "\n");
                     $this->cliEcho("Database name: \t\t", 'white', 'bold');
                     $this->cliEcho($db_name . "\n");
                     $this->cliEcho("\nIf these settings are ok, press ENTER, or anything else to retry: ");
                     $e_ok = $this->askToDecline();
                 } while (!$e_ok);
                 try {
                     B2DB::setHost($db_hostname);
                     B2DB::setUname($db_username);
                     B2DB::setPasswd($db_password);
                     B2DB::setDBtype($db_type);
                     B2DB::initialize();
                     $engine_path = B2DB::getEngineClassPath();
                     if ($engine_path !== null) {
                         TBGContext::addClasspath($engine_path);
                     } else {
                         throw new Exception("Cannot initialize the B2DB engine");
                     }
                     B2DB::doConnect();
                     B2DB::createDatabase($db_name);
                     B2DB::setDBname($db_name);
                     B2DB::doConnect();
                 } catch (Exception $e) {
                     throw new Exception("Could not connect to the database:\n" . $e->getMessage());
                 }
                 B2DB::setDBname($db_name);
                 B2DB::doSelectDB();
                 $this->cliEcho("\nSuccessfully connected to the database.\n", 'green');
                 $this->cliEcho("Press ENTER to continue ... ");
                 $this->pressEnterToContinue();
                 $this->cliEcho("\n");
                 $this->cliEcho("Saving database connection information ... ", 'white', 'bold');
                 $this->cliEcho("\n");
                 B2DB::saveConnectionParameters(THEBUGGENIE_CORE_PATH . 'b2db_bootstrap.inc.php');
                 $this->cliEcho("Successfully saved database connection information.\n", 'green');
                 $this->cliEcho("\n");
             } else {
                 B2DB::initialize(THEBUGGENIE_CORE_PATH . 'b2db_bootstrap.inc.php');
                 $this->cliEcho("Successfully connected to the database.\n", 'green');
                 if ($this->getProvidedArgument('use_existing_db_info') != 'yes') {
                     $this->cliEcho("Press ENTER to continue ... ");
                     $this->pressEnterToContinue();
                 }
             }
             $this->cliEcho("\nThe Bug Genie needs some server settings to function properly...\n\n");
             do {
                 $this->cliEcho("URL rewriting\n", 'cyan', 'bold');
                 $this->cliEcho("The Bug Genie uses a technique called \"url rewriting\" - which allows for pretty\nURLs such as ") . $this->cliEcho('/issue/1', 'white', 'bold') . $this->cliEcho(' instead of ') . $this->cliEcho("viewissue.php?issue_id=1\n", 'white', 'bold');
                 $this->cliEcho("Make sure you have read the URL_REWRITE document located in the root\nfolder, or at http://www.thebuggenie.com before you continue\n");
                 if (!$this->hasProvidedArgument('url_subdir')) {
                     $this->cliEcho("Press ENTER to continue ... ");
                     $this->pressEnterToContinue();
                 }
                 $this->cliEcho("\n");
                 $this->cliEcho("The Bug Genie subdir\n", 'white', 'bold');
                 $this->cliEcho("This is the sub-path of the Web server where The Bug Genie will be located.\n");
                 if ($this->hasProvidedArgument('url_subdir')) {
                     $this->cliEcho('The Bug Genie subdir: ', 'white', 'bold');
                     $url_subdir = $this->getProvidedArgument('url_subdir');
                     $this->cliEcho($url_subdir, 'yellow', 'bold');
                     $this->cliEcho("\n");
                 } else {
                     $this->cliEcho('Start and end this with a forward slash', 'white', 'bold');
                     $this->cliEcho(". (ex: \"/thebuggenie/\")\nIf The Bug Genie is running at the root directory, just type \"/\" (without the quotes)\n\n");
                     $this->cliEcho('The Bug Genie subdir: ', 'white', 'bold');
                     $url_subdir = $this->getInput();
                 }
                 $this->cliEcho("\n");
                 $this->cliEcho("The Bug Genie will now be accessible at\n");
                 $this->cliEcho("http://example.com" . $url_subdir, 'white', 'bold');
                 if ($this->hasProvidedArgument('url_subdir')) {
                     $this->cliEcho("\n");
                     $this->cliEcho("Using existing values", 'yellow', 'bold');
                     $this->cliEcho("\n");
                     $e_ok = true;
                 } else {
                     $this->cliEcho("\nPress ENTER if ok, or \"no\" to try again: ");
                     $e_ok = $this->askToDecline();
                 }
                 $this->cliEcho("\n");
             } while (!$e_ok);
             if ($this->getProvidedArgument('setup_htaccess') != 'yes') {
                 $this->cliEcho("Setup can autoconfigure your .htaccess file (located in the thebuggenie/ subfolder), so you don't have to.\n");
                 $this->cliEcho('Would you like setup to auto-generate the .htaccess file for you?');
                 $this->cliEcho("\nPress ENTER if ok, or \"no\" to not set up the .htaccess file: ");
                 $htaccess_ok = $this->askToDecline();
             } else {
                 $this->cliEcho('Autoconfiguring .htaccess', 'yellow', 'bold');
                 $this->cliEcho("\n");
                 $htaccess_ok = true;
             }
             $this->cliEcho("\n");
             if ($htaccess_ok) {
                 if (!is_writable(THEBUGGENIE_PATH . 'thebuggenie/') || file_exists(THEBUGGENIE_PATH . 'thebuggenie/.htaccess') && !is_writable(THEBUGGENIE_PATH . 'thebuggenie/.htaccess')) {
                     $this->cliEcho("Permission denied when trying to save the [main folder]/thebuggenie/.htaccess\n", 'red', 'bold');
                     $this->cliEcho("You will have to set up the .htaccess file yourself. See the README file for more information.\n", 'white', 'bold');
                     $this->cliEcho('Please note: ', 'white', 'bold');
                     $this->cliEcho("The Bug Genie will not function properly until the .htaccess file is properly set up!\n");
                 } else {
                     $content = str_replace('###PUT URL SUBDIRECTORY HERE###', $url_subdir, file_get_contents(THEBUGGENIE_CORE_PATH . 'templates/htaccess.template'));
                     file_put_contents(THEBUGGENIE_PATH . 'thebuggenie/.htaccess', $content);
                     if (file_get_contents(THEBUGGENIE_PATH . 'thebuggenie/.htaccess') != $content) {
                         $this->cliEcho("Permission denied when trying to save the [main folder]/thebuggenie/.htaccess\n", 'red', 'bold');
                         $this->cliEcho("You will have to set up the .htaccess file yourself. See the README file for more information.\n", 'white', 'bold');
                         $this->cliEcho('Please note: ', 'white', 'bold');
                         $this->cliEcho("The Bug Genie will not function properly until the .htaccess file is properly set up!\n");
                     } else {
                         $this->cliEcho("The .htaccess file was successfully set up...\n", 'green', 'bold');
                     }
                 }
             } else {
                 $this->cliEcho("Skipping .htaccess auto-setup.");
             }
             if ($this->getProvidedArgument('setup_htaccess') != 'yes') {
                 $this->cliEcho("Press ENTER to continue ... ");
                 $this->pressEnterToContinue();
                 $this->cliEcho("\n");
             }
             $enable_modules = array();
             if ($this->getProvidedArgument('enable_all_modules') != 'yes') {
                 $this->cliEcho("You will now get a list of available modules.\nTo enable the module after installation, just press ENTER.\nIf you don't want to enable the module, type \"no\".\nRemember that all these modules can be disabled/uninstalled after installation.\n\n");
             }
             $this->cliEcho("Enable incoming and outgoing email? ", 'white', 'bold') . $this->cliEcho('(yes): ');
             $enable_modules['mailing'] = $this->getProvidedArgument('enable_all_modules') == 'yes' ? true : $this->askToDecline();
             if ($this->getProvidedArgument('enable_all_modules') == 'yes') {
                 $this->cliEcho("Yes\n", 'yellow', 'bold');
             }
             $this->cliEcho("Enable communication with version control systems (i.e. svn)? ", 'white', 'bold') . $this->cliEcho('(yes): ');
             $enable_modules['vcs_integration'] = $this->getProvidedArgument('enable_all_modules') == 'yes' ? true : $this->askToDecline();
             if ($this->getProvidedArgument('enable_all_modules') == 'yes') {
                 $this->cliEcho("Yes\n", 'yellow', 'bold');
             }
             $enable_modules['publish'] = true;
             $this->cliEcho("\n");
             $this->cliEcho("Creating tables ...\n", 'white', 'bold');
             $tables_path = THEBUGGENIE_CORE_PATH . 'classes' . DIRECTORY_SEPARATOR . 'B2DB' . DIRECTORY_SEPARATOR;
             TBGContext::addClasspath($tables_path);
             $tables_path_handle = opendir($tables_path);
             $tables_created = array();
             while ($table_class_file = readdir($tables_path_handle)) {
                 if (($tablename = substr($table_class_file, 0, strpos($table_class_file, '.'))) != '') {
                     B2DB::getTable($tablename)->create();
                     $this->cliEcho("Creating table {$tablename}\n", 'white', 'bold');
                 }
             }
             $this->cliEcho("\n");
             $this->cliEcho("All tables successfully created...\n\n", 'green', 'bold');
             $this->cliEcho("Setting up initial scope... \n", 'white', 'bold');
             TBGContext::reinitializeI18n('en_US');
             $scope = new TBGScope();
             $scope->setName('The default scope');
             $scope->addHostname('*');
             $scope->setEnabled();
             TBGContext::setScope($scope);
             $scope->save();
             TBGSettings::saveSetting('language', 'en_US');
             $this->cliEcho("Initial scope setup successfully... \n\n", 'green', 'bold');
             $this->cliEcho("Setting up modules... \n", 'white', 'bold');
             try {
                 foreach ($enable_modules as $module => $install) {
                     if ((bool) $install && file_exists(THEBUGGENIE_MODULES_PATH . $module . DS . 'module')) {
                         $this->cliEcho("Installing {$module}... \n");
                         TBGModule::installModule($module);
                         $this->cliEcho("Module {$module} installed successfully...\n", 'green');
                     }
                 }
                 $this->cliEcho("\n");
                 $this->cliEcho("All modules installed successfully...\n", 'green', 'bold');
                 $this->cliEcho("\n");
                 $this->cliEcho("Finishing installation... \n", 'white', 'bold');
                 if (!is_writable(THEBUGGENIE_PATH . 'installed')) {
                     $this->cliEcho("\n");
                     $this->cliEcho("Could not create the 'installed' file.\n", 'red', 'bold');
                     $this->cliEcho("Please create the file ");
                     $this->cliEcho(THEBUGGENIE_PATH . "installed\n", 'white', 'bold');
                     $this->cliEcho("with the following line inside:\n");
                     $this->cliEcho('3.0, installed ' . date('d.m.Y H:i'), 'blue', 'bold');
                     $this->cliEcho("\n");
                     $this->cliEcho("This can be done by running the following command when installation has finished:\n");
                     $this->cliEcho('echo "3.0, installed ' . date('d.m.Y H:i') . '" > ' . THEBUGGENIE_PATH . 'installed', 'white', 'bold');
                     $this->cliEcho("\n");
                     $this->cliEcho("Press ENTER to continue ... ");
                     $this->pressEnterToContinue();
                     $this->cliEcho("\n");
                     $this->cliEcho("\n");
                 } else {
                     file_put_contents(THEBUGGENIE_PATH . 'installed', '3.0, installed ' . date('d.m.Y H:i'));
                 }
                 $this->cliEcho("The installation was completed successfully!\n", 'green', 'bold');
                 $this->cliEcho("\nTo use The Bug Genie, access http://example.com" . $url_subdir . "index.php with a web-browser.\n");
                 $this->cliEcho("The default username is ") . $this->cliEcho('Administrator') . $this->cliEcho(' and the password is ') . $this->cliEcho('admin');
                 $this->cliEcho("\n\nFor support, please visit ") . $this->cliEcho('http://www.thebuggenie.com/', 'blue', 'underline');
                 $this->cliEcho("\n");
             } catch (Exception $e) {
                 throw new Exception("Could not install the {$module} module:\n" . $e->getMessage());
             }
         }
     } catch (Exception $e) {
         $this->cliEcho("\n\nThe installation was interrupted\n", 'red');
         $this->cliEcho($e->getMessage() . "\n");
         var_dump($e->getTraceAsString());
         die;
     }
     $this->cliEcho("\n");
 }
Exemplo n.º 20
0
 public function runUpgrade(TBGRequest $request)
 {
     $version_info = explode(',', file_get_contents(THEBUGGENIE_PATH . 'installed'));
     $this->current_version = $version_info[0];
     $this->upgrade_available = $this->current_version != '3.3';
     if ($this->upgrade_available) {
         $scope = new TBGScope();
         $scope->setID(1);
         $scope->setEnabled();
         TBGContext::setScope($scope);
         TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.2');
         $this->statuses = TBGListTypesTable::getTable()->getStatusListForUpgrade();
         $this->adminusername = TBGUsersTable3dot2::getTable()->getAdminUsername();
     }
     $this->upgrade_complete = false;
     if ($this->upgrade_available && $request->isPost()) {
         $this->upgrade_complete = false;
         switch ($this->current_version) {
             case '3.0':
                 $this->_upgradeFrom3dot0();
             case '3.1':
                 $this->_upgradeFrom3dot1();
             case '3.2':
                 $this->_upgradeFrom3dot2($request);
         }
         if ($this->upgrade_complete) {
             $existing_installed_content = file_get_contents(THEBUGGENIE_PATH . 'installed');
             file_put_contents(THEBUGGENIE_PATH . 'installed', TBGSettings::getVersion(false, false) . ', upgraded ' . date('d.m.Y H:i') . "\n" . $existing_installed_content);
             $prev_error_reportiong_level = error_reporting(0);
             unlink(THEBUGGENIE_PATH . 'upgrade');
             error_reporting($prev_error_reportiong_level);
             if (file_exists(THEBUGGENIE_PATH . 'upgrade')) {
                 $this->upgrade_file_failed = true;
             }
             $this->current_version = TBGSettings::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(TBGContext::getRouting()->generate('home'));
     }
 }
 public function loadFixtures(TBGScope $scope, $admin_group_id, $guest_group_id)
 {
     $scope_id = $scope->getID();
     $this->setPermission(0, $admin_group_id, 0, true, 'core', 'cansaveconfig', 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', 'page_account_access', 0, $scope_id);
     $this->setPermission(0, $guest_group_id, 0, false, 'core', 'page_account_access', 0, $scope_id);
     $this->setPermission(0, 0, 0, false, 'core', 'candoscrumplanning', 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', 'cancreateandeditissues', 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', 'canfindissuesandsavesearches', 0, $scope_id);
     $this->setPermission(0, 0, 0, false, 'core', 'cancreatepublicsearches', 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', 'cancreatepublicsearches', 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', 'caneditmainmenu', 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', 'caneditissuecustomfieldsown', 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', 'canpostandeditcomments', 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', 'canpostseeandeditallcomments', 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "canseeproject", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', 'candoscrumplanning', 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "page_project_allpages_access", 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', "page_home_access", 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', "page_about_access", 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', "page_dashboard_access", 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', "page_search_access", 0, $scope_id);
     $this->setPermission(0, 0, 0, true, 'core', 'page_confirm_scope_access', 0, $scope_id);
     $this->setPermission(0, $guest_group_id, 0, false, 'core', "page_dashboard_access", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "page_teamlist_access", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "page_clientlist_access", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "canvoteforissues", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "canlockandeditlockedissues", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "cancreateandeditissues", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "caneditissue", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "candeleteissues", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "caneditissuecustomfields", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "canaddextrainformationtoissues", 0, $scope_id);
     $this->setPermission(0, $admin_group_id, 0, true, 'core', "canpostseeandeditallcomments", 0, $scope_id);
 }
Exemplo n.º 22
0
 public static function loadFixtures(TBGScope $scope)
 {
     $workflow = new TBGWorkflow();
     $workflow->setName("Default workflow");
     $workflow->setDescription("This is the default workflow. It is used by all projects with no specific workflow selected, and for issue types with no specific workflow specified. This workflow cannot be edited or removed.");
     $workflow->setScope($scope->getID());
     $workflow->save();
     TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_WORKFLOW, $workflow->getID(), 'core', $scope->getID());
     TBGWorkflowStep::loadFixtures($scope, $workflow);
 }