151 $this->
init(
'oxuser' );
163 $this->_blMallUsers = $blOn;
173 public function __get( $sParamName )
176 switch ( $sParamName ) {
180 case 'iCntNoticeListArticles':
183 case 'iCntWishListArticles':
186 case 'iCntRecommLists':
195 case 'oxuser__oxcountry':
214 if ( $this->_oNewsSubscription !== null ) {
218 $this->_oNewsSubscription =
oxNew(
'oxnewssubscribed' );
221 if ( !$this->_oNewsSubscription->loadFromUserId( $this->getId() ) ) {
222 if ( !$this->_oNewsSubscription->loadFromEmail( $this->oxuser__oxusername->value ) ) {
226 $this->_oNewsSubscription->oxnewssubscribed__oxemail =
new oxField($this->oxuser__oxusername->value,
oxField::T_RAW);
227 $this->_oNewsSubscription->oxnewssubscribed__oxsal =
new oxField($this->oxuser__oxsal->value,
oxField::T_RAW);
228 $this->_oNewsSubscription->oxnewssubscribed__oxfname =
new oxField($this->oxuser__oxfname->value,
oxField::T_RAW);
229 $this->_oNewsSubscription->oxnewssubscribed__oxlname =
new oxField($this->oxuser__oxlname->value,
oxField::T_RAW);
247 if ( $this->_oUserCountryTitle == null || $sCountryId ) {
248 $sId = $sCountryId ? $sCountryId : $this->oxuser__oxcountryid->value;
251 $sQ =
"select oxtitle from {$sViewName} where oxid = " . $oDb->quote( $sId ) .
" ";
253 if ( !$sCountryId ) {
254 $this->_oUserCountryTitle = $oCountry;
273 $sQ =
"select oxid from ".getviewName(
"oxcountry" ).
" where oxactive = '1' and oxisoalpha2 = " . $oDb->quote( $sCountry ) .
" ";
274 $sCountryId = $oDb->getOne( $sQ );
289 if ( isset( $this->_oGroups ) ) {
294 $sOXID = $this->
getId();
298 $this->_oGroups =
oxNew(
'oxlist',
'oxgroups' );
299 $sSelect =
"select {$sViewName}.* from {$sViewName} left join oxobject2group on oxobject2group.oxgroupsid = {$sViewName}.oxid
300 where oxobject2group.oxobjectid = " .
oxDb::getDb()->quote( $sOXID );
301 $this->_oGroups->selectString( $sSelect );
314 $sUserId = isset( $sUserId ) ? $sUserId : $this->
getId();
315 if ( !isset( $this->_aAddresses[$sUserId] ) ) {
316 $sSelect =
"select * from oxaddress where oxaddress.oxuserid = " .
oxDb::getDb()->quote( $sUserId );
319 $this->_aAddresses[$sUserId] =
oxNew(
"oxlist" );
320 $this->_aAddresses[$sUserId]->init(
"oxaddress" );
321 $this->_aAddresses[$sUserId]->selectString( $sSelect );
325 foreach ( $this->_aAddresses[$sUserId] as $oAddress ) {
326 if ( $oAddress->getId() === $sAddressId ) {
327 $oAddress->setSelected();
333 return $this->_aAddresses[$sUserId];
345 $this->_sSelAddressId = $sAddressId;
355 if ( $this->_sSelAddressId !== null ) {
373 $this->_sWishId = null;
376 foreach ( $oBasket->getContents() as $oBasketItem ) {
377 if ( $this->_sWishId = $oBasketItem->getWishId() ) {
395 if ( $this->_oSelAddress !== null ) {
399 $oSelectedAddress = null;
401 if ( $oAddresses->count() ) {
403 foreach ( $oAddresses as $oAddress ) {
404 if ( $oAddress->getId() == $sAddressId ) {
405 $oAddress->selected = 1;
406 $oAddress->setSelected();
407 $oSelectedAddress = $oAddress;
414 if ( !$oSelectedAddress ) {
415 if ( !$sAddressId || $sAddressId >= 0 ) {
416 $oAddresses->rewind();
417 $oAddress = $oAddresses->current();
419 $aAddresses = $oAddresses->getArray();
420 $oAddress = array_pop( $aAddresses );
422 $oAddress->selected = 1;
423 $oAddress->setSelected();
424 $oSelectedAddress = $oAddress;
427 $this->_oSelAddress = $oSelectedAddress;
428 return $oSelectedAddress;
440 if ( $this->_oPayments === null ) {
443 $sOXID = $this->
getId();
446 $sSelect =
'select * from oxuserpayments where oxuserid = ' .
oxDb::getDb()->quote( $sOXID ) .
' ';
448 $this->_oPayments =
oxNew(
'oxlist' );
449 $this->_oPayments->init(
'oxUserPayment' );
450 $this->_oPayments->selectString( $sSelect );
453 foreach ( $this->_oPayments as $oPayment ) {
455 $oPayment = $myUtils->assignValuesFromText( $val->oxuserpayments__oxvalue->value );
471 $blAddRemark =
false;
472 if ( $this->oxuser__oxpassword->value && $this->oxuser__oxregister->value < 1 ) {
482 if ( is_array( $this->oxuser__oxbirthdate->value ) ) {
487 if (
$myConfig->getConfigParam(
"bl_showFbConnect" ) ) {
489 if ( $oFb->isConnected() && $oFb->getUser() ) {
490 $this->oxuser__oxfbid =
new oxField( $oFb->getUser() );
497 if ( $blAddRemark && $blRet ) {
498 $oRemark =
oxNew(
'oxremark' );
529 $blIn = isset( $oGroups[ $sGroupID ] );
543 public function delete( $sOXID = null )
547 $sOXID = $this->
getId();
557 $sOXIDQuoted = $oDb->quote($sOXID);
560 $rs = $oDb->execute(
"delete from oxaddress where oxaddress.oxuserid = {$sOXIDQuoted}" );
561 $rs = $oDb->execute(
"delete from oxobject2group where oxobject2group.oxobjectid = {$sOXIDQuoted}" );
564 $rs = $oDb->execute(
"delete oxuserbasketitems.* from oxuserbasketitems, oxuserbaskets where oxuserbasketitems.oxbasketid = oxuserbaskets.oxid and oxuserid = {$sOXIDQuoted}" );
565 $rs = $oDb->execute(
"delete from oxuserbaskets where oxuserid = {$sOXIDQuoted}" );
568 $rs = $oDb->execute(
"delete from oxnewssubscribed where oxuserid = {$sOXIDQuoted}" );
571 $rs = $oDb->execute(
"delete from oxobject2delivery where oxobjectid = {$sOXIDQuoted}");
574 $rs = $oDb->execute(
"delete from oxobject2discount where oxobjectid = {$sOXIDQuoted}");
578 $rs = $oDb->execute(
"delete from oxremark where oxparentid = {$sOXIDQuoted} and oxtype !='o'" );
580 $blDeleted = $rs->EOF;
599 if ( isset( $this->oxuser__oxcreate->value ) ) {
600 $this->oxuser__oxcreate->setValue(
oxRegistry::get(
"oxUtilsDate")->formatDBDate( $this->oxuser__oxcreate->value ));
604 if ( isset($this->_oNewsSubscription) ) {
621 $sOXID = $this->
getId();
624 if (parent::exists($sOXID)) {
625 $this->
setId($sOXID);
635 if (!$this->_blMallUsers && $this->oxuser__oxrights->value !=
'malladmin') {
636 $sShopSelect =
' AND oxshopid = "' . $this->
getConfig()->getShopId() .
'" ';
639 $sSelect =
'SELECT oxid FROM ' . $this->
getViewName() .
'
640 WHERE ( oxusername = ' . $oDb->quote($this->oxuser__oxusername->value) .
' ) ';
641 $sSelect .= $sShopSelect;
643 if (($sOxid = $oDb->getOne($sSelect,
false,
false))) {
645 $this->
setId($sOxid);
660 public function getOrders( $iLimit =
false, $iPage = 0 )
662 $oOrders =
oxNew(
'oxlist' );
663 $oOrders->init(
'oxorder' );
665 if ( $iLimit !==
false ) {
666 $oOrders->setSqlLimit( $iLimit * $iPage, $iLimit );
676 if ( $this->oxuser__oxregister->value > 1 ) {
678 $sQ =
'select * from oxorder where oxuserid = '.$oDb->quote( $this->
getId() ).
' and oxorderdate >= ' . $oDb->quote( $this->oxuser__oxregister->value ) .
' ';
682 $sQ .=
' order by oxorderdate desc ';
683 $oOrders->selectString( $sQ );
697 if ( $this->
getId() && $this->oxuser__oxregister->value > 1 ) {
699 $sQ =
'select count(*) from oxorder where oxuserid = '.$oDb->quote( $this->
getId() ).
' AND oxorderdate >= ' . $oDb->quote( $this->oxuser__oxregister->value) .
' and oxshopid = "'.$this->getConfig()->getShopId().
'" ';
700 $iCnt = (int) $oDb->getOne( $sQ );
713 if ( $this->_iCntNoticeListArticles === null ) {
714 $this->_iCntNoticeListArticles = 0;
715 if ( $this->
getId() ) {
716 $this->_iCntNoticeListArticles = $this->
getBasket(
'noticelist' )->getItemCount();
729 if ( $this->_iCntWishListArticles === null ) {
730 $this->_iCntWishListArticles =
false;
731 if ( $this->
getId() ) {
732 $this->_iCntWishListArticles = $this->
getBasket(
'wishlist' )->getItemCount();
756 $sDeliveryCountry =
'';
758 if ( $soxAddressId ) {
759 $oDelAddress =
oxNew(
'oxaddress' );
760 $oDelAddress->load( $soxAddressId );
761 $sDeliveryCountry = $oDelAddress->oxaddress__oxcountryid->value;
762 } elseif ( $this->
getId() ) {
763 $sDeliveryCountry = $this->oxuser__oxcountryid->value;
765 $oUser =
oxNew(
'oxuser' );
766 if ( $oUser->loadActiveUser() ) {
767 $sDeliveryCountry = $oUser->oxuser__oxcountryid->value;
771 return $sDeliveryCountry;
784 $sShopID = $this->
getConfig()->getShopId();
787 $sSelect =
"select oxid from oxuser where oxusername = " . $oDb->quote( $this->oxuser__oxusername->value ) .
" and oxpassword = '' ";
788 if ( !$this->_blMallUsers ) {
789 $sSelect .=
" and oxshopid = '{$sShopID}' ";
791 $sOXID = $oDb->getOne( $sSelect,
false,
false );
794 if ( isset( $sOXID ) && $sOXID ) {
796 $this->
delete( $sOXID );
797 } elseif ( $this->_blMallUsers ) {
799 $sQ =
"select oxid from oxuser where oxusername = " . $oDb->quote( $this->oxuser__oxusername->value ) .
" and oxusername != '' ";
800 if ( $oDb->getOne( $sQ,
false,
false ) ) {
801 $oEx =
oxNew(
'oxUserException' );
803 $oEx->setMessage( sprintf( $oLang->translateString(
'ERROR_MESSAGE_USER_USEREXISTS', $oLang->getTplLanguage() ), $this->oxuser__oxusername->value ) );
809 if ( ( $blOK = $this->
save() ) ) {
811 $oDb->execute(
"delete from oxaddress where oxaddress.oxuserid = " . $oDb->quote( $this->oxuser__oxid->value ) .
" " );
812 $oDb->execute(
"update oxuserpayments set oxuserpayments.oxuserid = " . $oDb->quote( $this->oxuser__oxusername->value ) .
" where oxuserpayments.oxuserid = " . $oDb->quote( $this->oxuser__oxid->value ) .
" " );
814 $oEx =
oxNew(
'oxUserException' );
815 $oEx->setMessage(
'EXCEPTION_USER_USERCREATIONFAILED' );
831 if ( !$this->
inGroup( $sGroupID ) ) {
833 $oGroup =
oxNew(
'oxGroups');
834 if ( $oGroup->load($sGroupID) ) {
835 $oNewGroup =
oxNew(
'oxobject2group' );
838 if ( $oNewGroup->save() ) {
839 $this->_oGroups[$sGroupID] = $oGroup;
856 if ( $sGroupID != null && $this->
inGroup( $sGroupID ) ) {
857 $oGroups =
oxNew(
'oxlist' );
858 $oGroups->init(
'oxobject2group' );
859 $sSelect =
'select * from oxobject2group where oxobject2group.oxobjectid = "'.$this->getId().
'" and oxobject2group.oxgroupsid = "'.$sGroupID.
'" ';
860 $oGroups->selectString( $sSelect );
861 foreach ( $oGroups as $oRemgroup ) {
862 if ( $oRemgroup->delete() ) {
863 unset( $this->_oGroups[$oRemgroup->oxobject2group__oxgroupsid->value] );
880 if ( is_numeric( $iSuccess ) && $iSuccess != 2 && $iSuccess <= 3 ) {
882 if ( !$this->oxuser__oxdisableautogrp->value ) {
885 $dMidlleCustPrice = (float)
$myConfig->getConfigParam(
'sMidlleCustPrice' );
886 $dLargeCustPrice = (float)
$myConfig->getConfigParam(
'sLargeCustPrice' );
889 $dBasketPrice = $oBasket->getPrice()->getBruttoPrice();
890 if ( $dBasketPrice < $dMidlleCustPrice ) {
893 if ( $dBasketPrice >= $dMidlleCustPrice && $dBasketPrice < $dLargeCustPrice ) {
896 if ( $dBasketPrice >= $dLargeCustPrice ) {
901 if ( $this->
inGroup(
'oxidnotyetordered' ) ) {
916 if ( !isset( $this->_aBaskets[$sName] ) ) {
917 $oBasket =
oxNew(
'oxuserbasket' );
918 $aWhere = array(
'oxuserbaskets.oxuserid' => $this->
getId(),
'oxuserbaskets.oxtitle' => $sName );
921 if ( !$oBasket->assignRecord( $oBasket->buildSelectString( $aWhere ) ) ) {
922 $oBasket->oxuserbaskets__oxtitle =
new oxField($sName);
923 $oBasket->oxuserbaskets__oxuserid =
new oxField($this->
getId());
926 $oBasket->setIsNewBasket();
929 $this->_aBaskets[$sName] = $oBasket;
932 return $this->_aBaskets[$sName];
947 $iYear = isset($aData[
'year'])?((int) $aData[
'year']):
false;
948 $iMonth = isset($aData[
'month'])?((int) $aData[
'month']):
false;
949 $iDay = isset($aData[
'day'])?((int) $aData[
'day']):
false;
952 if ( !$iYear && !$iMonth && !$iDay )
956 if ( !$iYear || $iYear < 1000 || $iYear > 9999)
960 if ( !$iMonth || $iMonth < 1 || $iMonth > 12)
968 $iMaxDays = ($iYear % 4 == 0 && ($iYear % 100 != 0 || $iYear % 400 == 0)) ? 29 : 28;
974 $iMaxDays = min(30, $iMaxDays);
979 if ( !$iDay || $iDay < 1 || $iDay > $iMaxDays) {
984 return sprintf(
"%04d-%02d-%02d", $iYear, $iMonth, $iDay);
994 if ( ! $iBoni = $this->
getConfig()->getConfigParam(
'iCreditRating' ) ) {
1016 $sDynGoup = strtolower( trim( $sDynGoup ) );
1019 $aDisabledDynGroups = array_merge( array(
'oxidadmin' ), (array) $aDeniedDynGroups );
1025 if ( $this->oxuser__oxdisableautogrp->value || !$sDynGoup ) {
1027 } elseif ( in_array( $sDynGoup, $aDisabledDynGroups ) ) {
1030 } elseif ( $this->
addToGroup( $sDynGoup ) ) {
1058 public function checkValues( $sLogin, $sPassword, $sPassword2, $aInvAddress, $aDelAddress )
1061 $sLogin = $this->
_checkLogin( $sLogin, $aInvAddress );
1080 if ( $oError =
oxRegistry::get(
"oxInputValidator")->getFirstValidationError() ) {
1103 if ( $oNewsSubscription ) {
1104 if ( $blSubscribe && ($blForceCheckOptIn || ( $iOptInStatus = $oNewsSubscription->getOptInStatus() ) != 1) ) {
1105 if ( !$blSendOptIn ) {
1110 $oNewsSubscription->setOptInStatus( 1 );
1115 if ( $iOptInStatus != 2 ) {
1117 $oEmail =
oxNew(
'oxemail' );
1118 $blSuccess = $oEmail->sendNewsletterDbOptInMail( $this );
1124 $oNewsSubscription->setOptInStatus( 2 );
1126 } elseif ( !$blSubscribe ) {
1129 $oNewsSubscription->setOptInStatus( 0 );
1154 public function changeUserData( $sUser, $sPassword, $sPassword2, $aInvAddress, $aDelAddress )
1158 $this->
checkValues( $sUser, $sPassword, $sPassword2, $aInvAddress, $aDelAddress );
1163 $this->
assign( $aInvAddress );
1176 if ( $this->
save() ) {
1179 $sCountryId = isset( $aInvAddress[
'oxuser__oxcountryid'] )?$aInvAddress[
'oxuser__oxcountryid']:
'';
1192 $sDelAddress .= $this->oxuser__oxcompany;
1193 $sDelAddress .= $this->oxuser__oxusername;
1194 $sDelAddress .= $this->oxuser__oxfname;
1195 $sDelAddress .= $this->oxuser__oxlname;
1196 $sDelAddress .= $this->oxuser__oxstreet;
1197 $sDelAddress .= $this->oxuser__oxstreetnr;
1198 $sDelAddress .= $this->oxuser__oxaddinfo;
1199 $sDelAddress .= $this->oxuser__oxustid;
1200 $sDelAddress .= $this->oxuser__oxcity;
1201 $sDelAddress .= $this->oxuser__oxcountryid;
1202 $sDelAddress .= $this->oxuser__oxstateid;
1203 $sDelAddress .= $this->oxuser__oxzip;
1204 $sDelAddress .= $this->oxuser__oxfon;
1205 $sDelAddress .= $this->oxuser__oxfax;
1206 $sDelAddress .= $this->oxuser__oxsal;
1208 return $sDelAddress;
1220 if ( is_array( $aDelAddress ) && count( $aDelAddress ) ) {
1222 $sAddressId = $this->
getConfig()->getRequestParameter(
'oxaddressid' );
1223 $sAddressId = ( $sAddressId === null || $sAddressId == -1 || $sAddressId == -2 ) ? null : $sAddressId;
1225 $oAddress =
oxNew(
'oxaddress' );
1226 $oAddress->setId( $sAddressId );
1227 $oAddress->load( $sAddressId );
1228 $oAddress->assign( $aDelAddress );
1230 $oAddress->oxaddress__oxcountry = $this->
getUserCountry( $oAddress->oxaddress__oxcountryid->value );
1234 $this->_aAddresses = null;
1259 $sUserSelect = is_numeric( $sUser ) ?
"oxuser.oxcustnr = {$sUser} " :
"oxuser.oxusername = " . $oDb->quote( $sUser );
1260 $sPassSelect =
" oxuser.oxpassword = BINARY MD5( CONCAT( ".$oDb->quote( $sPassword ).
", UNHEX( oxuser.oxpasssalt ) ) ) ";
1266 $sShopSelect =
" and ( oxrights != 'user' ) ";
1269 $sSelect =
"select `oxid` from oxuser where oxuser.oxactive = 1 and {$sPassSelect} and {$sUserSelect} {$sShopSelect} ";
1292 $sUserSelect = is_numeric( $sUser ) ?
"oxuser.oxcustnr = {$sUser} " :
"oxuser.oxusername = " . $oDb->quote( $sUser );
1298 $sShopSelect =
" and ( oxrights != 'user' ) ";
1301 $sSalt = $oDb->getOne(
"SELECT `oxpasssalt` FROM `oxuser` WHERE " . $sUserSelect . $sShopSelect);
1303 $sPassSelect =
" oxuser.oxpassword = " . $oDb->quote($this->
encodePassword($sPassword, $sSalt));
1305 $sSelect =
"select `oxid` from oxuser where oxuser.oxactive = 1 and {$sPassSelect} and {$sUserSelect} {$sShopSelect} ";
1325 $sShopSelect =
" and ( oxrights != 'user' ) ";
1328 return $sShopSelect;
1339 if ( !$this->
isAdmin() && !$this->
getConfig()->getConfigParam(
'blPerfNoBasketSaving' )) {
1365 public function login( $sUser, $sPassword, $blCookie =
false)
1369 $oEx =
oxNew(
'oxCookieException' );
1370 $oEx->setMessage(
'ERROR_MESSAGE_COOKIE_NOCOOKIE' );
1379 $sShopID = $oConfig->getShopId();
1380 $this->
_dbLogin( $sUser, $sPassword, $sShopID );
1391 if ( $this->oxuser__oxid->value ) {
1405 if ( $blCookie && $oConfig->getConfigParam(
'blShowRememberMe' ) ) {
1406 oxRegistry::get(
"oxUtilsServer")->setUserCookie( $this->oxuser__oxusername->value, $this->oxuser__oxpassword->value, $oConfig->getShopId(), 31536000, $this->oxuser__oxpasssalt->value );
1412 $oEx =
oxNew(
'oxUserException' );
1413 $oEx->setMessage(
'ERROR_MESSAGE_USER_NOVALIDLOGIN' );
1465 $blAdmin = $this->
isAdmin() || $blForceAdmin;
1471 $blFoundInCookie =
false;
1472 if ( !$sUserID && !$blAdmin && $oConfig->getConfigParam(
'blShowRememberMe') ) {
1474 $blFoundInCookie = $sUserID?
true :
false;
1478 if ( !$sUserID && !$blAdmin && $oConfig->getConfigParam(
"bl_showFbConnect") ) {
1484 if ( $this->
load( $sUserID ) ) {
1493 $this->_blLoadedFromCookie = $blFoundInCookie;
1518 if ( $oFb->isConnected() && $oFb->getUser() ) {
1519 $sUserSelect =
"oxuser.oxfbid = " . $oDb->quote( $oFb->getUser() );
1523 $sSelect =
"select oxid from oxuser where oxuser.oxactive = 1 and {$sUserSelect} {$sShopSelect} ";
1524 $sUserID = $oDb->getOne( $sSelect );
1538 $sShopID = $oConfig->getShopId();
1539 if ( ( $sSet =
oxRegistry::get(
"oxUtilsServer")->getUserCookie( $sShopID ) ) ) {
1541 $aData = explode(
'@@@', $sSet );
1545 $sSelect =
'select oxid, oxpassword, oxpasssalt from oxuser where oxuser.oxpassword != "" and oxuser.oxactive = 1 and oxuser.oxusername = '.$oDb->quote($sUser);
1547 $rs = $oDb->select( $sSelect );
1548 if ( $rs !=
false && $rs->recordCount() > 0 ) {
1550 $sTest = crypt( $rs->fields[1], $rs->fields[2] );
1551 if ( $sTest == $sPWD ) {
1553 $sUserID = $rs->fields[0];
1579 protected function _ldapLogin( $sUser, $sPassword, $sShopID, $sShopSelect)
1581 $aLDAPParams = $this->
getConfig()->getConfigParam(
'aLDAPParams' );
1582 $oLDAP =
oxNew(
"oxLDAP", $aLDAPParams[
'HOST'], $aLDAPParams[
'PORT'] );
1586 $sLDAPKey = $oDb->getOne(
"select oxldapkey from oxuser where oxuser.oxactive = 1 and oxuser.oxusername = ".$oDb->quote( $sUser ).
" $sShopSelect");
1587 if ( isset( $sLDAPKey) && $sLDAPKey) {
1592 $oLDAP->login( $sUser, $sPassword, $aLDAPParams[
'USERQUERY'], $aLDAPParams[
'BASEDN'], $aLDAPParams[
'FILTER'] );
1594 $aData = $oLDAP->mapData($aLDAPParams[
'DATAMAP']);
1595 if ( isset( $aData[
'OXUSERNAME']) && $aData[
'OXUSERNAME']) {
1599 $sSelect =
"select oxid from oxuser where oxuser.oxusername = ".$oDb->quote( $aData[
'OXUSERNAME'] ).
" $sShopSelect";
1600 $sOXID = $oDb->getOne( $sSelect );
1602 if ( !isset( $sOXID ) || !$sOXID ) {
1608 foreach ( $aData as $fldname => $value) {
1609 $sField =
"oxuser__".strtolower( $fldname);
1610 $this->$sField =
new oxField( $aData[$fldname] );
1613 $this->oxuser__oxactive =
new oxField( 1 );
1614 $this->oxuser__oxshopid =
new oxField( $sShopID );
1615 $this->oxuser__oxldapkey =
new oxField( $sUser );
1616 $this->oxuser__oxrights =
new oxField(
"user" );
1622 $this->
load( $sOXID);
1626 $oEx =
oxNew(
'oxUserException' );
1627 $oEx->setMessage(
'EXCEPTION_USER_NOVALUES');
1641 if ( !$this->oxuser__oxrights->value )
1646 $sAuthRights = null;
1651 if ( $sAuthUserID ) {
1652 $sAuthRights = $oDb->getOne(
'select oxrights from '.$this->
getViewName().
' where oxid='.$oDb->quote( $sAuthUserID ) );
1659 if ( $sCurrRights = $oDb->getOne(
'select oxrights from '.$this->getViewName().
' where oxid='.$oDb->quote( $this->
getId() ) ) ) {
1660 $aRights[] = $sCurrRights;
1662 $aRights[] =
'user';
1664 if ( !$sAuthRights || !( $sAuthRights ==
'malladmin' || $sAuthRights ==
$myConfig->getShopId() ) ) {
1665 return current( $aRights );
1666 } elseif ( $sAuthRights ==
$myConfig->getShopId() ) {
1667 $aRights[] = $sAuthRights;
1668 if ( !in_array( $this->oxuser__oxrights->value, $aRights ) ) {
1669 return current( $aRights );
1674 return $this->oxuser__oxrights->value;
1688 if ( !isset( $this->oxuser__oxboni->value ) ) {
1703 if (!$this->oxuser__oxpassword->value && $this->oxuser__oxregister->value < 1) {
1704 $this->_aSkipSaveFields[] =
'oxboni';
1708 $this->_aSkipSaveFields[] =
'oxcreate';
1710 $this->_aSkipSaveFields[] =
'oxcustnr';
1711 $this->_aSkipSaveFields[] =
'oxrights';
1715 if ( ( $blUpdate = parent::_update() ) ) {
1739 $sLogin = ( isset( $aInvAddress[
'oxuser__oxusername'] ) )?$aInvAddress[
'oxuser__oxusername'] : $sLogin;
1740 oxRegistry::get(
"oxInputValidator")->checkLogin( $this, $sLogin, $aInvAddress );
1758 $sQ =
'select oxshopid, oxrights, oxpassword from oxuser where oxusername = '. $oDb->quote( $sEmail );
1759 if ( ( $sOxid = $this->
getId() ) ) {
1760 $sQ .=
" and oxid <> ".$oDb->quote( $sOxid );
1762 $oRs = $oDb->select( $sQ,
false,
false );
1763 if ( $oRs !=
false && $oRs->recordCount() > 0 ) {
1765 if ( $this->_blMallUsers ) {
1768 if ( $oRs->fields[1] ==
'user' && !$oRs->fields[2] ) {
1776 while ( !$oRs->EOF ) {
1777 if ( $oRs->fields[1] !=
'user' ) {
1782 } elseif ( $oRs->fields[0] == $iShopId && $oRs->fields[2] ) {
1806 $sOXID = $this->
getId();
1810 $iActPage = ($iActPage < 0) ? 0 : $iActPage;
1813 $iNrofCatArticles = $this->
getConfig()->getConfigParam(
'iNrofCatArticles' );
1814 $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 10;
1817 $oRecommList =
oxNew(
'oxlist' );
1818 $oRecommList->init(
'oxrecommlist' );
1819 $oRecommList->setSqlLimit( $iNrofCatArticles * $iActPage, $iNrofCatArticles );
1820 $iShopId = $this->
getConfig()->getShopId();
1821 $sSelect =
'select * from oxrecommlists where oxuserid ='.
oxDb::getDb()->quote( $sOXID ) .
' and oxshopid ="'. $iShopId .
'"';
1822 $oRecommList->selectString( $sSelect );
1824 return $oRecommList;
1837 $sOx = $this->
getId();
1840 if ( $this->_iCntRecommLists === null || $sOx ) {
1842 $this->_iCntRecommLists = 0;
1843 $iShopId = $this->
getConfig()->getShopId();
1844 $sSelect =
'select count(oxid) from oxrecommlists where oxuserid = ' . $oDb->quote( $sOx ) .
' and oxshopid ="'. $iShopId .
'"';
1845 $this->_iCntRecommLists = $oDb->getOne( $sSelect );
1879 return oxRegistry::get(
"oxInputValidator")->checkPassword( $this, $sNewPass, $sConfPass, $blCheckLenght );
1894 oxRegistry::get(
"oxInputValidator")->checkCountries( $this, $aInvAddress, $aDelAddress );
1910 oxRegistry::get(
"oxInputValidator")->checkRequiredFields( $this, $aInvAddress, $aDelAddress );
1925 oxRegistry::get(
"oxInputValidator")->checkRequiredArrayFields( $this, $sFieldName, $aFieldValues );
1940 oxRegistry::get(
"oxInputValidator")->checkVatId( $this, $aInvAddress );
1954 $blForeigner =
true;
1955 $blForeignGroupExists =
false;
1956 $blInlandGroupExists =
false;
1958 $aHomeCountry = $this->
getConfig()->getConfigParam(
'aHomeCountry' );
1960 if ( is_array($aHomeCountry)) {
1961 if (in_array($sCountryId, $aHomeCountry)) {
1962 $blForeigner =
false;
1964 } elseif ($sCountryId == $aHomeCountry) {
1965 $blForeigner =
false;
1968 if ( $this->
inGroup(
'oxidforeigncustomer' ) ) {
1969 $blForeignGroupExists =
true;
1970 if ( !$blForeigner ) {
1975 if ( $this->
inGroup(
'oxidnewcustomer' ) ) {
1976 $blInlandGroupExists =
true;
1977 if ( $blForeigner ) {
1982 if ( !$this->oxuser__oxdisableautogrp->value ) {
1983 if ( !$blForeignGroupExists && $blForeigner ) {
1986 if ( !$blInlandGroupExists && !$blForeigner ) {
2004 $sQ =
"select oxid from ".$this->getViewName().
" where oxupdateexp >= ".time().
" and MD5( CONCAT( oxid, oxshopid, oxupdatekey ) ) = ".$oDb->quote( $sUid );
2005 if ( $sUserId = $oDb->getOne( $sQ ) ) {
2006 return $this->
load( $sUserId );
2052 $sQ =
"select 1 from ".$this->getViewName().
" where oxupdateexp >= ".time().
" and MD5( CONCAT( oxid, oxshopid, oxupdatekey ) ) = ".$oDb->quote( $sKey );
2053 return !( (bool) $oDb->getOne( $sQ ) );
2063 if ( $this->_sUpdateKey === null ) {
2065 $this->_sUpdateKey = md5( $this->
getId() . $this->oxuser__oxshopid->value . $this->oxuser__oxupdatekey->value );
2083 $oSha512Hasher =
oxNew(
'oxSha512Hasher');
2085 $oHasher =
oxNew(
'oxPasswordHasher', $oSha512Hasher );
2087 return $oHasher->hash($sPassword, $sSalt);
2102 $oOpenSSLFunctionalityChecker =
oxNew(
'oxOpenSSLFunctionalityChecker');
2104 $oGenerator =
oxNew(
'oxPasswordSaltGenerator', $oOpenSSLFunctionalityChecker);
2106 return $oGenerator->generate();
2120 return ( $sSaltHex ?
oxDb::getDb()->getOne(
"select UNHEX( '{$sSaltHex}' )" ) :
'' );
2133 $oOpenSSLFunctionalityChecker =
oxNew(
'oxOpenSSLFunctionalityChecker');
2136 $oSaltGenerator =
oxNew(
'oxPasswordSaltGenerator', $oOpenSSLFunctionalityChecker);
2138 $sSalt = $sPassword ? $oSaltGenerator->generate() :
'';
2141 $sPassword = $sPassword ? $this->
encodePassword( $sPassword, $sSalt ) :
'';
2156 return $this->
encodePassword( $sNewPass, $this->oxuser__oxpasssalt->value ) == $this->oxuser__oxpassword->value;
2178 if ( $this->oxuser__oxpassword->value ) {
2179 if ( strlen( $this->oxuser__oxpassword->value ) < 32 ) {
2180 $this->
setPassword( $this->oxuser__oxpassword->value );
2182 $sHash = $this->oxuser__oxpassword->value;
2197 $sReviewUserHash = $oDb->getOne(
'select md5(concat("oxid", oxpassword, oxusername )) from oxuser where oxid = ' . $oDb->quote( $sUserId ) .
'');
2198 return $sReviewUserHash;
2211 $sUserId = $oDb->getOne(
'select oxid from oxuser where md5(concat("oxid", oxpassword, oxusername )) = ' . $oDb->quote( $sReviewUserHash ) .
'');
2222 return $this->oxuser__oxstateid->value;
2233 $sShopId = $this->
getConfig()->getShopId();
2234 $sUserId = $oDb->quote( $this->
getId() );
2235 return (
bool) $oDb->getOne(
"select 1 from oxacceptedterms where oxuserid={$sUserId} and oxshopid='{$sShopId}'" );
2246 $sUserId = $oDb->quote( $this->
getId() );
2247 $sShopId = $this->
getConfig()->getShopId();
2248 $sVersion =
oxNew(
"oxcontent" )->getTermsVersion();
2250 $oDb->execute(
"replace oxacceptedterms set oxuserid={$sUserId}, oxshopid='{$sShopId}', oxtermversion='{$sVersion}'" );
2266 $iPoints = $this->
getConfig()->getConfigParam(
'dPointsForRegistration' );
2268 $iPending = $oDb->getOne(
"select count(oxuserid) from oxinvitations where oxuserid = ".$oDb->quote( $sUserId ).
" and md5(oxemail) = ".$oDb->quote( $sRecEmail ).
" and oxpending = 1 and oxaccepted = 0",
false,
false);
2269 if ( $iPoints && $iPending ) {
2271 if ( $blSet = $this->
save() ) {
2273 $oDb->execute(
"UPDATE oxinvitations SET oxpending = '0', oxaccepted = '1' where oxuserid = ".$oDb->quote( $sUserId ).
" and md5(oxemail) = ".$oDb->quote( $sRecEmail ) );
2274 $oInvUser =
oxNew(
"oxuser" );
2275 if ( $oInvUser->load( $sUserId ) ) {
2276 $blSet = $oInvUser->setCreditPointsForInviter();
2294 $iPoints = $this->
getConfig()->getConfigParam(
'dPointsForInvitation' );
2296 $iNewPoints = $this->oxuser__oxpoints->value + $iPoints;
2298 $blSet = $this->
save();
2314 if ( $oFb->isConnected() && $oFb->getUser() ) {
2315 $this->oxuser__oxfbid =
new oxField( $oFb->getUser() );
2316 $blRet = $this->
save();
2332 $sUserId = $this->
getId();
2334 if ( $sUserId && is_array( $aRecEmail ) && count( $aRecEmail ) > 0 ) {
2336 $sDate =
oxRegistry::get(
"oxUtilsDate")->formatDBDate( date(
"Y-m-d"),
true );
2338 foreach ( $aRecEmail as $sRecEmail ) {
2339 $sSql =
"INSERT INTO oxinvitations SET oxuserid = ".$oDb->quote( $sUserId ).
", oxemail = $sRecEmail, oxdate='$sDate', oxpending = '1', oxaccepted = '0', oxtype = '1' ";
2340 $oDb->execute( $sSql );
2355 $sQ =
"SELECT `oxid` FROM `oxuser` WHERE `oxusername` = ". $oDb->quote( $sUserName );
2356 if ( !$this->
getConfig()->getConfigParam(
'blMallUsers' ) ) {
2360 return $oDb->getOne( $sQ );
2372 return (
bool) $this->oxuser__oxpassword->value;
2383 return (
bool) $this->
getConfig()->getConfigParam(
'blShowNetPrice');
2393 protected function _dbLogin( $sUser, $sPassword, $sShopID )
2401 $sUserOxId = $oDb->getOne( $this->
_getLoginQuery( $sUser, $sPassword, $sShopID, $this->
isAdmin() ) );
2409 if ( !$this->
load( $sUserOxId ) ) {
2411 $oEx =
oxNew(
'oxUserException' );
2412 $oEx->setMessage(
'ERROR_MESSAGE_USER_NOVALIDLOGIN' );
2414 }elseif($blOldHash && $this->
getId()){
2424 $blDemoMode =
false;
2435 if ( $sPassword ==
"admin" && $sUser ==
"admin" ) {
2436 $sSelect =
"SELECT `oxid` FROM `oxuser` WHERE `oxrights` = 'malladmin' ";
2439 $oEx =
oxNew(
'oxUserException' );
2440 $oEx->setMessage(
'ERROR_MESSAGE_USER_NOVALIDLOGIN' );