本文整理汇总了PHP中DataAccess::SaveUser方法的典型用法代码示例。如果您正苦于以下问题:PHP DataAccess::SaveUser方法的具体用法?PHP DataAccess::SaveUser怎么用?PHP DataAccess::SaveUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataAccess
的用法示例。
在下文中一共展示了DataAccess::SaveUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Execute
//.........这里部分代码省略.........
$d["deleteId"] = "deleteCategory_" . $c->ID;
} else {
$id = (int) substr($key, 2);
$d["nameId"] = "categoryName_new_{$id}";
$d["defaultValue"] = "new_{$id}";
$d["deleteId"] = "deleteCategory_new_{$id}";
}
$d["defaultId"] = "categoryDefault_" . $d["defaultValue"];
if ($defaultCategory == $d["defaultValue"]) {
$defaultCategoryIndex = count($categoryData);
}
$categoryData[] = $d;
}
$defaultCategory = $defaultCategoryIndex == -1 ? 0 : $categoryData[$defaultCategoryIndex]["defaultValue"];
if (isset($_POST["save"])) {
// validate
if (DataAccess::UsernameExists($user->Username, $user->ID)) {
$errors[] = __("USERNAME_EXISTS");
}
if (trim($user->Username) == "") {
$errors[] = __("NO_USERNAME_ENTERED");
}
if (!$user->ID && trim($password) == "") {
$errors[] = __("NO_PASSWORD_ENTERED");
}
if (trim($user->FirstName) == "") {
$errors[] = __("NO_FIRST_NAME_ENTERED");
}
if (trim($user->LastName) == "") {
$errors[] = __("NO_LAST_NAME_ENTERED");
}
if ($user->Email == "") {
$errors[] = __("NO_EMAIL_ENTERED");
}
if ($user->Email != "" && !Helper::IsValidEmailAddress($user->Email)) {
$errors[] = __("INVALID_EMAIL");
}
foreach ($categories as $c) {
if (trim($c->Name) == "") {
$emptyCategoryNameFound = true;
}
}
if (isset($emptyCategoryNameFound)) {
$errors[] = __("CATEGORY_NAME_CANNOT_BE_EMPTY");
}
if (count($errors) == 0) {
$userSettings = array();
foreach ($_POST as $key => $value) {
if (substr($key, 0, 3) == "CV_") {
$key = substr($key, 3);
$userSettings[$key] = stripslashes($value);
}
}
DataAccess::SaveUser($user, $categories, $defaultCategoryIndex, $userSettings);
// send welcome email
if ($isNewUser && !($isAdmin && !$_POST["sendEmail"])) {
$fromName = __("DOMA_ADMIN_EMAIL_NAME");
$subject = __("NEW_USER_EMAIL_SUBJECT");
$baseAddress = Helper::GlobalPath("");
$userAddress = Helper::GlobalPath("index.php?user=" . $user->Username);
$body = sprintf(__("NEW_USER_EMAIL_BODY"), $user->FirstName, $baseAddress, $userAddress, $user->Username, $password);
$emailSent = true;
$emailSentSuccessfully = Helper::SendEmail($fromName, $user->Email, $subject, $body);
}
// clear language cache
Session::SetLanguageStrings(null);
if ($isAdmin) {
Helper::Redirect("users.php" . ($emailSent && !$emailSentSuccessfully ? "?error=email" : ""));
} else {
Helper::Redirect("index.php?" . Helper::CreateQuerystring($user));
}
}
}
if ($isAdmin) {
$viewData["Title"] = $user->ID ? sprintf(__("EDIT_USER_X"), $user->FirstName . " " . $user->LastName) : __("ADD_USER");
$viewData["Info"] = ($user->ID ? __("ADMIN_EDIT_USER_INFO") : __("ADMIN_ADD_USER_INFO")) . " " . sprintf(__("REQUIRED_FIELDS_INFO"), '<span class="required">*</span>');
} else {
$viewData["Title"] = $isNewUser ? __("ADD_USER_PROFILE_TITLE") : __("EDIT_USER_PROFILE_TITLE");
$viewData["Info"] = sprintf(__("REQUIRED_FIELDS_INFO"), '<span class="required">*</span>');
}
$atoms = array();
if ($isAdmin) {
$atoms[] = "mode=admin";
}
if ($user->ID) {
$atoms[] = Helper::CreateQuerystring($user);
}
$viewData["FormActionURL"] = $_SERVER["PHP_SELF"] . (count($atoms) > 0 ? "?" . join("&", $atoms) : "");
$viewData["Errors"] = $errors;
$viewData["IsAdmin"] = $isAdmin;
$viewData["IsNewUser"] = $isNewUser;
$viewData["User"] = $user;
$viewData["SendEmail"] = isset($_POST["sendEmail"]);
$viewData["CategoryData"] = $categoryData;
$viewData["DefaultCategory"] = $defaultCategory;
$viewData["DeleteButtonClicked"] = isset($_POST["delete"]);
$viewData["NoOfCategoriesAdded"] = isset($noOfCategoriesAdded) ? $noOfCategoriesAdded : 0;
$viewData["CustomizableSettings"] = Helper::GetCustomizableStrings();
return $viewData;
}