當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserTable::getError方法代碼示例

本文整理匯總了PHP中CB\Database\Table\UserTable::getError方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserTable::getError方法的具體用法?PHP UserTable::getError怎麽用?PHP UserTable::getError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CB\Database\Table\UserTable的用法示例。


在下文中一共展示了UserTable::getError方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: cbDeleteUser

 /**
  * Deletes a user without any check or warning, and related reports, sessions
  *
  * @deprecated 2.0 Use UserTable()->load( $condition or $id )->delete( null, $cbUserOnly )
  *
  * @param  int      $id                 User id
  * @param  string   $condition          ONLY allowed string: "return (\$user->block == 1);" (CBSubs 3.0.0) php condition string on $user e.g. "return (\$user->block == 1);"
  * @param  boolean  $inComprofilerOnly  deletes user only in CB, not in Mambo/Joomla
  * @return null|boolean|string          '' if user deleted and found ok, NULL if user not found, FALSE if condition was not met, STRING error in case of error raised by plugin
  */
 function cbDeleteUser($id, $condition = null, $inComprofilerOnly = false)
 {
     if (!$id) {
         return null;
     }
     $user = new UserTable();
     if ($inComprofilerOnly) {
         $user->load(array('user_id' => (int) $id));
     } else {
         $user->load((int) $id);
     }
     if (!$user->id) {
         return null;
     }
     if ($condition == null || eval($condition)) {
         if (!$user->delete((int) $id, $inComprofilerOnly)) {
             return $user->getError();
         }
         return '';
     }
     return false;
 }
開發者ID:bobozhangshao,項目名稱:HeartCare,代碼行數:32,代碼來源:LegacyComprofilerFunctions.php

示例2: saveUser

 /**
  * Saves legacy user edit display
  *
  * @param string $option
  * @param string $task
  */
 public function saveUser($option, $task = 'save')
 {
     global $_CB_framework, $_CB_Backend_task, $_POST, $_PLUGINS;
     cbimport('language.all');
     cbimport('cb.tabs');
     cbimport('cb.params');
     cbimport('cb.adminfilesystem');
     cbimport('cb.imgtoolbox');
     $userIdPosted = (int) cbGetParam($_POST, 'id', 0);
     if ($userIdPosted == 0) {
         $_POST['id'] = null;
     }
     $msg = $this->_authorizedEdit($userIdPosted);
     if (!$msg) {
         if ($userIdPosted != 0) {
             $msg = checkCBpermissions(array($userIdPosted), 'save', true);
         } else {
             $msg = checkCBpermissions(null, 'save', true);
         }
     }
     if ($userIdPosted != 0) {
         $_PLUGINS->trigger('onBeforeUserProfileSaveRequest', array($userIdPosted, &$msg, 2));
     }
     if ($msg) {
         cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error');
     }
     $_PLUGINS->loadPluginGroup('user');
     // Get current user state:
     if ($userIdPosted != 0) {
         $userComplete = CBuser::getUserDataInstance($userIdPosted);
         if (!($userComplete && $userComplete->id)) {
             cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('Your profile could not be updated.'), 'error');
         }
     } else {
         $userComplete = new UserTable();
     }
     // Store new user state:
     $saveResult = $userComplete->saveSafely($_POST, $_CB_framework->getUi(), 'edit');
     if (!$saveResult) {
         $regErrorMSG = $userComplete->getError();
         $msg = checkCBpermissions(array((int) $userComplete->id), 'edit', true);
         if ($userIdPosted != 0) {
             $_PLUGINS->trigger('onBeforeUserProfileEditRequest', array((int) $userComplete->id, &$msg, 2));
         }
         if ($msg) {
             cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error');
         }
         if ($userIdPosted != 0) {
             $_PLUGINS->trigger('onAfterUserProfileSaveFailed', array(&$userComplete, &$regErrorMSG, 2));
         } else {
             $_PLUGINS->trigger('onAfterUserRegistrationSaveFailed', array(&$userComplete, &$regErrorMSG, 2));
         }
         $_CB_framework->enqueueMessage($regErrorMSG, 'error');
         $_CB_Backend_task = 'edit';
         // so the toolbar comes up...
         $_PLUGINS->loadPluginGroup('user');
         // resets plugin errors
         $userView = _CBloadView('user');
         /** @var CBController_user $userView */
         $userView->edituser($userComplete, $option, $userComplete->user_id != null ? 0 : 1, $_POST);
         return;
     }
     // Checks-in the row:
     $userComplete->checkin();
     if ($userIdPosted != 0) {
         $_PLUGINS->trigger('onAfterUserProfileSaved', array(&$userComplete, 2));
     } else {
         $messagesToUser = array();
         $_PLUGINS->trigger('onAfterSaveUserRegistration', array(&$userComplete, &$messagesToUser, 2));
     }
     if ($task == 'apply') {
         cbRedirect($_CB_framework->backendViewUrl('edit', false, array('cid' => (int) $userComplete->user_id)), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username)));
     } else {
         cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username)));
     }
 }
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:82,代碼來源:controller.user.php

示例3: fieldsFetch

	/**
	 * @param FieldTable[] $fields
	 * @param UserTable    $user
	 * @param string       $reason
	 * @param int          $tabid
	 * @param int|string   $fieldIdOrName
	 * @param bool         $fullAccess
	 */
	public function fieldsFetch( &$fields, &$user, $reason, $tabid, $fieldIdOrName, $fullAccess )
	{
		$post							=	$this->getInput()->getNamespaceRegistry( 'post' );
		$view							=	$this->input( 'view', null, GetterInterface::STRING );

		if ( ( ! Application::Cms()->getClientId() ) && ( ! $fullAccess ) ) {
			$checkView					=	( ( in_array( $reason, array( 'register', 'edit' ) ) && ( $post->count() && in_array( $view, array( 'saveregisters', 'saveuseredit' ) ) ) ) || ( $reason == 'profile' ) );
		} elseif ( Application::Cms()->getClientId() && $this->params->get( 'cond_backend', 0 ) && ( ! $fullAccess ) ) {
			$checkView					=	( ( in_array( $reason, array( 'register', 'edit' ) ) && ( $post->count() && ( $view != 'edit' ) ) ) || ( $reason == 'profile' ) );
		} else {
			$checkView					=	false;
		}

		if ( $checkView && $fields && ( $user && ( $user instanceof UserTable ) && ( ! $user->getError() ) ) ) {
			$tabs						=	array();
			$hide						=	array();

			foreach ( $fields as $field ) {
				if ( ! in_array( (int) $field->get( 'tabid' ), $tabs ) ) {
					$tabs[]				=	(int) $field->get( 'tabid' );
				}
			}

			if ( $tabs ) {
				$tabCondition			=	$this->getTabConditional( $tabs, $reason, $user->get( 'id' ) );

				if ( $tabCondition ) {
					foreach ( $fields as $field ) {
						if ( in_array( (int) $field->get( 'tabid' ), $tabCondition ) ) {
							$hide[]		=	(int) $field->get( 'fieldid' );
						}
					}
				}
			}

			if ( ! $hide ) {
				$condition				=	$this->getFieldConditional( $fields, $reason, $user->get( 'id' ) );

				if ( $condition->hide ) {
					foreach ( $fields as $field ) {
						if ( in_array( (int) $field->get( 'fieldid' ), $condition->hide ) ) {
							$hide[]		=	(int) $field->get( 'fieldid' );
						}
					}
				}
			}

			if ( $hide ) {
				foreach ( $fields as $k => $field ) {
					if ( in_array( (int) $field->get( 'fieldid' ), $hide ) ) {
						unset( $fields[$k] );
					}
				}
			}
		}
	}
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:64,代碼來源:cbconditional.php

示例4: execute

	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		if ( ! $user->get( 'id' ) ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_USER', ':: Action [action] :: Usergroup skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		$cache										=	$user->get( 'password' );

		$user->set( 'password', null );

		foreach ( $trigger->getParams()->subTree( 'usergroup' ) as $row ) {
			/** @var ParamsInterface $row */
			$groups									=	$row->get( 'groups', null, GetterInterface::STRING );

			if ( $groups ) {
				$groups								=	explode( '|*|', $groups );

				cbArrayToInts( $groups );
			}

			$session								=	JFactory::getSession();
			$jUser									=	$session->get( 'user' );
			$isMe									=	( $jUser ? ( $jUser->id == $user->get( 'id' ) ) : false );

			switch ( $row->get( 'mode', 'add', GetterInterface::STRING ) ) {
				case 'create':
					$title							=	$trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::STRING ) );

					if ( ! $title ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_TITLE', ':: Action [action] :: Usergroup skipped due to missing title', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$usergroup						=	JTable::getInstance( 'usergroup' );

					$usergroup->load( array( 'title' => $title ) );

					if ( ! $usergroup->id ) {
						$usergroup->parent_id		=	(int) $row->get( 'parent', 0, GetterInterface::INT );
						$usergroup->title			=	$title;

						if ( ! $usergroup->store() ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_CREATE_FAILED', ':: Action [action] :: Usergroup failed to create', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
							}

							continue;
						}
					}

					if ( $row->get( 'add', 1, GetterInterface::BOOLEAN ) ) {
						if ( ! in_array( $usergroup->id, $user->get( 'gids' ) ) ) {
							$user->gids[]			=	$usergroup->id;

							if ( ! $user->store() ) {
								if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
									var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) );
								}

								continue;
							}

							if ( $isMe ) {
								JAccess::clearStatics();

								$session->set( 'user', new JUser( $user->get( 'id'  ) ) );
							}
						}
					}
					break;
				case 'replace':
					if ( ! $groups ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_GROUPS', ':: Action [action] :: Usergroup skipped due to missing groups', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$user->set( 'gids', $groups );

					if ( ! $user->store() ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) );
						}

						continue;
					}

//.........這裏部分代碼省略.........
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:101,代碼來源:usergroup.php

示例5: sendNewPass

function sendNewPass($option)
{
    global $_CB_framework, $ueConfig, $_PLUGINS, $_POST;
    $loginType = isset($ueConfig['login_type']) ? (int) $ueConfig['login_type'] : 0;
    if ($loginType == 4) {
        cbRedirect($_CB_framework->viewUrl('done', false), CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!'), 'error');
        return;
    }
    // simple spoof check security
    checkCBPostIsHTTPS();
    cbSpoofCheck('lostPassForm');
    cbRegAntiSpamCheck();
    $liveSite = $_CB_framework->getCfg('live_site');
    $usernameExists = $loginType != 2;
    // ensure no malicous sql gets past
    $checkusername = trim(cbGetParam($_POST, 'checkusername', ''));
    $confirmEmail = trim(cbGetParam($_POST, 'checkemail', ''));
    $_PLUGINS->loadPluginGroup('user');
    $_PLUGINS->trigger('onStartNewPassword', array(&$checkusername, &$confirmEmail));
    if ($_PLUGINS->is_errors()) {
        cbRedirect($_CB_framework->viewUrl('lostpassword', false), $_PLUGINS->getErrorMSG(), 'error');
        return;
    }
    $checkusername = stripslashes($checkusername);
    $confirmEmail = stripslashes($confirmEmail);
    $res = false;
    $error = null;
    if ($usernameExists && $confirmEmail != '' && !$checkusername) {
        $user = new UserTable();
        if (!$user->loadByEmail($confirmEmail)) {
            cbRedirect($_CB_framework->viewUrl('lostpassword', false), CBTxt::Th('UE_EMAIL_DOES_NOT_EXISTS_ON_SITE', "The email '[email]' does not exist on this site.", array('[email]' => htmlspecialchars($confirmEmail))), 'error');
        }
        $message = str_replace('\\n', "\n", sprintf(CBTxt::T('UE_USERNAMEREMINDER_MSG', 'Hello,\\nA username reminder has been requested for your %s account.\\n\\nYour username is: %s\\n\\nTo log in to your account, click on the link below:\\n%s\\n\\nThank you.\\n'), $_CB_framework->getCfg('sitename'), $user->username, $liveSite));
        /*
        'Hello,\n'
        .'A username reminder has been requested for your %s account.\n\n'
        .'Your username is: %s\n\n'
        .'To log in to your account, click on the link below:\n'
        .'%s\n\n'
        .'Thank you.\n'
        */
        $subject = sprintf(CBTxt::T('UE_USERNAMEREMINDER_SUB', 'Username reminder for %s'), $user->username);
        $_PLUGINS->trigger('onBeforeUsernameReminder', array($user, &$subject, &$message));
        if ($_PLUGINS->is_errors()) {
            cbRedirect($_CB_framework->viewUrl('lostpassword', false), $_PLUGINS->getErrorMSG(), 'error');
            return;
        }
        $cbNotification = new cbNotification();
        $res = $cbNotification->sendFromSystem($user->id, $subject, $message);
        $error = $cbNotification->errorMSG;
        $_PLUGINS->trigger('onAfterUsernameReminder', array($user, &$res));
        if ($res) {
            cbRedirect($_CB_framework->viewUrl('done', false), sprintf(CBTxt::Th('UE_USERNAME_REMINDER_SENT', 'Username reminder sent to your email address %s. Please check your email (and if needed your spambox too)!'), htmlspecialchars($confirmEmail)));
        } else {
            cbRedirect($_CB_framework->viewUrl('done', false), $error ? CBTxt::Th('SENDING_EMAIL_FAILED_ERROR_ERROR', 'Sending Email Failed! Error: [error]', array('[error]' => $error)) : CBTxt::Th('UE_EMAIL_SENDING_ERROR', 'Error sending email'), 'error');
        }
    } elseif ($confirmEmail != '') {
        $user = new UserTable();
        if ($usernameExists) {
            $foundUser = $user->loadByUsername($checkusername);
            if ($foundUser && cbutf8_strtolower($user->email) != cbutf8_strtolower($confirmEmail)) {
                $foundUser = false;
            }
        } else {
            $foundUser = $user->loadByEmail($confirmEmail);
        }
        if (!$foundUser) {
            cbRedirect($_CB_framework->viewUrl('lostpassword', false), CBTxt::Th('ERROR_PASS', 'Sorry, no corresponding user was found'), 'error');
        }
        $resetTime = (int) $_CB_framework->getCfg('reset_time');
        $resetCount = (int) $_CB_framework->getCfg('reset_count');
        $hoursSinceLastReset = ($_CB_framework->getUTCNow() - (int) $_CB_framework->getUTCTimestamp($user->lastResetTime)) / 3600;
        if ($hoursSinceLastReset > $resetTime) {
            $user->lastResetTime = $_CB_framework->getUTCDate();
            $user->resetCount = 1;
        } else {
            $user->resetCount = $user->resetCount + 1;
        }
        if ($resetCount && $user->resetCount > $resetCount) {
            cbRedirect($_CB_framework->viewUrl('lostpassword', false), CBTxt::Th('EXCEEDED_MAXIMUM_PASSWORD_RESETS', 'You have exceeded the maximum number of password resets allowed. Please try again in %%COUNT%% hours.|You have exceeded the maximum number of password resets allowed. Please try again in 1 hour.', array('%%COUNT%%' => $resetTime)), 'error');
        }
        $newpass = $user->getRandomPassword();
        $message = str_replace('\\n', "\n", sprintf(CBTxt::T('UE_NEWPASS_MSG', 'The user account %s has this email associated with it.\\nA web user from %s has just requested that a new password be sent.\\n\\nYour New Password is: %s\\n\\nIf you didn\'t ask for this, don\'t worry. You are seeing this message, not them. If this was an error just log in with your new password and then change your password to what you would like it to be.'), $user->username, $liveSite, $newpass));
        /*
        'The user account %s has this email associated with it.\n'
        .'A web user from %s has just requested that a new password be sent.\n\n'
        .'Your New Password is: %s\n\n'
        .'If you didn\'t ask for this, don\'t worry. You are seeing this message, not them. If this was an error just log in with your new password and then change your password to what you would like it to be.'
        */
        $subject = sprintf(CBTxt::T('UE_NEWPASS_SUB', 'New password for: %s'), $user->username);
        $_PLUGINS->trigger('onBeforeNewPassword', array($user, &$newpass, &$subject, &$message));
        if ($_PLUGINS->is_errors()) {
            cbRedirect($_CB_framework->viewUrl('lostpassword', false), $_PLUGINS->getErrorMSG(), 'error');
        }
        $_PLUGINS->trigger('onNewPassword', array($user, $newpass));
        $storeValues = array('password' => $newpass, 'lastResetTime' => $user->lastResetTime, 'resetCount' => $user->resetCount);
        if (!$user->storeDatabaseValues($storeValues)) {
            cbRedirect($_CB_framework->viewUrl('lostpassword', false), $user->getError(), 'error');
        } else {
            $cbNotification = new cbNotification();
//.........這裏部分代碼省略.........
開發者ID:ankaau,項目名稱:GathBandhan,代碼行數:101,代碼來源:comprofiler.php

示例6: onSaveUserError

	/**
	 * Stores user save attempt
	 *
	 * @param UserTable $user
	 * @param string    $error
	 * @param string    $reason
	 */
	public function onSaveUserError( &$user, $error, $reason )
	{
		global $_PLUGINS;

		if ( $error || $_PLUGINS->is_errors() || $user->getError() ) {
			$this->storeAttempt( (int) $user->get( 'id' ), 'reg' );
		}
	}
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:15,代碼來源:cbantispam.php

示例7: storeDatabaseValues

 /**
  * Store an array of values to user object
  * Used only in banUser function in FE: TODO: Change usage in banUser ?
  *
  * @param $values
  * @param bool $triggers
  * @return bool
  */
 public function storeDatabaseValues($values, $triggers = true)
 {
     global $_CB_framework, $_PLUGINS;
     if ($this->id && is_array($values) && $values) {
         $ui = $_CB_framework->getUi();
         $userVars = array_keys(get_object_vars($this));
         $user = new UserTable($this->_db);
         $oldUserComplete = new UserTable($this->_db);
         foreach ($userVars as $k) {
             if (substr($k, 0, 1) != '_') {
                 $user->set($k, $this->get($k));
                 $oldUserComplete->set($k, $this->get($k));
             }
         }
         foreach ($values as $name => $value) {
             if (in_array($name, $userVars)) {
                 $user->set($name, $value);
             }
         }
         if ($triggers) {
             if ($ui == 1) {
                 $_PLUGINS->trigger('onBeforeUserUpdate', array(&$user, &$user, &$oldUserComplete, &$oldUserComplete));
             } elseif ($ui == 2) {
                 $_PLUGINS->trigger('onBeforeUpdateUser', array(&$user, &$user, &$oldUserComplete));
             }
         }
         if (isset($values['password'])) {
             $clearTextPassword = $user->get('password');
             $user->set('password', $this->hashAndSaltPassword($clearTextPassword));
         } else {
             $clearTextPassword = null;
             $user->set('password', null);
         }
         $return = $user->store();
         if ($clearTextPassword) {
             $user->set('password', $clearTextPassword);
         }
         if ($triggers) {
             if ($return) {
                 if ($ui == 1) {
                     $_PLUGINS->trigger('onAfterUserUpdate', array(&$user, &$user, $oldUserComplete));
                 } elseif ($ui == 2) {
                     $_PLUGINS->trigger('onAfterUpdateUser', array(&$user, &$user, $oldUserComplete));
                 }
             }
         }
         $error = $user->getError();
         if ($error) {
             $this->set('_error', $error);
         }
         unset($user, $oldUserComplete);
         return $return;
     }
     return false;
 }
開發者ID:Raul-mz,項目名稱:web-erpcya,代碼行數:63,代碼來源:UserTable.php

示例8: fieldsFetch

	/**
	 * @param FieldTable[] $fields
	 * @param UserTable    $user
	 * @param string       $reason
	 * @param int          $tabid
	 * @param int|string   $fieldIdOrName
	 * @param bool         $fullAccess
	 */
	public function fieldsFetch( &$fields, &$user, $reason, $tabid, $fieldIdOrName, $fullAccess )
	{
		$checkUser		=	( $user && ( $user instanceof UserTable ) && ( ! $user->getError() ) );

		if ( ( ! Application::Cms()->getClientId() ) && ( ! cbprivacyClass::checkUserModerator() ) && ( ! $fullAccess ) && $checkUser ) {
			if ( ( $reason == 'profile' ) && ( Application::MyUser()->getUserId() != $user->get( 'id' ) ) ) {
				if ( $fields ) foreach ( $fields as $fieldId => $field ) {
					if ( isset( $fields[$fieldId] ) && $field->get( 'profile' ) && ( ! cbprivacyClass::checkFieldDisplayAccess( $field, $user ) )  ) {
						unset( $fields[$fieldId] );
					}
				}
			} elseif ( ( $reason == 'edit' ) && $user->get( 'id' ) ) {
				if ( $fields ) foreach ( $fields as $fieldId => $field ) {
					if ( isset( $fields[$fieldId] ) && ( ! cbprivacyClass::checkFieldEditAccess( $field ) ) ) {
						unset( $fields[$fieldId] );
					}
				}
			}
		}
	}
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:28,代碼來源:cbprivacy.php

示例9: execute

	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework, $_PLUGINS, $ueConfig;

		$params						=	$trigger->getParams()->subTree( 'registration' );

		$approve					=	(int) $params->get( 'approve', null, GetterInterface::INT );
		$confirm					=	(int) $params->get( 'confirm', null, GetterInterface::INT );
		$approval					=	( $approve == 2 ? $ueConfig['reg_admin_approval'] : $approve );
		$confirmation				=	( $confirm == 2 ? $ueConfig['reg_confirmation'] : $confirm );
		$usergroup					=	$params->get( 'usergroup', null, GetterInterface::STRING );
		$password					=	$trigger->getSubstituteString( $params->get( 'password', null, GetterInterface::STRING ) );
		$name						=	array();

		if ( ! $usergroup ) {
			$gids					=	array( $_CB_framework->getCfg( 'new_usertype' ) );
		} else {
			$gids					=	explode( '|*|', $usergroup );
		}

		cbArrayToInts( $gids );

		$newUser					=	new UserTable();

		$newUser->set( 'gids', $gids );
		$newUser->set( 'sendEmail', 0 );
		$newUser->set( 'registerDate', $_CB_framework->getUTCDate() );
		$newUser->set( 'username', $trigger->getSubstituteString( $params->get( 'username', null, GetterInterface::STRING ) ) );
		$newUser->set( 'firstname', $trigger->getSubstituteString( $params->get( 'firstname', null, GetterInterface::STRING ) ) );
		$newUser->set( 'middlename', $trigger->getSubstituteString( $params->get( 'middlename', null, GetterInterface::STRING ) ) );
		$newUser->set( 'lastname', $trigger->getSubstituteString( $params->get( 'lastname', null, GetterInterface::STRING ) ) );

		if ( $newUser->get( 'firstname' ) ) {
			$name[]					=	$newUser->get( 'firstname' );
		}

		if ( $newUser->get( 'middlename' ) ) {
			$name[]					=	$newUser->get( 'middlename' );
		}

		if ( $newUser->get( 'lastname' ) ) {
			$name[]					=	$newUser->get( 'lastname' );
		}

		$newUser->set( 'name', implode( ' ', $name ) );
		$newUser->set( 'email', $trigger->getSubstituteString( $params->get( 'email', null, GetterInterface::STRING ) ) );

		if ( $password ) {
			$newUser->set( 'password', $newUser->hashAndSaltPassword( $password ) );
		} else {
			$newUser->setRandomPassword();

			$newUser->set( 'password', $newUser->hashAndSaltPassword( $newUser->get( 'password' ) ) );
		}

		$newUser->set( 'registeripaddr', cbGetIPlist() );

		if ( $approval == 0 ) {
			$newUser->set( 'approved', 1 );
		} else {
			$newUser->set( 'approved', 0 );
		}

		if ( $confirmation == 0 ) {
			$newUser->set( 'confirmed', 1 );
		} else {
			$newUser->set( 'confirmed', 0 );
		}

		if ( ( $newUser->get( 'confirmed' ) == 1 ) && ( $newUser->get( 'approved' ) == 1 ) ) {
			$newUser->set( 'block', 0 );
		} else {
			$newUser->set( 'block', 1 );
		}

		foreach ( $params->subTree( 'fields' ) as $row ) {
			/** @var ParamsInterface $row */
			$field					=	$row->get( 'field', null, GetterInterface::STRING );

			if ( $field ) {
				$newUser->set( $field, $trigger->getSubstituteString( $row->get( 'value', null, GetterInterface::RAW ), false, $row->get( 'translate', false, GetterInterface::BOOLEAN ) ) );
			}
		}

		$_PLUGINS->trigger( 'onBeforeUserRegistration', array( &$newUser, &$newUser ) );

		if ( ! $newUser->store() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_REGISTRATION_FAILED', ':: Action [action] :: Registration failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $newUser->getError() ) ) );
			}

			return;
		}

		if ( ( $newUser->get( 'confirmed' ) == 0 ) && ( $confirmation != 0 ) ) {
			if ( ! $newUser->store() ) {
//.........這裏部分代碼省略.........
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:101,代碼來源:registration.php


注:本文中的CB\Database\Table\UserTable::getError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。