File TODO changed (mode: 100644) (index cdb786f..c41a4fb) |
|
1 |
|
[ ] Integrate max_public/private_repos into HL. |
|
2 |
|
[ ] Allow specifying base language for a project. |
|
3 |
|
[ ] Allow specifying license for a project. |
|
4 |
|
[ ] When changind db structure, invalidate all caches. |
|
5 |
|
[ ] Check with owasp about html escaping. I do now htmlspecialchars -> |
|
6 |
|
db -> HTML:nl2br() |
|
7 |
|
[ ] Log also the last IP used. |
|
8 |
|
|
|
9 |
|
== Plans for repo redesign == |
|
10 |
|
Because we can have a project without a repository, for example only with |
|
11 |
|
bugtracker, we need to redesign the interface. |
|
12 |
|
|
|
13 |
|
We need to have projects, where you can attach: a repo, a bugtracker |
|
14 |
|
and/or a mailing list. |
|
15 |
|
|
|
16 |
|
We need rights to admin/create/delete/grant_rights against repo/bugtracker/mailing list. |
|
17 |
|
Pay attention. A project has an owner. Without "admin" rights, you cannot |
|
18 |
|
deal with the rest of |
|
19 |
|
A project is public/private. |
|
20 |
|
A repository/bt/ml link with a project. |
|
21 |
|
|
|
22 |
|
We begin with an admin user. We have no projects, so no repo/bt/ml. |
|
23 |
|
Admin user will create a user for a team-leader. |
|
24 |
|
Two cases: |
|
25 |
|
1. Allow user to create project |
|
26 |
|
So, we need "CREATE PROJECTS" right. |
|
27 |
|
2. Create project for him |
|
28 |
|
So, what rights should we give to him? "ADMIN PROJECT"? |
|
29 |
|
We should split"ADMIN" in finer rights: "DELETE PROJECT", |
|
30 |
|
"CREATE/DELETE/LOCK REPO", |
|
31 |
|
"CREATE/DELETE/LOCK BT", |
|
32 |
|
"CREATE/DELETE/LOCK ML". |
|
33 |
|
"LOCK" means that it will become read-only. |
|
34 |
|
|
|
35 |
|
Now, team-leader has a project. |
|
36 |
|
Two cases: |
|
37 |
|
1. Give "CREATE REPO" rights to a team member. |
|
38 |
|
2. Creates the repo and give rights to user. |
|
39 |
|
|
1 |
40 |
== BEFORE NEXT RELEASE == |
== BEFORE NEXT RELEASE == |
|
41 |
|
[ ] Maybe add an indirection level: Projects. Because an admin may use |
|
42 |
|
rocketgit only for the bug tracker, for example. Or only for mailing |
|
43 |
|
list. So, "Repositories" will become "Projects". Hm. |
|
44 |
|
[ ] 'first_install' value is not cached in RAM! |
2 |
45 |
[ ] Seems that an annotated tag cannot be overwritten, even with rights. |
[ ] Seems that an annotated tag cannot be overwritten, even with rights. |
3 |
46 |
[ ] Test bug.php is not working. Seems that repo_info is not working right for |
[ ] Test bug.php is not working. Seems that repo_info is not working right for |
4 |
47 |
an inexistent repo_id! |
an inexistent repo_id! |
5 |
48 |
[ ] From arora I cannot login! See a tcpdump. |
[ ] From arora I cannot login! See a tcpdump. |
6 |
49 |
[ ] Rights management |
[ ] Rights management |
7 |
|
- A user is trying to push some commits in a branch B, for a file F |
|
|
50 |
|
- A user USER is trying to push some commits in a branch B, |
|
51 |
|
for a file F |
8 |
52 |
- The set of rights may be: |
- The set of rights may be: |
9 |
53 |
Branch File/dir Rights |
Branch File/dir Rights |
10 |
54 |
B2 dir/*.png FPA |
B2 dir/*.png FPA |
|
17 |
61 |
private branch (refs/heads/USER/...). |
private branch (refs/heads/USER/...). |
18 |
62 |
* USER/ ??? - give rights to any user to a |
* USER/ ??? - give rights to any user to a |
19 |
63 |
private dir. |
private dir. |
|
64 |
|
- "USER" is the user that is logged in. Maybe find a better string |
|
65 |
|
because we may have a user "USER". |
20 |
66 |
- Also limit by IP and by time. |
- Also limit by IP and by time. |
21 |
67 |
- We have a problem: some rights do not map correctly to the plan above. |
- We have a problem: some rights do not map correctly to the plan above. |
22 |
|
For example, A(admin) |
|
|
68 |
|
For example, A(admin) etc. Seems we need to have >2 categories. |
23 |
69 |
- Also, we will have problems classifying a project as public or private. |
- Also, we will have problems classifying a project as public or private. |
24 |
70 |
Maybe we can compute the rights as an event after any rights change. |
Maybe we can compute the rights as an event after any rights change. |
25 |
|
Maybe we should let the user what type of project it is, and, if is |
|
26 |
|
public, to grant fetch right. |
|
|
71 |
|
Maybe we should let the user choose what type of project it is, and, |
|
72 |
|
if is public, to grant fetch right. |
27 |
73 |
- Should I add "Create users right"? |
- Should I add "Create users right"? |
|
74 |
|
- Repo rights: I should split admin into: "edit repo", "delete repo", |
|
75 |
|
"give rights" (should limit to his rights), "fill bugs", |
|
76 |
|
"close bugs", |
|
77 |
|
- Repo rights: allow "*" as user: default rights. |
|
78 |
|
- Very tempting to give up "register_rights" function and have the |
|
79 |
|
form as template. But I have to list them, join them etc. Hm. |
|
80 |
|
Think about translations, some time. |
|
81 |
|
I could use a rights file: "<right><tab><category><tab><name>" |
|
82 |
|
but this will duplicate the categories with translations. |
|
83 |
|
Maybe have two files, one with "<right><tab><category>" and one |
|
84 |
|
with "<right><tab><text>". |
|
85 |
|
I decided to let them in php file, but replace text with a |
|
86 |
|
translation lookup. |
|
87 |
|
[ ] Remove 'admin' stuff. We will give normal rights. |
|
88 |
|
[ ] We will use '*' = all rights, so we can extend the list and some users to |
|
89 |
|
get them automatically. |
|
90 |
|
[ ] You can grant the rights that you have, no more. |
|
91 |
|
[ ] De scos 'rights' din user/add_edit.html |
|
92 |
|
[ ] Allow comma separated users for grant rights. |
|
93 |
|
[ ] Loading defaults for refs_rights seems to not working. |
|
94 |
|
[ ] Secure transport X in configuratia de apache. Sau in index.php? |
|
95 |
|
[ ] |
28 |
96 |
|
|
29 |
|
== BEFORE NEXT RELEASE == |
|
30 |
|
[ ] Does it makes sense to have a local cache (user/repo/etc.) when we have |
|
31 |
|
another local cache (cache.inc.php). |
|
32 |
|
[ ] Search for "parmas" and "$e_". |
|
33 |
|
[ ] Remove all db escaping after switching to params! |
|
34 |
|
[ ] keys.inc.php - convert to params! |
|
35 |
|
[ ] Switch from pg_query to pg_query_params. |
|
36 |
|
[ ] Finish high level sql function. |
|
37 |
|
[ ] When we escape, it will try to connect to database, that may fail. |
|
38 |
|
This is not good at all and it seems a little bit hard to fix. |
|
39 |
|
Maybe switch to prepared statements? |
|
40 |
|
[ ] pg_fetch_assoc returns FALSE if error or no more rows. |
|
41 |
|
We must know the difference! |
|
|
97 |
|
== BEFORE NEXT-NEXT RELEASE == |
|
98 |
|
[ ] After resetting password, go to the login form, with user prefiled so the user can cache the password. |
|
99 |
|
[ ] Add number of bugs multiplied with a value to total disk space. |
|
100 |
|
[ ] How should I verify repo rights? |
|
101 |
|
if (admin) |
|
102 |
|
if (owner) |
|
103 |
|
if (public) |
|
104 |
|
pentru fiecare drept din lista ordonata dupa prioritati (putem avea mai multe din cauza ip/time/etc.) |
|
105 |
|
verifica daca are dreptul |
|
106 |
|
E valabil si pentru drepturi pe user? |
|
107 |
|
Cum ar trebui sa arate tabela de drepturi? Cred ca e ok. misc poate |
|
108 |
|
suporta drepturi ciudate. |
|
109 |
|
Sa vedem cum arata acum: |
|
110 |
|
type uid obj_id itime misc rights |
|
111 |
|
Ar trebui sa avem si prioritatea in lista ca sa puetm ordona |
|
112 |
|
dupa cum vrea user-ul. |
|
113 |
|
Se pare ca rg_rights_load e folosit doar pentru repo si nu si pentru user. |
|
114 |
|
rg_rights_set nu are notiunea de prio. |
|
115 |
|
As vrea ca si owner-ul sa poata sa se limiteze la un anumit set de ip-uri. |
|
116 |
|
Asta inseamna ca, din start, ar trebui sa adaug o regula pentru owner. |
|
117 |
|
Sa incerc sa schitez partea de admin a user-ilor. |
|
118 |
|
|
|
119 |
|
[ ] Do not pass a lot parameters in environment. Because of rights, we must |
|
120 |
|
do a lookup in cache/db anyway. Or, compute correct rights (take in |
|
121 |
|
account IP/time/etc.). No, because we need paths. |
|
122 |
|
[ ] 'rg_rights_allow' needs a first parameter that is the set. |
|
123 |
|
[ ] 'default_rights' must disappear. If repo is public, give basic rights. |
|
124 |
|
Else, none. Must disappear only because we have two sets of rights now. |
|
125 |
|
[ ] Repo rights were split in two. Check all rights checks! Maybe in check |
|
126 |
|
function, verify that there is a possible right and if not internal_error. |
|
127 |
|
[ ] Tree rights are a mess. User/Repo mixed rights. |
|
128 |
|
[ ] "Create repositories" user right should not be in repo rights? |
|
129 |
|
Probably not, because we may have no repo in the beginning. |
|
130 |
|
[ ] I will have a csv document with translations from where I will build |
|
131 |
|
some hash tables for fast lookups. |
42 |
132 |
[ ] Check "suspend"/"make admin"/etc. in admin area. Maybe use a checkbox and |
[ ] Check "suspend"/"make admin"/etc. in admin area. Maybe use a checkbox and |
43 |
133 |
an operation to avoid CSRF and to be consistent with ssh keys forms? |
an operation to avoid CSRF and to be consistent with ssh keys forms? |
44 |
134 |
[ ] Fix rights saga on user side. We may remove user_allow and replace with |
[ ] Fix rights saga on user side. We may remove user_allow and replace with |
45 |
135 |
rights_check? |
rights_check? |
46 |
|
[ ] Riths use-cases: |
|
47 |
|
[ ] An admin may not have "Remove" access. |
|
48 |
|
[ ] An admin may not have "Suspend" access. |
|
49 |
|
[ ] An admin may have only add/edit rights. |
|
50 |
136 |
[ ] "Reset password" in admin area? |
[ ] "Reset password" in admin area? |
51 |
137 |
[ ] "Make admin" will be replaced by "Edit"? |
[ ] "Make admin" will be replaced by "Edit"? |
52 |
138 |
[ ] Problems trying to push to rg1 because of SELinux: |
[ ] Problems trying to push to rg1 because of SELinux: |
|
75 |
161 |
[ ] Adding an account seems to just show "Account was created". |
[ ] Adding an account seems to just show "Account was created". |
76 |
162 |
Maybe redirect to user page? Only if there is no need to confirm. |
Maybe redirect to user page? Only if there is no need to confirm. |
77 |
163 |
What about lock_ip? |
What about lock_ip? |
78 |
|
[ ] Where to check if plan exists (rg_user_edit_high_level). |
|
|
164 |
|
[ ] Where to check if plan exists (rg_user_edit_high_level)? |
79 |
165 |
|
|
80 |
166 |
== Medium == |
== Medium == |
|
167 |
|
[ ] Add hit/miss stats to caches. |
|
168 |
|
[ ] If we have bug tracker, why not a mailing list?! |
|
169 |
|
[ ] Allow comma separated users in (at least) rights grant. |
|
170 |
|
[ ] Suggest some users on repo's "Grant rights". Maybe contributors? |
|
171 |
|
[ ] Does it makes sense to have a local cache (user/repo/etc.) when we have |
|
172 |
|
another local cache (cache.inc.php)? Pay attention to |
|
173 |
|
invalidating/refreshing the cache. Hm. |
|
174 |
|
Really-local one is faster for big lists. But, do we allow such big |
|
175 |
|
lists without pagination? |
|
176 |
|
[ ] pg_fetch_assoc returns FALSE if error or no more rows. |
|
177 |
|
We must know the difference! |
|
178 |
|
[ ] Finish high level sql function. |
|
179 |
|
[ ] No caching for keys.php? If we add one, update first_use only if needed. |
|
180 |
|
[ ] Rate limit at least login operations to prevent brute force passwords. |
|
181 |
|
Because the attack may come from several IPs, it is tempting to |
|
182 |
|
use target user for rate limit. But, we will prevent legitimate users |
|
183 |
|
to login. Maybe just increase the delay for login? Maybe notify user |
|
184 |
|
how many attempts were before succesful login. |
|
185 |
|
[ ] remote.php: call keys_update_use from an event. |
81 |
186 |
[ ] Allow user to change timezone! |
[ ] Allow user to change timezone! |
82 |
187 |
[ ] Prea mult spatiu gol la notificarea de schimbare repo. |
[ ] Prea mult spatiu gol la notificarea de schimbare repo. |
83 |
|
[ ] @@if: if after {{/}} follows a \n, just remove it? |
|
|
188 |
|
[ ] @@if: if after {{/}} follows a \n, just remove it? Maybe only if the if |
|
189 |
|
tokens are the only things on a line. |
84 |
190 |
[ ] Think about moving unused tokens to a new session after login. |
[ ] Think about moving unused tokens to a new session after login. |
85 |
191 |
[ ] Security: Edit info: user can chage the uid behind my back in form! |
[ ] Security: Edit info: user can chage the uid behind my back in form! |
86 |
192 |
This is fixed with rg_user_allow_access. It should be used everywhere. |
This is fixed with rg_user_allow_access. It should be used everywhere. |
|
153 |
259 |
[ ] We should have a log with logins, not only last_login per user. |
[ ] We should have a log with logins, not only last_login per user. |
154 |
260 |
So, we should have an event on login and explode it in several queries. |
So, we should have an event on login and explode it in several queries. |
155 |
261 |
Also session may be updated from this event, but still with a 1 min gap. |
Also session may be updated from this event, but still with a 1 min gap. |
156 |
|
[ ] Max number of users must be removed from repo. No need for it. |
|
157 |
262 |
[ ] Max commit size must be added per repo. |
[ ] Max commit size must be added per repo. |
158 |
263 |
[ ] A script to check if all CSS classes in templates are present in css file. |
[ ] A script to check if all CSS classes in templates are present in css file. |
159 |
264 |
[ ] Export/import a repo (xml maybe). |
[ ] Export/import a repo (xml maybe). |
|
... |
... |
them after processing is done. |
394 |
499 |
[ ] I am not sure I can reload xinetd and httpd from spec file |
[ ] I am not sure I can reload xinetd and httpd from spec file |
395 |
500 |
[ ] Check SELinux context on /var/lib/rocketgit |
[ ] Check SELinux context on /var/lib/rocketgit |
396 |
501 |
[ ] admin: "Lock all accounts" and "Reset password for all accounts and send mail". |
[ ] admin: "Lock all accounts" and "Reset password for all accounts and send mail". |
397 |
|
[ ] rg_repo_allow seems to not be used. |
|
398 |
502 |
[ ] Get memory statistics from /proc. |
[ ] Get memory statistics from /proc. |
399 |
503 |
[ ] Add support for refs/notes/ pushes. |
[ ] Add support for refs/notes/ pushes. |
400 |
504 |
[ ] When logging _SERVER variables, log only the ones prefixed by ROCKETGIT_. |
[ ] When logging _SERVER variables, log only the ones prefixed by ROCKETGIT_. |
File inc/bug.inc.php changed (mode: 100644) (index 1cb7d2c..fadfa1a) |
... |
... |
function rg_bug_search($db, $repo_id, $uid, $q) |
791 |
791 |
rg_log("bug_search: repo_id=$repo_id uid=$uid" |
rg_log("bug_search: repo_id=$repo_id uid=$uid" |
792 |
792 |
. " q=" . rg_array2string($q)); |
. " q=" . rg_array2string($q)); |
793 |
793 |
|
|
|
794 |
|
$params = array($repo_id); $index = 2; |
794 |
795 |
$add = array(); |
$add = array(); |
795 |
796 |
$limit = 25; |
$limit = 25; |
796 |
797 |
$ret = FALSE; |
$ret = FALSE; |
|
... |
... |
function rg_bug_search($db, $repo_id, $uid, $q) |
802 |
803 |
rg_bug_set_error("cannot lookup user (reported_by)"); |
rg_bug_set_error("cannot lookup user (reported_by)"); |
803 |
804 |
break; |
break; |
804 |
805 |
} |
} |
805 |
|
$add[] = "AND uid = " . $_ui['uid']; |
|
|
806 |
|
$add[] = "AND uid = \$" . $index; |
|
807 |
|
$params[] = $_ui['uid']; |
|
808 |
|
$index++; |
806 |
809 |
} |
} |
807 |
810 |
|
|
808 |
811 |
// assigned to |
// assigned to |
|
... |
... |
function rg_bug_search($db, $repo_id, $uid, $q) |
812 |
815 |
rg_bug_set_error("cannot lookup user (assigned_to)"); |
rg_bug_set_error("cannot lookup user (assigned_to)"); |
813 |
816 |
break; |
break; |
814 |
817 |
} |
} |
815 |
|
$add[] = "AND assigned_uid = " . $_ui['uid']; |
|
|
818 |
|
$add[] = "AND assigned_uid = \$" . $index; |
|
819 |
|
$params[] = $_ui['uid']; |
|
820 |
|
$index++; |
816 |
821 |
} |
} |
817 |
822 |
|
|
818 |
823 |
// state |
// state |
819 |
|
if (isset($q['state']) && ($q['state'] > 0)) |
|
820 |
|
$add[] = "AND state = " . $q['state']; |
|
|
824 |
|
if (isset($q['state']) && ($q['state'] > 0)) { |
|
825 |
|
$add[] = "AND state = \$" . $index; |
|
826 |
|
$params[] = $q['state']; |
|
827 |
|
$index++; |
|
828 |
|
} |
821 |
829 |
|
|
822 |
830 |
// start |
// start |
823 |
831 |
if (!empty($q['start'])) { |
if (!empty($q['start'])) { |
|
... |
... |
function rg_bug_search($db, $repo_id, $uid, $q) |
826 |
834 |
rg_bug_set_error("invalid start date format"); |
rg_bug_set_error("invalid start date format"); |
827 |
835 |
break; |
break; |
828 |
836 |
} |
} |
829 |
|
$add[] = "AND itime >= $ts"; |
|
|
837 |
|
$add[] = "AND itime >= \$" . $index; |
|
838 |
|
$params[] = $ts; |
|
839 |
|
$index++; |
830 |
840 |
} |
} |
831 |
841 |
|
|
832 |
842 |
// end |
// end |
|
... |
... |
function rg_bug_search($db, $repo_id, $uid, $q) |
836 |
846 |
rg_bug_set_error("invalid end date format"); |
rg_bug_set_error("invalid end date format"); |
837 |
847 |
break; |
break; |
838 |
848 |
} |
} |
839 |
|
$add[] = "AND itime <= $ts"; |
|
|
849 |
|
$add[] = "AND itime <= \$" . $index; |
|
850 |
|
$params[] = $ts; |
|
851 |
|
$index++; |
840 |
852 |
} |
} |
841 |
853 |
|
|
842 |
854 |
// title_string |
// title_string |
843 |
855 |
if (!empty($q['title_string'])) { |
if (!empty($q['title_string'])) { |
844 |
|
$_t = rg_sql_escape($db, $q['title_string']); |
|
845 |
|
$add[] = "AND title ILIKE '%" . $_t . "%'"; |
|
|
856 |
|
$add[] = "AND title ILIKE \$" . $index; |
|
857 |
|
$params[] = "%" . $q['title_string'] . "%"; |
|
858 |
|
$index++; |
846 |
859 |
} |
} |
847 |
860 |
|
|
848 |
861 |
// body_string |
// body_string |
849 |
862 |
if (!empty($q['body_string'])) { |
if (!empty($q['body_string'])) { |
850 |
|
$_t = rg_sql_escape($db, $q['body_string']); |
|
851 |
|
$add[] = "AND body ILIKE '%$" . $_t . "%'"; |
|
|
863 |
|
$add[] = "AND body ILIKE \$" . $index; |
|
864 |
|
$params[] = "%" . $q['body_string'] . "%"; |
|
865 |
|
$index++; |
852 |
866 |
} |
} |
853 |
867 |
|
|
854 |
868 |
// bugs_per_page |
// bugs_per_page |
|
... |
... |
function rg_bug_search($db, $repo_id, $uid, $q) |
862 |
876 |
break; |
break; |
863 |
877 |
} |
} |
864 |
878 |
|
|
865 |
|
$params = array($repo_id); |
|
866 |
879 |
$sql = "SELECT * FROM bugs" |
$sql = "SELECT * FROM bugs" |
867 |
880 |
. " WHERE repo_id = $1" |
. " WHERE repo_id = $1" |
868 |
881 |
. " AND deleted = 0" |
. " AND deleted = 0" |
|
... |
... |
function rg_bug_label_insert($db, $repo_id, $bug_id, $labels) |
1140 |
1153 |
} |
} |
1141 |
1154 |
|
|
1142 |
1155 |
// TODO: switch to params |
// TODO: switch to params |
|
1156 |
|
$params = array(); $index = 1; |
1143 |
1157 |
$list = array(); |
$list = array(); |
1144 |
1158 |
foreach ($diff as $label) { |
foreach ($diff as $label) { |
1145 |
|
$e_label = rg_sql_escape($db, $label); |
|
1146 |
|
$list[] = "($repo_id, $bug_id, '$e_label')"; |
|
|
1159 |
|
$params[] = $label; |
|
1160 |
|
$list[] = "($repo_id, $bug_id, \$" . $index . ")"; |
|
1161 |
|
$index++; |
1147 |
1162 |
} |
} |
1148 |
1163 |
$sql = "INSERT INTO bug_labels (repo_id, bug_id, label)" |
$sql = "INSERT INTO bug_labels (repo_id, bug_id, label)" |
1149 |
1164 |
. " VALUES " . implode(", ", $list); |
. " VALUES " . implode(", ", $list); |
1150 |
|
$res = rg_sql_query($db, $sql); |
|
|
1165 |
|
$res = rg_sql_query_params($db, $sql, $params); |
1151 |
1166 |
if ($res === FALSE) { |
if ($res === FALSE) { |
1152 |
1167 |
rg_bug_set_error("Cannot insert labels (" . rg_sql_error() . ")"); |
rg_bug_set_error("Cannot insert labels (" . rg_sql_error() . ")"); |
1153 |
1168 |
break; |
break; |
File inc/plan.inc.php changed (mode: 100644) (index 21c662b..c48167c) |
... |
... |
function rg_plan_edit($db, $d) |
46 |
46 |
|
|
47 |
47 |
$params = array($d['name'], $d['description'], $d['disk_mb'], |
$params = array($d['name'], $d['description'], $d['disk_mb'], |
48 |
48 |
$d['users'], $d['bw'], $d['speed'], $d['position'], |
$d['users'], $d['bw'], $d['speed'], $d['position'], |
49 |
|
$d['id']); |
|
|
49 |
|
$d['max_public_repos'], $d['max_private_repos']); |
50 |
50 |
if ($d['id'] == 0) { // add |
if ($d['id'] == 0) { // add |
51 |
51 |
$sql = "INSERT INTO plans (name, description, disk_mb" |
$sql = "INSERT INTO plans (name, description, disk_mb" |
52 |
|
. ", users, bw, speed, position)" |
|
53 |
|
. " VALUES ($1, $2, $3, $4, $5, $6, $7)" |
|
|
52 |
|
. ", users, bw, speed, position" |
|
53 |
|
. ", max_public_repos, max_private_repos)" |
|
54 |
|
. " VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)" |
54 |
55 |
. " RETURNING id"; |
. " RETURNING id"; |
55 |
56 |
} else { // edit |
} else { // edit |
|
57 |
|
$params[] = $d['id']; |
56 |
58 |
$sql = "UPDATE plans" |
$sql = "UPDATE plans" |
57 |
59 |
. " SET name = $1" |
. " SET name = $1" |
58 |
60 |
. ", description = $2" |
. ", description = $2" |
|
... |
... |
function rg_plan_edit($db, $d) |
61 |
63 |
. ", bw = $5" |
. ", bw = $5" |
62 |
64 |
. ", speed = $6" |
. ", speed = $6" |
63 |
65 |
. ", position = $7" |
. ", position = $7" |
64 |
|
. " WHERE id = $8" |
|
|
66 |
|
. ", max_public_repos = $8" |
|
67 |
|
. ", max_private_repos = $9" |
|
68 |
|
. " WHERE id = $10" |
65 |
69 |
. " RETURNING id"; |
. " RETURNING id"; |
66 |
70 |
} |
} |
67 |
71 |
|
|
|
... |
... |
function rg_plan_list($db) |
147 |
151 |
while (($row = rg_sql_fetch_array($res))) { |
while (($row = rg_sql_fetch_array($res))) { |
148 |
152 |
$row['exists'] = 1; |
$row['exists'] = 1; |
149 |
153 |
$id = $row['id']; |
$id = $row['id']; |
|
154 |
|
|
|
155 |
|
// fixes |
|
156 |
|
$row['HTML:description'] = nl2br($row['description']); |
|
157 |
|
unset($row['description']); |
|
158 |
|
|
150 |
159 |
$ret[$id] = $row; |
$ret[$id] = $row; |
151 |
160 |
} |
} |
152 |
161 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
|
... |
... |
function rg_plan_list_high_level($db, $sid, $more) |
261 |
270 |
*/ |
*/ |
262 |
271 |
function rg_plan_edit_high_level($db, $sid, $more) |
function rg_plan_edit_high_level($db, $sid, $more) |
263 |
272 |
{ |
{ |
264 |
|
rg_log("plan_edit_high_level"); |
|
|
273 |
|
rg_log("plan_edit_high_level more:" . rg_array2string($more)); |
265 |
274 |
|
|
266 |
275 |
$doit = rg_var_uint("doit"); |
$doit = rg_var_uint("doit"); |
267 |
|
$plan_id = rg_var_uint("id"); |
|
|
276 |
|
$id = isset($more['id']) ? sprintf("%u", $more['id']) : 0; |
268 |
277 |
|
|
269 |
278 |
$ret = ""; |
$ret = ""; |
270 |
279 |
$pi = array(); |
$pi = array(); |
271 |
280 |
|
|
272 |
281 |
if ($doit == 0) { |
if ($doit == 0) { |
273 |
|
if ($plan_id > 0) { |
|
274 |
|
$pi = rg_plan_info($db, $plan_id); |
|
|
282 |
|
if ($id > 0) { |
|
283 |
|
$pi = rg_plan_info($db, $id); |
275 |
284 |
if ($pi['exists'] != 1) { |
if ($pi['exists'] != 1) { |
276 |
285 |
$ret .= rg_warning("Invalid plan."); |
$ret .= rg_warning("Invalid plan."); |
277 |
286 |
return $ret; |
return $ret; |
278 |
287 |
} |
} |
279 |
288 |
} else { |
} else { |
280 |
|
// Defaults. |
|
|
289 |
|
// Defaults |
281 |
290 |
$pi['id'] = 0; |
$pi['id'] = 0; |
282 |
291 |
$pi['name'] = ""; |
$pi['name'] = ""; |
283 |
292 |
$pi['description'] = ""; |
$pi['description'] = ""; |
|
... |
... |
function rg_plan_edit_high_level($db, $sid, $more) |
286 |
295 |
$pi['bw'] = "0"; |
$pi['bw'] = "0"; |
287 |
296 |
$pi['speed'] = "0"; |
$pi['speed'] = "0"; |
288 |
297 |
$pi['position'] = "100"; |
$pi['position'] = "100"; |
|
298 |
|
$pi['max_public_repos'] = "0"; |
|
299 |
|
$pi['max_private_repos'] = "0"; |
289 |
300 |
} |
} |
290 |
301 |
} |
} |
291 |
302 |
|
|
|
... |
... |
function rg_plan_edit_high_level($db, $sid, $more) |
296 |
307 |
break; |
break; |
297 |
308 |
|
|
298 |
309 |
$pi = array(); |
$pi = array(); |
299 |
|
$pi['id'] = $plan_id; |
|
|
310 |
|
$pi['id'] = $id; |
300 |
311 |
$pi['name'] = rg_var_str("name"); |
$pi['name'] = rg_var_str("name"); |
301 |
312 |
$pi['description'] = rg_var_str("description"); |
$pi['description'] = rg_var_str("description"); |
302 |
313 |
$pi['disk_mb'] = rg_var_uint("disk_mb"); |
$pi['disk_mb'] = rg_var_uint("disk_mb"); |
|
... |
... |
function rg_plan_edit_high_level($db, $sid, $more) |
304 |
315 |
$pi['bw'] = rg_var_uint("bw"); |
$pi['bw'] = rg_var_uint("bw"); |
305 |
316 |
$pi['speed'] = rg_var_uint("speed"); |
$pi['speed'] = rg_var_uint("speed"); |
306 |
317 |
$pi['position'] = rg_var_uint("position"); |
$pi['position'] = rg_var_uint("position"); |
|
318 |
|
$pi['max_public_repos'] = rg_var_uint("max_public_repos"); |
|
319 |
|
$pi['max_private_repos'] = rg_var_uint("max_private_repos"); |
307 |
320 |
$token = rg_var_str("token"); |
$token = rg_var_str("token"); |
308 |
321 |
|
|
309 |
322 |
if (!rg_token_valid($db, $sid, $token)) { |
if (!rg_token_valid($db, $sid, $token)) { |
|
... |
... |
function rg_plan_edit_high_level($db, $sid, $more) |
318 |
331 |
} |
} |
319 |
332 |
|
|
320 |
333 |
// TODO: move to template. |
// TODO: move to template. |
321 |
|
$ret = rg_ok("Plan was added with success."); |
|
|
334 |
|
$ret .= rg_template("admin/plans/add_ok.html", $more); |
322 |
335 |
$load_form = FALSE; |
$load_form = FALSE; |
323 |
336 |
} while (0); |
} while (0); |
324 |
337 |
|
|
File inc/repo.inc.php changed (mode: 100644) (index f566a7f..0b9f210) |
... |
... |
require_once($INC . "/rights.inc.php"); |
8 |
8 |
require_once($INC . "/prof.inc.php"); |
require_once($INC . "/prof.inc.php"); |
9 |
9 |
require_once($INC . "/events.inc.php"); |
require_once($INC . "/events.inc.php"); |
10 |
10 |
|
|
11 |
|
$rg_repo_rights = array( |
|
12 |
|
"A" => "Admin", |
|
|
11 |
|
$rg_repo_refs_rights = array( |
13 |
12 |
"F" => "Fetch", |
"F" => "Fetch", |
14 |
13 |
"P" => "Push", |
"P" => "Push", |
15 |
14 |
"H" => "Anonymous push", |
"H" => "Anonymous push", |
16 |
15 |
"S" => "Create annotated tag", |
"S" => "Create annotated tag", |
17 |
|
"n" => "Delete annotated tag", |
|
|
16 |
|
"n" => "Delete annotated tag", // Seems this cannot be deleted. Remove this from here! |
18 |
17 |
"Y" => "Create un-annotated tag", |
"Y" => "Create un-annotated tag", |
19 |
18 |
"U" => "Modify un-annotated tag", |
"U" => "Modify un-annotated tag", |
20 |
19 |
"u" => "Delete un-annotated tag", |
"u" => "Delete un-annotated tag", |
|
... |
... |
$rg_repo_rights = array( |
25 |
24 |
"W" => "Bad whitespace" |
"W" => "Bad whitespace" |
26 |
25 |
); |
); |
27 |
26 |
|
|
|
27 |
|
// Admin = edit name/description/etc. |
|
28 |
|
$rg_repo_rights = array( |
|
29 |
|
"A" => "Access repo (read-only)", // this also define public/private |
|
30 |
|
"E" => "Edit repo", |
|
31 |
|
"D" => "Delete repo", |
|
32 |
|
"G" => "Grant rights", |
|
33 |
|
"a" => "Access bug tracker", |
|
34 |
|
"X" => "Delete bug tracker", |
|
35 |
|
"B" => "Add bugs", |
|
36 |
|
"C" => "Close bugs" |
|
37 |
|
); |
|
38 |
|
|
28 |
39 |
// What rights are on by default |
// What rights are on by default |
29 |
40 |
// TODO: this should go into conf file? |
// TODO: this should go into conf file? |
30 |
|
$rg_repo_rights_default = "FMH"; |
|
|
41 |
|
// TODO: better move all config to database (modulo db conn info)? |
|
42 |
|
$rg_repo_refs_rights_default = "FMH"; |
|
43 |
|
$rg_repo_rights_default = "B"; |
31 |
44 |
|
|
|
45 |
|
rg_rights_register("repo_refs", $rg_repo_refs_rights); |
32 |
46 |
rg_rights_register("repo", $rg_repo_rights); |
rg_rights_register("repo", $rg_repo_rights); |
33 |
47 |
|
|
34 |
48 |
|
|
|
... |
... |
function rg_repo_set_error($str) |
46 |
60 |
{ |
{ |
47 |
61 |
global $rg_repo_error; |
global $rg_repo_error; |
48 |
62 |
$rg_repo_error = $str; |
$rg_repo_error = $str; |
|
63 |
|
rg_log($str); |
49 |
64 |
} |
} |
50 |
65 |
|
|
51 |
66 |
function rg_repo_error() |
function rg_repo_error() |
|
... |
... |
function rg_repo_info($db, $repo_id, $uid, $repo_name) |
505 |
520 |
} |
} |
506 |
521 |
|
|
507 |
522 |
/* |
/* |
508 |
|
* Check if a user has access to repository |
|
|
523 |
|
* Check if a user has access to a repository |
509 |
524 |
*/ |
*/ |
510 |
525 |
function rg_repo_allow($db, $ri, $ui, $needed_rights) |
function rg_repo_allow($db, $ri, $ui, $needed_rights) |
511 |
526 |
{ |
{ |
|
... |
... |
function rg_repo_allow($db, $ri, $ui, $needed_rights) |
521 |
536 |
} |
} |
522 |
537 |
|
|
523 |
538 |
if (empty($needed_rights)) { |
if (empty($needed_rights)) { |
524 |
|
rg_log("\tNo perms passed!"); |
|
|
539 |
|
rg_internal_error("You asked for no rights!"); |
525 |
540 |
return FALSE; |
return FALSE; |
526 |
541 |
} |
} |
527 |
542 |
|
|
|
... |
... |
function rg_repo_allow($db, $ri, $ui, $needed_rights) |
557 |
572 |
* TODO: unify this function with rg_repo_update. |
* TODO: unify this function with rg_repo_update. |
558 |
573 |
*/ |
*/ |
559 |
574 |
function rg_repo_create($db, $master, $ui, $name, $max_commit_size, |
function rg_repo_create($db, $master, $ui, $name, $max_commit_size, |
560 |
|
$description, $rights, $max_users) |
|
|
575 |
|
$description, $rights) |
561 |
576 |
{ |
{ |
562 |
577 |
rg_prof_start("repo_create"); |
rg_prof_start("repo_create"); |
563 |
578 |
|
|
|
... |
... |
function rg_repo_create($db, $master, $ui, $name, $max_commit_size, |
566 |
581 |
. ", name=[$name], master=$master" |
. ", name=[$name], master=$master" |
567 |
582 |
. ", max_commit_size=$max_commit_size" |
. ", max_commit_size=$max_commit_size" |
568 |
583 |
. ", description=[$description]" |
. ", description=[$description]" |
569 |
|
. ", rights=$rights, max_users=$max_users..."); |
|
|
584 |
|
. ", rights=$rights"); |
570 |
585 |
|
|
571 |
586 |
// TODO: test if user is allowed to add a repository |
// TODO: test if user is allowed to add a repository |
572 |
587 |
|
|
|
... |
... |
function rg_repo_create($db, $master, $ui, $name, $max_commit_size, |
588 |
603 |
$itime = time(); |
$itime = time(); |
589 |
604 |
|
|
590 |
605 |
$params = array($ui['uid'], $master, $name, $itime, |
$params = array($ui['uid'], $master, $name, $itime, |
591 |
|
$max_commit_size, $description, $rights, $max_users); |
|
|
606 |
|
$max_commit_size, $description, $rights); |
592 |
607 |
$sql = "INSERT INTO repos (uid, master, name" |
$sql = "INSERT INTO repos (uid, master, name" |
593 |
608 |
. ", itime, max_commit_size, description, git_dir_done" |
. ", itime, max_commit_size, description, git_dir_done" |
594 |
|
. ", default_rights, max_users)" |
|
595 |
|
. " VALUES ($1, $2, $3, $4, $5, $6, 0, $7, $8)" |
|
|
609 |
|
. ", default_rights)" |
|
610 |
|
. " VALUES ($1, $2, $3, $4, $5, $6, 0, $7)" |
596 |
611 |
. " RETURNING repo_id"; |
. " RETURNING repo_id"; |
597 |
612 |
$res = rg_sql_query_params($db, $sql, $params); |
$res = rg_sql_query_params($db, $sql, $params); |
598 |
613 |
if ($res === FALSE) { |
if ($res === FALSE) { |
|
... |
... |
function rg_repo_update($db, $login_ui, &$new) |
805 |
820 |
|
|
806 |
821 |
$params = array($new['name'], $new['max_commit_size'], |
$params = array($new['name'], $new['max_commit_size'], |
807 |
822 |
trim($new['description']), $new['default_rights'], |
trim($new['description']), $new['default_rights'], |
808 |
|
$new['max_users'], $new['repo_id']); |
|
|
823 |
|
$new['repo_id']); |
809 |
824 |
$sql = "UPDATE repos SET name = $1" |
$sql = "UPDATE repos SET name = $1" |
810 |
825 |
. ", max_commit_size = $2" |
. ", max_commit_size = $2" |
811 |
826 |
. ", description = $3" |
. ", description = $3" |
812 |
827 |
. ", default_rights = $4" |
. ", default_rights = $4" |
813 |
|
. ", max_users = $5" |
|
814 |
|
. " WHERE repo_id = $6"; |
|
|
828 |
|
. " WHERE repo_id = $5"; |
815 |
829 |
$res = rg_sql_query_params($db, $sql, $params); |
$res = rg_sql_query_params($db, $sql, $params); |
816 |
830 |
if ($res === FALSE) { |
if ($res === FALSE) { |
817 |
831 |
rg_repo_set_error("Cannot update (" . rg_sql_error() . ")"); |
rg_repo_set_error("Cannot update (" . rg_sql_error() . ")"); |
|
... |
... |
function rg_repo_list($db, $url, $ui) |
905 |
919 |
{ |
{ |
906 |
920 |
rg_log("repo_list: url=$url, uid=" . $ui['uid']); |
rg_log("repo_list: url=$url, uid=" . $ui['uid']); |
907 |
921 |
|
|
|
922 |
|
$params = array(); |
|
923 |
|
$index = 1; |
|
924 |
|
|
908 |
925 |
$add = ""; |
$add = ""; |
909 |
|
if ($ui['uid'] > 0) |
|
910 |
|
$add = " AND uid = $1"; |
|
|
926 |
|
if ($ui['uid'] > 0) { |
|
927 |
|
$add = " AND uid = \$" . $index; |
|
928 |
|
$params[] = $ui['uid']; |
|
929 |
|
$index++; |
|
930 |
|
} |
911 |
931 |
|
|
912 |
|
$params = array($ui['uid']); |
|
913 |
932 |
$sql = "SELECT * FROM repos" |
$sql = "SELECT * FROM repos" |
914 |
933 |
. " WHERE deleted = 0" |
. " WHERE deleted = 0" |
915 |
934 |
. $add |
. $add |
|
... |
... |
function rg_repo_search($db, $login_ui, $q) |
931 |
950 |
if (isset($login_ui['admin']) && ($login_ui['admin'] == 1)) |
if (isset($login_ui['admin']) && ($login_ui['admin'] == 1)) |
932 |
951 |
$admin = 1; |
$admin = 1; |
933 |
952 |
|
|
934 |
|
$params = array($q, $login_ui['uid']); |
|
|
953 |
|
$params = array("%" . $q . "%", $login_ui['uid']); |
935 |
954 |
$sql = "SELECT * FROM repos" |
$sql = "SELECT * FROM repos" |
936 |
955 |
. " WHERE deleted = 0" |
. " WHERE deleted = 0" |
937 |
|
. " AND (name ILIKE '%$1%' OR description ILIKE '%$1%')" |
|
938 |
|
. " AND (uid = $2 OR default_rights LIKE '%F%'" |
|
939 |
|
. " OR " . $admin . " = 1)" |
|
|
956 |
|
. " AND (name ILIKE $1 OR description ILIKE $1)" |
|
957 |
|
. " AND (uid = $2 OR default_rights LIKE '%F%' OR " . $admin . " = 1)" |
940 |
958 |
. " ORDER BY master, name" |
. " ORDER BY master, name" |
941 |
959 |
. " LIMIT 10"; |
. " LIMIT 10"; |
942 |
960 |
|
|
File inc/repo/repo.php changed (mode: 100644) (index 1edc485..5823907) |
... |
... |
if ($login_ui['uid'] == 0) { |
11 |
11 |
|
|
12 |
12 |
$name = rg_var_str("name"); |
$name = rg_var_str("name"); |
13 |
13 |
$max_commit_size = rg_var_uint("max_commit_size"); |
$max_commit_size = rg_var_uint("max_commit_size"); |
14 |
|
$max_users = rg_var_uint("max_users"); |
|
15 |
14 |
$description = rg_var_str("description"); |
$description = rg_var_str("description"); |
16 |
15 |
$master_repo_id = rg_var_uint("master_repo_id"); |
$master_repo_id = rg_var_uint("master_repo_id"); |
17 |
16 |
$repo_id = rg_var_uint("repo_id"); |
$repo_id = rg_var_uint("repo_id"); |
|
... |
... |
case 'create': |
48 |
47 |
|
|
49 |
48 |
do { |
do { |
50 |
49 |
$_r = rg_repo_create($db, $master_repo_id, $login_ui, $name, |
$_r = rg_repo_create($db, $master_repo_id, $login_ui, $name, |
51 |
|
$max_commit_size, $description, $rights, $max_users); |
|
|
50 |
|
$max_commit_size, $description, $rights); |
52 |
51 |
if ($_r === FALSE) { |
if ($_r === FALSE) { |
53 |
52 |
$errmsg[] = rg_repo_error(); |
$errmsg[] = rg_repo_error(); |
54 |
53 |
break; |
break; |
|
... |
... |
case 'create': |
76 |
75 |
$repo_more['button'] = "Create"; |
$repo_more['button'] = "Create"; |
77 |
76 |
$repo_more['name'] = $name; |
$repo_more['name'] = $name; |
78 |
77 |
$repo_more['max_commit_size'] = $max_commit_size; |
$repo_more['max_commit_size'] = $max_commit_size; |
79 |
|
$repo_more['max_users'] = $max_users; |
|
80 |
78 |
$repo_more['description'] = $description; |
$repo_more['description'] = $description; |
81 |
79 |
$repo_more['master_repo_id'] = $master_repo_id; |
$repo_more['master_repo_id'] = $master_repo_id; |
82 |
80 |
$repo_more['HTML:rights'] = rg_rights_checkboxes("repo", $rights); |
$repo_more['HTML:rights'] = rg_rights_checkboxes("repo", $rights); |
83 |
81 |
$repo_more['repo_id'] = $repo_id; |
$repo_more['repo_id'] = $repo_id; |
84 |
82 |
$repo_more['HTML:errmsg'] = rg_template_errmsg($errmsg); |
$repo_more['HTML:errmsg'] = rg_template_errmsg($errmsg); |
85 |
83 |
$repo_more['rg_form_token'] = rg_token_get($db, $sid); |
$repo_more['rg_form_token'] = rg_token_get($db, $sid); |
|
84 |
|
|
|
85 |
|
$hints = array(); |
|
86 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/create_repo.html", $repo_more); |
|
87 |
|
$repo_more['HTML:hints'] = rg_template_table("hints/list", $hints, $repo_more); |
|
88 |
|
|
86 |
89 |
$_repo .= rg_template("repo/add_edit.html", $repo_more); |
$_repo .= rg_template("repo/add_edit.html", $repo_more); |
87 |
90 |
break; |
break; |
88 |
91 |
|
|
File inc/rights.inc.php changed (mode: 100644) (index 8873b5a..2d4baaa) |
... |
... |
function rg_rights_a2s($a) |
128 |
128 |
$rights = ""; |
$rights = ""; |
129 |
129 |
|
|
130 |
130 |
if (!is_array($a)) { |
if (!is_array($a)) { |
131 |
|
rg_internal_error("Para is not an array"); |
|
|
131 |
|
rg_internal_error("Rights array is not an array"); |
132 |
132 |
return ""; |
return ""; |
133 |
133 |
} |
} |
134 |
134 |
|
|
|
... |
... |
function rg_rights_a2s($a) |
138 |
138 |
return rg_rights_fix($rights); |
return rg_rights_fix($rights); |
139 |
139 |
} |
} |
140 |
140 |
|
|
141 |
|
|
|
142 |
141 |
/* |
/* |
143 |
142 |
* Get rights for an object |
* Get rights for an object |
|
143 |
|
* TODO: caching in RAM? |
144 |
144 |
*/ |
*/ |
145 |
145 |
function rg_rights_get($db, $type, $obj_id, $uid) |
function rg_rights_get($db, $type, $obj_id, $uid) |
146 |
146 |
{ |
{ |
|
... |
... |
function rg_rights_get($db, $type, $obj_id, $uid) |
159 |
159 |
} |
} |
160 |
160 |
|
|
161 |
161 |
$params = array($type, $uid, $obj_id); |
$params = array($type, $uid, $obj_id); |
162 |
|
$sql = "SELECT itime, rights, misc FROM rights" |
|
|
162 |
|
$sql = "SELECT itime, rights, misc, prio FROM rights" |
163 |
163 |
. " WHERE type = $1" |
. " WHERE type = $1" |
164 |
164 |
. " AND uid = $2" |
. " AND uid = $2" |
165 |
165 |
. " AND obj_id = $3" |
. " AND obj_id = $3" |
166 |
|
. " LIMIT 1"; |
|
|
166 |
|
. " ORDER BY prio"; |
167 |
167 |
$res = rg_sql_query_params($db, $sql, $params); |
$res = rg_sql_query_params($db, $sql, $params); |
168 |
168 |
if ($res === FALSE) { |
if ($res === FALSE) { |
169 |
169 |
rg_rights_set_error("cannot get info (" . rg_sql_error() . ")!"); |
rg_rights_set_error("cannot get info (" . rg_sql_error() . ")!"); |
|
... |
... |
function rg_rights_get($db, $type, $obj_id, $uid) |
182 |
182 |
$ret['itime'] = $row['itime']; |
$ret['itime'] = $row['itime']; |
183 |
183 |
$ret['rights'] = $row['rights']; |
$ret['rights'] = $row['rights']; |
184 |
184 |
$ret['misc'] = empty($row['misc']) ? array() : unserialize($row['misc']); |
$ret['misc'] = empty($row['misc']) ? array() : unserialize($row['misc']); |
|
185 |
|
$ret['prio'] = $row['prio']; |
185 |
186 |
$ret['exists'] = 1; |
$ret['exists'] = 1; |
186 |
187 |
} while (0); |
} while (0); |
187 |
188 |
|
|
|
... |
... |
function rg_rights_set($db, $type, $obj_id, $uid, $rights, $misc) |
240 |
241 |
} |
} |
241 |
242 |
|
|
242 |
243 |
/* |
/* |
243 |
|
* Returns an array with the rights |
|
|
244 |
|
* Returns an array with the rights, for all users |
244 |
245 |
*/ |
*/ |
245 |
246 |
function rg_rights_load($db, $type, $obj_id) |
function rg_rights_load($db, $type, $obj_id) |
246 |
247 |
{ |
{ |
|
... |
... |
function rg_rights_load($db, $type, $obj_id) |
274 |
275 |
$row['itime_text'] = gmdate("Y-m-d H:i", $row['itime']); |
$row['itime_text'] = gmdate("Y-m-d H:i", $row['itime']); |
275 |
276 |
|
|
276 |
277 |
// To avoid confusion |
// To avoid confusion |
277 |
|
$row['right_uid'] = $row['uid']; |
|
278 |
|
unset($row['uid']); |
|
|
278 |
|
$row['right_uid'] = $row['uid']; unset($row['uid']); |
279 |
279 |
|
|
280 |
280 |
$ret[] = $row; |
$ret[] = $row; |
281 |
281 |
} |
} |
File inc/user.inc.php changed (mode: 100644) (index ffb18bf..724f6fb) |
... |
... |
require_once($INC . "/cache.inc.php"); |
9 |
9 |
require_once($INC . "/plan.inc.php"); |
require_once($INC . "/plan.inc.php"); |
10 |
10 |
|
|
11 |
11 |
$rg_user_rights = array( |
$rg_user_rights = array( |
12 |
|
"C" => "Create repositories", |
|
13 |
|
"U" => "Add/edit users", |
|
14 |
|
"S" => "Suspend accounts", |
|
15 |
|
"A" => "Up/downgrade to admin level", |
|
16 |
|
"R" => "Remove account" |
|
|
12 |
|
"C" => "Create repository", |
|
13 |
|
"A" => "Create user", |
|
14 |
|
"E" => "Edit user", |
|
15 |
|
"R" => "Remove user", |
|
16 |
|
"S" => "Suspend user", |
|
17 |
|
"G" => "Grant rights" |
17 |
18 |
); |
); |
18 |
19 |
|
|
19 |
20 |
rg_rights_register("user", $rg_user_rights); |
rg_rights_register("user", $rg_user_rights); |
|
... |
... |
function rg_user_suspend($db, $uid, $op) |
811 |
812 |
else |
else |
812 |
813 |
$v = 0; |
$v = 0; |
813 |
814 |
|
|
814 |
|
$parmas = array($v, $uid); |
|
|
815 |
|
$params = array($v, $uid); |
815 |
816 |
$sql = "UPDATE users SET suspended = $1 WHERE uid = $2"; |
$sql = "UPDATE users SET suspended = $1 WHERE uid = $2"; |
816 |
817 |
$res = rg_sql_query_params($db, $sql, $params); |
$res = rg_sql_query_params($db, $sql, $params); |
817 |
818 |
if ($res === FALSE) { |
if ($res === FALSE) { |
|
... |
... |
function rg_user_set_last_seen($db, $uid) |
868 |
869 |
|
|
869 |
870 |
$now = time(); |
$now = time(); |
870 |
871 |
|
|
871 |
|
$params = array($now, $uid); |
|
872 |
|
$sql = "UPDATE users SET last_seen = $1 WHERE uid = $2"; |
|
|
872 |
|
$IP = $_SERVER['REMOTE_ADDR']; |
|
873 |
|
|
|
874 |
|
$params = array($now, $IP, $uid); |
|
875 |
|
$sql = "UPDATE users SET last_seen = $1, last_ip = $2 WHERE uid = $3"; |
873 |
876 |
$res = rg_sql_query_params($db, $sql, $params); |
$res = rg_sql_query_params($db, $sql, $params); |
874 |
877 |
if ($res === FALSE) { |
if ($res === FALSE) { |
875 |
878 |
rg_user_set_error("cannot update last seen (" . rg_sql_error() . ")"); |
rg_user_set_error("cannot update last seen (" . rg_sql_error() . ")"); |
|
... |
... |
function rg_user_list($db) |
911 |
914 |
$ret .= " <th>Confirmed?</th>\n"; |
$ret .= " <th>Confirmed?</th>\n"; |
912 |
915 |
$ret .= " <th>Session time</th>\n"; |
$ret .= " <th>Session time</th>\n"; |
913 |
916 |
$ret .= " <th>Last seen (UTC)</th>\n"; |
$ret .= " <th>Last seen (UTC)</th>\n"; |
|
917 |
|
$ret .= " <th>Last IP</th>\n"; |
914 |
918 |
$ret .= " <th>Rights</th>\n"; |
$ret .= " <th>Rights</th>\n"; |
915 |
919 |
$ret .= " <th>Operations</th>\n"; |
$ret .= " <th>Operations</th>\n"; |
916 |
920 |
$ret .= "</tr>\n"; |
$ret .= "</tr>\n"; |
|
... |
... |
function rg_user_list($db) |
932 |
936 |
$ret .= " <td>" . $row['session_time'] . "s</td>\n"; |
$ret .= " <td>" . $row['session_time'] . "s</td>\n"; |
933 |
937 |
$v = $row['last_seen'] == 0 ? "-" : gmdate("Y-m-d", $row['last_seen']); |
$v = $row['last_seen'] == 0 ? "-" : gmdate("Y-m-d", $row['last_seen']); |
934 |
938 |
$ret .= " <td>" . $v . "</td>\n"; |
$ret .= " <td>" . $v . "</td>\n"; |
|
939 |
|
$ret .= " <td>" . $row['last_ip'] . "</td>\n"; |
935 |
940 |
$v = implode(", ", rg_rights_text("user", $row['rights'])); |
$v = implode(", ", rg_rights_text("user", $row['rights'])); |
936 |
941 |
$ret .= " <td>" . $v . "</td>\n"; |
$ret .= " <td>" . $v . "</td>\n"; |
937 |
942 |
|
|
File inc/user/repo/admin/rights/rights.php changed (mode: 100644) (index 5a0786b..464321f) |
... |
... |
$_rights = ""; |
6 |
6 |
|
|
7 |
7 |
$target_user = rg_var_str("target_user"); |
$target_user = rg_var_str("target_user"); |
8 |
8 |
$rights = rg_rights_a2s(rg_var_str("rights")); |
$rights = rg_rights_a2s(rg_var_str("rights")); |
|
9 |
|
$refs_rights = rg_rights_a2s(rg_var_str("refs_rights")); |
9 |
10 |
$delete = rg_var_uint("delete"); |
$delete = rg_var_uint("delete"); |
10 |
11 |
$edit_uid = rg_var_uint("edit_uid"); |
$edit_uid = rg_var_uint("edit_uid"); |
11 |
12 |
$grant = rg_var_uint("grant"); |
$grant = rg_var_uint("grant"); |
|
... |
... |
$del_errmsg = array(); |
21 |
22 |
|
|
22 |
23 |
$repo_rights_more['target_user'] = $target_user; |
$repo_rights_more['target_user'] = $target_user; |
23 |
24 |
$repo_rights_more['rights'] = $rights; |
$repo_rights_more['rights'] = $rights; |
|
25 |
|
$repo_rights_more['refs_rights'] = $refs_rights; |
|
26 |
|
$repo_rights_more['ref'] = $ref; |
|
27 |
|
$repo_rights_more['path'] = $path; |
24 |
28 |
|
|
25 |
29 |
$load_defaults = 1; |
$load_defaults = 1; |
26 |
30 |
|
|
|
... |
... |
do { |
71 |
75 |
|
|
72 |
76 |
$repo_rights_more['target_user'] = $target_ui['username']; |
$repo_rights_more['target_user'] = $target_ui['username']; |
73 |
77 |
$repo_rights_more['rights'] = $r['rights']; |
$repo_rights_more['rights'] = $r['rights']; |
|
78 |
|
$repo_rights_more['refs_rights'] = $r['refs_rights']; |
74 |
79 |
} while (0); |
} while (0); |
75 |
80 |
|
|
76 |
81 |
// Adding |
// Adding |
|
... |
... |
do { |
102 |
107 |
break; |
break; |
103 |
108 |
} |
} |
104 |
109 |
|
|
105 |
|
// no need to pre-fill user beause was just added |
|
|
110 |
|
// no need to pre-fill user because was just added |
106 |
111 |
$repo_rights_more['target_user'] = ""; |
$repo_rights_more['target_user'] = ""; |
107 |
112 |
$repo_rights_more['rights'] = ""; |
$repo_rights_more['rights'] = ""; |
|
113 |
|
$repo_rights_more['refs_rights'] = ""; |
108 |
114 |
} while (0); |
} while (0); |
109 |
115 |
|
|
110 |
116 |
if ($load_defaults == 1) { |
if ($load_defaults == 1) { |
111 |
117 |
$ref = ""; |
$ref = ""; |
112 |
118 |
$path = ""; |
$path = ""; |
113 |
119 |
$rights = $rg_repo_rights_default; |
$rights = $rg_repo_rights_default; |
|
120 |
|
$refs_rights = $rg_repo_refs_rights_default; |
114 |
121 |
} |
} |
115 |
122 |
|
|
116 |
123 |
$repo_rights_more['rg_form_token'] = rg_token_get($db, $sid); |
$repo_rights_more['rg_form_token'] = rg_token_get($db, $sid); |
117 |
124 |
$repo_rights_more['HTML:errmsg'] = rg_template_errmsg($errmsg); |
$repo_rights_more['HTML:errmsg'] = rg_template_errmsg($errmsg); |
118 |
125 |
$repo_rights_more['HTML:del_errmsg'] = rg_template_errmsg($del_errmsg); |
$repo_rights_more['HTML:del_errmsg'] = rg_template_errmsg($del_errmsg); |
119 |
126 |
$repo_rights_more['HTML:rights_checkboxes'] = rg_rights_checkboxes("repo", $rights); |
$repo_rights_more['HTML:rights_checkboxes'] = rg_rights_checkboxes("repo", $rights); |
|
127 |
|
$repo_rights_more['HTML:refs_rights_checkboxes'] = rg_rights_checkboxes("repo_refs", $rights); |
120 |
128 |
|
|
121 |
129 |
// list rights |
// list rights |
122 |
130 |
$rights_list = rg_repo_rights_load($db, $ri); |
$rights_list = rg_repo_rights_load($db, $ri); |