From 021d72b93e05b6cbbe75fd95e280fd36188d8479 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 15 Oct 2005 07:57:06 +0000 Subject: [PATCH] extended the check for (admin-)accounts to other account storages --- setup/inc/class.setup.inc.php | 55 +++++++++++++++++++++++++++-------- setup/index.php | 4 +-- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/setup/inc/class.setup.inc.php b/setup/inc/class.setup.inc.php index c8611f4f0c..474c85d2a1 100644 --- a/setup/inc/class.setup.inc.php +++ b/setup/inc/class.setup.inc.php @@ -293,20 +293,19 @@ return False; } - /** - * check if username and password is valid - * - * this function compares the supplied and stored username and password + /** + * check if username and password is valid + * + * this function compares the supplied and stored username and password * as any of the passwords can be clear text or md5 we convert them to md5 * internal and compare always the md5 hashs - * - * @param string $user the user supplied username - * @param string $pw the user supplied password - * @param string $conf_user the configured username - * @param string $conf_pw the configured password - * @returns bool - */ - + * + * @param string $user the user supplied username + * @param string $pw the user supplied password + * @param string $conf_user the configured username + * @param string $conf_pw the configured password + * @returns bool + */ function check_auth($user,$pw,$conf_user,$conf_pw) { #echo "

setup::check_auth('$user','$pw','$conf_user','$conf_pw')

\n";exit; @@ -946,6 +945,38 @@ return $accountid; } + + /** + * Check if accounts other then the automatically installed anonymous account exist + * + * We check via the account object, to deal with different account-storages + * + * @return boolean + */ + function accounts_exist() + { + $this->setup_account_object(); + + $accounts = $GLOBALS['egw']->accounts->search(array( + 'type' => 'accounts', + 'start' => 0, + 'offset' => 2, // we only need to check 2 accounts, if we just check for not anonymous + )); + + if (!$accounts || !is_array($accounts) || !count($accounts)) + { + return false; + } + foreach($accounts as $account) + { + if ($account['account_lid'] != 'anonymous') + { + // we might add further checks, eg. if the account really has admin rights here + return true; + } + } + return false; + } /** * Add ACL rights diff --git a/setup/index.php b/setup/index.php index e9ecee308a..81b1079170 100644 --- a/setup/index.php +++ b/setup/index.php @@ -512,9 +512,7 @@ function check_dir($dir,&$msg,$check_in_docroot=false) { case 10: // check if there is already a user account (not the anonymous account of sitemgr or a group) - // Note: this does not check the availiblitly of accounts via other auth-methods then sql !!! - $GLOBALS['egw_setup']->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u' AND account_lid!='anonymous'",__LINE__,__FILE__); - $no_accounts = !$GLOBALS['egw_setup']->db->next_record() || !$GLOBALS['egw_setup']->db->f(0); + $no_accounts = !$GLOBALS['egw_setup']->accounts_exist(); $setup_tpl->set_var('admin_status_img',$no_accounts ? $incomplete : $completed); $setup_tpl->set_var('admin_status_alt',$no_accounts ? lang('not completed') : lang('completed')); $setup_tpl->set_var('admin_table_data',$GLOBALS['egw_setup']->html->make_frm_btn_simple(