Project

General

Profile

Bug #3196 » 3196-p1_rev1.patch

krileon, 01 February 2012 21:38

View differences:

administrator/components/com_comprofiler/library/cb/cb.tables.php
return $result;
}
/**
* Updates only in database $this->block
*
* @return boolean Store query error
*/
function storeBlock( ) {
global $_CB_framework, $_PLUGINS;
if ( $this->id ) {
$ui = $_CB_framework->getUi();
$user = new moscomprofilerUser( $_CB_database );
$user->load( (int) $this->id );
$oldUserComplete = $user;
$user->block = (int) $this->block;
if ( $ui == 1 ) {
$_PLUGINS->trigger( 'onBeforeUserUpdate', array( &$user, &$user, &$oldUserComplete, &$oldUserComplete ) );
} elseif ( $ui == 2 ) {
$_PLUGINS->trigger( 'onBeforeUpdateUser', array( &$user, &$user, &$oldUserComplete ) );
}
$return = $user->store();
if ( $ui == 1 ) {
$_PLUGINS->trigger( 'onAfterUserUpdate', array( &$user, &$user, $oldUserComplete ) );
} elseif ( $ui == 2 ) {
$_PLUGINS->trigger( 'onAfterUpdateUser', array( &$user, &$user, $oldUserComplete ) );
}
return $return;
}
return false;
}
/**
* Updates only in database the cleartext $this->password
*
* @return boolean Store query error
*/
function storePassword( ) {
global $_CB_framework, $_CB_database, $_PLUGINS;
if ( $this->id ) {
$this->_db->setQuery( "UPDATE #__users SET password=" . $this->_db->Quote( $this->hashAndSaltPassword( $this->password ) ) . " WHERE id = " . (int) $this->id );
return $this->_db->query();
$ui = $_CB_framework->getUi();
$user = new moscomprofilerUser( $_CB_database );
$user->load( (int) $this->id );
$oldUserComplete = $user;
$user->password = $this->hashAndSaltPassword( $this->password );
if ( $ui == 1 ) {
$_PLUGINS->trigger( 'onBeforeUserUpdate', array( &$user, &$user, &$oldUserComplete, &$oldUserComplete ) );
} elseif ( $ui == 2 ) {
$_PLUGINS->trigger( 'onBeforeUpdateUser', array( &$user, &$user, &$oldUserComplete ) );
}
$return = $user->store();
if ( $ui == 1 ) {
$_PLUGINS->trigger( 'onAfterUserUpdate', array( &$user, &$user, $oldUserComplete ) );
} elseif ( $ui == 2 ) {
$_PLUGINS->trigger( 'onAfterUpdateUser', array( &$user, &$user, $oldUserComplete ) );
}
return $return;
}
return false;
}
/**
* Updates only in database $this->approved
*
* @return boolean Store query error
*/
function storeApproved( ) {
global $_CB_framework, $_PLUGINS;
if ( $this->id ) {
$this->_db->SetQuery( "UPDATE #__comprofiler SET approved=" . (int) $this->approved . " WHERE id=" . (int) $this->id );
return $this->_db->query();
$ui = $_CB_framework->getUi();
$user = new moscomprofilerUser( $_CB_database );
$user->load( (int) $this->id );
$oldUserComplete = $user;
$user->approved = (int) $this->approved;
if ( $ui == 1 ) {
$_PLUGINS->trigger( 'onBeforeUserUpdate', array( &$user, &$user, &$oldUserComplete, &$oldUserComplete ) );
} elseif ( $ui == 2 ) {
$_PLUGINS->trigger( 'onBeforeUpdateUser', array( &$user, &$user, &$oldUserComplete ) );
}
$return = $user->store();
if ( $ui == 1 ) {
$_PLUGINS->trigger( 'onAfterUserUpdate', array( &$user, &$user, $oldUserComplete ) );
} elseif ( $ui == 2 ) {
$_PLUGINS->trigger( 'onAfterUpdateUser', array( &$user, &$user, $oldUserComplete ) );
}
return $return;
}
return false;
}
/**
* Updates only in database $this->approved
*
* @return boolean Store query error
*/
function storeConfirmed( ) {
global $_CB_framework, $_PLUGINS;
if ( $this->id ) {
$this->_db->SetQuery( "UPDATE #__comprofiler SET confirmed=" . (int) $this->confirmed . " WHERE id=" . (int) $this->id );
return $this->_db->query();
$ui = $_CB_framework->getUi();
$user = new moscomprofilerUser( $_CB_database );
$user->load( (int) $this->id );
$oldUserComplete = $user;
$user->confirmed = (int) $this->confirmed;
if ( $ui == 1 ) {
$_PLUGINS->trigger( 'onBeforeUserUpdate', array( &$user, &$user, &$oldUserComplete, &$oldUserComplete ) );
} elseif ( $ui == 2 ) {
$_PLUGINS->trigger( 'onBeforeUpdateUser', array( &$user, &$user, &$oldUserComplete ) );
}
$return = $user->store();
if ( $ui == 1 ) {
$_PLUGINS->trigger( 'onAfterUserUpdate', array( &$user, &$user, $oldUserComplete ) );
} elseif ( $ui == 2 ) {
$_PLUGINS->trigger( 'onAfterUpdateUser', array( &$user, &$user, $oldUserComplete ) );
}
return $return;
}
return false;
}
/**
* Saves a new or existing CB+CMS user
* WARNINGS:
......
if ( $bindResults && $beforeResult && $pluginTabsResult ) {
$this->_cbTabs->commitTabsContents( $this, $array, $reason );
$commit_errors = $_PLUGINS->getErrorMSG( false );
if ( count( $commit_errors ) > 0 ) {
$this->_error = $commit_errors;
if ( $_PLUGINS->is_errors() ) {
$this->_error = $_PLUGINS->getErrorMSG( false );
$bindResults = false;
}
}
......
if( isset( $ueConfig['emailpass'] ) && ( $ueConfig['emailpass'] == "1" ) && ( $this->password == '' ) ) {
// generate the password is auto-generated and not set by the admin at this occasion:
$this->setRandomPassword();
$pwd = $this->hashAndSaltPassword( $this->password );
$_CB_database->setQuery( "UPDATE #__users SET password=" . $_CB_database->Quote($pwd) . " WHERE id = " . (int) $this->id );
$_CB_database->query();
$this->storePassword();
}
}
$_PLUGINS->trigger( 'onAfterUpdateUser', array( &$this, &$this, $oldUserComplete ) );
......
* @return string|boolean salted/hashed password if $row not provided, otherwise TRUE/FALSE on password check
*/
function _cbHashPassword( $passwd, $check ) {
global $_CB_database;
$version = checkJversion();
$method = 'md5';
if ( $version == 0 ) {
......
$crypt = md5( $passwd . $salt );
$hashedPwd = $crypt. ':' . $salt;
if ( md5( $passwd ) === $this->password ) {
$query = "UPDATE #__users SET password = '"
. $_CB_database->getEscaped( $hashedPwd ) . "'"
. " WHERE id = " . (int) $this->id;
$_CB_database->setQuery( $query );
$_CB_database->query();
$this->password = $hashedPwd;
$this->storePassword();
}
}
} else {
......
$crypt = md5( $passwd . $salt );
$hashedPwd = $crypt. ':' . $salt;
if ( $hashedPwd === $this->password ) {
$hashedPwd = md5( $passwd );
$query = "UPDATE #__users SET password = '"
. $_CB_database->getEscaped( $hashedPwd ) . "'"
. " WHERE id = " . (int) $this->id;
$_CB_database->setQuery( $query );
$_CB_database->query();
$this->password = $hashedPwd;
$this->storePassword();
}
}
}
(5-5/6)