本文整理汇总了PHP中CB\Database\Table\UserTable::store方法的典型用法代码示例。如果您正苦于以下问题:PHP UserTable::store方法的具体用法?PHP UserTable::store怎么用?PHP UserTable::store使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CB\Database\Table\UserTable
的用法示例。
在下文中一共展示了UserTable::store方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _adjustUserAclBlock
/**
* Adjusts user's ACL and block user if no subscriptions left.
*
* @param UserTable $user
* @param string $cause cause of the change
* @param int $block 1: block user, 0: don't block
* @param int[] $gids new ACL gids (in Joomla < 1.6: only 1 entry)
* @param int[] $removeGids old ACL gids from plans that just expired
* @param array $oldChldGids old ACL gids and children
* @param string $reason reason of change: 'N'=new subscription (default), 'R'=renewal, 'U'=update + 'X'=expiries
*/
protected function _adjustUserAclBlock($user, $cause, $block, $gids, $removeGids, $oldChldGids, $reason)
{
global $_CB_framework;
if ($user && $user->id) {
if (self::_anyValueOfArrayInArray((array) $user->gids, $oldChldGids)) {
// test above is to not degrade higher-level users !
$wasBlocked = $user->block;
$gidsUniqueSorted = array_unique($gids);
sort($gidsUniqueSorted, SORT_NUMERIC);
$userGids = array_unique((array) $user->gids);
sort($userGids, SORT_NUMERIC);
if ($block != $wasBlocked || $userGids != $gidsUniqueSorted) {
$superadministratorgid = $_CB_framework->acl->mapGroupNamesToValues('Superadministrator');
$k_SA = array_search($superadministratorgid, $removeGids);
if ($k_SA !== false) {
unset($removeGids[$k_SA]);
}
$user->gids = array_unique(array_merge(array_diff($userGids, $removeGids), $gidsUniqueSorted));
sort($user->gids, SORT_NUMERIC);
if ($block && !in_array($superadministratorgid, (array) $user->gids)) {
$user->block = 1;
}
$oldPwd = $user->password;
$user->password = null;
// don't update cleartext password in case of registration
$user->store();
// takes care of Mambo/Joomla ACL tables and many other stuff
$user->password = $oldPwd;
if (checkJversion() == 2) {
// This is needed for instant adding of groups to logged-in user (fixing bug #3581): Can be removed once CB 1.9 is released:
$session = JFactory::getSession();
$jUser = $session->get('user');
if ($jUser && $jUser->id == $user->id) {
JAccess::clearStatics();
$session->set('user', new JUser((int) $user->id));
}
}
if ($block == 0 && $wasBlocked == 1) {
$messagesToUser = $reason == 'N' && (!$user->lastvisitDate || $user->lastvisitDate == '0000-00-00 00:00:00');
activateUser($user, 0, 'PaidSubscription', $messagesToUser, $messagesToUser);
//TBD: //FIXME Don't ACTIVATE user 2nd time if this function is called from subscription->activate as a result of onUserActivate?
}
}
}
} else {
user_error(sprintf('AdjustUserAclBlock: user id %d not found in users table.', $user->id), E_USER_NOTICE);
}
}
示例2: 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;
}
示例3: 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;
}
//.........这里部分代码省略.........
示例4: 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() ) {
//.........这里部分代码省略.........