Inheritance: extends Gpf_Object, implements Iterator, implements Gpf_Rpc_Serializable, implements Gpf_Templates_HasAttributes, implements Gpf_Data_Row
Exemplo n.º 1
0
 private function saveField(Gpf_Data_Record $field) {
 	$dbRow = $this->createDbRowObject();
     $dbRow->setPrimaryKeyValue($field->get('id'));
     $dbRow->load();
     $dbRow->set($field->get("name"), $field->get("value"));
     $dbRow->save();
 }
 private function addFilteredByHeader(Gpf_Data_Record $record)
 {
     $newRecord = new Gpf_Data_Record($this->header);
     foreach ($this->header as $column) {
         $newRecord->set($column, $record->get($column));
     }
     $this->encode($newRecord->toObject());
 }
Exemplo n.º 3
0
    /**
     * Returns banner object for given banner record
     *
     * @param string $record banner record loaded from other code
     * @return Pap_Common_Banner
     */
    public function getBannerFromRecord(Gpf_Data_Record $record) {
        $banner = $this->getBannerObjectFromType($record->get('rtype'));
        if($banner == null) {
            throw new Pap_Common_Banner_NotFound($record->get('id'));
        }

        $banner->fillFromRecord($record);
        return $banner;
    }
 private function fillResultRecord(Gpf_Data_Record $record, Gpf_Data_Record $row) {
     foreach ($this->dataColumns as $columnId => $column) {
         try {
             $record->set($columnId, $row->get($column->getName()));
         } catch (Gpf_Exception $e) {
             $record->set($columnId, '');
         }
     }
     return $record;
 }
	/**
	 * @param Gpf_Data_Record $campaign
	 * @return boolean
	 */
	private function isAffiliateInCampaign(Gpf_Data_Record $campaign) {
		try {
			Pap_Db_Table_UserInCommissionGroup::getStatus($campaign->get($this->campaignIDColumnName), $this->affiliateID);
		} catch (Gpf_DbEngine_NoRowException $e) {
			if ($campaign->get(Pap_Db_Table_Campaigns::TYPE) == Pap_Db_Campaign::CAMPAIGN_TYPE_ON_INVITATION) {
				return false;
			}
		}
		return true;
	}
	/**
	 * @param String $field
	 * @return Pap_Db_AffiliateTrackingCode
	 */
	protected function loadAffTrackingCode(Gpf_Data_Record $field) {
		$codeId = $field->get('id');
		if (substr($codeId, 0, 4) == 'NEW_') {
			return $this->loadAffTrackingCodeFrom(substr($codeId, 4), $this->getAffiliateId());
		}
		$dbRow = $this->createDbRowObject();
		$dbRow->setPrimaryKeyValue($codeId);
		$dbRow->load();
		return $dbRow;
	}
 /**
  * Load role privileges
  *
  * @service
  * @anonym
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Data_RecordSet
  */
 public function loadRolePrivileges(Gpf_Rpc_Params $params)
 {
     if (!Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Gpf_Privileges::P_READ) && !Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Pap_Privileges::P_READ_OWN)) {
         throw new Gpf_Rpc_PermissionDeniedException('Gpf_Role_RolePrivilegesForm', 'loadRolePrivileges');
     }
     $role = new Gpf_Db_Role();
     $role->setId($params->get('roleid'));
     $role->load();
     $defaultPrivileges = Gpf_Application::getInstance()->getDefaultPrivilegesByRoleType($role->getRoleType());
     $result = new Gpf_Data_RecordSet();
     $result->addColumn('object');
     $result->addColumn('objectName');
     $result->addColumn('possiblePrivileges');
     $result->addColumn('activePrivileges');
     $rolePrivileges = Gpf_Privileges::loadPrivileges($role->getId());
     foreach ($defaultPrivileges->getDefaultPrivileges() as $object => $privileges) {
         $record = new Gpf_Data_Record($result->getHeader());
         $record->add('object', $object);
         $record->add('objectName', ucfirst(str_replace('_', ' ', strtolower($object))));
         $allTypes = $defaultPrivileges->getObjectToTypeRelation();
         $record->add('possiblePrivileges', implode(',', $allTypes[$object]));
         if (array_key_exists($object, $rolePrivileges)) {
             $record->add('activePrivileges', implode(',', array_keys($rolePrivileges[$object])));
         } else {
             $record->add('activePrivileges', '');
         }
         $result->addRecord($record);
     }
     $result->sort('objectName');
     return $result;
 }
    protected function afterExecute(Gpf_Data_RecordSet $inputResult) {
        $outputResult = new Gpf_Data_RecordSet();
        $outputResult->setHeader($inputResult->getHeader());

        $tree = new Pap_Features_BannersCategories_Tree(false);
        foreach ($inputResult as $record) {
            if ($record->get('code')=='0' || $record->get('selected')=='N') {
                continue;
            }

            $newRecord = new Gpf_Data_Record($inputResult->getHeader());
            $newRecord->add('name', $this->_localize($tree->getBreadcrumb($record->get('id'), ' > ')));
            $newRecord->add('id', $record->get('id'));

            $outputResult->add($newRecord);
        }
        return $outputResult;
    }
    protected function afterExecute(Gpf_Data_RecordSet $inputResult) {
        $outputResult = new Gpf_Data_RecordSet();
        $outputResult->setHeader($inputResult->getHeader());

        $tree = new Pap_Features_BannersCategories_Tree(false);
        foreach ($inputResult as $record) {
            if ($record->get('code')=='0') {
                $this->_count--;
                continue;
            }

            $newRecord = new Gpf_Data_Record($inputResult->getHeader());
            $newRecord->add('name', $record->get('name'));
            $newRecord->add('id', $record->get('id'));
            $newRecord->add('state', $record->get('state'));
            $newRecord->add('depth', $record->get('depth'));


            $outputResult->add($newRecord);
        }
        return $outputResult;
    }
Exemplo n.º 10
0
 /**
  * Fills Db_Row from a record
  * Fields that are not part of the Db_Row are ignored
  *
  * @param Gpf_Data_Record $record
  */
 public function fillFromRecord(Gpf_Data_Record $record)
 {
     foreach ($this->tableColumns as $column) {
         $name = $column->name;
         try {
             $this->set($name, $record->get($name));
         } catch (Gpf_Exception $e) {
         }
     }
     $this->afterLoad();
 }
    /**
     * @service payout_history export
     * @return Gpf_Rpc_Serializable
     */
    public function getIIFFile(Gpf_Rpc_Params $params) {
        $this->initParamsForCSVFile($params);

        $views = $params->get("columns");
        $header = array();
        for ($i = 2; $i < count($views); $i++) {
            if ($views[$i][0] === self::ACTIONS) {
                continue;
            }
            $header[] = $views[$i][0];
        }
        if (!in_array('payouthistoryid', $header)) {
            $header[] = 'payouthistoryid';
        }
        if (!in_array('amount', $header)) {
            $header[] = 'amount';
        }
        if (!in_array('merchantnote', $header)) {
            $header[] = 'merchantnote';
        }
        if (!in_array('affiliatenote', $header)) {
            $header[] = 'affiliatenote';
        }

        $viewResult = new Gpf_Data_RecordSet();
        $viewResult->setHeader($header);

        $payoutHistoryIds = array();

        $result = $this->getResultForCSV();

        if ($result->getSize() > 0) {
            foreach ($result as $record) {
               $row = new Gpf_Data_Record($header);
               foreach ($header as $column) {
                  $row->set($column, $record->get($column));
               }
               $row = $this->addAffiliateInfo($row);
               $viewResult->addRecord($row);
               $payoutHistoryIds[] = $row->get('payouthistoryid');
            }
        }

        if ($this->_fileName != null) {
            $fileName = $this->_fileName.".iif";
        } else {
            $fileName = "grid.iif";
        }

        $affiliates = $this->getUsersFromPayouts($payoutHistoryIds);

        $iifGenerator = new QuickBooks_GeneratorResponse($fileName, $viewResult, $affiliates);
        return $iifGenerator->generateFile();
    }
Exemplo n.º 12
0
 protected function loadAuthData(Gpf_Data_Record $data)
 {
     $this->username = $data->get("username");
     $this->accountUserId = $data->get("accountuserid");
     $this->authtoken = $data->get("authtoken");
     $this->accountid = $data->get("accountid");
     $this->roletypeid = $data->get("roletypeid");
     $this->roleid = $data->get('roleid');
     $this->authId = $data->get('authid');
     $this->firstname = $data->get('firstname');
     $this->lastname = $data->get('lastname');
     $this->ip = $data->get('ip');
     $attributes = Gpf_Db_Table_UserAttributes::getInstance();
     $attributes->loadAttributes($this->accountUserId);
     $this->setLanguage($attributes->getAttributeWithDefaultValue(self::LANGUAGE_ATTRIBUTE_NAME, Gpf_Lang_Dictionary::getDefaultLanguage()));
 }
Exemplo n.º 13
0
 private function addValueToRecord(Gpf_Data_Record $record, $name)
 {
     $record->set($name, $this->configFile->getSetting($name));
 }
Exemplo n.º 14
0
 /**
  * @param Gpf_Data_Record $record
  */
 public function writeRecord($record)
 {
     if ($record != null) {
         $this->encode($record->toObject());
     }
 }
Exemplo n.º 15
0
 public function getCampaigns(Gpf_Data_Record $record) {
     try {
         Pap_Db_Table_UserInCommissionGroup::getStatus($record->get('id'), Gpf_Session::getAuthUser()->getPapUserId());
     } catch (Gpf_DbEngine_NoRowException $e) {
         if ($record->get('rtype') == Pap_Db_Campaign::CAMPAIGN_TYPE_ON_INVITATION) {
             throw new Gpf_Exception($this->_('Private campaign'));
         }
     }
 }
Exemplo n.º 16
0
 /**
  * Returns row data for grid
  *
  * @service language read
  *
  * @param $filters
  * @param $limit
  * @param $offset
  * @param $sort_col
  * @param $sort_asc
  * @param Gpf_Data_RecordSet $columns
  * @return Gpf_Rpc_Serializable
  */
 public function getRows(Gpf_Rpc_Params $params)
 {
     $this->_params = $params;
     $this->_sortColumn = $params->get('sort_col');
     $this->_sortAsc = $params->get('sort_asc');
     $this->_requiredColumns = new Gpf_Data_IndexedRecordSet('id');
     $this->_requiredColumns->loadFromArray($params->get('columns'));
     $response = new Gpf_Rpc_Object();
     $recordHeader = new Gpf_Data_RecordHeader();
     $result = new Gpf_Data_RecordSet();
     foreach ($this->getAllViewColumns() as $column) {
         $result->addColumn($column->get('id'));
         $recordHeader->add($column->get('id'));
     }
     $result->addColumn('id');
     $recordHeader->add('id');
     $languagesIterator = new Gpf_Io_DirectoryIterator(Gpf_Paths::getInstance()->getLanguageInstallDirectory(), 'csv', false);
     $languagesCount = 0;
     foreach ($languagesIterator as $fullName => $file) {
         if (preg_match('/^' . Gpf_Application::getInstance()->getCode() . '_(.+)\\.csv$/', $file, $matches)) {
             $file = new Gpf_Io_Csv_Reader($fullName, ';', '"', array('source', 'translation', 'type', 'module', 'status', 'customer'));
             $language = new Gpf_Lang_CsvLanguage();
             $language->loadFromCsvFile($file, true);
             $languagesCount++;
             $record = new Gpf_Data_Record($recordHeader);
             $record->set('id', $fullName);
             $record->set(Gpf_Db_Table_Languages::CODE, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_CODE));
             $record->set(Gpf_Db_Table_Languages::NAME, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_NAME));
             $record->set(Gpf_Db_Table_Languages::ENGLISH_NAME, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_ENG_NAME));
             $record->set(Gpf_Db_Table_Languages::TRANSLATED_PERCENTAGE, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_TRANSLATION_PERCENTAGE));
             $record->set(Gpf_Db_Table_Languages::AUTHOR, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_AUTHOR));
             $record->set(Gpf_Db_Table_Languages::VERSION, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_VERSION));
             $result->addRecord($record);
         }
     }
     $response->rows = $result->toObject();
     $response->count = $languagesCount;
     return $response;
 }
Exemplo n.º 17
0
 public function loadFromRecord(Gpf_Data_Record $record)
 {
     $this->setSourceMessage($record->get('source'));
     $this->setDestinationMessage($record->get('translation'));
     $this->setType($record->get('type'));
     $this->setStatus($record->get('status'));
     $this->addModule($record->get('module'));
     $this->setCustomerSpecific($record->get('customer'));
 }
 private function replaceConstants(Gpf_Data_Record $row) {
     $coupon = new Pap_Db_Coupon();
     $coupon->setId($row->get('id'));
     $coupon->setCode($row->get('code'));
     $coupon->setStatus($row->get('status'));
     $coupon->set(Pap_Db_Table_Coupons::MAX_USE_COUNT, $row->get('limit_use'));
     $coupon->set(Pap_Db_Table_Coupons::VALID_FROM, $row->get('valid_from'));
     $coupon->set(Pap_Db_Table_Coupons::VALID_TO, $row->get('valid_to'));
     $row->add('coupon', $this->banner->getCouponText($coupon));                
     $row->add('validity', $coupon->isValid());
 }
Exemplo n.º 19
0
 private function processRow(Gpf_Data_Record $dataRow) {
     $time = $dataRow->get("datetime");
     $value = $dataRow->get("value");
     $this->result[$this->convertTimeColumn($time)] = $value;
 }
Exemplo n.º 20
0
 public function getCountryCode(Gpf_Data_Record $context) {
     if ($context->get(Pap_Db_Table_RawImpressions::IP) == '127.0.0.1') {
         $context->set(Pap_Db_Table_Impressions::COUNTRYCODE, '');
         return;
     }
     if (in_array($context->get(Pap_Db_Table_RawImpressions::IP), self::$recognizedIPs)) {
         $context->set(Pap_Db_Table_Impressions::COUNTRYCODE, self::$recognizedIPs[array_search($context->get(Pap_Db_Table_RawImpressions::IP), self::$recognizedIPs)]);
         return;
     }
     try {
         $location = new GeoIp_Location();
         $location->setIpString($context->get(Pap_Db_Table_RawImpressions::IP));
         $location->load();
         $context->set(Pap_Db_Table_Impressions::COUNTRYCODE, $location->getCountryCode());
     } catch (Exception $e) {
     }
     self::$recognizedIPs[$context->get(Pap_Db_Table_RawImpressions::IP)] = $context->get(Pap_Db_Table_Impressions::COUNTRYCODE);
 }
Exemplo n.º 21
0
 public function matches(Gpf_Data_Record $record)
 {
     try {
         $value = $record->get($this->getCode());
     } catch (Gpf_Exception $e) {
         return true;
     }
     switch ($this->operator->getCode()) {
         case 'E':
             return $value == $this->getValue();
         case 'NE':
             return $value != $this->getValue();
         case 'L':
             return strpos($value, $this->getValue()) !== false;
         case 'NL':
             return strpos($value, $this->getValue()) === false;
         case 'IN':
             return array_search($value, $this->decodeArrayValue()) !== false;
         case 'NOT IN':
             return array_search($value, $this->decodeArrayValue()) !== false;
         default:
             throw new Gpf_Exception('Unimplemented');
             break;
     }
 }
Exemplo n.º 22
0
 public function loadFromObject($array)
 {
     if ($array === null) {
         throw new Gpf_Exception('Array must be not NULL');
     }
     $this->_header = new Gpf_Data_RecordHeader($array[0]);
     for ($i = 1; $i < count($array); $i++) {
         $record = new Gpf_Data_Record($this->_header);
         $record->loadFromObject($array[$i]);
         $this->loadRecordFromObject($record);
     }
 }
Exemplo n.º 23
0
 public function writeRecord(Gpf_Data_Record $record)
 {
     $row = array();
     foreach ($this->headers as $header) {
         $row[] = $record->get($header);
     }
     fputcsv($this->getFileHandler(), $row, $this->delimiter, $this->enclosure);
 }
Exemplo n.º 24
0
 /**
  * Mark outbox entry as pending + store error message why it failed
  *
  * @param Gpf_Data_Record $mail
  * @param string $error
  */
 private function failedSending(Gpf_Data_Record $mail, $error)
 {
     //mark outbox entry with status pending
     $outbox = new Gpf_Db_MailOutbox();
     $outbox->set('outboxid', $mail->get('outboxid'));
     $outbox->set('status', Gpf_Db_Table_MailOutbox::STATUS_PENDING);
     $outbox->set('error_msg', $error);
     $outbox->set('scheduled_at', $this->createDatabase()->getDateString(time() + self::RETRY_TIME));
     $outbox->update(array('status', 'error_msg', 'scheduled_at'));
 }
Exemplo n.º 25
0
 public function getLastId()
 {
     return $this->getName() . $this->lastRecord->get(self::WIDGET_ID);
 }
Exemplo n.º 26
0
 protected function insertTransaction($affiliateId, $type, $commissionValue, $status, Gpf_Data_Record $commission = null) {
     if ($affiliateId == null) {
         return;
     }
     $transaction = new Pap_Common_Transaction();
     $transaction->setUserId($affiliateId);
     $transaction->setType($type);
     if ($commission != null) {
         $transaction->setTier($commission->get(Pap_Db_Table_Commissions::TIER));
     } else {
         $transaction->setTier('1');
     }
     $transaction->setStatus($status);
     $transaction->setPayoutStatus('U');
     $transaction->setDateInserted(Gpf_Common_DateUtils::now());
     $transaction->setCommission($commissionValue);
     $transaction->setData5($this->user->getId());
     $transaction->setIp(Gpf_Http::getRemoteIp());
     $transaction->insert();
 }
Exemplo n.º 27
0
    protected function processRow(Gpf_Data_Record $dataRow, $commissionTypeId = self::DEFAULT_COMMISSION_TYPEID) {
        if (!array_key_exists($commissionTypeId, $this->resultCommissions)) {
            $this->resultCommissions[$commissionTypeId] = new Pap_Stats_Data_Commission();
            $this->resultTotalCost[$commissionTypeId] = new Pap_Stats_Data_Commission();
            $this->resultCount[$commissionTypeId] = new Pap_Stats_Data_Commission();
        }
        
        $status = $dataRow->get("status");
        $commission = $dataRow->get("commission");
        $totalcost = $dataRow->get("totalcost");
        $count = $dataRow->get("cnt");

        if ($dataRow->get("payoutstatus") == Pap_Common_Constants::PSTATUS_PAID) {
            if ($status == Pap_Common_Constants::STATUS_APPROVED) {
                $this->resultCommissions[$commissionTypeId]->addPaid($commission);
                $this->resultTotalCost[$commissionTypeId]->addPaid($totalcost);
                $this->resultCount[$commissionTypeId]->addPaid($count);
            }
            return;
        }

        if ($status == Pap_Common_Constants::STATUS_APPROVED) {
            $this->resultCommissions[$commissionTypeId]->addApproved($commission);
            $this->resultTotalCost[$commissionTypeId]->addApproved($totalcost);
            $this->resultCount[$commissionTypeId]->addApproved($count);
            return;
        }
        if ($status == Pap_Common_Constants::STATUS_PENDING) {
            $this->resultCommissions[$commissionTypeId]->addPending($commission);
            $this->resultTotalCost[$commissionTypeId]->addPending($totalcost);
            $this->resultCount[$commissionTypeId]->addPending($count);
            return;
        }
        $this->resultCommissions[$commissionTypeId]->addDeclined($commission);
        $this->resultTotalCost[$commissionTypeId]->addDeclined($totalcost);
        $this->resultCount[$commissionTypeId]->addDeclined($count);
    }
Exemplo n.º 28
0
 protected function loadRecordFromObject(Gpf_Data_Record $record)
 {
     $this->_array[$record->get($this->key)] = $record;
 }
	private function getCommissionText(Gpf_Data_Record $commission) {
		$tier = $commission->get('tier');
		if ($tier > 1) {
			return $this->getTier($tier);
		}
		switch ($commission->get('rtype')) {
			case Pap_Common_Constants::TYPE_CLICK:
				return $this->_('per click').' :';
			case Pap_Common_Constants::TYPE_SALE:
				return $this->_('per sale') . ' :';
			case Pap_Common_Constants::TYPE_CPM:
				return $this->_('per CPM') . ' :';
			case Pap_Common_Constants::TYPE_ACTION:
				return $this->_($commission->get('commissionTypeName')).":";
		}
		return '';
	}