From: Nik Okuntseff Date: Fri, 16 Nov 2018 18:54:40 +0000 (+0000) Subject: Some refactoring for subgroup support. X-Git-Tag: timetracker_1.19-1~639 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8492dc052ad85039e0bbe11c7c3e1b8554907f64;p=timetracker.git Some refactoring for subgroup support. --- diff --git a/WEB-INF/lib/ttAdmin.class.php b/WEB-INF/lib/ttAdmin.class.php index 23d8480d..ef55ae50 100644 --- a/WEB-INF/lib/ttAdmin.class.php +++ b/WEB-INF/lib/ttAdmin.class.php @@ -176,7 +176,7 @@ class ttAdmin { // // 1) Users may mark some of them deleted during their work. // If we mark all of them deleted here, we can't recover nicely - // as we'll lose track of what was deleted by user. + // as we'll lose track of what was accidentally deleted by user. // // 2) DB maintenance script (Clean up DB from inactive groups) should // get rid of these items permanently eventually. diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 128650c6..6ddffaa8 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -30,25 +30,6 @@ // This is a planned replacement for ttTeamHelper as we move forward with subgroups. class ttGroupHelper { - // The getTopGroups function returns an array of all active top groups on the server. - static function getTopGroups() { - $result = array(); - $mdb2 = getConnection(); - - $sql = "select id, name, created, lang from tt_groups". - " where status = 1 and org_id = id order by id desc"; - $res = $mdb2->query($sql); - $result = array(); - if (!is_a($res, 'PEAR_Error')) { - while ($val = $res->fetchRow()) { - $val['date'] = substr($val['created'], 0, 10); // Strip the time. - $result[] = $val; - } - return $result; - } - return false; - } - // The getGroupName function returns group name. static function getGroupName($group_id) { $mdb2 = getConnection(); diff --git a/WEB-INF/lib/ttOrgHelper.class.php b/WEB-INF/lib/ttOrgHelper.class.php new file mode 100644 index 00000000..2cf04506 --- /dev/null +++ b/WEB-INF/lib/ttOrgHelper.class.php @@ -0,0 +1,65 @@ +query($sql); + $result = array(); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $val['date'] = substr($val['created'], 0, 10); // Strip the time. + $result[] = $val; + } + return $result; + } + return false; + } + + // The getName function returns organization name (which is a name of its top group). + static function getName($org_id) { + $mdb2 = getConnection(); + + $sql = "select name from tt_groups where id = $org_id and (status = 1 or status = 0) and parent_id is NULL"; + $res = $mdb2->query($sql); + + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + return $val['name']; + } + return false; + } +} diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 06e09393..8529b53c 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.14.4432 | Copyright © Anuko | +  Anuko Time Tracker 1.18.14.4433 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/admin_groups.php b/admin_groups.php index 78e083ca..ae66d150 100644 --- a/admin_groups.php +++ b/admin_groups.php @@ -27,7 +27,7 @@ // +----------------------------------------------------------------------+ require_once('initialize.php'); -import('ttGroupHelper'); +import('ttOrgHelper'); // Access checks. if (!ttAccessAllowed('administer_site')) { @@ -36,7 +36,7 @@ if (!ttAccessAllowed('administer_site')) { } // End of access checks. -$smarty->assign('groups', ttGroupHelper::getTopGroups()); +$smarty->assign('groups', ttOrgHelper::getOrgs()); $smarty->assign('title', $i18n->get('title.groups')); $smarty->assign('content_page_name', 'admin_groups.tpl'); $smarty->display('index.tpl'); diff --git a/login.php b/login.php index 3bfed9a4..e7254152 100644 --- a/login.php +++ b/login.php @@ -28,7 +28,7 @@ require_once('initialize.php'); import('form.Form'); -import('ttGroupHelper'); +import('ttOrgHelper'); import('ttUser'); $cl_login = $request->getParameter('login'); @@ -75,7 +75,7 @@ if ($request->isPost()) { } } // isPost -if(!isTrue(MULTITEAM_MODE) && !ttGroupHelper::getTopGroups()) +if(!isTrue(MULTITEAM_MODE) && !ttOrgHelper::getOrgs()) $err->add($i18n->get('error.no_groups')); // Determine whether to show login hint. It is currently used only for Windows LDAP authentication. diff --git a/mobile/login.php b/mobile/login.php index d094dfbf..243aa578 100644 --- a/mobile/login.php +++ b/mobile/login.php @@ -28,7 +28,7 @@ require_once('../initialize.php'); import('form.Form'); -import('ttGroupHelper'); +import('ttOrgHelper'); import('ttUser'); if ($request->isPost()) { @@ -80,7 +80,7 @@ if ($request->isPost()) { } } // isPost -if(!isTrue(MULTITEAM_MODE) && !ttGroupHelper::getTopGroups()) +if(!isTrue(MULTITEAM_MODE) && !ttOrgHelper::getOrgs()) $err->add($i18n->get('error.no_groups')); // Determine whether to show login hint. It is currently used only for Windows LDAP authentication.