From d26c95718cac0a2994ab4e9633b59f420a0816b4 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 20 Mar 2016 14:49:47 -0700 Subject: [PATCH] Cleaning up whitespace --- export.php | 16 ++++++++-------- index.php | 4 ++-- initialize.php | 12 ++++++------ invoice_add.php | 8 ++++---- invoice_delete.php | 2 +- invoice_send.php | 10 +++++----- invoice_view.php | 8 ++++---- login.php | 12 ++++++------ mysql.sql | 12 ++++++------ notification_add.php | 11 +++++------ notification_delete.php | 10 +++++----- notification_edit.php | 14 ++++++-------- notifications.php | 6 +++--- password_change.php | 7 +++---- password_reset.php | 36 ++++++++++++++++++------------------ 15 files changed, 82 insertions(+), 86 deletions(-) diff --git a/export.php b/export.php index e0894da2..3c46a5b5 100644 --- a/export.php +++ b/export.php @@ -58,16 +58,16 @@ if ($request->getMethod() == 'POST') { $exportHelper = new ttExportHelper(); if ($exportHelper->createDataFile($compress)) { - header('Pragma: public'); // This is needed for IE8 to download files over https. - header('Content-Type: '.$mime_type); - header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); - header('Content-Disposition: attachment; filename="'.$filename.'"'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Cache-Control: private', false); - + header('Pragma: public'); // This is needed for IE8 to download files over https. + header('Content-Type: '.$mime_type); + header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); + header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Cache-Control: private', false); + if ($file_pointer = fopen($exportHelper->getFileName(), 'r')) { while ($data = fread($file_pointer, 4096)) { - echo $data; + echo $data; } fclose($file_pointer); unlink($exportHelper->getFileName()); diff --git a/index.php b/index.php index a6eac171..610794e0 100644 --- a/index.php +++ b/index.php @@ -36,7 +36,7 @@ if ($auth->isAuthenticated()) { } else if ($user->isClient()) { header('Location: reports.php'); - exit(); + exit(); } } @@ -77,4 +77,4 @@ if ($mobileBrowser) { \ No newline at end of file +?> diff --git a/initialize.php b/initialize.php index c6226fce..9dc9d7bc 100644 --- a/initialize.php +++ b/initialize.php @@ -67,7 +67,7 @@ check_extension('mbstring'); // If auth params are not defined (in config.php) - initialize with an empty array. if (!isset($GLOBALS['AUTH_MODULE_PARAMS']) || !is_array($GLOBALS['AUTH_MODULE_PARAMS'])) $GLOBALS['AUTH_MODULE_PARAMS'] = array(); - + // Smarty initialization. import('smarty.Smarty'); $smarty = new Smarty; @@ -93,7 +93,7 @@ if (isset($_COOKIE['tt_PHPSESSID'])) { } // Start or resume PHP session. -session_name('tt_PHPSESSID'); // "tt_" prefix is to avoid sharing session with other PHP apps that do not name session. +session_name('tt_PHPSESSID'); // "tt_" prefix is to avoid sharing session with other PHP apps that do not name session. @session_start(); // Authorization. @@ -173,11 +173,11 @@ $lang = $user->lang; if (!$lang) { if (defined('LANG_DEFAULT')) $lang = LANG_DEFAULT; - + // If we still do not have the language get it from the browser. if (!$lang) { $lang = $i18n->getBrowserLanguage(); - + // Finally - English is the default. if (!$lang) { $lang = 'en'; @@ -196,8 +196,8 @@ $smarty->assign('i18n', $i18n->keys); $smarty->assign('errors', $errors); $smarty->assign('messages', $messages); -// TODO: move this code out of here to the files that use it. - +// TODO: move this code out of here to the files that use it. + // We use js/strftime.js to print dates in JavaScript (in DateField controls). // One of our date formats (%d.%m.%Y %a) prints a localized short weekday name (%a). // The init_js_date_locale function iniitializes Date.ext.locales array in js/strftime.js for our language diff --git a/invoice_add.php b/invoice_add.php index fb2c7fe3..67ae8c14 100644 --- a/invoice_add.php +++ b/invoice_add.php @@ -76,18 +76,18 @@ if ($request->getMethod() == 'POST') { if ($errors->isEmpty()) { if (ttInvoiceHelper::getInvoiceByName($cl_number)) $errors->add($i18n->getKey('error.invoice_exists')); - + if (!ttInvoiceHelper::invoiceableItemsExist($fields)) - $errors->add($i18n->getKey('error.no_invoiceable_items')); + $errors->add($i18n->getKey('error.no_invoiceable_items')); } if ($errors->isEmpty()) { - // Now we can go ahead and create our invoice. + // Now we can go ahead and create our invoice. if (ttInvoiceHelper::createInvoice($fields)) { header('Location: invoices.php'); exit(); } - $errors->add($i18n->getKey('error.db')); + $errors->add($i18n->getKey('error.db')); } } // post diff --git a/invoice_delete.php b/invoice_delete.php index 7ef50f84..b688335a 100644 --- a/invoice_delete.php +++ b/invoice_delete.php @@ -54,7 +54,7 @@ if ($request->getMethod() == 'POST') { if (ttInvoiceHelper::getInvoice($cl_invoice_id)) { if (ttInvoiceHelper::delete($cl_invoice_id, $request->getParameter('delete_invoice_entries'))) { header('Location: invoices.php'); - exit(); + exit(); } else $errors->add($i18n->getKey('error.db')); } else diff --git a/invoice_send.php b/invoice_send.php index 9f933a0c..a013bdf7 100644 --- a/invoice_send.php +++ b/invoice_send.php @@ -70,14 +70,14 @@ if ($request->getMethod() == 'POST') { if (!ttValidEmailList($cl_cc, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.cc')); if (!ttValidString($cl_subject)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.subject')); if (!ttValidString($cl_comment, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.comment')); - + if ($errors->isEmpty()) { // Save last invoice emails for future use. $sc->setValue(SYSC_LAST_INVOICE_EMAIL, $cl_receiver); - $sc->setValue(SYSC_LAST_INVOICE_CC, $cl_cc); - - $body = ttInvoiceHelper::prepareInvoiceBody($cl_invoice_id, $cl_comment); - + $sc->setValue(SYSC_LAST_INVOICE_CC, $cl_cc); + + $body = ttInvoiceHelper::prepareInvoiceBody($cl_invoice_id, $cl_comment); + import('mail.Mailer'); $mailer = new Mailer(); $mailer->setCharSet(CHARSET); diff --git a/invoice_view.php b/invoice_view.php index f05b766e..79efdd9b 100644 --- a/invoice_view.php +++ b/invoice_view.php @@ -54,9 +54,9 @@ foreach($invoice_items as $item) if ($tax_percent) { $tax_expenses = in_array('et', explode(',', $user->plugins)); foreach($invoice_items as $item) { - if ($item['type'] == 2 && !$tax_expenses) - continue; - $tax += round($item['cost'] * $tax_percent / 100, 2); + if ($item['type'] == 2 && !$tax_expenses) + continue; + $tax += round($item['cost'] * $tax_percent / 100, 2); } } $total = $subtotal + $tax; @@ -67,7 +67,7 @@ $smarty->assign('total', $user->currency.' '.str_replace('.', $user->decimal_mar if ('.' != $user->decimal_mark) { foreach ($invoice_items as &$item) - $item['cost'] = str_replace('.', $user->decimal_mark, $item['cost']); + $item['cost'] = str_replace('.', $user->decimal_mark, $item['cost']); } // Calculate colspan for invoice summary. diff --git a/login.php b/login.php index a6195b28..20499a6f 100644 --- a/login.php +++ b/login.php @@ -46,21 +46,21 @@ if ($request->getMethod() == 'POST') { // Validate user input. if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login')); if (!ttValidString($cl_password)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password')); - + if ($errors->isEmpty()) { - // Use the "limit" plugin if we have one. Ignore include errors. + // Use the "limit" plugin if we have one. Ignore include errors. // The "limit" plugin is not required for normal operation of Time Tracker. @include('plugins/limit/access_check.php'); - + if ($auth->doLogin($cl_login, $cl_password)) { // Set current user date (as determined by user browser) into session. $current_user_date = $request->getParameter('browser_today', null); if ($current_user_date) $_SESSION['date'] = $current_user_date; - + // Remember user login in a cookie. setcookie('tt_login', $cl_login, time() + COOKIE_EXPIRE, '/'); - + $user = new ttUser(null, $auth->getUserId()); // Redirect, depending on user role. if ($user->isAdmin()) { @@ -69,7 +69,7 @@ if ($request->getMethod() == 'POST') { } else if ($user->isClient()) { header('Location: reports.php'); - exit(); + exit(); } else { header('Location: time.php'); diff --git a/mysql.sql b/mysql.sql index 3e283255..e964ac72 100644 --- a/mysql.sql +++ b/mysql.sql @@ -68,7 +68,7 @@ CREATE TABLE `tt_projects` ( `name` varchar(80) COLLATE utf8_bin NOT NULL, # project name `description` varchar(255) default NULL, # project description `tasks` text default NULL, # comma-separated list of task ids associated with this project - `status` tinyint(4) default '1', # project status + `status` tinyint(4) default '1', # project status PRIMARY KEY (`id`) ); @@ -112,7 +112,7 @@ create unique index bind_idx on tt_user_project_binds(user_id, project_id); # Structure for table tt_project_task_binds. This table maps projects to assigned tasks. # CREATE TABLE `tt_project_task_binds` ( - `project_id` int(11) NOT NULL, # project id + `project_id` int(11) NOT NULL, # project id `task_id` int(11) NOT NULL # task id ); @@ -191,16 +191,16 @@ CREATE TABLE `tt_fav_reports` ( `task_id` int(11) default NULL, # task id (if selected) `billable` tinyint(4) default NULL, # whether to include billable, not billable, or all records `invoice` tinyint(4) default NULL, # whether to include invoiced, not invoiced, or all records - `users` text default NULL, # Comma-separated list of user ids. Nothing here means "all" users. + `users` text default NULL, # Comma-separated list of user ids. Nothing here means "all" users. `period` tinyint(4) default NULL, # selected period type for report `period_start` date default NULL, # period start `period_end` date default NULL, # period end `show_client` tinyint(4) NOT NULL default '0', # whether to show client column - `show_invoice` tinyint(4) NOT NULL default '0', # whether to show invoice column + `show_invoice` tinyint(4) NOT NULL default '0', # whether to show invoice column `show_project` tinyint(4) NOT NULL default '0', # whether to show project column `show_start` tinyint(4) NOT NULL default '0', # whether to show start field `show_duration` tinyint(4) NOT NULL default '0', # whether to show duration field - `show_cost` tinyint(4) NOT NULL default '0', # whether to show cost field + `show_cost` tinyint(4) NOT NULL default '0', # whether to show cost field `show_task` tinyint(4) NOT NULL default '0', # whether to show task column `show_end` tinyint(4) NOT NULL default '0', # whether to show end field `show_note` tinyint(4) NOT NULL default '0', # whether to show note column @@ -293,7 +293,7 @@ CREATE TABLE `tt_custom_fields` ( # CREATE TABLE `tt_custom_field_options` ( `id` int(11) NOT NULL auto_increment, # option id - `field_id` int(11) NOT NULL, # custom field id + `field_id` int(11) NOT NULL, # custom field id `value` varchar(32) NOT NULL default '', # option value PRIMARY KEY (`id`) ); diff --git a/notification_add.php b/notification_add.php index 52e4193e..8a0cddf1 100644 --- a/notification_add.php +++ b/notification_add.php @@ -69,9 +69,9 @@ if ($request->getMethod() == 'POST') { if (!ttValidEmail($cl_email)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email')); if ($errors->isEmpty()) { - // Calculate next execution time. - $next = tdCron::getNextOccurrence($cl_cron_spec, mktime()); - + // Calculate next execution time. + $next = tdCron::getNextOccurrence($cl_cron_spec, mktime()); + if (ttNotificationHelper::insert(array( 'team_id' => $user->team_id, 'cron_spec' => $cl_cron_spec, @@ -82,12 +82,11 @@ if ($request->getMethod() == 'POST') { header('Location: notifications.php'); exit(); } else - $errors->add($i18n->getKey('error.db')); + $errors->add($i18n->getKey('error.db')); } -} // post +} // POST $smarty->assign('forms', array($form->getName()=>$form->toArray())); -// $smarty->assign('onload', 'onLoad="document.clientForm.name.focus()"'); $smarty->assign('title', $i18n->getKey('title.add_notification')); $smarty->assign('content_page_name', 'notification_add.tpl'); $smarty->display('index.tpl'); diff --git a/notification_delete.php b/notification_delete.php index 8c3681b0..d6a04179 100644 --- a/notification_delete.php +++ b/notification_delete.php @@ -47,7 +47,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getK if ($request->getMethod() == 'POST') { if ($request->getParameter('btn_delete')) { - if(ttNotificationHelper::get($cl_notification_id)) { + if(ttNotificationHelper::get($cl_notification_id)) { if (ttNotificationHelper::delete($cl_notification_id)) { header('Location: notifications.php'); exit(); @@ -56,11 +56,11 @@ if ($request->getMethod() == 'POST') { } else $errors->add($i18n->getKey('error.db')); } else if ($request->getParameter('btn_cancel')) { - header('Location: notifications.php'); - exit(); + header('Location: notifications.php'); + exit(); } -} // post - +} // POST + $smarty->assign('notification_to_delete', $notification_to_delete); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="document.notificationDeleteForm.btn_cancel.focus()"'); diff --git a/notification_edit.php b/notification_edit.php index d04430b0..f4d1d1d0 100644 --- a/notification_edit.php +++ b/notification_edit.php @@ -61,8 +61,7 @@ $form->addInput(array('type'=>'combobox', 'value'=>$cl_fav_report, 'data'=>$fav_reports, 'datakeys'=>array('id','name'), - 'empty'=>array(''=>$i18n->getKey('dropdown.select')) -)); + 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'cron_spec','style'=>'width: 250px;','value'=>$cl_cron_spec)); $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','style'=>'width: 250px;','value'=>$cl_email)); $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.save'))); @@ -74,9 +73,9 @@ if ($request->getMethod() == 'POST') { if (!ttValidEmail($cl_email)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email')); if ($errors->isEmpty()) { - // Calculate next execution time. - $next = tdCron::getNextOccurrence($cl_cron_spec, mktime()); - + // Calculate next execution time. + $next = tdCron::getNextOccurrence($cl_cron_spec, mktime()); + if (ttNotificationHelper::update(array( 'id' => $notification_id, 'team_id' => $user->team_id, @@ -88,12 +87,11 @@ if ($request->getMethod() == 'POST') { header('Location: notifications.php'); exit(); } else - $errors->add($i18n->getKey('error.db')); + $errors->add($i18n->getKey('error.db')); } -} // post +} // POST $smarty->assign('forms', array($form->getName()=>$form->toArray())); -// $smarty->assign('onload', 'onLoad="document.clientForm.name.focus()"'); $smarty->assign('title', $i18n->getKey('title.add_notification')); $smarty->assign('content_page_name', 'notification_edit.tpl'); $smarty->display('index.tpl'); diff --git a/notifications.php b/notifications.php index 3848f862..75b0dbbd 100644 --- a/notifications.php +++ b/notifications.php @@ -40,9 +40,9 @@ $form = new Form('notificationsForm'); if ($request->getMethod() == 'POST') { if ($request->getParameter('btn_add')) { - // The Add button clicked. Redirect to notification_add.php page. - header('Location: notification_add.php'); - exit(); + // The Add button clicked. Redirect to notification_add.php page. + header('Location: notification_add.php'); + exit(); } } else { $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add'))); diff --git a/password_change.php b/password_change.php index a44a505e..8e565212 100644 --- a/password_change.php +++ b/password_change.php @@ -72,15 +72,14 @@ if ($request->getMethod() == 'POST') { $errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password')); if ($errors->isEmpty()) { - // Use the "limit" plugin if we have one. Ignore include errors. + // Use the "limit" plugin if we have one. Ignore include errors. // The "limit" plugin is not required for normal operation of Time Tracker. $cl_login = $user->login; // $cl_login is used in access_check.cpp. @include('plugins/limit/access_check.php'); - - ttUserHelper::setPassword($user_id, $cl_password1); - if ($auth->doLogin($user->login, $cl_password1)) { + ttUserHelper::setPassword($user_id, $cl_password1); + if ($auth->doLogin($user->login, $cl_password1)) { setcookie('tt_login', $user->login, time() + COOKIE_EXPIRE, '/'); header('Location: time.php'); exit(); diff --git a/password_reset.php b/password_reset.php index cb84c002..de0a02c1 100644 --- a/password_reset.php +++ b/password_reset.php @@ -42,15 +42,15 @@ $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getK if ($request->getMethod() == 'POST') { $cl_login = $request->getParameter('login'); - + // Validate user input. if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login')); if ($errors->IsEmpty()) { - if (!ttUserHelper::getUserByLogin($cl_login)) { - // User with a specified login was not found. - // In this case, if login looks like email, try finding user by email. - if (ttValidEmail($cl_login)) { + if (!ttUserHelper::getUserByLogin($cl_login)) { + // User with a specified login was not found. + // In this case, if login looks like email, try finding user by email. + if (ttValidEmail($cl_login)) { $login = ttUserHelper::getUserByEmail($cl_login); if ($login) $cl_login = $login; @@ -58,12 +58,12 @@ if ($request->getMethod() == 'POST') { $errors->add($i18n->getKey('error.no_login')); } else $errors->add($i18n->getKey('error.no_login')); - } + } } - - if ($errors->IsEmpty()) { + + if ($errors->IsEmpty()) { $user = new ttUser($cl_login); // Note: reusing $user from initialize.php here. - + // Prepare and save a temporary reference for user. $temp_ref = md5(uniqid()); ttUserHelper::saveTmpRef($temp_ref, $user->id); @@ -71,10 +71,10 @@ if ($request->getMethod() == 'POST') { $user_i18n = null; if ($user->lang != $i18n->lang) { $user_i18n = new I18n(); - $user_i18n->load($user->lang); + $user_i18n->load($user->lang); } else $user_i18n = &$i18n; - + // Where do we email to? $receiver = null; if ($user->email) @@ -85,11 +85,11 @@ if ($request->getMethod() == 'POST') { else $errors->add($i18n->getKey('error.no_email')); } - + if ($receiver) { import('mail.Mailer'); $sender = new Mailer(); - $sender->setCharSet(CHARSET); + $sender->setCharSet(CHARSET); $sender->setSender(SENDER); $sender->setReceiver("$receiver"); if ((!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) || ($_SERVER['SERVER_PORT'] == 443)) @@ -101,14 +101,14 @@ if ($request->getMethod() == 'POST') { $cl_subject = $user_i18n->getKey('form.reset_password.email_subject'); if (APP_NAME) - $pass_edit_url = $http.'://'.$_SERVER['HTTP_HOST'].'/'.APP_NAME.'/password_change.php?ref='.$temp_ref; + $pass_edit_url = $http.'://'.$_SERVER['HTTP_HOST'].'/'.APP_NAME.'/password_change.php?ref='.$temp_ref; else - $pass_edit_url = $http.'://'.$_SERVER['HTTP_HOST'].'/password_change.php?ref='.$temp_ref; - + $pass_edit_url = $http.'://'.$_SERVER['HTTP_HOST'].'/password_change.php?ref='.$temp_ref; + $sender->setSendType(MAIL_MODE); $res = $sender->send($cl_subject, sprintf($user_i18n->getKey('form.reset_password.email_body'), $pass_edit_url)); - $smarty->assign('result_message', $res ? $i18n->getKey('form.reset_password.message') : $i18n->getKey('error.mail_send')); - } + $smarty->assign('result_message', $res ? $i18n->getKey('form.reset_password.message') : $i18n->getKey('error.mail_send')); + } } } -- 2.20.1