예제 #1
0
 /**
  * PayPal active, PayPal user is set, PayPal user loaded
  *
  * @dataProvider providerGetUser
  */
 public function testGetUser($sPaymentId, $sPayPalUserId, $sDefaultUserId, $sExpectedUserId)
 {
     $oUser = new oxUser();
     $oUser->setId($sPayPalUserId);
     $oUser->save();
     $this->getSession()->setVariable("paymentid", $sPaymentId);
     $this->getSession()->setVariable("oepaypal-userId", $sPayPalUserId);
     $this->getSession()->setVariable('usr', $sDefaultUserId);
     $oOrder = new oePayPalOrder();
     $oOrder->setUser(null);
     $oUser = $oOrder->getUser();
     $this->assertEquals($sExpectedUserId, $oUser->oxuser__oxid->value);
 }
예제 #2
0
 /**
  * Method is called when order email is sent to owner.
  *
  * @param oxUser  $user
  * @param oxOrder $order
  */
 protected function onOrderEmailToOwnerSent($user, $order)
 {
     // add user history
     $remark = oxNew("oxRemark");
     $remark->oxremark__oxtext = new oxField($this->getAltBody(), oxField::T_RAW);
     $remark->oxremark__oxparentid = new oxField($user->getId(), oxField::T_RAW);
     $remark->oxremark__oxtype = new oxField("o", oxField::T_RAW);
     $remark->save();
 }
예제 #3
0
 /**
  * Get user payment by payment id
  *
  * @param oxUser $oUser        user object
  * @param string $sPaymentType payment type
  *
  * @return bool
  */
 public function getPaymentByPaymentType($oUser = null, $sPaymentType = null)
 {
     $blGet = false;
     if ($oUser && $sPaymentType != null) {
         $oDb = oxDb::getDb();
         $sQ = 'select oxpaymentid from oxorder where oxpaymenttype=' . $oDb->quote($sPaymentType) . ' and
                 oxuserid=' . $oDb->quote($oUser->getId()) . ' order by oxorderdate desc';
         if ($sOxId = $oDb->getOne($sQ)) {
             $blGet = $this->load($sOxId);
         }
     }
     return $blGet;
 }
 /**
  * Test case for oepaypalexpresscheckoutdispatcher::_getPayPalUser()
  * No user id setted to session
  *
  * @return null
  */
 public function testGetPayPalUser_noUserIdInSession()
 {
     oxTestModules::addModuleObject('oxUser', new oePayPalOxUser());
     // setting user id to session
     $this->setSessionParam("oepaypal-userId", null);
     $oTestUser = new oxUser();
     $oTestUser->setId("testUserId");
     $oDispatcher = $this->getMock("oePayPalExpressCheckoutDispatcher", array("getUser"));
     $oDispatcher->expects($this->once())->method("getUser")->will($this->returnValue($oTestUser));
     $oPayPalUser = $oDispatcher->UNITgetPayPalUser();
     $this->assertEquals("testUserId", $oPayPalUser->getId());
 }
예제 #5
0
 /**
  * default check if it is allowed to delete the OXID of the current table
  *
  * @param string $sId object id
  *
  * @throws Exception on no access
  *
  * @return null
  */
 public function checkForDeletion($sId)
 {
     if (!isset($sId)) {
         throw new Exception("Missing ID!");
     }
     // malladmin can do it
     if ($oUsr = oxUser::getAdminUser()) {
         if ($oUsr->oxuser__oxrights->value == "malladmin") {
             return;
         }
     }
     try {
         $this->getObjectForDeletion($sId);
     } catch (oxSystemComponentException $e) {
         if ($e->getMessage() == 'EXCEPTION_SYSTEMCOMPONENT_CLASSNOTFOUND') {
             $this->_directSqlCheckForDeletion($sId);
         } else {
             throw $e;
         }
     }
 }
예제 #6
0
 /**
  * Checks if user name does not break logic:
  *  - if user wants to UPDATE his login name, performing check if
  *    user entered correct password
  *  - additionally checking for user name duplicates. This is usually
  *    needed when creating new users.
  * On any error exception is thrown.
  *
  * @param oxUser $oUser       active user
  * @param string $sLogin      user preferred login name
  * @param array  $aInvAddress user information
  *
  * @return string login name
  */
 public function checkLogin($oUser, $sLogin, $aInvAddress)
 {
     $sLogin = isset($aInvAddress['oxuser__oxusername']) ? $aInvAddress['oxuser__oxusername'] : $sLogin;
     // check only for users with password during registration
     // if user wants to change user name - we must check if passwords are ok before changing
     if ($oUser->oxuser__oxpassword->value && $sLogin != $oUser->oxuser__oxusername->value) {
         // on this case password must be taken directly from request
         $sNewPass = isset($aInvAddress['oxuser__oxpassword']) && $aInvAddress['oxuser__oxpassword'] ? $aInvAddress['oxuser__oxpassword'] : oxRegistry::getConfig()->getRequestParameter('user_password');
         if (!$sNewPass) {
             // 1. user forgot to enter password
             $oEx = oxNew('oxInputException');
             $oEx->setMessage(oxRegistry::getLang()->translateString('ERROR_MESSAGE_INPUT_NOTALLFIELDS'));
             return $this->_addValidationError("oxuser__oxpassword", $oEx);
         } else {
             // 2. entered wrong password
             if (!$oUser->isSamePassword($sNewPass)) {
                 $oEx = oxNew('oxUserException');
                 $oEx->setMessage(oxRegistry::getLang()->translateString('ERROR_MESSAGE_PASSWORD_DO_NOT_MATCH'));
                 return $this->_addValidationError("oxuser__oxpassword", $oEx);
             }
         }
     }
     if ($oUser->checkIfEmailExists($sLogin)) {
         //if exists then we do now allow to do that
         $oEx = oxNew('oxUserException');
         $oEx->setMessage(sprintf(oxRegistry::getLang()->translateString('ERROR_MESSAGE_USER_USEREXISTS'), $sLogin));
         return $this->_addValidationError("oxuser__oxusername", $oEx);
     }
     return $sLogin;
 }
예제 #7
0
 /**
  * Test case for oePayPaloxUser::loadUserPayPalUser()
  *
  * @return null
  */
 public function testLoadUserPayPalUser()
 {
     //session empty
     $oUser = new oePayPalOxUser();
     $this->assertNull($oUser->loadUserPayPalUser());
     $oUser = new oxUser();
     $oUser->oxuser__oxusername = new oxField('*****@*****.**');
     $oUser->oxuser__oxpassword = new oxField('paswd');
     $oUser->setId('_testId');
     $oUser->save();
     // user id in session
     $this->getSession()->setVariable('oepaypal-userId', '_testId');
     $oUser = new oePayPalOxUser();
     $this->assertTrue($oUser->loadUserPayPalUser());
     $this->assertEquals('_testId', $oUser->oxuser__oxid->value);
 }
예제 #8
0
 /**
  * Creates delivery set list filter SQL to load current state delivery set list
  *
  * @param oxUser $oUser      user object
  * @param string $sCountryId user country id
  *
  * @return string
  */
 protected function _getFilterSelect($oUser, $sCountryId)
 {
     $sTable = getViewName('oxdeliveryset');
     $sQ = "select {$sTable}.* from {$sTable} ";
     $sQ .= "where " . $this->getBaseObject()->getSqlActiveSnippet() . ' ';
     // defining initial filter parameters
     $sUserId = null;
     $aGroupIds = null;
     // checking for current session user which gives additional restrictions for user itself, users group and country
     if ($oUser) {
         // user ID
         $sUserId = $oUser->getId();
         // user groups ( maybe would be better to fetch by function oxuser::getUserGroups() ? )
         $aGroupIds = $oUser->getUserGroups();
     }
     $aIds = array();
     if (count($aGroupIds)) {
         foreach ($aGroupIds as $oGroup) {
             $aIds[] = $oGroup->getId();
         }
     }
     $sUserTable = getViewName('oxuser');
     $sGroupTable = getViewName('oxgroups');
     $sCountryTable = getViewName('oxcountry');
     $oDb = oxDb::getDb();
     $sCountrySql = $sCountryId ? "EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid={$sTable}.OXID and oxobject2delivery.oxtype='oxdelset' and oxobject2delivery.OXOBJECTID=" . $oDb->quote($sCountryId) . ")" : '0';
     $sUserSql = $sUserId ? "EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid={$sTable}.OXID and oxobject2delivery.oxtype='oxdelsetu' and oxobject2delivery.OXOBJECTID=" . $oDb->quote($sUserId) . ")" : '0';
     $sGroupSql = count($aIds) ? "EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid={$sTable}.OXID and oxobject2delivery.oxtype='oxdelsetg' and oxobject2delivery.OXOBJECTID in (" . implode(', ', oxDb::getDb()->quoteArray($aIds)) . ") )" : '0';
     $sQ .= "and (\n            select\n                if(EXISTS(select 1 from oxobject2delivery, {$sCountryTable} where {$sCountryTable}.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid={$sTable}.OXID and oxobject2delivery.oxtype='oxdelset' LIMIT 1),\n                    {$sCountrySql},\n                    1) &&\n                if(EXISTS(select 1 from oxobject2delivery, {$sUserTable} where {$sUserTable}.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid={$sTable}.OXID and oxobject2delivery.oxtype='oxdelsetu' LIMIT 1),\n                    {$sUserSql},\n                    1) &&\n                if(EXISTS(select 1 from oxobject2delivery, {$sGroupTable} where {$sGroupTable}.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid={$sTable}.OXID and oxobject2delivery.oxtype='oxdelsetg' LIMIT 1),\n                    {$sGroupSql},\n                    1)\n            )";
     //order by
     $sQ .= " order by {$sTable}.oxpos";
     return $sQ;
 }
예제 #9
0
 /**
  * Sets user registration action to Emos.
  *
  * @param Emos $oEmos
  * @param oxUser $oUser
  */
 private function _setUserRegistration($oEmos, $oUser)
 {
     $iError = oxRegistry::getConfig()->getRequestParameter('newslettererror');
     $iSuccess = oxRegistry::getConfig()->getRequestParameter('success');
     if ($iError && $iError < 0) {
         $oEmos->addRegister($oUser ? $oUser->getId() : 'NULL', abs($iError));
     }
     if ($iSuccess && $iSuccess > 0 && $oUser) {
         $oEmos->addRegister($oUser->getId(), 0);
     }
 }
 /**
  * Add device and user client data.
  *
  * @param array                      $aData
  * @param OxpsPaymorrowOxUser|oxUser $oUser
  *
  * @return array
  */
 protected function _addDeviceAndClientData(array $aData, oxUser $oUser)
 {
     $oSession = oxRegistry::getSession();
     $sSessionId = $oSession->getId();
     $aData['device_checkId'] = $sSessionId;
     $aData['client_browser_session_id'] = $sSessionId;
     $aData['client_cookies_id'] = $sSessionId;
     $aData['client_ipAddress'] = $oUser->getUserPaymorrowIpAddress();
     $aData['client_browser_header'] = $this->_getBrowserHeaders();
     return $aData;
 }
 /**
  * Returns user shipping address country id.
  *
  * @param oxUser $oUser
  *
  * @return string
  */
 protected function _getUserShippingCountryId($oUser)
 {
     if ($oUser->getSelectedAddressId() && $oUser->getSelectedAddress()) {
         $sCountryId = $oUser->getSelectedAddress()->oxaddress__oxcountryid->value;
     } else {
         $sCountryId = $oUser->oxuser__oxcountryid->value;
     }
     return $sCountryId;
 }
예제 #12
0
 /**
  * Returns country id which VAT should be applied to.
  * Depending on configuration option either user billing country or shipping country (if available) is returned.
  *
  * @param oxUser $oUser user object
  *
  * @return string
  */
 protected function _getVatCountry(oxUser $oUser)
 {
     $blUseShippingCountry = $this->getConfig()->getConfigParam("blShippingCountryVat");
     if ($blUseShippingCountry) {
         $aAddresses = $oUser->getUserAddresses($oUser->getId());
         $sSelectedAddress = $oUser->getSelectedAddressId();
         if (isset($aAddresses[$sSelectedAddress])) {
             return $aAddresses[$sSelectedAddress]->oxaddress__oxcountryid->value;
         }
     }
     return $oUser->oxuser__oxcountryid->value;
 }
예제 #13
0
 /**
  * Checks if delivery address (billing or shipping) was not changed during checkout
  * Throws exception if not available
  *
  * @param oxUser $oUser user object
  *
  * @return int
  */
 public function validateDeliveryAddress($oUser)
 {
     $sDelAddressMD5 = $this->getConfig()->getRequestParameter('sDeliveryAddressMD5');
     $sDeliveryAddress = $oUser->getEncodedDeliveryAddress();
     /** @var oxRequiredAddressFields $oRequiredAddressFields */
     $oRequiredAddressFields = oxNew('oxRequiredAddressFields');
     /** @var oxRequiredFieldsValidator $oFieldsValidator */
     $oFieldsValidator = oxNew('oxRequiredFieldsValidator');
     $oFieldsValidator->setRequiredFields($oRequiredAddressFields->getBillingFields());
     $blFieldsValid = $oFieldsValidator->validateFields($oUser);
     /** @var oxAddress $oDeliveryAddress */
     $oDeliveryAddress = $this->getDelAddressInfo();
     if ($blFieldsValid && $oDeliveryAddress) {
         $sDeliveryAddress .= $oDeliveryAddress->getEncodedDeliveryAddress();
         $oFieldsValidator->setRequiredFields($oRequiredAddressFields->getDeliveryFields());
         $blFieldsValid = $oFieldsValidator->validateFields($oDeliveryAddress);
     }
     $iState = 0;
     if ($sDelAddressMD5 != $sDeliveryAddress || !$blFieldsValid) {
         $iState = self::ORDER_STATE_INVALIDDElADDRESSCHANGED;
     }
     return $iState;
 }
 /**
  * Init ERP Framework parameters
  * Creates Objects, checks Rights etc.
  *
  * @param mixed   $sUserName user name
  * @param mixed   $sPassword password
  * @param integer $iShopID   shop ID
  * @param integer $iLanguage language ID
  *
  * @return boolean
  */
 public function init($sUserName, $sPassword, $iShopID = 1, $iLanguage = 0)
 {
     $myConfig = oxConfig::getInstance();
     $mySession = oxSession::getInstance();
     $oUser = oxUser::getAdminUser();
     if ($oUser->oxuser__oxrights->value == "malladmin" || $oUser->oxuser__oxrights->value == $myConfig->getShopID()) {
         $this->_sSID = $mySession->getId();
         $this->_blInit = true;
         $this->_iLanguage = oxLang::getInstance()->getBaseLanguage();
         $this->_sUserID = $oUser->getId();
         //$mySession->freeze();
     } else {
         //user does not have sufficient rights for shop
         throw new Exception(self::ERROR_USER_NO_RIGHTS);
     }
     $this->_resetIdx();
     return $this->_blInit;
 }
예제 #15
0
 /**
  * Returns current order user object
  *
  * @return oxuser
  */
 public function getOrderUser()
 {
     if ($this->_oUser === null) {
         $this->_oUser = oxNew("oxuser");
         $this->_oUser->load($this->oxorder__oxuserid->value);
         // if object is loaded then reusing its order info
         if ($this->_isLoaded) {
             // bill address
             $this->_oUser->oxuser__oxcompany = clone $this->oxorder__oxbillcompany;
             $this->_oUser->oxuser__oxusername = clone $this->oxorder__oxbillemail;
             $this->_oUser->oxuser__oxfname = clone $this->oxorder__oxbillfname;
             $this->_oUser->oxuser__oxlname = clone $this->oxorder__oxbilllname;
             $this->_oUser->oxuser__oxstreet = clone $this->oxorder__oxbillstreet;
             $this->_oUser->oxuser__oxstreetnr = clone $this->oxorder__oxbillstreetnr;
             $this->_oUser->oxuser__oxaddinfo = clone $this->oxorder__oxbilladdinfo;
             $this->_oUser->oxuser__oxustid = clone $this->oxorder__oxbillustid;
             $this->_oUser->oxuser__oxcity = clone $this->oxorder__oxbillcity;
             $this->_oUser->oxuser__oxcountryid = clone $this->oxorder__oxbillcountryid;
             $this->_oUser->oxuser__oxstateid = clone $this->oxorder__oxbillstateid;
             $this->_oUser->oxuser__oxzip = clone $this->oxorder__oxbillzip;
             $this->_oUser->oxuser__oxfon = clone $this->oxorder__oxbillfon;
             $this->_oUser->oxuser__oxfax = clone $this->oxorder__oxbillfax;
             $this->_oUser->oxuser__oxsal = clone $this->oxorder__oxbillsal;
         }
     }
     return $this->_oUser;
 }
 /**
  * Get user active shipping address if it is used in the session and update it.
  *
  * @param OxpsPaymorrowOxUser|oxUser $oUser
  * @param array                      $aPostData
  *
  * @return bool
  */
 protected function _updateUserActiveShippingAddress(oxUser $oUser, array $aPostData)
 {
     /** @var oxAddress $oShippingAddress */
     $oShippingAddress = $oUser->getSelectedAddress();
     $blShowShippingAddress = (bool) oxRegistry::getSession()->getVariable('blshowshipaddress');
     if (!$blShowShippingAddress or !$oShippingAddress instanceof oxAddress or !$oShippingAddress->getId()) {
         return false;
     }
     return $oUser->mapShippingDataAndUpdateAddress($aPostData, $oShippingAddress);
 }