# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: Joomla root # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. --- administrator/components/com_comprofiler/library/cb/cb.tables.php +++ administrator/components/com_comprofiler/library/cb/cb.tables.php @@ -1243,41 +1243,157 @@ 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: @@ -1492,10 +1608,8 @@ 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; } } @@ -1544,9 +1658,7 @@ 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 ) ); @@ -1661,8 +1773,6 @@ * @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 ) { @@ -1688,12 +1798,9 @@ $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 { @@ -1713,13 +1820,9 @@ $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(); } } }