function loadUser($loginname = "") { dbg("Loading User"); if (!Sql_Table_exists("user")) return; initialiseUserSession(); if (!$loginname) { if ($_SESSION["userloggedin"] != "" && $_SESSION["username"] != "") { $loginname = $_SESSION["username"]; } else { return ""; } } $att_req = Sql_Query(sprintf('select attribute.id, %s.name,%s.type, %s.value,%s.tablename from %s,%s,%s where %s.userid = %s.id and %s.email = "%s" and %s.id = %s.attributeid', "attribute", "attribute", "user_attribute", "attribute", "user", "user_attribute", "attribute", "user_attribute", "user", "user", $loginname, "attribute", "user_attribute" )); while ($att = Sql_fetch_array($att_req)) { # if (!defined($_SESSION["userdata"]["attribute".$att["id"]])) { $_SESSION["userdata"]["attribute".$att["id"]] = array( "name" => $att["name"], "value" => $att["value"], "type" => $att["type"], "attid" => $att["id"] ); switch ($att["type"]) { case "textline": case "hidden": $_SESSION["userdata"]["attribute".$att["id"]]["displayvalue"] = $att["value"]; break; case "creditcardno": $_SESSION["userdata"]["attribute".$att["id"]]["displayvalue"] = obscureCreditCard($att["value"]); break; case "select": $_SESSION["userdata"]["attribute".$att["id"]]["displayvalue"] = AttributeValue($att["tablename"],$att["value"]); break; } # } } $d_req = Sql_Fetch_Array_Query("select * from user where email = \"$loginname\""); $_SESSION["userid"] = $d_req["id"]; foreach (array("email","disabled","confirmed","htmlemail","uniqid") as $field) { # if (!defined($_SESSION["userdata"][$field])) { $_SESSION["userdata"][$field] = array( "name" => $field, "value" => $d_req[$field], "type" => "static", "displayvalue" => $d_req[$field] ); # } } dbg("done loading user"); $_SESSION["groups"] = userGroups($loginname); return 1; }
function loadUser($loginname = '') { if (!Sql_Table_exists('user')) { return; } initialiseUserSession(); if (!$loginname) { if ($_SESSION['userloggedin'] != '' && $_SESSION['username'] != '') { $loginname = $_SESSION['username']; } else { return ''; } } $att_req = Sql_Query(sprintf('select attribute.id, %s.name,%s.type, %s.value,%s.tablename from %s,%s,%s where %s.userid = %s.id and %s.email = "%s" and %s.id = %s.attributeid', 'attribute', 'attribute', 'user_attribute', 'attribute', 'user', 'user_attribute', 'attribute', 'user_attribute', 'user', 'user', addslashes($loginname), 'attribute', 'user_attribute')); while ($att = Sql_fetch_array($att_req)) { # if (!defined($_SESSION["userdata"]["attribute".$att["id"]])) { $_SESSION['userdata']['attribute' . $att['id']] = array('name' => $att['name'], 'value' => $att['value'], 'type' => $att['type'], 'attid' => $att['id'], 'displayvalue' => $att['value']); switch ($att['type']) { case 'textline': case 'hidden': $_SESSION['userdata']['attribute' . $att['id']]['displayvalue'] = $att['value']; break; case 'creditcardno': $_SESSION['userdata']['attribute' . $att['id']]['displayvalue'] = obscureCreditCard($att['value']); break; case 'select': $_SESSION['userdata']['attribute' . $att['id']]['displayvalue'] = AttributeValue($att['tablename'], $att['value']); break; case 'date': $_SESSION['userdata']['attribute' . $att['id']]['displayvalue'] = formatDate($att['value']); break; } # } } $d_req = Sql_Fetch_Array_Query("select * from user where email = \"{$loginname}\""); $_SESSION['userid'] = $d_req['id']; foreach (array('email', 'disabled', 'confirmed', 'htmlemail', 'uniqid', 'password', 'foreignkey') as $field) { # if (!defined($_SESSION["userdata"][$field])) { $_SESSION['userdata'][$field] = array('name' => $field, 'value' => $d_req[$field], 'type' => 'static', 'displayvalue' => $d_req[$field]); # } } $_SESSION['usergroups'] = userGroups($loginname); if (is_array($GLOBALS['config']['usergreeting'])) { $_SESSION['usergreeting'] = ''; foreach ($GLOBALS['config']['usergreeting'] as $att) { $_SESSION['usergreeting'] .= $_SESSION['userdata'][$att]['displayvalue'] . ' '; } $_SESSION['usergreeting'] = rtrim($_SESSION['usergreeting']); } dbg('done loading user'); return 1; }