Skip to content

Commit 251996a

Browse files
committed
Work in progress populating repo...
Included a few files to see how the process is going to work...
1 parent 10eda5d commit 251996a

15 files changed

Lines changed: 1021 additions & 0 deletions

.htaccess

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AddDefaultCharset utf-8

access_denied.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
// +----------------------------------------------------------------------+
3+
// | Anuko Time Tracker
4+
// +----------------------------------------------------------------------+
5+
// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6+
// +----------------------------------------------------------------------+
7+
// | LIBERAL FREEWARE LICENSE: This source code document may be used
8+
// | by anyone for any purpose, and freely redistributed alone or in
9+
// | combination with other software, provided that the license is obeyed.
10+
// |
11+
// | There are only two ways to violate the license:
12+
// |
13+
// | 1. To redistribute this code in source form, with the copyright
14+
// | notice or license removed or altered. (Distributing in compiled
15+
// | forms without embedded copyright notices is permitted).
16+
// |
17+
// | 2. To redistribute modified versions of this code in *any* form
18+
// | that bears insufficient indications that the modifications are
19+
// | not the work of the original author(s).
20+
// |
21+
// | This license applies to this document only, not any other software
22+
// | that it may be combined with.
23+
// |
24+
// +----------------------------------------------------------------------+
25+
// | Contributors:
26+
// | https://www.anuko.com/time_tracker/credits.htm
27+
// +----------------------------------------------------------------------+
28+
29+
require_once('initialize.php');
30+
31+
$errors->add($i18n->getKey('error.access_denied'));
32+
if ($auth->isAuthenticated()) $GLOBALS['SMARTY']->assign('authenticated', true); // Used in header.tpl for menu display.
33+
34+
$smarty->assign('title', $i18n->getKey('label.error'));
35+
$smarty->assign('content_page_name', 'access_denied.tpl');
36+
$smarty->display('index.tpl');
37+
?>

admin_options.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
// +----------------------------------------------------------------------+
3+
// | Anuko Time Tracker
4+
// +----------------------------------------------------------------------+
5+
// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6+
// +----------------------------------------------------------------------+
7+
// | LIBERAL FREEWARE LICENSE: This source code document may be used
8+
// | by anyone for any purpose, and freely redistributed alone or in
9+
// | combination with other software, provided that the license is obeyed.
10+
// |
11+
// | There are only two ways to violate the license:
12+
// |
13+
// | 1. To redistribute this code in source form, with the copyright
14+
// | notice or license removed or altered. (Distributing in compiled
15+
// | forms without embedded copyright notices is permitted).
16+
// |
17+
// | 2. To redistribute modified versions of this code in *any* form
18+
// | that bears insufficient indications that the modifications are
19+
// | not the work of the original author(s).
20+
// |
21+
// | This license applies to this document only, not any other software
22+
// | that it may be combined with.
23+
// |
24+
// +----------------------------------------------------------------------+
25+
// | Contributors:
26+
// | https://www.anuko.com/time_tracker/credits.htm
27+
// +----------------------------------------------------------------------+
28+
29+
require_once('initialize.php');
30+
import('form.Form');
31+
import('ttUserHelper');
32+
33+
// Access check.
34+
if (!ttAccessCheck(right_administer_site)) {
35+
header('Location: access_denied.php');
36+
exit();
37+
}
38+
39+
if ($request->getMethod() == 'POST') {
40+
$cl_password1 = $request->getParameter('password1');
41+
$cl_password2 = $request->getParameter('password2');
42+
}
43+
44+
$form = new Form('optionsForm');
45+
$form->addInput(array('type'=>'text','aspassword'=>true,'maxlength'=>'30','name'=>'password1','style'=>'width: 150px;','value'=>$cl_password1));
46+
$form->addInput(array('type'=>'text','aspassword'=>true,'maxlength'=>'30','name'=>'password2','style'=>"width: 150px;",'value'=>$cl_password2));
47+
$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.submit')));
48+
49+
if ($request->getMethod() == 'POST') {
50+
if ($cl_password1 || $cl_password2) {
51+
// Validate user input.
52+
if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
53+
if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
54+
if ($cl_password1 !== $cl_password2)
55+
$errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
56+
}
57+
58+
if ($errors->isEmpty() && $cl_password1) {
59+
if (ttUserHelper::setPassword($user->id, $cl_password1)) {
60+
header('Location: admin_teams.php');
61+
exit();
62+
} else
63+
$errors->add($i18n->getKey('error.db'));
64+
}
65+
} // post
66+
67+
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
68+
$smarty->assign('title', $i18n->getKey('title.options'));
69+
$smarty->assign('content_page_name', 'admin_options.tpl');
70+
$smarty->display('index.tpl');
71+
?>

admin_team_add.php

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
// +----------------------------------------------------------------------+
3+
// | Anuko Time Tracker
4+
// +----------------------------------------------------------------------+
5+
// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6+
// +----------------------------------------------------------------------+
7+
// | LIBERAL FREEWARE LICENSE: This source code document may be used
8+
// | by anyone for any purpose, and freely redistributed alone or in
9+
// | combination with other software, provided that the license is obeyed.
10+
// |
11+
// | There are only two ways to violate the license:
12+
// |
13+
// | 1. To redistribute this code in source form, with the copyright
14+
// | notice or license removed or altered. (Distributing in compiled
15+
// | forms without embedded copyright notices is permitted).
16+
// |
17+
// | 2. To redistribute modified versions of this code in *any* form
18+
// | that bears insufficient indications that the modifications are
19+
// | not the work of the original author(s).
20+
// |
21+
// | This license applies to this document only, not any other software
22+
// | that it may be combined with.
23+
// |
24+
// +----------------------------------------------------------------------+
25+
// | Contributors:
26+
// | https://www.anuko.com/time_tracker/credits.htm
27+
// +----------------------------------------------------------------------+
28+
29+
require_once('initialize.php');
30+
import('form.Form');
31+
import('ttUserHelper');
32+
33+
// Access check.
34+
if (!ttAccessCheck(right_administer_site)) {
35+
header('Location: access_denied.php');
36+
exit();
37+
}
38+
39+
if ($request->getMethod() == 'POST') {
40+
$cl_team_name = trim($request->getParameter('team_name'));
41+
$cl_manager_name = trim($request->getParameter('manager_name'));
42+
$cl_manager_login = trim($request->getParameter('manager_login'));
43+
if (!$auth->isPasswordExternal()) {
44+
$cl_password1 = $request->getParameter('password1');
45+
$cl_password2 = $request->getParameter('password2');
46+
}
47+
$cl_manager_email = trim($request->getParameter('manager_email'));
48+
}
49+
50+
$form = new Form('teamForm');
51+
$form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'team_name','value'=>$cl_team_name));
52+
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_name','value'=>$cl_manager_name));
53+
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_login','value'=>$cl_manager_login));
54+
if (!$auth->isPasswordExternal()) {
55+
$form->addInput(array('type'=>'text','maxlength'=>'30','name'=>'password1','aspassword'=>true,'value'=>$cl_password1));
56+
$form->addInput(array('type'=>'text','maxlength'=>'30','name'=>'password2','aspassword'=>true,'value'=>$cl_password2));
57+
}
58+
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_email','value'=>$cl_manager_email));
59+
$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.submit')));
60+
61+
if ($request->getMethod() == 'POST') {
62+
// Validate user input.
63+
if (!ttValidString($cl_team_name, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.team_name'));
64+
if (!ttValidString($cl_manager_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.manager_name'));
65+
if (!ttValidString($cl_manager_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.manager_login'));
66+
if (!$auth->isPasswordExternal()) {
67+
if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
68+
if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
69+
if ($cl_password1 !== $cl_password2)
70+
$errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
71+
}
72+
if (!ttValidEmail($cl_manager_email, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
73+
74+
if ($errors->isEmpty()) {
75+
if (!ttUserHelper::getUserByLogin($cl_manager_login)) {
76+
// Create a new team.
77+
if (!defined('CURRENCY_DEFAULT')) define('CURRENCY_DEFAULT', '$');
78+
$team_id = ttTeamHelper::insert(array('name'=>$cl_team_name,'currency'=>CURRENCY_DEFAULT));
79+
if ($team_id) {
80+
// Team created, now create a team manager.
81+
$user_id = ttUserHelper::insert(array(
82+
'team_id' => $team_id,
83+
'role' => ROLE_MANAGER,
84+
'name' => $cl_manager_name,
85+
'login' => $cl_manager_login,
86+
'password' => $cl_password1,
87+
'email' => $cl_manager_email));
88+
}
89+
if ($team_id && $user_id) {
90+
header('Location: admin_teams.php');
91+
} else
92+
$errors->add($i18n->getKey('error.db'));
93+
} else
94+
$errors->add($i18n->getKey('error.user_exists'));
95+
}
96+
}
97+
98+
$smarty->assign('auth_external', $auth->isPasswordExternal());
99+
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
100+
$smarty->assign('onload', 'onLoad="document.teamForm.team.focus()"');
101+
$smarty->assign('content_page_name', 'admin_team_add.tpl');
102+
$smarty->assign('title', $i18n->getKey('title.create_team'));
103+
$smarty->display('index.tpl');
104+
?>

admin_team_delete.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
// +----------------------------------------------------------------------+
3+
// | Anuko Time Tracker
4+
// +----------------------------------------------------------------------+
5+
// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6+
// +----------------------------------------------------------------------+
7+
// | LIBERAL FREEWARE LICENSE: This source code document may be used
8+
// | by anyone for any purpose, and freely redistributed alone or in
9+
// | combination with other software, provided that the license is obeyed.
10+
// |
11+
// | There are only two ways to violate the license:
12+
// |
13+
// | 1. To redistribute this code in source form, with the copyright
14+
// | notice or license removed or altered. (Distributing in compiled
15+
// | forms without embedded copyright notices is permitted).
16+
// |
17+
// | 2. To redistribute modified versions of this code in *any* form
18+
// | that bears insufficient indications that the modifications are
19+
// | not the work of the original author(s).
20+
// |
21+
// | This license applies to this document only, not any other software
22+
// | that it may be combined with.
23+
// |
24+
// +----------------------------------------------------------------------+
25+
// | Contributors:
26+
// | https://www.anuko.com/time_tracker/credits.htm
27+
// +----------------------------------------------------------------------+
28+
29+
require_once('initialize.php');
30+
import('form.Form');
31+
import('ttTeamHelper');
32+
33+
// Access check.
34+
if (!ttAccessCheck(right_administer_site)) {
35+
header('Location: access_denied.php');
36+
exit();
37+
}
38+
39+
$team_id = (int)$request->getParameter('id');
40+
$team_details = ttTeamHelper::getTeamDetails($team_id);
41+
$team_name = $team_details['team_name'];
42+
43+
$form = new Form('teamForm');
44+
$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$team_id));
45+
$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
46+
$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel')));
47+
48+
if ($request->getMethod() == 'POST') {
49+
if ($request->getParameter('btn_delete')) {
50+
if (ttTeamHelper::markDeleted($team_id)) {
51+
header('Location: admin_teams.php');
52+
exit();
53+
} else
54+
$errors->add($i18n->getKey('error.db'));
55+
}
56+
57+
if ($request->getParameter('btn_cancel')) {
58+
header('Location: admin_teams.php');
59+
exit();
60+
}
61+
}
62+
63+
$smarty->assign('team_to_delete', $team_name);
64+
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
65+
$smarty->assign('title', $i18n->getKey('title.delete_team'));
66+
$smarty->assign('content_page_name', 'admin_team_delete.tpl');
67+
$smarty->display('index.tpl');
68+
?>

0 commit comments

Comments
 (0)