コード例 #1
0
ファイル: Users.class.php プロジェクト: AmineCherrai/rostanvo
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #2
0
	/**
	 * @return array
	 */
	public function getChildren(Pap_Common_User $parent, $offset = '', $limit = '') {
		$children = array();

		$selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
		$selectBuilder->select->addAll(Pap_Db_Table_Users::getInstance(), 'pu');
		$selectBuilder->select->addAll(Gpf_Db_Table_AuthUsers::getInstance(), 'au');

		$selectBuilder->from->add(Pap_Db_Table_Users::getName(), 'pu');
		$selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu', 'pu.accountuserid = gu.accountuserid');
		$selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'gu.authid = au.authid');

		$selectBuilder->where->add(Pap_Db_Table_Users::PARENTUSERID, '=', $parent->getId());
		$selectBuilder->where->add(Gpf_Db_Table_Users::STATUS, 'IN', array(Pap_Common_Constants::STATUS_APPROVED, Pap_Common_Constants::STATUS_PENDING));
		$selectBuilder->orderBy->add(Pap_Db_Table_Users::DATEINSERTED);

		$selectBuilder->limit->set($offset, $limit);
			
		foreach ($selectBuilder->getAllRowsIterator() as $userRecord) {
			$user = new Pap_Common_User();
			$user->fillFromRecord($userRecord);
			$children[] = $user;
		}

		return $children;
	}
コード例 #3
0
    public function getNumberOfSubaffiliates($userid = null) {
        $result = new Gpf_Data_RecordSet();
        $selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
        $selectBuilder->select->add('COUNT(u.userid)', 'amount');

        $selectBuilder->from->add(Pap_Db_Table_Users::getName(), "u");
        $selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "u.accountuserid = gu.accountuserid");
        $selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");

        $selectBuilder->where->add('u.deleted', '=', Gpf::NO);
        if ($userid === null) {
            $selectBuilder->where->add('u.parentuserid', '=', Gpf_Session::getAuthUser()->getPapUserId());
        } else {
            $selectBuilder->where->add('u.parentuserid', '=', $userid);
        }
        $selectBuilder->where->add('gu.rstatus', '<>', 'D');
        if ($this->params->isDateFromDefined()) {
            $selectBuilder->where->add('u.' . Pap_Stats_Table::DATEINSERTED, '>=', $this->params->getDateFrom()->toDateTime());
        }
        if ($this->params->isDateToDefined()) {
            $selectBuilder->where->add('u.' . Pap_Stats_Table::DATEINSERTED, '<=', $this->params->getDateTo()->toDateTime());
        }
        $selectBuilder->limit->set(0, 1);

        $result->load($selectBuilder);

        if($result->getSize() == 0) {
            return 0;
        }

        foreach($result as $record) {
            return $record->get('amount');
        }
    }
コード例 #4
0
    /**
     * @service pay_affiliate read
     * @param $data
     */
    public function load(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->select->add("au.username","userName");
        $select->select->add("au.firstname","firstName");
        $select->select->add("au.lastname","lastname");
        $select->select->add("SUM(t.".Pap_Db_Table_Transactions::COMMISSION.")", "payout");
        $select->select->add("pu.".Pap_Db_Table_Users::MINIMUM_PAYOUT, "minimumPayout");
        $select->select->add("IFNULL(po.".Gpf_Db_Table_FieldGroups::NAME.", 'undefined')", "payoutMethod");
        $select->from->add(Pap_Db_Table_Transactions::getName(), "t");
        $select->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "t.userid = pu.userid");
        $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid");
        $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");
        $select->groupBy->add("t.".Pap_Db_Table_Transactions::USER_ID);
        $select->from->addLeftJoin(Gpf_Db_Table_FieldGroups::getName(), "po", "pu.payoutoptionid = po.fieldgroupid");
        $select->where->add("t.".Pap_Db_Table_Transactions::USER_ID, "=", $params->get("id"));
        $row = $select->getOneRow();

        $data->setValue("userName", $row->get("userName"));
        $data->setValue("firstName", $row->get("firstName"));
        $data->setValue("lastname", $row->get("lastname"));
        $data->setValue("payout", $row->get("payout"));
        $data->setValue("minimumPayout", $row->get("minimumPayout"));
        $data->setValue("payoutMethod", $row->get("payoutMethod"));

        return $data;
    }
コード例 #5
0
    /**
     *
     * @service affiliate_stats read
     * @param $data
     */
    public function load(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);
        $filters = $data->getFilters();
		$statsParams = new Pap_Stats_Params();
		$statsParams->initFrom($filters);				
		$transactions = new Pap_Stats_Transactions($statsParams);                

        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->from->add(Pap_Db_Table_Users::getName(), "pu");
        $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "gu.accountuserid = pu.accountuserid");
        $select->select->add("SUM(IF(pu.rtype = '". Pap_Application::ROLETYPE_AFFILIATE ."', 1, 0))", "countAffiliates");
        $select->select->add("SUM(IF(gu.rstatus = 'A', 1, 0))", "approvedAffiliates");
        $select->select->add("SUM(IF(gu.rstatus = 'P', 1, 0))", "pendingAffiliates");
        $filters->addTo($select->where);
        $select->where->add("pu.".Pap_Db_Table_Users::TYPE, "=", Pap_Application::ROLETYPE_AFFILIATE);        
        $row = $select->getOneRow();

        $data->setValue("countAffiliates", $this->checkNullValue($row->get("countAffiliates")));
        $data->setValue("approvedAffiliates", $this->checkNullValue($row->get("approvedAffiliates")));
        $data->setValue("pendingAffiliates", $this->checkNullValue($row->get("pendingAffiliates")));
        $data->setValue("totalSales", $transactions->getTotalCost()->getAll());
        $data->setValue("approvedCommissions", $transactions->getCommission()->getApproved());
        $data->setValue("pendingCommissions", $transactions->getCommission()->getPending());

        return $data;
    }
コード例 #6
0
 protected function buildFrom()
 {
     $this->_selectBuilder->from->add(Gpf_Db_Table_LoginsHistory::getName(), 'l');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'u', 'l.accountuserid=u.accountuserid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'u.authid=au.authid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Roles::getName(), 'r', 'r.roleid=u.roleid');
 }
コード例 #7
0
 function buildFrom() {       
     $this->_selectBuilder->from->add(Pap_Db_Table_Payouts::getName(), "p"); 
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "p.userid = pu.userid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");
     $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_FieldGroups::getName(), "po", "pu.payoutoptionid = po.fieldgroupid");
     $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_Currencies::getName(), "c", "p.currencyid = c.currencyid");
 }
コード例 #8
0
 private function isMasterMerchant($authId) {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add(Gpf_Db_Table_Users::ROLEID);
     $select->from->add(Gpf_Db_Table_AuthUsers::getName(), 'au');
     $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'u', 'au.' . Gpf_Db_Table_AuthUsers::ID . '=u.' . Gpf_Db_Table_Users::AUTHID);
     $select->where->add('au.' . Gpf_Db_Table_AuthUsers::ID, '=', $authId);
     return $select->getOneRow()->get(Gpf_Db_Table_Users::ROLEID) == Pap_Application::DEFAULT_ROLE_MERCHANT;
 }
コード例 #9
0
 function buildFrom() {
     $this->_selectBuilder->from->add(Pap_Db_Table_Payouts::getName(), "p");
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_PayoutsHistory::getName(), "ph", "p.payouthistoryid = ph.payouthistoryid");
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "p.userid = pu.userid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");
     $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_Currencies::getName(), "c", "p.currencyid = c.currencyid");
 }
コード例 #10
0
 protected function buildFrom() {
     $this->_selectBuilder->from->add(Pap_Db_Table_AffiliateTrackingCodes::getName(), 'atc');
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_CommissionTypes::getName(), 'com', 'com.commtypeid=atc.commtypeid');
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'cam', 'cam.campaignid=com.campaignid');
     
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), 'u', 'u.userid=atc.userid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu', 'u.accountuserid=gu.accountuserid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'au.authid=gu.authid');
 }
コード例 #11
0
 protected function buildFrom() {
     $this->_selectBuilder->from->add(Pap_Db_Table_Coupons::getName(), 'c');
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(),
         'pu', 'pu.'.Pap_Db_Table_Users::ID.'=c.'.Pap_Db_Table_Coupons::USERID);
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(),
         'gu', 'pu.'.Pap_Db_Table_Users::ACCOUNTUSERID.'=gu.'.Gpf_Db_Table_Users::ID);
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(),
         'au', 'au.'.Gpf_Db_Table_AuthUsers::ID.'=gu.'.Gpf_Db_Table_Users::AUTHID);
 }
コード例 #12
0
 protected function buildFrom() {
     $this->_selectBuilder->from->add(Pap_Db_Table_DirectLinkUrls::getName(), "l");
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "l.userid = pu.userid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");        
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Channels::getName(), "ch", "ch.channelid = l.channelid");
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), "b", "b.bannerid = l.bannerid");
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Campaigns::getName(), "c", "c.campaignid = l.campaignid");
 }
コード例 #13
0
 function buildFrom() {
     $this->_selectBuilder->from->add(Pap_Db_Table_RecurringCommissions::getName(), 'rc');
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_RecurringCommissionEntries::getName(),
         "rce", "rce.recurringcommissionid = rc.recurringcommissionid AND rce.tier = 1");
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Users::getName(), "pu", "rce.userid = pu.userid");
     $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid");
     $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");
     
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Transactions::getName(), "t", "t.transid = rc.transid");
     $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_RecurrencePresets::getName(), 'rp', 'rp.recurrencepresetid = rc.recurrencepresetid');
 }
コード例 #14
0
 protected function buildFrom() {
     $this->_selectBuilder->from->add(Pap_Db_Table_Users::getName(), 'u');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(),
         'gu', 'u.accountuserid=gu.accountuserid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(),
         'au', 'au.authid=gu.authid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Accounts::getName(),
         'a', 'a.accountid=gu.accountid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Roles::getName(),
         'r', 'r.roleid=gu.roleid');
 }
コード例 #15
0
 protected function buildFrom() {
 	$this->_selectBuilder->from->add(Pap_Db_Table_UserInCommissionGroup::getName(), 'ucg');
 	$this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_CommissionGroups::getName(), 'cg',
 	    'cg.'.Pap_Db_Table_CommissionGroups::ID.'=ucg.'.Pap_Db_Table_UserInCommissionGroup::COMMISSION_GROUP_ID);
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), 
         'u', 'ucg.userid=u.userid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 
         'gu', 'u.accountuserid=gu.accountuserid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 
         'au', 'au.authid=gu.authid');
 }
コード例 #16
0
    public function getPendingAffiliatesCount() {
    	$select = new Gpf_SqlBuilder_SelectBuilder();
    	$select->select->add(Gpf_Db_Table_Users::ID);
    	$select->from->add(Gpf_Db_Table_Users::getName());
    	$select->where->add(Gpf_Db_Table_Users::STATUS, "=", self::PENDING);
    	$select->where->add(Gpf_Db_Table_Users::ROLEID, "=", Pap_Application::DEFAULT_ROLE_AFFILIATE);

    	Gpf_Plugins_Engine::extensionPoint('AffiliateNetwork.modifyWhere', new Gpf_Common_SelectBuilderCompoundRecord($select, new Gpf_Data_Record(array())));

    	$result = $select->getAllRows();
    	
    	return $result->getSize();
    }
コード例 #17
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
 protected function getUserId($username) {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('pu.'.Pap_Db_Table_Users::ID, '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',
         'gu.'.Gpf_Db_Table_Users::AUTHID.'=au.'.Gpf_Db_Table_AuthUsers::ID);
     $select->where->add('pu.'.Pap_Db_Table_Users::TYPE, '=', Pap_Application::ROLETYPE_AFFILIATE);
     $select->where->add('pu.'.Pap_Db_Table_Users::DELETED, '<>', Gpf::YES);
     $select->where->add('au.'.Gpf_Db_Table_AuthUsers::USERNAME, '=', $username);
     return $select->getOneRow()->get('id');
 }
コード例 #18
0
 /**
  * @return Gpf_SqlBuilder_SelectBuilder
  */
 protected function createSelectBuilder()
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add("users." . Gpf_Db_Table_Users::ID, self::ID);
     $select->select->add("authUsers." . Gpf_Db_Table_AuthUsers::USERNAME, 'username');
     $select->select->add("authUsers." . Gpf_Db_Table_AuthUsers::FIRSTNAME, 'firstname');
     $select->select->add("authUsers." . Gpf_Db_Table_AuthUsers::LASTNAME, 'lastname');
     $select->from->add(Gpf_Db_Table_Users::getName(), 'users');
     $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'authUsers', "users." . Gpf_Db_Table_Users::AUTHID . "=authUsers." . Gpf_Db_Table_AuthUsers::ID);
     Gpf_Plugins_Engine::extensionPoint('Gpf_Common_UserRichListBox.createSelectBuilder', $select->where);
     $select->orderBy->add("authUsers." . Gpf_Db_Table_AuthUsers::USERNAME);
     return $select;
 }
コード例 #19
0
ファイル: User.class.php プロジェクト: AmineCherrai/rostanvo
 public function loadByRoleType($roleType, $application)
 {
     $query = new Gpf_SqlBuilder_SelectBuilder();
     $query->select->addAll(Gpf_Db_Table_Users::getInstance(), 'u');
     $query->from->add(Gpf_Db_Table_Users::getName(), "u");
     $query->from->addInnerJoin(Gpf_Db_Table_Roles::getName(), "r", "r.roleid = u.roleid");
     $query->from->addInnerJoin(Gpf_Db_Table_Accounts::getName(), "a", "u.accountid = a.accountid");
     $query->where->add('u.authid', '=', $this->getAuthId());
     $query->where->add('u.accountid', '=', $this->getAccountId());
     $query->where->add('a.application', '=', $application);
     $query->where->add('r.roletype', '=', $roleType);
     $record = $query->getOneRow();
     $this->fillFromRecord($record);
 }
コード例 #20
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);
    }
コード例 #21
0
 /**
  * Return count of online users per role
  *
  * @service online_user read
  * @param Gpf_Rpc_Params $params
  */
 public function getOnlineRolesCount(Gpf_Rpc_Params $params)
 {
     $sql = new Gpf_SqlBuilder_SelectBuilder();
     $sql->from->add(Gpf_Db_Table_Roles::getName(), 'r');
     $sql->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'u', 'u.roleid=r.roleid');
     $sql->from->addInnerJoin(Gpf_Db_Table_LoginsHistory::getName(), 'l', 'l.accountuserid=u.accountuserid');
     $sql->select->add(Gpf_Db_Table_Roles::NAME, Gpf_Db_Table_Roles::NAME, 'r');
     $sql->select->add('count(*)', 'usersCount');
     $sql->where->add(Gpf_Db_Table_LoginsHistory::LOGOUT, 'is', 'NULL', 'AND', false);
     $sql->where->add(Gpf_Db_Table_LoginsHistory::LAST_REQUEST, '>', "('" . $this->createDatabase()->getDateString() . "' - INTERVAL 1800 SECOND)", 'AND', false);
     Gpf_Plugins_Engine::extensionPoint('Gpf_Report_OnlineUsersGadget.getOnlineRolesCount', $sql->where);
     $sql->groupBy->add('r.' . Gpf_Db_Table_Roles::ID);
     return $this->translateRoleNames($sql->getAllRows());
 }
コード例 #22
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
    /**
     * Load Location of last 20 IP addresses of logins of selected affiliate
     *
     * @service online_user read
     * @return Gpf_Data_RecordSet
     */
    public function getAffiliateLogins(Gpf_Rpc_Params $params) {
        $sql = new Gpf_SqlBuilder_SelectBuilder();

        $sql->select->add('l.'.Gpf_Db_Table_LoginsHistory::IP);
        $sql->select->add('MAX(l.'.Gpf_Db_Table_LoginsHistory::LOGIN . ')', 'login');

        $sql->from->add(Gpf_Db_Table_LoginsHistory::getName(), 'l');
        $sql->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'u', 'l.accountuserid=u.accountuserid');
        $sql->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'u.authid=au.authid');

        $sql->where->add(Gpf_Db_Table_AuthUsers::USERNAME, '=', $params->get('username'));
        $sql->where->add('l.'.Gpf_Db_Table_LoginsHistory::IP, '<>', '127.0.0.1');

        $sql->orderBy->add(Gpf_Db_Table_LoginsHistory::LOGIN, false);

        $sql->groupBy->add('l.'.Gpf_Db_Table_LoginsHistory::IP);

        $sql->limit->set(0, 20);

        $recordset = $sql->getAllRows();

        $recordset->addColumn('countryCode', '');
        $recordset->addColumn('countryName', '');
        $recordset->addColumn('city', '');
        $recordset->addColumn('latitude', '');
        $recordset->addColumn('longitude', '');
        $recordset->addColumn('postalCode', '');
        $recordset->addColumn('region', '');

        foreach ($recordset as $record) {
            $location = new GeoIp_Location();
            $location->setIpString($record->get('ip'));
            $location->load();

            $record->set('countryCode', $location->getCountryCode());
            $record->set('countryName', $location->getCountryName());
            $record->set('city', $location->getCity());
            $record->set('latitude', $location->getLatitude());
            $record->set('longitude', $location->getLongitude());
            $record->set('postalCode', $location->getPostalCode());
            $record->set('region', $location->getRegion());

            $record->set('login', Gpf_Common_DateUtils::getHumanRelativeTime(Gpf_Common_DateUtils::getClientTime(
            Gpf_Common_DateUtils::mysqlDateTime2Timestamp($record->get('login')))));
        }

        return $recordset;
    }
コード例 #23
0
 /**
  * @return Gpf_SqlBuilder_SelectBuilder
  */
 private function getAffiliatesToPaySelect($payoutOptionId = null) {
     $selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
     $selectBuilder->select->addAll(Pap_Db_Table_Users::getInstance(), 'pu');
     $selectBuilder->select->addAll(Gpf_Db_Table_AuthUsers::getInstance(), 'au');
     $selectBuilder->select->add('SUM('.Pap_Db_Table_Transactions::COMMISSION.')', 'amountRaw');
     
     $selectBuilder->from->add(Pap_Db_Table_Transactions::getName(), 't');    
     $selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), 'pu', 't.userid = pu.userid');
     $selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu', 'pu.accountuserid = gu.accountuserid');
     $selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'gu.authid = au.authid');
     
     if ($payoutOptionId != null) {
         $selectBuilder->where->add('pu.'.Pap_Db_Table_Users::PAYOUTOPTION_ID, '=', $payoutOptionId);
     }
     $selectBuilder->where->add('t.'.Pap_Db_Table_Transactions::PAYOUTHISTORY_ID, '=', Pap_Common_Transaction::PAYMENT_PENDING_ID);
     $selectBuilder->groupBy->add(Pap_Db_Table_Transactions::USER_ID);
     
     return $selectBuilder;
 }
コード例 #24
0
 /**
  * @return Gpf_SqlBuilder_SelectBuilder
  */
 protected function createSelectBuilder() {
 	$select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add("users.".Pap_Db_Table_Users::ID, self::ID);
     $select->select->add("users.".Pap_Db_Table_Users::REFID, 'refid');
     $select->select->add("authUsers.".Gpf_Db_Table_AuthUsers::USERNAME, 'username');
     $select->select->add("authUsers.".Gpf_Db_Table_AuthUsers::FIRSTNAME, 'firstname');
     $select->select->add("authUsers.".Gpf_Db_Table_AuthUsers::LASTNAME, 'lastname');
     $select->from->add(Pap_Db_Table_Users::getName(), 'users');
     $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'accountUsers',
         'users.'.Pap_Db_Table_Users::ACCOUNTUSERID."=accountUsers.".Gpf_Db_Table_Users::ID);
     $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'authUsers',
         "accountUsers.".Gpf_Db_Table_Users::AUTHID."=authUsers.".Gpf_Db_Table_AuthUsers::ID);
     $select->where->add('users.'.Pap_Db_Table_Users::TYPE,
         '=', Pap_Application::ROLETYPE_AFFILIATE);
     $select->where->add('users.'.Pap_Db_Table_Users::DELETED,
         '<>', Gpf::YES);
     $select->orderBy->add("authUsers.".Gpf_Db_Table_AuthUsers::USERNAME);
     $this->modifySelect($select);
   
     return $select;
 }
コード例 #25
0
 /**
  * Validate Db_Row
  *
  * @param Gpf_DbEngine_Row $row
  * @throws Gpf_DbEngine_Row_ConstraintException
  */
 public function validate(Gpf_DbEngine_Row $row)
 {
     $role = new Gpf_Db_Role();
     $role->setId($row->getRoleId());
     $role->load();
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('r.' . Gpf_Db_Table_Roles::TYPE);
     $select->from->add(Gpf_Db_Table_Users::getName(), 'u');
     $select->from->addInnerJoin(Gpf_Db_Table_Roles::getName(), 'r', 'u.' . Gpf_Db_Table_Users::ROLEID . '=r.' . Gpf_Db_Table_Roles::ID);
     $select->where->add('u.' . Gpf_Db_Table_Users::AUTHID, '=', $row->getAuthId());
     $select->where->add('u.' . Gpf_Db_Table_Users::ACCOUNTID, '=', $row->getAccountId());
     $select->where->add('r.' . Gpf_Db_Table_Roles::TYPE, '=', $role->getRoleType());
     $select->where->add('u.' . Gpf_Db_Table_Users::ID, '<>', $row->getPrimaryKeyValue());
     try {
         $select->getOneRow();
     } catch (Gpf_DbEngine_NoRowException $e) {
         return;
     } catch (Gpf_DbEngine_TooManyRowsException $e) {
     }
     throw new Gpf_DbEngine_Row_ConstraintException('username', $this->_('Selected username already exists'));
 }
コード例 #26
0
	/**
	 *
	 * Pap alert application handle, do not modify this source!
	 *
	 * @param String $dateFrom
	 * @param String $dateTo
	 * @param String $userId
	 * @return Gpf_Data_RecordSet
	 */
	public static function getTransactions(Pap_Stats_Params $statsParams) {
		$select = new Gpf_SqlBuilder_SelectBuilder();
		$select->select->add('tr.'.Pap_Db_Table_Transactions::USER_ID, 'userid');
		$select->select->add('au.'.Gpf_Db_Table_AuthUsers::FIRSTNAME, 'name');
		$select->select->add('au.'.Gpf_Db_Table_AuthUsers::LASTNAME, 'surname');
		$select->select->add('au.'.Gpf_Db_Table_AuthUsers::USERNAME, 'username');
		$select->select->add('pu.data1', 'weburl');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::TRANSACTION_ID, 'transid');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::TOTAL_COST, 'totalcost');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::FIXED_COST, 'fixedcost');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::ORDER_ID, 'orderid');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::PRODUCT_ID, 'productid');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::DATE_INSERTED, 'dateinserted');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::R_STATUS, 'rstatus');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::R_TYPE, 'transtype');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::PARRENT_TRANSACTION_ID, 'transkind');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::PAYOUT_STATUS, 'payoutstatus');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::DATE_APPROVED, 'dateapproved');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::COMMISSION, 'commission');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::REFERER_URL, 'refererurl');
		$select->select->add('c.'.Pap_Db_Table_Campaigns::ID, 'campcategoryid');
        $select->select->add('c.'.Pap_Db_Table_Campaigns::NAME, 'campaign');
		$select->select->add('tr.data1', 'data1');
		$select->select->add('tr.data2', 'data2');
		$select->select->add('tr.data3', 'data3');
		$select->select->add('tr.'.Pap_Db_Table_Transactions::COUNTRY_CODE, 'countrycode');
		$select->from->add(Pap_Db_Table_Transactions::getName(), 'tr');
		$select->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'c',
            'tr.'.Pap_Db_Table_Transactions::CAMPAIGN_ID.'=c.'.Pap_Db_Table_Campaigns::ID);
		$select->from->addInnerJoin(Pap_Db_Table_Users::getName(), 'pu',
            'tr.'.Pap_Db_Table_Transactions::USER_ID.'=pu.'.Pap_Db_Table_Users::ID);
		$select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu',
            'gu.'.Gpf_Db_Table_Users::ID.'=pu.'.Pap_Db_Table_Users::ACCOUNTUSERID);
		$select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au',
            'gu.'.Gpf_Db_Table_Users::AUTHID.'=au.'.Gpf_Db_Table_AuthUsers::ID);

		if ($statsParams->isDateFromDefined()) {
			$select->where->add('tr.'.Pap_Db_Table_Transactions::DATE_INSERTED, '>=', $statsParams->getDateFrom()->toDateTime());
		}
		if ($statsParams->isDateToDefined()) {
			$select->where->add('tr.'.Pap_Db_Table_Transactions::DATE_INSERTED, '<=', $statsParams->getDateTo()->toDateTime());
		}
		if ($statsParams->getAffiliateId() != '') {
			$select->where->add('tr.'.Pap_Db_Table_Transactions::USER_ID, '=', $statsParams->getAffiliateId());
		}

		return $select->getAllRows();
	}
コード例 #27
0
    public function getUsersInCommissionGroupCount($campaignId) {
        $selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
        $selectBuilder->select->add('COUNT(*)', 'count');
        $selectBuilder->from->add(Pap_Db_Table_UserInCommissionGroup::getName(), 'ucg');
        $selectBuilder->from->addInnerJoin(Pap_Db_Table_CommissionGroups::getName(), 'cg',
             'cg.'.Pap_Db_Table_CommissionGroups::ID.'=ucg.'.Pap_Db_Table_UserInCommissionGroup::COMMISSION_GROUP_ID);
        $selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), 'pu',
             'pu.'.Pap_Db_Table_Users::ID.'=ucg.'.Pap_Db_Table_UserInCommissionGroup::USER_ID);
        $selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'u',
             'u.'.Gpf_Db_Table_Users::ID.'=pu.'.Pap_Db_Table_Users::ACCOUNTUSERID);
        $selectBuilder->where->add('cg.'.Pap_Db_Table_CommissionGroups::CAMPAIGN_ID, '=', $campaignId);
        $selectBuilder->where->add('pu.' . Pap_Db_Table_Users::TYPE, '=', Pap_Application::ROLETYPE_AFFILIATE);
        $selectBuilder->where->add('u.'.Gpf_Db_Table_Users::STATUS, '=', Gpf_Db_User::APPROVED);
        $selectBuilder->where->add('pu.'.Pap_Db_Table_Users::DELETED, '=', Gpf::NO);

        try {
            $commissionGroupId = $selectBuilder->getOneRow();
        } catch (Gpf_DbEngine_NoRowException $e) {
            return null;
        }
        return $selectBuilder->getOneRow()->get('count');
    }
コード例 #28
0
 function buildFrom() {
     $this->_selectBuilder->from->add(Pap_Db_Table_Transactions::getName(), "t");
     $onCondition = "t.".Pap_Db_Table_Transactions::CAMPAIGN_ID." = c.".Pap_Db_Table_Campaigns::ID;
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Campaigns::getName(), 'c', $onCondition);
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "t.userid = pu.userid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Channels::getName(), "ch", "t.channel = ch.channelid");
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_CommissionTypes::getName(), "ct", "t.commtypeid = ct.commtypeid");
     $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_Currencies::getName(), 'cs', 't.originalcurrencyid = cs.currencyid');
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), 'b', 'b.bannerid = t.bannerid');
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_PayoutsHistory::getName(), 'ph',
         'ph.'.Pap_Db_Table_PayoutsHistory::ID.' = t.'.Pap_Db_Table_Transactions::PAYOUTHISTORY_ID);
 }
コード例 #29
0
    /**
     * Get recordset of merchants recipients
     * 
     * @param $from
     * @return Gpf_Data_RecordSet
     */
    private function getMerchantsRecipients($from) {
        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->select->addAll(Gpf_Db_Table_AuthUsers::getInstance(), 'au');
        $select->select->addAll(Gpf_Db_Table_Accounts::getInstance(), 'a');
        $select->select->addAll(Gpf_Db_Table_Users::getInstance(), 'gu');
        $select->select->addAll(Pap_Db_Table_Users::getInstance(), 'u');
        $select->from->add(Pap_Db_Table_Users::getName(), 'u');
        $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu', 'u.'.Pap_Db_Table_Users::ACCOUNTUSERID.'=gu.'.Gpf_Db_Table_Users::ID.
        ' AND u.'.Pap_Db_Table_Users::DELETED . ' = \'' . Gpf::NO . '\''.
        ' AND u.' .Pap_Db_Table_Users::TYPE . ' = \'' . Pap_Application::ROLETYPE_MERCHANT . '\'');
        $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'au.'.Gpf_Db_Table_AuthUsers::ID.'=gu.'.Gpf_Db_Table_Users::AUTHID);
        $select->from->addInnerJoin(Gpf_Db_Table_Accounts::getName(), 'a', 'a.'.Gpf_Db_Table_Accounts::ID.'=gu.'.Gpf_Db_Table_Users::ACCOUNTID);
        $select->limit->set($from, Pap_Mail_MassMailAffiliatesGrid::MAX_ROWS_PER_SQL);

        return $select->getAllRows();
    }
コード例 #30
0
	private function deleteAffiliates() {
		Pap3Compatibility_Migration_OutputWriter::logOnce("&nbsp;&nbsp;Deleting affiliates .....");
		// pap users
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Pap_Db_Table_Users::getName());
    	$sql->where->add('rtype', '=', 'A');
    	$sql->execute();

    	// g_users
    	$inSelect = new Gpf_SqlBuilder_SelectBuilder();
    	$inSelect->select->add(Pap_Db_Table_Users::ACCOUNTUSERID);
    	$inSelect->from->add(Pap_Db_Table_Users::getName());
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Gpf_Db_Table_Users::getName());
    	$sql->where->add('accountuserid', 'NOT IN', $inSelect, 'AND', false);
    	$sql->execute();

    	// g_authusers
    	$inSelect = new Gpf_SqlBuilder_SelectBuilder();
        $inSelect->select->add(Gpf_Db_Table_Users::AUTHID);
        $inSelect->from->add(Gpf_Db_Table_Users::getName());
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Gpf_Db_Table_AuthUsers::getName());
    	$sql->where->add('authid', 'NOT IN', $inSelect, 'AND', false);
    	$sql->execute();

    	// g_userattributes
    	$inSelect = new Gpf_SqlBuilder_SelectBuilder();
        $inSelect->select->add(Gpf_Db_Table_Users::ID);
        $inSelect->from->add(Gpf_Db_Table_Users::getName());
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Gpf_Db_Table_UserAttributes::getName());
    	$sql->where->add('accountuserid', 'NOT IN', $inSelect, 'AND', false);
    	$sql->execute();

    	// g_gadgets
    	$inSelect = new Gpf_SqlBuilder_SelectBuilder();
        $inSelect->select->add(Gpf_Db_Table_Users::ID);
        $inSelect->from->add(Gpf_Db_Table_Users::getName());
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Gpf_Db_Table_Gadgets::getName());
    	$sql->where->add('accountuserid', 'NOT IN', $inSelect, 'AND', false);
    	$sql->execute();

    	Pap3Compatibility_Migration_OutputWriter::log("DONE<br/>");
	}