Secure authentication using Active Directory
Problems with external Database
Display Custom Fields on Profile Page
echo custom field in table on 'time' page?
// Check if PHP version is good enough. // $required_version = '5.2.1'; // Something in TCPDF library does not work below this one. $required_version = '5.4.0'; // Week view (week.php) requires 5.4 because of []-way of referencing arrays. // This needs further investigation as we use [] elsewhere without obvious problems.
$smarty->assign('content_page_name', 'time.tpl'); $smarty->display('index.tpl');Which means use time.tpl from the templates directory, and then display everything using index.tpl. Therefore, for each PHP page we show to users, we have a corresponding template file, usually named similarly. Pages for mobile access are organized the same way in mobile subdirectories.
$user
global $user;
class ttUser { var $login = null; // User login. var $name = null; // User name. var $id = null; // User id. var $team_id = null; // Team id. var $role = null; // User role (user, client, comanager, manager, admin). var $client_id = null; // Client id for client user role. var $behalf_id = null; // User id, on behalf of whom we are working. var $behalf_name = null; // User name, on behalf of whom we are working. var $email = null; // User email. var $lang = null; // Language. var $decimal_mark = null; // Decimal separator. var $date_format = null; // Date format. var $time_format = null; // Time format. var $week_start = 0; // Week start day. var $tracking_mode = 0; // Tracking mode. var $project_required = 0; // Whether project selection is required on time entires. var $task_required = 0; // Whether task selection is required on time entires. var $record_type = 0; // Record type (duration vs start and finish, or both). var $uncompleted_indicators = 0; // Uncompleted time entry indicators (show nowhere or on users page). var $bcc_email = null; // Bcc email. var $currency = null; // Currency. var $plugins = null; // Comma-separated list of enabled plugins. var $team = null; // Team name. var $custom_logo = 0; // Whether to use a custom logo for team. var $address = null; // Address for invoices. var $lock_spec = null; // Cron specification for record locking. var $workday_hours = 8; // Number of work hours in a regular day. var $rights = 0; // A mask of user rights. ... }These properties are initialized when the instance is created in initialize.php. As a programmer, you have access to $user instance from everywhere else in the code.
$i18nor, inside of functions, where needed:
global $i18n;Translation strings are loaded from files in WEB-INF/resources/ - one file per language. Some files are only partially translated. Feel free to improve the translation for your language.
require_once('initialize.php');Then we do access checks.
// Access checks. if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) { header('Location: access_denied.php'); exit(); }The ttAccessAllowed call above redirects to login.php if a visitor is not logged in.
/ - PHP pages for desktop browsers. /WEB-INF/config.php - Time Tracker configuration file. /WEB-INF/config.php.dist - distribution example of the config.php file with default settings. /WEB-INF/lib/ - library directory containing helper classes, PEAR, Smarty, and other packages and modules. /WEB-INF/resources/ - translation files, one per language. /WEB-INF/templates/ - Smarty templates for desktop pages. /WEB-INF/templates/mobile/ - Smarty templates for mobile pages. /WEB-INF/templates_c/ - directory where Smarty stores compiled templates. It must be writable. /img/ - graphic files. /js/ - JavaScript files. /mobile - PHP pages for mobile browsers. /plugins/ - plugins directory.To understand basic execution flow, pay attention only to these four:
/ - PHP pages for desktop browsers. /mobile - PHP pages for mobile browsers. /WEB-INF/templates/ - Smarty templates for desktop pages. /WEB-INF/templates/mobile/ - Smarty templates for mobile pages.Everything else is secondary and is used to create output for each PHP-template pair.
ch - charts. cl - clients. iv - invoices.When $user instance is initialized, it obtains a list of enabled plugins into its $plugins member, which is a comma-separated list of plugin designations. You can determine whether a plugin is enabled by calling the ttUser::isPluginEnabled() function with a plugin designation parameter:
// isPluginEnabled checks whether a plugin is enabled for user. function isPluginEnabled($plugin) { return in_array($plugin, explode(',', $this->plugins)); }Then, on presentation PHP pages, we invoke plugin code depending on whether or not it is enabled for user, and conditionally include plugin presentation parts in corresponding Smarty templates.