xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit f54af2c20ebd4df3b3424cab2e0bfb80aa8bafe6

worker fixes for when admin edits workers

Author: Catalin(ux) M. BOIE
Author date (UTC): 2016-09-25 20:26
Committer: Catalin(ux) M. BOIE
Commit date (UTC): 2016-09-25 20:26
Tree: 9465f1b39f975ee7f4afd8bb5887ec0ed877c491
Parents: ab0c22fb84e13b9699b45ca8bc8181dd15f7a4a5
File Lines added Lines deleted
inc/workers.inc.php 12 16

File inc/workers.inc.php changed (mode: 100644) (index 43096a2..7e6f287)
... ... function rg_worker_add($db, $uid, $a)
253 253 rg_prof_start('worker_add'); rg_prof_start('worker_add');
254 254 rg_log_enter('worker_add'); rg_log_enter('worker_add');
255 255
256 //rg_log_ml('DEBUG: a: ' . print_r($a, TRUE));
256 //rg_log_ml('DEBUG: uid=' . $uid . ', a: ' . print_r($a, TRUE));
257 257
258 258 $ret = FALSE; $ret = FALSE;
259 259 while (1) { while (1) {
260 $params = array();
260 $params = $a;
261 261 $params['uid'] = $uid; $params['uid'] = $uid;
262 $params['id'] = $a['id'];
263 $params['name'] = $a['name'];
264 $params['cost'] = $a['cost'];
265 $params['workers'] = $a['workers'];
266 262
267 263 if ($a['id'] == 0) { if ($a['id'] == 0) {
268 264 $params['itime'] = time(); $params['itime'] = time();
 
... ... function rg_worker_add_high_level($db, $rg, $op, $paras)
485 481 $ret = ''; $ret = '';
486 482 $errmsg = array(); $errmsg = array();
487 483
484 // All admins will have 'who' == 0
485 if ($rg['login_ui']['is_admin'] == 1)
486 $target_uid = 0;
487 else
488 $target_uid = $rg['login_ui']['uid'];
489
488 490 $rg['worker'] = array(); $rg['worker'] = array();
489 491 if (strcmp($op, 'add') == 0) { if (strcmp($op, 'add') == 0) {
490 492 $rg['worker']['id'] = 0; $rg['worker']['id'] = 0;
 
... ... function rg_worker_add_high_level($db, $rg, $op, $paras)
492 494 $rg['worker']['key'] = rg_id(32); $rg['worker']['key'] = rg_id(32);
493 495 $rg['worker']['cost'] = 10; $rg['worker']['cost'] = 10;
494 496 $rg['worker']['workers'] = 1; $rg['worker']['workers'] = 1;
495 } else {
497 } else { // edit
496 498 if (isset($paras[0])) { if (isset($paras[0])) {
497 499 $id = intval($paras[0]); $id = intval($paras[0]);
498 $r = rg_worker_find_by_id($db, $rg['login_ui']['uid'],
499 $id);
500
501 $r = rg_worker_find_by_id($db, $target_uid, $id);
500 502 if ($r === -1) if ($r === -1)
501 503 $errmsg[] = 'error loading list; try again later'; $errmsg[] = 'error loading list; try again later';
502 504 else if ($r === 0) else if ($r === 0)
 
... ... function rg_worker_add_high_level($db, $rg, $op, $paras)
542 544 break; break;
543 545 } }
544 546
545 if ($rg['login_ui']['is_admin'] == 1) {
546 $rg['worker']['who'] = 0;
547 $target_uid = 0;
548 } else {
549 $rg['worker']['who'] = $rg['login_ui']['uid'];
550 $target_uid = $rg['login_ui']['uid'];
551 }
547 $rg['worker']['who'] = $target_uid;
552 548 $r = rg_worker_add($db, $target_uid, $rg['worker']); $r = rg_worker_add($db, $target_uid, $rg['worker']);
553 549 if ($r === FALSE) { if ($r === FALSE) {
554 550 $errmsg[] = rg_worker_error(); $errmsg[] = rg_worker_error();
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master