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


PHP PearDatabase::hasFailedTransaction方法代码示例

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


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

示例1: vglobal

 /**
  * @param string $user name - Must be non null and at least 1 character.
  * @param string $user_password - Must be non null and at least 1 character.
  * @param string $new_password - Must be non null and at least 1 character.
  * @return boolean - If passwords pass verification and query succeeds, return true, else return false.
  * @desc Verify that the current password is correct and write the new password to the DB.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
  * All Rights Reserved..
  * Contributor(s): ______________________________________..
  */
 function change_password($user_password, $new_password, $dieOnError = true)
 {
     $usr_name = $this->column_fields["user_name"];
     global $mod_strings;
     $current_user = vglobal('current_user');
     $this->log->debug("Starting password change for {$usr_name}");
     if (!isset($new_password) || $new_password == "") {
         $this->error_string = $mod_strings['ERR_PASSWORD_CHANGE_FAILED_1'] . $user_name . $mod_strings['ERR_PASSWORD_CHANGE_FAILED_2'];
         return false;
     }
     if (!is_admin($current_user)) {
         #commenting this as the the transaction is already started in vtws_changepassword
         //            $this->db->startTransaction();
         if (!$this->verifyPassword($user_password)) {
             $this->log->warn("Incorrect old password for {$usr_name}");
             $this->error_string = $mod_strings['ERR_PASSWORD_INCORRECT_OLD'];
             return false;
         }
         if ($this->db->hasFailedTransaction()) {
             if ($dieOnError) {
                 die("error verifying old transaction[" . $this->db->database->ErrorNo() . "] " . $this->db->database->ErrorMsg());
             }
             return false;
         }
     }
     $user_hash = $this->get_user_hash($new_password);
     //set new password
     $crypt_type = $this->DEFAULT_PASSWORD_CRYPT_TYPE;
     $encrypted_new_password = $this->encrypt_password($new_password, $crypt_type);
     $query = "UPDATE {$this->table_name} SET user_password=?, confirm_password=?, user_hash=?, " . "crypt_type=? where id=?";
     #commenting this as the the transaction is already started in vtws_changepassword
     //        $this->db->startTransaction();
     $this->db->pquery($query, array($encrypted_new_password, $encrypted_new_password, $user_hash, $crypt_type, $this->id));
     if ($this->db->hasFailedTransaction()) {
         if ($dieOnError) {
             die("error setting new password: [" . $this->db->database->ErrorNo() . "] " . $this->db->database->ErrorMsg());
         }
         return false;
     }
     // Fill up the post-save state of the instance.
     if (empty($this->column_fields['user_hash'])) {
         $this->column_fields['user_hash'] = $user_hash;
     }
     $this->column_fields['user_password'] = $encrypted_new_password;
     $this->column_fields['confirm_password'] = $encrypted_new_password;
     $this->triggerAfterSaveEventHandlers();
     return true;
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:58,代码来源:Users.php

示例2: die

 /**
  * @param string $user name - Must be non null and at least 1 character.
  * @param string $user_password - Must be non null and at least 1 character.
  * @param string $new_password - Must be non null and at least 1 character.
  * @return boolean - If passwords pass verification and query succeeds, return true, else return false.
  * @desc Verify that the current password is correct and write the new password to the DB.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
  * All Rights Reserved..
  * Contributor(s): ______________________________________..
  */
 function change_password($user_password, $new_password, $dieOnError = true)
 {
     $usr_name = $this->column_fields["user_name"];
     global $mod_strings;
     global $current_user;
     $this->log->debug("Starting password change for {$usr_name}");
     if (!isset($new_password) || $new_password == "") {
         $this->error_string = $mod_strings['ERR_PASSWORD_CHANGE_FAILED_1'] . $user_name . $mod_strings['ERR_PASSWORD_CHANGE_FAILED_2'];
         return false;
     }
     if (!is_admin($current_user)) {
         $this->db->startTransaction();
         if (!$this->verifyPassword($user_password)) {
             $this->log->warn("Incorrect old password for {$usr_name}");
             $this->error_string = $mod_strings['ERR_PASSWORD_INCORRECT_OLD'];
             return false;
         }
         if ($this->db->hasFailedTransaction()) {
             if ($dieOnError) {
                 die("error verifying old transaction[" . $this->db->database->ErrorNo() . "] " . $this->db->database->ErrorMsg());
             }
             return false;
         }
     }
     $user_hash = strtolower(md5($new_password));
     //set new password
     $crypt_type = $this->DEFAULT_PASSWORD_CRYPT_TYPE;
     $encrypted_new_password = $this->encrypt_password($new_password, $crypt_type);
     $query = "UPDATE {$this->table_name} SET user_password=?, confirm_password=?, user_hash=?, " . "crypt_type=? where id=?";
     $this->db->startTransaction();
     $this->db->pquery($query, array($encrypted_new_password, $encrypted_new_password, $user_hash, $crypt_type, $this->id));
     if ($this->db->hasFailedTransaction()) {
         if ($dieOnError) {
             die("error setting new password: [" . $this->db->database->ErrorNo() . "] " . $this->db->database->ErrorMsg());
         }
         return false;
     }
     $this->createAccessKey();
     return true;
 }
开发者ID:jaimeaga84,项目名称:corebos,代码行数:50,代码来源:Users.php


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