Skip to content

Commit

Permalink
TASK: Lots of code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Jan 13, 2018
1 parent ddf2509 commit 80bdd7a
Show file tree
Hide file tree
Showing 99 changed files with 2,439 additions and 2,182 deletions.
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@

/libraries/*
# libraries that will be autoloaded but cannot be fetched from external repositories
!/libraries/Kimai
!/libraries/jQuery
!/libraries/phpclasses
!/libraries/phpjs
!/libraries/TinyButStrong
/bin/
!/libraries/Kimai/
!/libraries/jQuery/
!/libraries/phpclasses/
!/libraries/phpjs/
!/libraries/TinyButStrong/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You can get more information about this time-tracking software:
## Features

This is just a short feature list, play around with the [demo installation](http://www.kimai.org/demo/) to see all features:

* Multi-user management
* Customer login with read only privileges
* Every user has its own timesheet
Expand Down
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion core/floaters.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
* some HTML will be returned, which will then be shown in a floater.
*/

// insert KSPI
$isCoreProcessor = 1;
$dir_templates = "templates/scripts/"; // folder of the template files
require "../includes/kspi.php";

$database = Kimai_Registry::getDatabase();

switch ($axAction) {

/**
Expand Down
13 changes: 7 additions & 6 deletions core/kimai.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

// =============================
// = Smarty (initialize class) =
// =============================
// =============================
require_once '../includes/basics.php';

$database = Kimai_Registry::getDatabase();

$view = new Zend_View();
$view->setBasePath(WEBROOT . '/templates');

Expand All @@ -39,7 +41,7 @@

// Jedes neue update schreibt seine Versionsnummer in die Datenbank.
// Beim nächsten Update kommt dann in der Datei /includes/var.php die neue V-Nr. mit.
// der updater.php weiss dann welche Aenderungen an der Datenbank vorgenommen werden muessen.
// der updater.php weiss dann welche Aenderungen an der Datenbank vorgenommen werden muessen.
checkDBversion("..");

$extensions = new Kimai_Extensions($kga, WEBROOT . '/extensions/');
Expand All @@ -61,8 +63,7 @@
$current_timer['hour'] = 0;
$current_timer['min'] = 0;
$current_timer['sec'] = 0;
}
else {
} else {
$current_timer = $database->get_current_timer();
}

Expand Down Expand Up @@ -194,7 +195,7 @@
$customerData = $database->customer_get_data($lastProject['customerID']);
}
if (!$lastActivity['trash'])
$activityData = $lastActivity;
$activityData = $lastActivity;
}
$view->assign('customerData', $customerData);
$view->assign('projectData', $projectData);
Expand Down Expand Up @@ -268,7 +269,7 @@
$view->assign('activity_display', $view->render("lists/activities.php"));

if (isset($kga['user'])) {
$view->assign('showInstallWarning', file_exists(WEBROOT . 'installer'));
$view->assign('showInstallWarning', file_exists(WEBROOT . '/installer'));
} else {
$view->assign('showInstallWarning', false);
}
Expand Down
28 changes: 16 additions & 12 deletions core/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@
* of customers.
*/

// insert KSPI
$isCoreProcessor = 1;
$dir_templates = "templates/core/";
require("../includes/kspi.php");
$dir_templates = 'templates/core/';
require('../includes/kspi.php');

$kga = Kimai_Registry::getConfig();
$database = Kimai_Registry::getDatabase();

switch ($axAction) {

/**
* Append a new entry to the logfile.
*/
case 'logfile':
Kimai_Logger::logfile("JavaScript: " . $axValue);
Kimai_Logger::logfile('JavaScript: ' . $axValue);
break;

/**
Expand Down Expand Up @@ -204,7 +206,7 @@

$view->assign('show_project_edit_button', coreObjectActionAllowed('project', 'edit'));

echo $view->render("lists/projects.php");
echo $view->render('lists/projects.php');
break;

/**
Expand All @@ -215,15 +217,15 @@
case 'reload_activities':
if (isset($kga['customer'])) {
$view->assign('activities', $database->get_activities_by_customer($kga['customer']['customerID']));
} else if (isset($_REQUEST['project'])) {
} elseif (isset($_REQUEST['project'])) {
$view->assign('activities', $database->get_activities_by_project($_REQUEST['project'], $kga['user']['groups']));
} else {
$view->assign('activities', $database->get_activities($kga['user']['groups']));
}

$view->assign('show_activity_edit_button', coreObjectActionAllowed('activity', 'edit'));

echo $view->render("lists/activities.php");
echo $view->render('lists/activities.php');
break;

/**
Expand All @@ -235,7 +237,7 @@
/**
* add or edit a customer
*/
case "customer":
case 'customer':
$data['name'] = $_REQUEST['name'];
$data['comment'] = $_REQUEST['comment'];
$data['company'] = $_REQUEST['company'];
Expand Down Expand Up @@ -278,7 +280,8 @@
$errorMessages['customerGroups'] = $kga['lang']['atLeastOneGroup'];
}

if (!checkGroupedObjectPermission('Customer', $id ? 'edit' : 'add', $oldGroups, $_REQUEST['customerGroups'])) {
if (!checkGroupedObjectPermission('Customer', $id ? 'edit' : 'add', $oldGroups,
$_REQUEST['customerGroups'])) {
$errorMessages[''] = $kga['lang']['errorMessages']['permissionDenied'];
}

Expand All @@ -304,7 +307,7 @@
/**
* add or edit a project
*/
case "project":
case 'project':
$data['name'] = $_REQUEST['name'];
$data['customerID'] = $_REQUEST['customerID'];
$data['comment'] = $_REQUEST['projectComment'];
Expand All @@ -330,7 +333,8 @@
$errorMessages['projectGroups'] = $kga['lang']['atLeastOneGroup'];
}

if (!checkGroupedObjectPermission('Project', $id ? 'edit' : 'add', $oldGroups, $_REQUEST['projectGroups'])) {
if (!checkGroupedObjectPermission('Project', $id ? 'edit' : 'add', $oldGroups,
$_REQUEST['projectGroups'])) {
$errorMessages[''] = $kga['lang']['errorMessages']['permissionDenied'];
}

Expand Down Expand Up @@ -391,7 +395,7 @@
/**
* add or edit a activity
*/
case "activity":
case 'activity':
$data['name'] = $_REQUEST['name'];
$data['comment'] = $_REQUEST['comment'];
$data['visible'] = getRequestBool('visible');
Expand Down
24 changes: 11 additions & 13 deletions error.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,28 @@
*/

if (!defined('WEBROOT')) {
define('WEBROOT', dirname(__FILE__) . DIRECTORY_SEPARATOR);
define('WEBROOT', dirname(__FILE__));
}

require_once WEBROOT . '/libraries/autoload.php';

$kga = Kimai_Registry::getConfig();

$view = new Zend_View();
$view->setBasePath(WEBROOT . 'templates');
$view->setBasePath(WEBROOT . '/templates');

if (!isset($_REQUEST['err'])) {
$_REQUEST['err'] = '';
}

switch ($_REQUEST['err']) {

// TODO - can we make sure $kga exists?
case 'db':
$headline = $kga['lang']['errors'][0]['hdl'];
$message = $kga['lang']['errors'][0]['txt'];
break;

default:
$headline = "Unknown Error";
$message = "No error information was specified.";
break;
case 'db':
$headline = $kga['lang']['errors'][0]['hdl'];
$message = $kga['lang']['errors'][0]['txt'];
break;
default:
$headline = 'Unknown Error';
$message = 'No error information was specified.';
}

$view->assign('headline', $headline);
Expand Down
15 changes: 7 additions & 8 deletions extensions/#ki_demoextension/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,22 @@
* along with Kimai; If not, see <http://www.gnu.org/licenses/>.
*/

// Include Basics
include('../../includes/basics.php');

$dir_templates = "templates/";
$datasrc = "config.ini";
$settings = parse_ini_file($datasrc);
$dir_ext = $settings['EXTENSION_DIR'];
$dir_templates = 'templates/';
$datasrc = 'config.ini';
$settings = parse_ini_file($datasrc);
$dir_ext = $settings['EXTENSION_DIR'];

$user = checkUser();
// =========================================
// = Get the currently displayed timeframe =
// =========================================
$timeframe = get_timeframe();
$in = $timeframe[0];
$out = $timeframe[1];
$in = $timeframe[0];
$out = $timeframe[1];

$view = new Zend_View();
$view->setBasePath(WEBROOT . 'extensions/' . $dir_ext . '/' . $dir_templates);
$view->setBasePath(WEBROOT . '/extensions/' . $dir_ext . '/' . $dir_templates);

echo $view->render('index.php');
9 changes: 4 additions & 5 deletions extensions/#ki_demoextension/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
* along with Kimai; If not, see <http://www.gnu.org/licenses/>.
*/

// Always include the Kimai Standard Processor Initialization!

// insert KSPI
$isCoreProcessor = 0;
$dir_templates = "templates/";
require("../../includes/kspi.php");
$dir_templates = 'templates/';
require('../../includes/kspi.php');

$kga = Kimai_Registry::getConfig();

switch ($axAction) {
case 'test':
Expand Down
5 changes: 3 additions & 2 deletions extensions/ext_debug/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
* along with Kimai; If not, see <http://www.gnu.org/licenses/>.
*/

// Include Basics
include '../../includes/basics.php';

$kga = Kimai_Registry::getConfig();

$user = checkUser();

$view = new Kimai_View();
$view->addBasePath(__DIR__ . '/templates/');

$view->assign('delete_logfile', $kga['delete_logfile']);
$view->assign(
'kga_sections',
'kga_sections',
array(
'all' => '',
'plain' => 'plain',
Expand Down
Loading

0 comments on commit 80bdd7a

Please sign in to comment.