/** * @covers TBGContext::isInstallmode * @covers TBGContext::checkInstallMode */ public function testInstallMode() { TBGContext::checkInstallMode(); if (file_exists(THEBUGGENIE_PATH . 'installed')) { $this->assertFalse(TBGContext::isInstallmode()); } else { $this->assertTrue(TBGContext::isInstallmode()); } }
public function hasCachedRoutes() { if ($this->has_cached_routes === null) { if (TBGContext::isInstallmode()) { $this->has_cached_routes = false; } else { $this->has_cached_routes = TBGCache::has(TBGCache::KEY_ROUTES_CACHE); if ($this->has_cached_routes) { TBGLogging::log('Routes are cached', 'routing'); } else { TBGLogging::log('Routes are not cached', 'routing'); } } } return $this->has_cached_routes; }
public function do_execute() { if (TBGContext::isInstallmode()) { $this->cliEcho("The Bug Genie is not installed\n", 'red'); } else { $this->cliEcho("Finding times to fix\n", 'white', 'bold'); $issuetimes = TBGIssueSpentTimesTable::getTable()->getAllSpentTimesForFixing(); $error_issues = array(); foreach ($issuetimes as $issue_id => $times) { if (count($times) > 1) { $this->cliEcho("Fixing times spent for issue ID {$issue_id}, " . count($times) . " entries\n"); $prev_times = array('hours' => 0, 'days' => 0, 'weeks' => 0, 'months' => 0, 'points' => 0); foreach ($times as $k => $row) { if ($row[TBGIssueSpentTimesTable::SPENT_DAYS] < $prev_times['days'] || $row[TBGIssueSpentTimesTable::SPENT_HOURS] < $prev_times['hours'] || $row[TBGIssueSpentTimesTable::SPENT_WEEKS] < $prev_times['weeks'] || $row[TBGIssueSpentTimesTable::SPENT_MONTHS] < $prev_times['months'] || $row[TBGIssueSpentTimesTable::SPENT_POINTS] < $prev_times['points']) { $error_issues[] = $issue_id; } else { TBGIssueSpentTimesTable::getTable()->fixRow($row, $prev_times); $prev_times['points'] += $row[TBGIssueSpentTimesTable::SPENT_POINTS]; $prev_times['hours'] += $row[TBGIssueSpentTimesTable::SPENT_HOURS]; $prev_times['days'] += $row[TBGIssueSpentTimesTable::SPENT_DAYS]; $prev_times['weeks'] += $row[TBGIssueSpentTimesTable::SPENT_WEEKS]; $prev_times['months'] += $row[TBGIssueSpentTimesTable::SPENT_MONTHS]; } } } } foreach (TBGIssueSpentTimesTable::getTable()->getAllSpentTimesForFixing() as $issue_id => $times) { foreach ($times as $row) { TBGIssueSpentTimesTable::getTable()->fixHours($row); } TBGIssuesTable::getTable()->fixHours($issue_id); } if (count($error_issues) > 0) { $this->cliEcho("\n"); $this->cliEcho("All spent times have been attempted fixed, but there were some issues that could not be fixed automatically!\n"); $this->cliEcho("This happens if there has been adjustments in time spent, lowering the value for spent points, hours, days, weeks or months.\n\n"); $this->cliEcho("You should fix the issues manually (issue ids corresponding to issue_ids in the timesspent table): "); $this->cliEcho(join(', ', $error_issues) . "\n\n"); $this->cliEcho("Spent times fixed!\n\n", 'green'); } else { $this->cliEcho("All spent times fixed successfully!\n\n", 'green'); } $this->cliEcho("IMPORTANT: Don't run this task again!\n", 'white', 'bold'); } }
public static function get($name, $module = 'core', $scope = null, $uid = 0) { if (TBGContext::isInstallmode() && !TBGContext::getScope() instanceof TBGScope) { return null; } if ($scope instanceof TBGScope) { $scope = $scope->getID(); } if (!TBGContext::getScope() instanceof TBGScope) { throw new Exception('The Bug Genie is not installed correctly'); } if ($scope != TBGContext::getScope()->getID() && $scope !== null) { $setting = self::_loadSetting($name, $module, $scope); return $setting[$uid]; } if (self::$_settings === null) { self::loadSettings(); } if ($uid > 0 && !array_key_exists($uid, self::$_loadedsettings)) { self::loadSettings($uid); } if (!is_array(self::$_settings) || !array_key_exists($module, self::$_settings)) { return null; } if (!array_key_exists($name, self::$_settings[$module])) { return null; //self::$_settings[$name] = self::_loadSetting($name, $module, TBGContext::getScope()->getID()); } if ($uid !== 0 && array_key_exists($uid, self::$_settings[$module][$name])) { return self::$_settings[$module][$name][$uid]; } else { if (!array_key_exists($uid, self::$_settings[$module][$name])) { return null; } return self::$_settings[$module][$name][$uid]; } }
public function getCharset() { if (TBGContext::isInstallmode()) { return $this->_charset; } return TBGSettings::get('charset') != '' ? TBGSettings::get('charset') : $this->_charset; }
public function do_execute() { if (TBGContext::isInstallmode()) { $this->cliEcho("Create module\n", 'white', 'bold'); $this->cliEcho("The Bug Genie is not installed\n", 'red'); } else { $module_name = ucfirst($this->getProvidedArgument('module_name')); $module_key = strtolower($module_name); $module_description = "Autogenerated module {$module_name}"; $this->cliEcho("Initializing empty module "); $this->cliEcho("{$module_key}\n", 'white', 'bold'); $this->cliEcho("Checking that the module doesn't exist ... "); if (file_exists(THEBUGGENIE_MODULES_PATH . $module_key)) { $this->cliEcho("fail\n", 'red'); $this->cliEcho("A module with this name already exists\n", 'red'); return false; } else { $this->cliEcho("OK\n", 'green', 'bold'); } $this->cliEcho("Checking for conflicting classnames ... "); if (class_exists($module_name)) { $this->cliEcho("fail\n", 'red'); $this->cliEcho("A class with this name already exists\n", 'red'); return false; } else { $this->cliEcho("OK\n", 'green', 'bold'); } $this->cliEcho("Checking that the module path is writable ... "); if (!is_writable(THEBUGGENIE_MODULES_PATH)) { $this->cliEcho("fail\n", 'red'); $this->cliEcho("Module path isn't writable\n\n", 'red'); $this->cliEcho("Please make sure that the following path is writable: \n"); $this->cliEcho(THEBUGGENIE_MODULES_PATH, 'cyan'); return false; } else { $this->cliEcho("OK\n", 'green', 'bold'); } $this->cliEcho("\nCreating module directory structure ... \n", 'white', 'bold'); $this_module_path = THEBUGGENIE_MODULES_PATH . $module_key . DS; mkdir(THEBUGGENIE_MODULES_PATH . $module_key); $this->cliEcho('modules' . DS . "{$module_key}\n"); mkdir($this_module_path . 'classes'); $this->cliEcho('modules' . DS . $module_key . DS . "classes\n"); mkdir($this_module_path . 'classes' . DS . 'cli'); $this->cliEcho('modules' . DS . $module_key . DS . 'classes' . DS . "cli\n"); mkdir($this_module_path . 'templates'); $this->cliEcho('modules' . DS . $module_key . DS . "templates\n"); $this->cliEcho("... ", 'white', 'bold'); $this->cliEcho("OK\n", 'green', 'bold'); $this->cliEcho("\nCreating module files ... \n", 'white', 'bold'); file_put_contents($this_module_path . "class", "{$module_name}|0.1"); $this->cliEcho('modules' . DS . $module_key . DS . "class\n"); file_put_contents($this_module_path . "module", $module_description); $this->cliEcho('modules' . DS . $module_key . DS . "module\n"); $module_class_template = file_get_contents(THEBUGGENIE_MODULES_PATH . "main" . DS . "fixtures" . DS . "emptymoduleclass"); $module_class_content = str_replace(array('%module_key%', '%module_name%', '%module_description%'), array($module_key, $module_name, $module_description), $module_class_template); file_put_contents($this_module_path . "classes" . DS . $module_name . ".class.php", $module_class_content); $this->cliEcho("modules" . DS . $module_key . DS . "classes" . DS . $module_name . ".class.php\n"); $module_actions_class_template = file_get_contents(THEBUGGENIE_MODULES_PATH . "main" . DS . "fixtures" . DS . "emptymoduleactionsclass"); $module_actions_class_content = str_replace(array('%module_key%', '%module_name%', '%module_description%'), array($module_key, $module_name, $module_description), $module_actions_class_template); file_put_contents($this_module_path . "classes" . DS . "actions.class.php", $module_actions_class_content); $this->cliEcho("modules" . DS . $module_key . DS . "classes" . DS . "actions.class.php\n"); $module_actioncomponents_class_template = file_get_contents(THEBUGGENIE_MODULES_PATH . "main" . DS . "fixtures" . DS . "emptymoduleactioncomponentsclass"); $module_actioncomponents_class_content = str_replace(array('%module_key%', '%module_name%', '%module_description%'), array($module_key, $module_name, $module_description), $module_actioncomponents_class_template); file_put_contents($this_module_path . "classes" . DS . "actioncomponents.class.php", $module_actioncomponents_class_content); $this->cliEcho("modules" . DS . $module_key . DS . "classes" . DS . "actioncomponents.class.php\n"); file_put_contents($this_module_path . "templates" . DS . "index.html.php", "{$module_name} frontpage"); $this->cliEcho("modules" . DS . $module_key . DS . "templates" . DS . "index.html.php\n"); $this->cliEcho("... ", 'white', 'bold'); $this->cliEcho("OK\n\n", 'green', 'bold'); $this->cliEcho("The module was created successfully!\n", 'green'); } }
public function do_execute() { if (TBGContext::isInstallmode()) { $this->cliEcho("Manage modules\n", 'white', 'bold'); $this->cliEcho("The Bug Genie is not installed\n", 'red'); } else { switch ($this->getProvidedArgument('action')) { case 'list_installed': $this->_listInstalled(); break; case 'list_available': $this->_listAvailable(); break; case 'install': $this->_installModule($this->getProvidedArgument('module_name')); break; case 'uninstall': $this->_uninstallModule($this->getProvidedArgument('module_name')); break; default: $this->cliEcho("Unknown action\n", 'red'); } } }