/** * starts timesheet record * * @param integer $projectID ID of project to record * @param $activityID * @param $user * @return int id of the new entry or false on failure * @author th, sl */ public function startRecorder($projectID, $activityID, $user) { $projectID = MySQL::SQLValue($projectID, MySQL::SQLVALUE_NUMBER); $activityID = MySQL::SQLValue($activityID, MySQL::SQLVALUE_NUMBER); $user = MySQL::SQLValue($user, MySQL::SQLVALUE_NUMBER); $values['projectID'] = $projectID; $values['activityID'] = $activityID; $values['start'] = time(); $values['userID'] = $user; $values['statusID'] = $this->kga->getDefaultStatus(); $rate = $this->get_best_fitting_rate($user, $projectID, $activityID); if ($rate) { $values['rate'] = $rate; } $fixedRate = $this->get_best_fitting_fixed_rate($projectID, $activityID); if ($fixedRate) { $values['fixedRate'] = $fixedRate; } if ($this->kga->getSettings()->getDefaultLocation() != '') { $values['location'] = "'" . $this->kga->getSettings()->getDefaultLocation() . "'"; } $table = $this->getTimeSheetTable(); $result = $this->conn->InsertRow($table, $values); if (!$result) { $this->logLastError('startRecorder'); return false; } return $this->conn->GetLastInsertID(); }
/** * @return string */ public function getName() { if (null === $this->skinName) { $skin = Kimai_Config::getDefault(Kimai_Config::DEFAULT_SKIN); $kga = Kimai_Registry::getConfig(); if (!empty($kga->getSettings()->getSkin())) { $skin = $kga->getSettings()->getSkin(); } else { if (!empty($kga->getSkin())) { $skin = $kga->getSkin(); } } $this->skinName = $this->view->escape($skin); } return $this->skinName; }
/** * Adds the translations for the given language. * * @param $language * @throws Exception */ public function addTranslations($language) { // no need to load the default or already requested language again! $default = Kimai_Config::getDefault(Kimai_Config::DEFAULT_LANGUAGE); if (empty($language) || $language == $default || $language == $this->language) { return; } $languageFile = WEBROOT . 'language/' . $language . '.php'; if (!file_exists($languageFile)) { Kimai_Logger::logfile('Requested translation is missing: ' . $language); return; } $this->language = $language; $data = array_replace_recursive($this->getArrayCopy(), include $languageFile); $this->exchangeArray($data); }
* here. */ defined('WEBROOT') || define('WEBROOT', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../')); set_include_path(implode(PATH_SEPARATOR, array('.', realpath(APPLICATION_PATH . 'libraries/')))); if (!file_exists(WEBROOT . 'includes/autoconf.php')) { header('Location: installer/index.php'); exit; } ini_set('display_errors', '0'); require_once WEBROOT . 'libraries/autoload.php'; require_once WEBROOT . 'includes/func.php'; // The $kga (formerly Kimai Global Array) is initialized here // It was replaced by an proxy object, but until refactored it is still used as array in a lot of places require_once WEBROOT . 'includes/autoconf.php'; $kga = new Kimai_Config(array('server_prefix' => $server_prefix, 'server_hostname' => $server_hostname, 'server_database' => $server_database, 'server_username' => $server_username, 'server_password' => $server_password, 'server_charset' => $server_charset, 'defaultTimezone' => $defaultTimezone, 'password_salt' => isset($password_salt) ? $password_salt : '')); // will inject the version variables into the Kimai_Config object include WEBROOT . 'includes/version.php'; // write vars from autoconf.php into kga if (isset($language)) { $kga->setLanguage($language); } if (isset($authenticator)) { $kga->setAuthenticator($authenticator); } if (isset($billable)) { $kga->setBillable($billable); } if (isset($skin)) { $kga->setSkin($skin); }
/** * Return default settings for the application. * * @return array */ protected function getDefaults() { return array('rowlimit' => 100, 'skin' => Kimai_Config::getDefault(Kimai_Config::DEFAULT_SKIN), 'autoselection' => 1, 'quickdelete' => 0, 'flip_project_display' => 0, 'project_comment_flag' => 0, 'showIDs' => 0, 'noFading' => 0, 'lang' => '', 'user_list_hidden' => 0, 'hideClearedEntries' => 0, 'durationWithSeconds' => 0, 'showQuickNote' => 0, 'defaultLocation' => '', 'showCommentsByDefault' => 0, 'hideOverlapLines' => 0, 'showTrackingNumber' => 0, 'sublistAnnotations' => 0); }
/** * @param $database * @param $hostname * @param $username * @param $password * @param $charset * @param $prefix * @param $lang * @param $salt * @param $timezone * @return bool */ function write_config_file($database, $hostname, $username, $password, $charset, $prefix, $lang, $salt, $timezone = null) { $kga = Kimai_Registry::getConfig(); $database = addcslashes($database, '"$'); $hostname = addcslashes($hostname, '"$'); $username = addcslashes($username, '"$'); $password = addcslashes($password, '"$'); $file = fopen(realpath(dirname(__FILE__)) . '/autoconf.php', 'w'); if (!$file) { return false; } // fallback if timezone was not provided if (!empty($timezone)) { $timezone = addcslashes($timezone, '"$'); $timezone = '"' . $timezone . '"'; } else { if (isset($kga['defaultTimezone'])) { $timezone = '"' . $kga['defaultTimezone'] . '"'; } else { $timezone = 'date_default_timezone_get()'; } } // fetch skin from global config with "standard" fallback $skin = !empty($kga->getSkin()) ? $kga->getSkin() : Kimai_Config::getDefault(Kimai_Config::DEFAULT_SKIN); $billable = !empty($kga->getBillable()) ? var_export($kga->getBillable(), true) : var_export(Kimai_Config::getDefault(Kimai_Config::DEFAULT_BILLABLE), true); $authenticator = !empty($kga->getAuthenticator()) ? $kga->getAuthenticator() : Kimai_Config::getDefault(Kimai_Config::DEFAULT_AUTHENTICATOR); $lang = !empty($lang) ? $lang : Kimai_Config::getDefault(Kimai_Config::DEFAULT_LANGUAGE); $config = <<<EOD <?php /** * This file is part of * Kimai - Open Source Time Tracking // http://www.kimai.org * (c) Kimai-Development-Team since 2006 * * Kimai is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; Version 3, 29 June 2007 * * Kimai is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Kimai; If not, see <http://www.gnu.org/licenses/>. */ // This file was automatically generated by the installer \$server_hostname = "{$hostname}"; \$server_database = "{$database}"; \$server_username = "******"; \$server_password = "******"; \$server_charset = "{$charset}"; \$server_prefix = "{$prefix}"; \$language = "{$lang}"; \$password_salt = "{$salt}"; \$defaultTimezone = {$timezone}; \$skin = "{$skin}"; \$authenticator = "{$authenticator}"; \$billable = {$billable}; EOD; fputs($file, $config); fclose($file); return true; }