From 40ee06a1d1a45513852a85de4ac3b6f1bab85ba9 Mon Sep 17 00:00:00 2001 From: skeeter Date: Thu, 27 Dec 2001 15:14:02 +0000 Subject: [PATCH] A few minor cleanups. Also, changed what I could to use ExecMethod(). This is much cleaner when calling a single function from a class than creating an instantiation of the class and calling a single method. --- admin/inc/class.boaccounts.inc.php | 47 ++++++++++------------------- admin/inc/class.uiaccounts.inc.php | 10 +++--- admin/inc/class.uimenuclass.inc.php | 17 +++++------ 3 files changed, 30 insertions(+), 44 deletions(-) diff --git a/admin/inc/class.boaccounts.inc.php b/admin/inc/class.boaccounts.inc.php index 7b48b34f9d..68f660ac89 100755 --- a/admin/inc/class.boaccounts.inc.php +++ b/admin/inc/class.boaccounts.inc.php @@ -78,8 +78,7 @@ { if (!@isset($GLOBALS['HTTP_POST_VARS']['account_id']) || !@$GLOBALS['HTTP_POST_VARS']['account_id'] || $GLOBALS['phpgw']->acl->check('group_access',32,'admin')) { - $ui = createobject('admin.uiaccounts'); - $ui->list_groups(); + ExecMethod('admin.uiaccounts.list_groups'); return False; } @@ -115,17 +114,15 @@ $GLOBALS['phpgw']->db->unlock(); - $ui = createobject('admin.uiaccounts'); - $ui->list_accounts(); - return False; + Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups')); + $GLOBALS['phpgw']->common->phpgw_exit(); } function delete_user() { if (isset($GLOBALS['HTTP_POST_VARS']['cancel']) || $GLOBALS['phpgw']->acl->check('account_access',32,'admin')) { - $ui = createobject('admin.uiaccounts'); - $ui->list_users(); + ExecMethod('admin.uiaccounts.list_users'); return False; } elseif($GLOBALS['HTTP_POST_VARS']['delete_account']) @@ -163,8 +160,7 @@ $cd = 29; } - $ui = createobject('admin.uiaccounts'); - $ui->list_users(); + ExecMethod('admin.uiaccounts.list_users'); return False; } } @@ -173,8 +169,7 @@ { if ($GLOBALS['phpgw']->acl->check('group_access',4,'admin')) { - $ui = createobject('admin.uiaccounts'); - $ui->list_groups(); + ExecMethod('admin.uiaccounts.list_groups'); return False; } @@ -288,8 +283,7 @@ $GLOBALS['phpgw']->db->unlock(); - $ui = createobject('admin.uiaccounts'); - $ui->list_groups(); + ExecMethod('admin.uiaccounts.list_groups'); return False; } @@ -297,8 +291,7 @@ { if ($GLOBALS['phpgw']->acl->check('account_access',4,'admin')) { - $ui = createobject('admin.uiaccounts'); - $ui->list_users(); + ExecMethod('admin.uiaccounts.list_users'); return False; } @@ -329,8 +322,7 @@ if (!$errors = $this->validate_user($userData)) { $this->so->add_user($userData); - $ui = createobject('admin.uiaccounts'); - $ui->list_users(); + ExecMethod('admin.uiaccounts.list_users'); return False; } else @@ -341,8 +333,7 @@ } else { - $ui = createobject('admin.uiaccounts'); - $ui->list_users(); + ExecMethod('admin.uiaccounts.list_users'); return False; } } @@ -351,8 +342,7 @@ { if ($GLOBALS['phpgw']->acl->check('group_access',16,'admin')) { - $ui = createobject('admin.uiaccounts'); - $ui->list_groups(); + ExecMethod('admin.uiaccounts.list_groups'); return False; } @@ -512,8 +502,7 @@ $GLOBALS['phpgw']->db->unlock(); - $ui = createobject('admin.uiaccounts'); - $ui->list_groups(); + ExecMethod('admin.uiaccounts.list_groups'); return False; } @@ -521,8 +510,7 @@ { if ($GLOBALS['phpgw']->acl->check('account_access',16,'admin')) { - $ui = createobject('admin.uiaccounts'); - $ui->list_users(); + ExecMethod('admin.uiaccounts.list_users'); return False; } @@ -555,17 +543,14 @@ // check if would create a menu // if we do, we can't return to the users list, because // there are also some other plugins - $menuClass = CreateObject('admin.uimenuclass'); - if (!$menuClass->createHTMLCode('edit_user')) + if (!ExecMethod('admin.uimenuclass.createHTMLCode','edit_user')) { - $ui = createobject('admin.uiaccounts'); - $ui->list_users(); + ExecMethod('admin.uiaccounts.list_users'); return False; } else { - $ui = createobject('admin.uiaccounts'); - $ui->edit_user($GLOBALS['HTTP_GET_VARS']['account_id']); + ExecMethod('admin.uiaccountsiedit_user',$GLOBALS['HTTP_GET_VARS']['account_id']); return False; } } diff --git a/admin/inc/class.uiaccounts.inc.php b/admin/inc/class.uiaccounts.inc.php index da168a6e18..c4f94a2dc1 100755 --- a/admin/inc/class.uiaccounts.inc.php +++ b/admin/inc/class.uiaccounts.inc.php @@ -663,8 +663,9 @@ $var['permissions_list'] = $appRightsOutput; // create the menu on the left, if needed - $menuClass = CreateObject('admin.uimenuclass'); - $var['rows'] = $menuClass->createHTMLCode('view_user'); +// $menuClass = CreateObject('admin.uimenuclass'); + // This is now using ExecMethod() + $var['rows'] = ExecMethod('admin.uimenuclass.createHTMLCode','view_user'); $t->set_var($var); $t->pfp('out','form'); } @@ -1038,8 +1039,9 @@ $t->set_var($var); // create the menu on the left, if needed - $menuClass = CreateObject('admin.uimenuclass'); - $t->set_var('rows',$menuClass->createHTMLCode('edit_user')); +// $menuClass = CreateObject('admin.uimenuclass'); + // This is now using ExecMethod() + $t->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','edit_user')); echo $t->fp('out','form'); } diff --git a/admin/inc/class.uimenuclass.inc.php b/admin/inc/class.uimenuclass.inc.php index 7e0282023a..6cb9de8165 100644 --- a/admin/inc/class.uimenuclass.inc.php +++ b/admin/inc/class.uimenuclass.inc.php @@ -13,6 +13,9 @@ class uimenuclass { + var $t; + var $rowColor = Array(); + function uimenuclass() { $this->t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('admin')); @@ -21,14 +24,12 @@ $this->t->set_block('menurow','menu_links','menu_links'); $this->t->set_block('menurow','link_row','link_row'); - $this->rowColor[0] = $GLOBALS['phpgw_info']["theme"]["row_on"]; - $this->rowColor[1] = $GLOBALS['phpgw_info']["theme"]["row_off"]; + $this->rowColor[0] = $GLOBALS['phpgw_info']['theme']['row_on']; + $this->rowColor[1] = $GLOBALS['phpgw_info']['theme']['row_off']; } function section_item($pref_link='',$pref_text='', $bgcolor) { - global $t; - $this->t->set_var('row_link',$pref_link); $this->t->set_var('row_text',$pref_text); $this->t->set_var('tr_color',$bgcolor); @@ -42,21 +43,19 @@ // This allows extra data to be sent along function display_section($_menuData) { - global $account_id; - $i=0; while(list($key,$value) = each($_menuData)) { if (!empty($value['extradata'])) { - $link = $GLOBALS['phpgw']->link($value['url'],'account_id=' . $account_id . '&' . $value['extradata']); + $link = $GLOBALS['phpgw']->link($value['url'],'account_id=' . $GLOBALS['account_id'] . '&' . $value['extradata']); } else { - $link = $GLOBALS['phpgw']->link($value['url'],'account_id=' . $account_id); + $link = $GLOBALS['phpgw']->link($value['url'],'account_id=' . $GLOBALS['account_id']); } - $this->section_item($link,lang($value['description']),$this->rowColor[$i%2]); + $this->section_item($link,lang($value['description']),$this->rowColor[($i % 2)]); $i++; }