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


PHP ca_users::getFormFields方法代码示例

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


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

示例1: register

 function register()
 {
     if ($this->request->config->get('dont_allow_registration_and_login')) {
         $this->notification->addNotification(_t("Registration is not enabled"), __NOTIFICATION_TYPE_ERROR__);
         $this->redirect(caNavUrl($this->request, '', 'Front', 'Index'));
         return;
     }
     MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . _t("Register"));
     # logout user in case is already logged in
     $this->request->deauthenticate();
     $t_user = new ca_users();
     $t_user->purify(true);
     # --- process incoming registration attempt
     $ps_email = $this->request->getParameter("email", pString);
     $ps_fname = $this->request->getParameter("fname", pString);
     $ps_lname = $this->request->getParameter("lname", pString);
     $ps_password = $this->request->getParameter("password", pString);
     $ps_password2 = $this->request->getParameter("password2", pString);
     $ps_security = $this->request->getParameter("security", pString);
     $va_errors = array();
     if (!caCheckEmailAddress($ps_email)) {
         $va_errors["email"] = _t("E-mail address is not valid.");
     } else {
         $t_user->set("email", $ps_email);
     }
     if (!$ps_fname) {
         $va_errors["fname"] = _t("Please enter your first name");
     } else {
         $t_user->set("fname", $ps_fname);
     }
     if (!$ps_lname) {
         $va_errors["lname"] = _t("Please enter your last name");
     } else {
         $t_user->set("lname", $ps_lname);
     }
     if (!$ps_password || !$ps_password2) {
         $va_errors["password"] = _t("Please enter and re-type your password.");
     } else {
         if ($ps_password != $ps_password2) {
             $va_errors["password"] = _t("Passwords do not match");
         } else {
             $t_user->set("password", $ps_password);
         }
     }
     if (!$ps_security) {
         $va_errors["security"] = _t("Please answer the security question.");
     } else {
         if ($ps_security != $_REQUEST["sum"]) {
             $va_errors["security"] = _t("Your answer was incorrect, please try again");
         }
     }
     // Check user profile responses
     $va_profile_prefs = $t_user->getValidPreferences('profile');
     if (is_array($va_profile_prefs) && sizeof($va_profile_prefs)) {
         foreach ($va_profile_prefs as $vs_pref) {
             $vs_pref_value = $this->request->getParameter('pref_' . $vs_pref, pString);
             if (!$t_user->isValidPreferenceValue($vs_pref, $vs_pref_value)) {
                 $va_errors[$vs_pref] = join("; ", $t_user->getErrors());
                 $t_user->clearErrors();
             }
         }
     }
     # --- does deleted user login record for this user already exist?
     # --- (look for active records only; inactive records will effectively block reregistration)
     $vb_user_exists_but_is_deleted = false;
     if ($t_user->load(array('user_name' => $ps_email))) {
         if ((int) $t_user->get('userclass') == 255) {
             if ($t_user->get('active') == 1) {
                 // yeah... so allow registration
                 $vb_user_exists_but_is_deleted = true;
             } else {
                 // existing inactive user record blocks registration
                 $va_errors["email"] = _t("User cannot register");
             }
         } else {
             // already valid login with this user name
             $va_errors["email"] = _t("A user has already registered with this email address");
         }
     }
     # get names of form fields
     $va_fields = $t_user->getFormFields();
     # loop through fields
     foreach ($va_fields as $vs_f => $va_attr) {
         switch ($vs_f) {
             case "user_name":
                 if (!$vb_user_exists_but_is_deleted && !sizeof($va_errors)) {
                     # set field value
                     $t_user->set("user_name", $ps_email);
                     if ($t_user->numErrors() > 0) {
                         $va_errors[$vs_f] = join("; ", $t_user->getErrors());
                     }
                 }
                 break;
                 # -------------
             # -------------
             case "active":
                 if ($this->request->config->get('dont_approve_logins_on_registration')) {
                     $t_user->set("active", 0);
                 } else {
                     $t_user->set("active", 1);
//.........这里部分代码省略.........
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:101,代码来源:LoginRegController.php

示例2: register

 function register()
 {
     # logout user in case is already logged in
     $this->request->deauthenticate();
     $t_user = new ca_users();
     # --- process incoming registration attempt
     $ps_email = $this->request->getParameter("email", pString);
     $ps_fname = $this->request->getParameter("fname", pString);
     $ps_lname = $this->request->getParameter("lname", pString);
     $ps_password = $this->request->getParameter("password", pString);
     $ps_password2 = $this->request->getParameter("password2", pString);
     $ps_security = $this->request->getParameter("security", pString);
     $va_errors = array();
     if (!caCheckEmailAddress($ps_email)) {
         $va_errors["email"] = _t("E-mail address is not valid.");
     } else {
         $t_user->set("email", $ps_email);
     }
     if (!$ps_fname) {
         $va_errors["fname"] = _t("Please enter your first name");
     } else {
         $t_user->set("fname", $ps_fname);
     }
     if (!$ps_lname) {
         $va_errors["lname"] = _t("Please enter your last name");
     } else {
         $t_user->set("lname", $ps_lname);
     }
     if (!$ps_password || !$ps_password2) {
         $va_errors["password"] = _t("Please enter and re-type your password.");
     } else {
         if ($ps_password != $ps_password2) {
             $va_errors["password"] = _t("Passwords do not match");
         } else {
             $t_user->set("password", $ps_password);
         }
     }
     if (!$ps_security) {
         $va_errors["security"] = _t("Please answer the security question.");
     } else {
         if ($ps_security != $_REQUEST["sum"]) {
             $va_errors["security"] = _t("Your answer was incorrect, please try again");
         }
     }
     # --- does deleted user login record for this user already exist?
     # --- (look for active records only; inactive records will effectively block reregistration)
     $vb_user_exists_but_is_deleted = false;
     if ($t_user->load(array('user_name' => $ps_email))) {
         if ((int) $t_user->get('userclass') == 255) {
             if ($t_user->get('active') == 1) {
                 // yeah... so allow registration
                 $vb_user_exists_but_is_deleted = true;
             } else {
                 // existing inactive user record blocks registration
                 $va_errors["email"] = _t("User cannot register");
             }
         } else {
             // already valid login with this user name
             $va_errors["email"] = _t("A user has already registered with this email address");
         }
     }
     //if (!sizeof($va_errors)) {
     # get names of form fields
     $va_fields = $t_user->getFormFields();
     # loop through fields
     foreach ($va_fields as $vs_f => $va_attr) {
         switch ($vs_f) {
             case "user_name":
                 if (!$vb_user_exists_but_is_deleted && !sizeof($va_errors)) {
                     # set field value
                     $t_user->set("user_name", $ps_email);
                     if ($t_user->numErrors() > 0) {
                         $va_errors[$vs_f] = join("; ", $t_user->getErrors());
                     }
                 }
                 break;
                 # -------------
             # -------------
             case "active":
                 $t_user->set("active", 1);
                 break;
                 # -------------
             # -------------
             case "userclass":
                 $t_user->set("userclass", 1);
                 // 1=public-only
                 break;
                 # -------------
             # -------------
             default:
                 if (!$va_errors[$vs_f]) {
                     $t_user->set($vs_f, $_REQUEST[$vs_f]);
                     # set field values
                     if ($t_user->numErrors() > 0) {
                         $va_errors[$vs_f] = join("; ", $t_user->getErrors());
                     }
                 }
                 break;
                 # -------------
         }
//.........这里部分代码省略.........
开发者ID:guaykuru,项目名称:pawtucket,代码行数:101,代码来源:LoginRegController.php


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