当前位置: 首页>>代码示例>>PHP>>正文


PHP DataAccess::NoOfMapsInCategory方法代码示例

本文整理汇总了PHP中DataAccess::NoOfMapsInCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP DataAccess::NoOfMapsInCategory方法的具体用法?PHP DataAccess::NoOfMapsInCategory怎么用?PHP DataAccess::NoOfMapsInCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataAccess的用法示例。


在下文中一共展示了DataAccess::NoOfMapsInCategory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Execute

 public function Execute()
 {
     $viewData = array();
     $isAdmin = isset($_GET["mode"]) && $_GET["mode"] == "admin" && Helper::IsLoggedInAdmin();
     // no user specified and not admin mode - redirect to user list page
     if (!$isAdmin && !getCurrentUser() && !Session::GetPublicCreationCodeEntered()) {
         Helper::Redirect("users.php");
     }
     $errors = array();
     $user = getCurrentUser();
     $isNewUser = !isset($user) || !$user->ID;
     if ($isNewUser) {
         $user = new User();
     }
     if (isset($_POST["cancel"])) {
         Helper::Redirect($isAdmin ? "users.php" : "index.php?" . Helper::CreateQuerystring($user));
     }
     if ($isAdmin && isset($_POST["deleteConfirmed"])) {
         DataAccess::DeleteUserByID($user->ID);
         Helper::Redirect($isAdmin ? "users.php" : "index.php?" . Helper::CreateQuerystring($user));
     }
     // any category handling button clicked?
     $addCategory = null;
     $deleteCategory = null;
     foreach ($_POST as $key => $value) {
         if (substr($key, 0, 15) == "deleteCategory_") {
             $deleteCategory = substr($key, 15);
             break;
         }
         if ($key == "addCategory") {
             $addCategory = true;
             break;
         }
     }
     if (isset($_POST["save"]) || isset($_POST["delete"]) || $deleteCategory || $addCategory) {
         // populate user object with data from form elements
         $user->Username = stripslashes($_POST["username"]);
         $password = stripslashes($_POST["password"]);
         if ($password) {
             $user->Password = md5($password);
         }
         $user->FirstName = stripslashes($_POST["firstName"]);
         $user->LastName = stripslashes($_POST["lastName"]);
         $user->Email = stripslashes($_POST["email"]);
         if ($isAdmin) {
             $user->Visible = $_POST["visible"] ? 1 : 0;
         }
         if (!$isAdmin && $isNewUser) {
             $user->Visible = 1;
         }
         $defaultCategory = $_POST["defaultCategory"];
         $noOfCategoriesAdded = $_POST["noOfCategoriesAdded"];
         // the category array
         foreach ($_POST as $key => $value) {
             if (substr($key, 0, 17) == "categoryName_new_") {
                 $id = "1_" . sprintf("%08d", substr($key, 17));
                 $categories[$id] = new Category();
                 $categories[$id]->Name = stripslashes($value);
                 $categories[$id]->UserID = $user->ID;
             } elseif (substr($key, 0, 13) == "categoryName_") {
                 $id = "0_" . sprintf("%08d", substr($key, 13));
                 $categories[$id] = new Category();
                 $categories[$id]->Name = stripslashes($value);
                 $categories[$id]->UserID = $user->ID;
                 $categories[$id]->ID = substr($key, 13);
             }
         }
         ksort($categories);
         // shall we delete a category?
         if ($deleteCategory) {
             if (count($categories) <= 1) {
                 $errors[] = __("CAN_NOT_DELETE_ALL_CATEGORIES");
             } else {
                 if (substr($deleteCategory, 0, 4) == "new_") {
                     // unsaved categories can be deleted directly
                     $id = "1_" . sprintf("%08d", substr($deleteCategory, 4));
                     unset($categories[$id]);
                 } else {
                     // for saved categories, we need to check for existing maps
                     $id = "0_" . sprintf("%08d", $deleteCategory);
                     $noOfMapsInCategory = DataAccess::NoOfMapsInCategory($deleteCategory);
                     if ($noOfMapsInCategory > 0) {
                         $errors[] = sprintf(__("CAN_NOT_DELETE_NONEMPTY_CATEGORY"), $categories[$id]->Name, $noOfMapsInCategory);
                     } else {
                         unset($categories[$id]);
                     }
                 }
             }
         }
         if ($addCategory) {
             $id = "1_" . sprintf("%08d", $noOfCategoriesAdded);
             $categories[$id] = new Category();
             $categories[$id]->UserID = $user->ID;
             $noOfCategoriesAdded++;
         }
     } else {
         // first page visit
         if ($isNewUser) {
             $noOfCategoriesAdded = 0;
             if ($isAdmin) {
//.........这里部分代码省略.........
开发者ID:andopor,项目名称:doma-project,代码行数:101,代码来源:edit_user.controller.php


注:本文中的DataAccess::NoOfMapsInCategory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。