Esempio n. 1
0
    /**
     * @throws Gpf_DbEngine_NoRowException
     * @return Pap_Common_User
     */
    public function getMerchant() {
    	$select = new Gpf_SqlBuilder_SelectBuilder();
		$select->select->add('pu.'.Pap_Db_Table_Users::ID, Pap_Db_Table_Users::ID);
		$select->from->add(Pap_Db_Table_Users::getName(), 'pu');
		$select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu',
		'pu.'.Pap_Db_Table_Users::ACCOUNTUSERID.'=gu.'.Gpf_Db_Table_Users::ID);
		$select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au',
		'au.'.Gpf_Db_Table_AuthUsers::ID.'=gu.'.Gpf_Db_Table_Users::AUTHID);
		$select->where->add('au.'.Gpf_Db_Table_AuthUsers::USERNAME, '=', $this->getEmail());
		$select->where->add('gu.'.Gpf_Db_Table_Users::ACCOUNTID, '=', $this->getId());
		$merchantId = $select->getOneRow()->get(Pap_Db_Table_Users::ID);
		
		return Pap_Merchants_User::getUserById($merchantId);
    }
	/**
	 * @service
	 * @anonym
	 * @return Gpf_Rpc_Data
	 */
	public function load(Gpf_Rpc_Params $params) {
		$data = new Gpf_Rpc_Data($params);
		$data->setValue('affManagerContact', Pap_Merchants_User::getMerchantEmail());
		return $data;
	}
    private function createMasterMerchantUser() {
        $filters = new Pap_Merchants_Filters();
        $filters->addDefaultFilters();

        $merchantUser = new Pap_Merchants_User();
        $merchantUser->setId(Gpf_Settings::get(Pap_Settings::DEFAULT_MERCHANT_ID));
        $merchantUser->setRefId("merchant");
        $merchantUser->setPassword($this->account->getPassword());
        $merchantUser->setUserName($this->account->getEmail());
        $merchantUser->setFirstName($this->account->getFirstname());
        $merchantUser->setLastName($this->account->getLastname());
        $merchantUser->setAccountId($this->account->getId());
        $merchantUser->setStatus(Gpf_Db_User::APPROVED);
        $merchantUser->setNote(Gpf_Lang::_runtime("Hello and welcome to our affiliate program.<br/>I'm your affiliate manager, and I'm here for you if you have ANY questions or problems related to our affiliate program.<br/><br/>I wish you all success in promoting our products, and profitable partnership for both you and us."));
        $merchantUser->setPhoto($this->copyToFileUploads('affiliate-manager.gif'));
        $merchantUser->setData('1', '12345678');
        $merchantUser->setData('6', $this->account->getEmail());
        $merchantUser->setDateInserted(Gpf_Common_DateUtils::getDateTime(time()));
        $merchantUser->save();

        $this->setMerchantNotificationMail($this->account->getEmail());

        $this->setQuickLaunchSettings($merchantUser->getAccountUserId(),
            'showDesktop,Campaigns-Manager,Banner-Manager,Affiliate-Manager,Transaction-Manager,Pay-Affiliates,Reports,Quick-Report,Trends-Report,Clicks-List,Configuration-Manager,Logs-History');

        // set wallpaper to tiled
        $attribute = new Gpf_Db_UserAttribute();
        $attribute->setName('wallpaperPosition');
        $attribute->set(Gpf_Db_Table_UserAttributes::VALUE, 'T');
        $attribute->setAccountUserId($merchantUser->getAccountUserId());
        $attribute->save();
        Gpf_Settings::set(Pap_Settings::DEFAULT_MERCHANT_PANEL_THEME, Pap_Branding::DEFAULT_MERCHANT_PANEL_THEME);
    }