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


PHP ca_users::set方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     $o_dm = new Datamodel(true);
     // PHPUnit seems to barf on the caching code if we don't instanciate a Datamodel instance
     $o_dm->getTableNum("ca_objects");
     // set up test role
     $this->opt_role = new ca_user_roles();
     $this->opt_role->setMode(ACCESS_WRITE);
     $this->opt_role->set("name", "UnitTestRole");
     $this->opt_role->set("code", "unit_test_role");
     if (!$this->opt_role->insert()) {
         print "ERROR inserting role: " . join(" ", $this->opt_role->getErrors()) . "\n";
     }
     $this->opt_role->setMode(ACCESS_READ);
     // set up test user
     $this->ops_username = "unit_test_user";
     $this->ops_password = "topsecret";
     $this->opt_user = new ca_users();
     $this->opt_user->setMode(ACCESS_WRITE);
     $this->opt_user->set(array('user_name' => $this->ops_username, 'password' => $this->ops_password, 'email' => 'foo@bar.com', 'active' => 1, 'userclass' => 0, 'fname' => 'Test', 'lname' => "User"));
     if (!$this->opt_user->insert()) {
         print "ERROR inserting user: " . join(" ", $this->opt_user->getErrors()) . "\n";
     }
     $this->opt_user->addRoles("unit_test_role");
     $this->opt_user->setMode(ACCESS_READ);
     global $req, $resp;
     $resp = new ResponseHTTP();
     $req = new RequestHTTP($resp, array("dont_create_new_session" => true));
     $this->assertInstanceOf('ca_users', $this->opt_user);
     $this->assertInstanceOf('ca_user_roles', $this->opt_role);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:31,代码来源:AccessControlTest.php

示例2: authenticate

 public static function authenticate($ps_username, $ps_password = '', $pa_options = null)
 {
     $t_user = new ca_users();
     $t_user->load($ps_username);
     if ($t_user->getPrimaryKey() > 0) {
         $vs_hash = $t_user->get('password');
         if (preg_match('/^[a-f0-9]{32}$/', $vs_hash)) {
             // old-style md5 passwords
             //throw new CaUsersException(_t('The stored password for this user seems to be in legacy format. Please update the user account by resetting the password.'));
             if (md5($ps_password) == $vs_hash) {
                 // if the md5 hash matches, authenticate successfully and move the user over to pbkdf2 key
                 $t_user->setMode(ACCESS_WRITE);
                 // ca_users::update takes care of the hashing by calling AuthenticationManager::updatePassword()
                 $t_user->set('password', $ps_password);
                 $t_user->update();
                 return true;
             } else {
                 return false;
             }
         }
         return validate_password($ps_password, $vs_hash);
     } else {
         return false;
     }
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:25,代码来源:CaUsers.php

示例3: createUser

 /**
  * Creates a new active user
  * 
  * @param string $user_name user name
  * @param string $password password
  * @param string $email email address
  * @param string $fname first name
  * @param string $lname  last name
  * @return int identifier of the new user
  * @throws SoapFault
  */
 public function createUser($user_name, $password, $email, $fname, $lname)
 {
     $t_user = new ca_users();
     $t_user->set("user_name", $user_name);
     $t_user->set("password", $password);
     $t_user->set("email", $email);
     $t_user->set("fname", $fname);
     $t_user->set("lname", $lname);
     $t_user->set("active", 1);
     $t_user->setMode(ACCESS_WRITE);
     $t_user->insert();
     if ($t_user->numErrors()) {
         throw new SoapFault("Server", "Could not create user: " . join(" ", $t_user->getErrors()));
     }
     return $t_user->getPrimaryKey();
 }
开发者ID:samrahman,项目名称:providence,代码行数:27,代码来源:AccessControlService.php

示例4: DoReset

 public function DoReset()
 {
     if (!AuthenticationManager::supports(__CA_AUTH_ADAPTER_FEATURE_RESET_PASSWORDS__)) {
         $this->Login();
         return;
     }
     $vs_token = $this->getRequest()->getParameter('token', pString);
     $vs_username = $this->getRequest()->getParameter('username', pString);
     $t_user = new ca_users();
     $vs_pw = $this->getRequest()->getParameter('password', pString);
     $vs_pw_check = $this->getRequest()->getParameter('password2', pString);
     if ($t_user->load($vs_username)) {
         if ($t_user->isValidToken($vs_token)) {
             // no password match
             if ($vs_pw !== $vs_pw_check) {
                 $this->notification->addNotification(_t("Passwords did not match. Please try again."), __NOTIFICATION_TYPE_ERROR__);
                 $this->view->setVar('notifications', $this->notification->getNotifications());
                 $this->view->setVar('renderForm', true);
                 $this->view->setVar('token', $vs_token);
                 $this->view->setVar('username', $vs_username);
                 $this->render('password_reset_form_html.php');
             } else {
                 $t_user->set('password', $vs_pw);
                 $t_user->setMode(ACCESS_WRITE);
                 $t_user->update();
                 $this->notification->addNotification(_t("Password was successfully changed. You can now log in with your new password."), __NOTIFICATION_TYPE_INFO__);
                 $this->view->setVar('notifications', $this->notification->getNotifications());
                 $this->Login();
             }
         }
     }
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:32,代码来源:AuthController.php

示例5: reset_password

 /**
  * Reset user password
  */
 public static function reset_password($po_opts = null)
 {
     if ($vs_user_name = (string) $po_opts->getOption('user')) {
         if (!($vs_password = (string) $po_opts->getOption('password'))) {
             CLIUtils::addError(_t("You must specify a password"));
             return false;
         }
         $t_user = new ca_users();
         if (!$t_user->load(array("user_name" => $vs_user_name))) {
             CLIUtils::addError(_t("User name %1 does not exist", $vs_user_name));
             return false;
         }
         $t_user->setMode(ACCESS_WRITE);
         $t_user->set('password', $vs_password);
         $t_user->update();
         if ($t_user->numErrors()) {
             CLIUtils::addError(_t("Password change for user %1 failed: %2", $vs_user_name, join("; ", $t_user->getErrors())));
             return false;
         }
         CLIUtils::addMessage(_t('Changed password for user %1', $vs_user_name), array('color' => 'bold_green'));
         return true;
     }
     CLIUtils::addError(_t("You must specify a user"));
     return false;
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:28,代码来源:CLIUtils.php

示例6: createAdminAccount

 public function createAdminAccount()
 {
     require_once __CA_MODELS_DIR__ . "/ca_users.php";
     $ps_password = $this->getRandomPassword();
     $t_user = new ca_users();
     $t_user->setMode(ACCESS_WRITE);
     $t_user->set("user_name", 'administrator');
     $t_user->set("password", $ps_password);
     $t_user->set("email", $this->ops_admin_email);
     $t_user->set("fname", 'CollectiveAccess');
     $t_user->set("lname", 'Administrator');
     $t_user->set("userclass", 0);
     $t_user->set("active", 1);
     $t_user->insert();
     if ($t_user->numErrors()) {
         $this->addError("Errors while adding the default administrator account: " . join("; ", $t_user->getErrors()));
         return false;
     }
     return $ps_password;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:20,代码来源:Installer.php

示例7: resetSave

 function resetSave()
 {
     MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . _t("Reset Password"));
     $ps_action = $this->request->getParameter('action', pString);
     if (!$ps_action) {
         $ps_action = "reset";
     }
     $ps_key = $this->request->getParameter('key', pString);
     $ps_key = preg_replace("/[^A-Za-z0-9]+/", "", $ps_key);
     $this->view->setVar("key", $ps_key);
     $this->view->setVar("email", $this->request->config->get("ca_admin_email"));
     $o_check_key = new Db();
     $qr_check_key = $o_check_key->query("\n\t\t\t\tSELECT user_id \n\t\t\t\tFROM ca_users \n\t\t\t\tWHERE\n\t\t\t\t\tmd5(concat(concat(user_id, '/'), password)) = ?\n\t\t\t", $ps_key);
     #
     # Check reset key
     #
     if (!$qr_check_key->nextRow() || !($vs_user_id = $qr_check_key->get("user_id"))) {
         $this->view->setVar("action", "reset_failure");
         $this->view->setVar("message", _t("Your password could not be reset"));
         $this->render('LoginReg/form_reset_html.php');
     } else {
         $ps_password = $this->request->getParameter('password', pString);
         $ps_password_confirm = $this->request->getParameter('password_confirm', pString);
         switch ($ps_action) {
             case 'reset_save':
                 if (!$ps_password || !$ps_password_confirm) {
                     $this->view->setVar("message", _t("Please enter and re-type your password."));
                     $ps_action = "reset";
                     break;
                 }
                 if ($ps_password != $ps_password_confirm) {
                     $this->view->setVar("message", _t("Passwords do not match. Please try again."));
                     $ps_action = "reset";
                     break;
                 }
                 $t_user = new ca_users();
                 $t_user->purify(true);
                 $t_user->load($vs_user_id);
                 # verify user exists with this e-mail address
                 if ($t_user->getPrimaryKey()) {
                     # user with e-mail already exists...
                     $t_user->setMode(ACCESS_WRITE);
                     $t_user->set("password", $ps_password);
                     $t_user->update();
                     if ($t_user->numErrors()) {
                         $this->notification->addNotification(join("; ", $t_user->getErrors()), __NOTIFICATION_TYPE_INFO__);
                         $ps_action = "reset_failure";
                     } else {
                         $ps_action = "reset_success";
                         $o_view = new View($this->request, array($this->request->getViewsDirectoryPath()));
                         # -- generate email subject
                         $vs_subject_line = $o_view->render("mailTemplates/notification_subject.tpl");
                         # -- generate mail text from template - get both the html and text versions
                         $vs_mail_message_text = $o_view->render("mailTemplates/notification.tpl");
                         $vs_mail_message_html = $o_view->render("mailTemplates/notification_html.tpl");
                         caSendmail($t_user->get('email'), $this->request->config->get("ca_admin_email"), $vs_subject_line, $vs_mail_message_text, $vs_mail_message_html);
                     }
                     break;
                 } else {
                     $this->notification->addNotification(_t("Invalid user"), __NOTIFICATION_TYPE_INFO__);
                     $ps_action = "reset_failure";
                 }
         }
         $this->view->setVar("action", $ps_action);
         $this->render('LoginReg/form_reset_html.php');
     }
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:67,代码来源:LoginRegController.php

示例8: Save

 public function Save()
 {
     // Field to user profile preference mapping
     $va_mapping = array('billing_organization' => 'user_profile_organization', 'billing_address1' => 'user_profile_address1', 'billing_address2' => 'user_profile_address2', 'billing_city' => 'user_profile_city', 'billing_zone' => 'user_profile_state', 'billing_postal_code' => 'user_profile_postalcode', 'billing_country' => 'user_profile_country', 'billing_phone' => 'user_profile_phone', 'billing_fax' => 'user_profile_fax', 'shipping_organization' => 'user_profile_organization', 'shipping_address1' => 'user_profile_address1', 'shipping_address2' => 'user_profile_address2', 'shipping_city' => 'user_profile_city', 'shipping_zone' => 'user_profile_state', 'shipping_postal_code' => 'user_profile_postalcode', 'shipping_country' => 'user_profile_country', 'shipping_phone' => 'user_profile_phone', 'shipping_fax' => 'user_profile_fax');
     $va_errors = array();
     $va_failed_insert_list = array();
     $va_fields = $this->opt_order->getFormFields();
     foreach ($va_fields as $vs_f => $va_field_info) {
         switch ($vs_f) {
             case 'transaction_id':
                 // noop
                 break;
             default:
                 if (isset($_REQUEST[$vs_f])) {
                     if (!$this->opt_order->set($vs_f, $this->request->getParameter($vs_f, pString))) {
                         $va_errors[$vs_f] = $this->opt_order->errors();
                     }
                 }
                 break;
         }
     }
     // Set additional fees for order
     $va_fees = $this->opo_client_services_config->getAssoc('additional_order_fees');
     if (is_array($va_fees)) {
         if (!is_array($va_fee_values = $this->opt_order->get('additional_fees'))) {
             $va_fee_values = array();
         }
         foreach ($va_fees as $vs_code => $va_info) {
             $va_fee_values[$vs_code] = (double) $this->request->getParameter("additional_fee_{$vs_code}", pString);
         }
         $this->opt_order->set('additional_fees', $va_fee_values);
     }
     $this->opt_order->setMode(ACCESS_WRITE);
     if ($this->opt_order->getPrimaryKey()) {
         $this->opt_order->update();
         $vn_transaction_id = $this->opt_order->get('transaction_id');
     } else {
         // Set transaction
         if (!($vn_transaction_id = $this->request->getParameter('transaction_id', pInteger))) {
             if (!($vn_user_id = $this->request->getParameter('transaction_user_id', pInteger))) {
                 if ($vs_user_name = $this->request->getParameter('billing_email', pString)) {
                     // Try to create user in-line
                     $t_user = new ca_users();
                     if ($t_user->load(array('user_name' => $vs_user_name))) {
                         if ($t_user->get('active') == 1) {
                             // user is active - if not active don't use
                             if ($t_user->get('userclass') == 255) {
                                 // user is deleted
                                 $t_user->setMode(ACCESS_WRITE);
                                 $t_user->set('userclass', 1);
                                 // 1=public user (no back-end login)
                                 $t_user->update();
                                 if ($t_user->numErrors()) {
                                     $this->notification->addNotification(_t('Errors occurred when undeleting user: %1', join('; ', $t_user->getErrors())), __NOTIFICATION_TYPE_ERROR__);
                                 } else {
                                     $vn_user_id = $t_user->getPrimaryKey();
                                 }
                             } else {
                                 $vn_user_id = $t_user->getPrimaryKey();
                             }
                         } else {
                             $t_user->setMode(ACCESS_WRITE);
                             $t_user->set('active', 1);
                             $t_user->set('userclass', 1);
                             // 1=public user (no back-end login)
                             $t_user->update();
                             if ($t_user->numErrors()) {
                                 $this->notification->addNotification(_t('Errors occurred when reactivating user: %1', join('; ', $t_user->getErrors())), __NOTIFICATION_TYPE_ERROR__);
                             } else {
                                 $vn_user_id = $t_user->getPrimaryKey();
                             }
                         }
                     } else {
                         $t_user->setMode(ACCESS_WRITE);
                         $t_user->set('user_name', $vs_user_name);
                         $t_user->set('password', $vs_password = substr(md5(uniqid(microtime())), 0, 6));
                         $t_user->set('userclass', 1);
                         // 1=public user (no back-end login)
                         $t_user->set('fname', $vs_fname = $this->request->getParameter('billing_fname', pString));
                         $t_user->set('lname', $vs_lname = $this->request->getParameter('billing_lname', pString));
                         $t_user->set('email', $vs_user_name);
                         $t_user->insert();
                         if ($t_user->numErrors()) {
                             $this->notification->addNotification(_t('Errors occurred when creating new user: %1', join('; ', $t_user->getErrors())), __NOTIFICATION_TYPE_ERROR__);
                         } else {
                             $vn_user_id = $t_user->getPrimaryKey();
                             $this->notification->addNotification(_t('Created new client login for <em>%1</em>. Login name is <em>%2</em> and password is <em>%3</em>', $vs_fname . ' ' . $vs_lname, $vs_user_name, $vs_password), __NOTIFICATION_TYPE_INFO__);
                             // Create related entity?
                         }
                     }
                 }
             }
             if ($vn_user_id) {
                 // try to create transaction
                 $t_trans = new ca_commerce_transactions();
                 $t_trans->setMode(ACCESS_WRITE);
                 $t_trans->set('user_id', $vn_user_id);
                 $t_trans->set('short_description', "Created on " . date("c"));
                 $t_trans->set('set_id', null);
                 $t_trans->insert();
//.........这里部分代码省略.........
开发者ID:idiscussforum,项目名称:providence,代码行数:101,代码来源:CheckOutController.php

示例9: resetSave

 function resetSave()
 {
     $ps_action = $this->request->getParameter('action', pString);
     $ps_key = $this->request->getParameter('key', pString);
     $ps_key = preg_replace("/[^A-Za-z0-9]+/", "", $ps_key);
     $this->view->setVar("key", $ps_key);
     $o_check_key = new Db();
     $qr_check_key = $o_check_key->query("\n\t\t\t\tSELECT user_id \n\t\t\t\tFROM ca_users \n\t\t\t\tWHERE\n\t\t\t\t\tmd5(concat(concat(user_id, '/'), password)) = ?\n\t\t\t", $ps_key);
     #
     # Check reset key
     #
     if (!$qr_check_key->nextRow() || !($vs_user_id = $qr_check_key->get("user_id"))) {
         $this->view->setVar("action", "reset_failure");
         $this->render('LoginReg/resetpw_html.php');
     } else {
         $ps_password = $this->request->getParameter('password', pString);
         $ps_password_confirm = $this->request->getParameter('password_confirm', pString);
         switch ($ps_action) {
             case 'reset_save':
                 if (!$ps_password || !$ps_password_confirm) {
                     $this->view->setVar("password_error", _t("Please enter and re-type your password."));
                     $ps_action = "reset";
                     break;
                 }
                 if ($ps_password != $ps_password_confirm) {
                     $this->view->setVar("password_error", _t("Passwords do not match. Please try again."));
                     $ps_action = "reset";
                     break;
                 }
                 $t_user = new ca_users();
                 $t_user->load($vs_user_id);
                 # verify user exists with this e-mail address
                 if ($t_user->getPrimaryKey()) {
                     # user with e-mail already exists...
                     $t_user->setMode(ACCESS_WRITE);
                     $t_user->set("password", $ps_password);
                     $t_user->update();
                     if ($t_user->numErrors()) {
                         $this->notification->addNotification(join("; ", $t_user->getErrors()), __NOTIFICATION_TYPE_INFO__);
                         $ps_action = "reset_failure";
                     } else {
                         $ps_action = "reset_success";
                         # -- generate mail text from template
                         ob_start();
                         require $this->request->getViewsDirectoryPath() . "/mailTemplates/notification.tpl";
                         $vs_mail_message = ob_get_contents();
                         ob_end_clean();
                         caSendmail($t_user->get('email'), $this->request->config->get("ca_admin_email"), "[" . $this->request->config->get("app_display_name") . "] " . _t("Your password has been reset"), $vs_mail_message);
                     }
                     break;
                 } else {
                     $this->notification->addNotification(_t("Invalid user"), __NOTIFICATION_TYPE_INFO__);
                     $ps_action = "reset_failure";
                 }
         }
         $this->view->setVar("action", $ps_action);
         $this->render('LoginReg/resetpw_html.php');
     }
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:59,代码来源:LoginRegController.php


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