001\n","" . getLngt("Registrierung fehlgeschlagen!") . "\n"); // Init only /* if ($appKey != "" && $appId != "") : // Get database instance connection data of metaobject $constExtDbInst = getExternalMetaDbInst(); $db_conn = getDbConnectionSpecial($constExtDbInst, $dbname, $dblogin, $dbpassword); $tmpSqlQuery = "SELECT mo_id, usr_id FROM meta_object.applicationuser WHERE app_id = '" . $appId . "' AND appusr_code = '" . $appKey . "' AND appusr_activated = '0'"; $result = $db_conn->query($tmpSqlQuery); while ($row = $result->fetch_assoc()): $retArray = array("0", $row["usr_id"], $row["mo_id"]); // Set activation flag $tmpSqlQuery = "UPDATE meta_object.applicationuser SET appusr_activated = '1' WHERE app_id = '" . $appId . "' AND appusr_code = '" . $appKey . "'"; $res = $db_conn->query($tmpSqlQuery); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; endwhile; $result->free(); endif; */ if ($userName != "" && $userFirstname != "" && $userEmail != "" && $userMobile != "") : // Get global IMPORT.UPLOAD path of the instance $importUploadPath = getParameterValue("0", "MD_IMPORT_UPLOAD_PATH", "0", "0"); if ($importUploadPath == "") : $importUploadPath = "../import/upload/"; endif; // Generate unique directory name do { $x_md_doc_dirname = md5(rand(0, getrandmax())); $tmpMdId = getFieldValueFromId("mandator", "md_doc_path", $importUploadPath . $x_md_doc_dirname . "/", "md_id"); } while ($tmpMdId != ""); // Generate unique user account $userAccount = trim($userAccount); do { $tmpUserAccount = $userAccount; $tmpUsrId = "0"; if ($tmpUserAccount != "") : $tmpUsrId = getFieldValueFromId("user", "usr_account", $tmpUserAccount, "usr_id"); if ($tmpUsrId != "") : $tmpUserAccount .= rand(10000, 99999); endif; else : $tmpUserAccount = rand(0, getrandmax()); endif; $tmpUsrId = getFieldValueFromId("user", "usr_account", $tmpUserAccount, "usr_id"); } while ($tmpUsrId != ""); $userAccount = $tmpUserAccount; // Generate user password $userPassword = trim($userPassword); if ($userPassword == "") : $userPassword = rand(0, getrandmax()); endif; if ($hqName == "") : $hqName = "101"; endif; if ($hqMnemonic == "") : $hqMnemonic = "101"; endif; // Insert company $sqlquery = "INSERT INTO company (cmp_comp, cmp_comp2, ad_id, cmp_hsno, cmp_iln, cmp_tax_idno, tx_id, br_id, cmp_bank, cmp_bankno, cmp_bankacc, cmp_bankmode, cmp_postage, cmp_inv2hq, cmp_authenticated, cmp_keyuser, cmp_publickey, cmp_defaultkey, cmp_logo, cmp_logo_width, cmp_logo_height, cmp_remark, cmp_match, cmp_match2, cmp_new_date, cmp_modify_status, cmp_export_time, cmp_visible) VALUES " . "('" . $cmpComp . "', '- " . $cmpComp2 . " -', 0, '', NULL, NULL, 0, 0, '', '', '0', 0, '0.00', 0, 0, NULL, NULL, NULL, '" . $logoFile . "', '" . $logoWidth . "', '" . $logoHeight . "', '', '', NULL, '0000-00-00 00:00:00', 0, '0000-00-00 00:00:00','1')"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF:
$sqlquery
" . $result->getMessage()); $cmp_id_last = getLastInsertId(); // Insert mandator $x_md_name = $x_md_doc_dirname; insertStmt("mandator", array("md_name", $x_md_name, "md_doc_path", $importUploadPath . $x_md_doc_dirname . "/")); $x_md_id = getLastInsertId(); // Insert headquarter $hqVhtDefault = getVhtId("2", "car_01"); $hqIsInserted = false; if ($hqId != "") : $tmpCmpIdHq = getFieldValueFromId("headquarters", "hq_id", $hqId, "cmp_id"); if ($tmpCmpIdHq == "") : insertStmt("headquarters", array("hq_id", $hqId, "hq_name", $hqName, "hq_mnemonic", $hqMnemonic, "cmp_id", $cmp_id_last, "hq_cr_prov", "0.0", "hq_prov", "0.0", "hq_workmode", "2", "hq_distancecalc", "0", "hq_vht_default", $hqVhtDefault, "hq_invmode", "1")); $x_hq_id = $hqId; $hqIsInserted = true; endif; endif; if (!$hqIsInserted) : insertStmt("headquarters", array("hq_name", $hqName, "hq_mnemonic", $hqMnemonic, "cmp_id", $cmp_id_last, "hq_cr_prov", "0.0", "hq_prov", "0.0", "hq_workmode", "2", "hq_distancecalc", "0", "hq_vht_default", $hqVhtDefault, "hq_invmode", "1")); $x_hq_id = getLastInsertId(); endif; // Insert mandatorheadquarters insertStmt("mandatorheadquarters", array("md_id", $x_md_id, "hq_id", $x_hq_id)); // Insert user "admin" for every mandator if ($insertAdmin == "1") : $adminPassword = "7348910256x%"; insertStmt("user", array("hq_id", $x_hq_id, "usr_type", "1", "usr_name", "Administrator " . $hqMnemonic, "usr_account", "admin_" . $x_md_id, "usr_password", $adminPassword)); $usr_id_last = getLastInsertId(); // Set crypted Password $sqlStmtPwd = "UPDATE user SET usr_password = PASSWORD('" . $adminPassword . "') WHERE usr_id = '" . $usr_id_last . "'"; $res = $db->query($sqlStmtPwd); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; insertStmt("employee", array("usr_id", $usr_id_last, "csc_id", "0", "emp_rights", "11111111111111111111111111111111111111111111111111", "emp_headquarters", $x_hq_id)); $emp_id_last = getLastInsertId(); updateStmt("headquarters", "hq_id", $x_hq_id, array("hq_admin", $emp_id_last)); // Set ALL rights in "employeerights" $rgtArray = getColVectorFromDB2Array("rights","rgt_type","emp","rgt_id","rgt_id"); $rgtArrayLen = count($rgtArray); for ($i = 0; $i < $rgtArrayLen; $i++) : insertStmt("employeerights", array("emp_id", $emp_id_last, "hq_id", $x_hq_id, "rgt_id", $rgtArray[$i])); endfor; endif; // Insert new user requested insertStmt("user", array("hq_id", $x_hq_id, "usr_type", "1", "usr_name", $userName, "usr_firstname", $userFirstname, "usr_email", $userEmail, "usr_phone", $userMobile, "usr_account", $userAccount, "usr_password", $userPassword)); $usr_id_last = getLastInsertId(); // Set crypted Password $sqlStmtPwd = "UPDATE user SET usr_password = PASSWORD('" . $userPassword . "') WHERE usr_id = '" . $usr_id_last . "'"; $res = $db->query($sqlStmtPwd); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; insertStmt("employee", array("usr_id", $usr_id_last, "csc_id", "0", "emp_rights", "11111111111111101111111111111111111111111111111111", "emp_headquarters", $x_hq_id)); $emp_id_last = getLastInsertId(); if ($insertAdmin != "1") : updateStmt("headquarters", "hq_id", $x_hq_id, array("hq_admin", $emp_id_last)); endif; // Set ALL rights in "employeerights" $rgtArray = getColVectorFromDB2Array("rights","rgt_type","emp","rgt_id","rgt_id"); $rgtArrayLen = count($rgtArray); for ($i = 0; $i < $rgtArrayLen; $i++) : insertStmt("employeerights", array("emp_id", $emp_id_last, "hq_id", $x_hq_id, "rgt_id", $rgtArray[$i])); endfor; // Insert database parameter insertParametersPerMandator($x_md_id, $x_hq_id, $hqMnemonic, $hqPrefix); $retArray = array("0", $usr_id_last, $x_hq_id); // Insert user into "metaobjects" // ........ endif; return $retArray; } ?>