/** * @service banner read * @param $bannerId * @return Gpf_Rpc_Action */ public function check(Gpf_Rpc_Params $params) { $response = new Gpf_Rpc_Action($params); $bannerFactory = new Pap_Common_Banner_Factory(); $site = $bannerFactory->getBanner($params->get('id')); $site->setDestinationUrl(rtrim($params->get('url'), "/\\").'/'); $response->setInfoMessage('Site replication .htaccess is working at this location'); $response->setErrorMessage('Site replication .htaccess is not set up at this location or it is not working correctly. Please make sure that you have mod_rewrite and mod_proxy enabled in your Apache configuration'); $testUser = new Pap_Common_User(); $testUser->setRefId(Pap_Features_SiteReplication_Replicator::TEST_STRING); $request = new Gpf_Net_Http_Request(); $request->setUrl($site->getUrl($testUser).Pap_Features_SiteReplication_Replicator::TEST_STRING); $httpClient = new Gpf_Net_Http_Client(); try { $testResponse = $httpClient->execute($request); if ($testResponse->getBody() == Pap_Features_SiteReplication_Replicator::TEST_RESPONSE) { $response->addOk(); } else { $response->addError(); } } catch (Gpf_Exception $e) { $response->addError(); } return $response; }
/** * Import data from file * * @service import_export import * @param Gpf_Rpc_Params $params */ public function importData(Gpf_Rpc_Params $params) { $this->file = new Gpf_Csv_File($params->get("fileUrl"), 'r'); $this->delimiter = $params->get("delimiter"); $this->fileUrl = $params->get("fileUrl"); $this->file->setDelimiter($this->delimiter); $this->delete = ($params->get("delete") == Gpf::YES ? true : false); $this->run($params->get('startTime') + 24 - time()); }
/** * @service theme read * * @return Gpf_Data_RecordSet */ public function getThemes(Gpf_Rpc_Params $params) { if ($params->exists('panelName')) { return $this->getThemesNoRpc($params->get('panelName')); } else { return $this->getThemesNoRpc(Gpf_Session::getModule()->getPanelName(), $params->get('filterDisabled')); } }
/** * @service language read * @return Gpf_Rpc_Serializable */ public function getRows(Gpf_Rpc_Params $params) { $language = new Gpf_Db_Language(); $language->setId($params->get(Gpf_Db_Table_Languages::ID)); $language->load(); $filters = $params->get('filters'); $filters[0][2] = htmlspecialchars($filters[0][2]); $params->set('filters', $filters); $this->setCsvReader(new Gpf_Io_Csv_Reader(Gpf_Lang_CsvLanguage::getAccountCsvFileName($language->getCode()))); return parent::getRows($params); }
protected function getRequestIdsIterator() { $json = new Gpf_Rpc_Json(); $requestParams = new Gpf_Rpc_Params($json->decode($this->params->get(self::IDS_REQUEST))); $c = $requestParams->getClass(); $gridService = new $c(); if (!$gridService instanceof Gpf_View_GridService) { throw new Gpf_Exception(sprintf('%s is not Gpf_View_GridService class.', $requestParams->getClass())); } return $gridService->getIdsIterator($requestParams); }
/** * @service theme read */ public function loadTree(Gpf_Rpc_Params $params) { $themeBase = $this->getThemeFile($params->get('panelName')); $themeDirName = $params->get('themeId'); $itemPath = $params->get('itemId'); $filter = $params->get('filter'); $files = array(); $dirs = array(); $this->loadFiles($files, $dirs, $themeBase.'/'.Gpf_Paths::DEFAULT_THEME.$itemPath, $filter); $this->loadFiles($files, $dirs, $themeBase.'/'.$themeDirName.'/'.$itemPath, $filter); return $this->createLoadTreeResult($files, $dirs, $itemPath); }
/** * Create instance to handle DataRequest * * @param Gpf_Rpc_Params $params */ public function __construct(Gpf_Rpc_Params $params = null) { if ($params === null) { $params = new Gpf_Rpc_Params(); } $this->filters = new Gpf_Rpc_FilterCollection($params); $this->params = new Gpf_Data_IndexedRecordSet(self::NAME); $this->params->setHeader(array(self::NAME, self::VALUE)); if ($params->exists(self::DATA) !== null) { $this->loadParamsFromArray($params->get(self::DATA)); } $this->id = $params->get(self::ID); $this->response = new Gpf_Data_IndexedRecordSet(self::NAME); $this->response->setHeader(array(self::NAME, self::VALUE)); }
protected function buildData(Gpf_Data_RecordSet $fields, Gpf_Rpc_Params $params) { $selectBuilder = Pap_Db_Table_Commissions::getInstance()->getAllCommissionsInCampaignSelectBuilder($params->get('campaignid'), ''); $selectBuilder->orderBy->add('c.' . Pap_Db_Table_Commissions::ID); $selectBuilder->orderBy->add('tier'); $selectBuilder->orderBy->add('ct.' . Pap_Db_Table_CommissionTypes::PARENT_COMMISSIONTYPE_ID); $commissionGroupID = $this->getCommissionGroupId($params->get('campaignid')); foreach ($selectBuilder->getAllRowsIterator() as $commission) { if ($commission->get('commissiongroupid') != $commissionGroupID) { continue; } $fields->add($this->createRecordArray($commission)); $this->addCommission($commission); } }
/** * returns all commission types for a campaign * * @service commission read * @param $fields */ public function loadAllCommissionSettings(Gpf_Rpc_Params $params) { $commissionGroupId = $params->get("commissiongroupid"); $campaignId = $params->get("campaignid"); $rtype = $params->get("rtype"); if($campaignId != '') { if($commissionGroupId == '') { $commissionGroupId = $this->getDefaultCommissionGroupId($campaignId); } return Pap_Db_Table_Commissions::getInstance()->getAllCommissions('', $commissionGroupId); } if($rtype != '') { return Pap_Db_Table_Commissions::getInstance()->getAllCommissions('', $commissionGroupId); } throw new Exception($this->_("Campaign ID cannot be empty!")); }
/** * @param $itemId * @return Gpf_Data_RecordSet */ public function loadTree(Gpf_Rpc_Params $params) { if (!$params->exists("itemId")) { throw new Gpf_Exception($this->_('Param itemId is mising')); } return $this->loadItems($params->get('itemId')); }
/** * @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; }
/** * 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; }
/** * returns available plugins * * @service plugin read * @param $fields */ public function load(Gpf_Rpc_Params $params) { $availablePlugins = Gpf_Plugins_Engine::getInstance()->getAvailablePlugins(); if ($params->exists("type")) { $type = $params->get("type"); } else { $type = Gpf_Plugins_Definition::PLUGIN_TYPE_NORMAL; } $response = new Gpf_Data_RecordSet(); $response->addColumn(Gpf_Plugins_Definition::CODE); $response->addColumn(Gpf_Plugins_Definition::NAME); $response->addColumn(Gpf_Plugins_Definition::URL); $response->addColumn(Gpf_Plugins_Definition::DESCRIPTION); $response->addColumn(Gpf_Plugins_Definition::VERSION); $response->addColumn(Gpf_Plugins_Definition::AUTHOR); $response->addColumn(Gpf_Plugins_Definition::AUTHOR_URL); $response->addColumn(Gpf_Plugins_Definition::ACTIVE); $response->addColumn(Gpf_Plugins_Definition::HELP); $response->addColumn(Gpf_Plugins_Definition::CONFIG_CLASS_NAME); foreach ($availablePlugins as $plugin) { if ($plugin->getPluginType() == $type) { $response->addRecord($plugin->toRecord($response)); } } $response = $this->setActivePlugins($response); return $response; }
/** * @service campaign read * @return Gpf_Data_Table */ public function getRows(Gpf_Rpc_Params $params) { $select = $this->createCommissionTypeSelect($params->get('campaignid')); $commTypes = $select->getAllRows(); $this->addSpecialTypes($commTypes); $this->translateCommTypes($commTypes); return $this->createResponse($params, $commTypes); }
/** * @param $params * @param $row * @param $primaryKeyName * @param $baseAttributes */ private function getResponse(Gpf_Rpc_Params $params, Gpf_DbEngine_RowBase $row, $primaryKeyName, array $baseAttributes = null) { $this->visitorId = $params->get('visitorId'); $response = new Gpf_Rpc_Data(); if ($this->visitorId == '') { return $response; } $this->setAccountId($params->get('accountId')); $this->processAllVisitorVisits(); if (($visitorAffiliate = $this->getCurrentVisitorAffiliate()) == null) { return $response; } if (is_null($baseAttributes)) { $baseAttributes = array($primaryKeyName); } $row->set($primaryKeyName, $visitorAffiliate->get($primaryKeyName)); try { $row->load(); } catch (Gpf_Exception $e) { return $response; } if (Gpf_Session::getAuthUser()->hasPrivilege('click', 'write')) { foreach ($row->getAttributes() as $name => $value) { $response->setValue($name, $value); } } else { foreach ($baseAttributes as $attribute) { $response->setValue($attribute, $row->get($attribute)); } } return $response; }
/** * @service coupon read * @param $params * @return Gpf_Data_RecordSet */ public function loadCouponConstants(Gpf_Rpc_Params $params) { $couponConstants = new Gpf_Data_RecordSet(); $couponConstants->setHeader(array('id', 'name')); foreach ($this->getCouponBannersSelect()->getAllRowsIterator() as $couponBannerData) { if ($params->get('bannertype') == Pap_Common_Banner_Factory::BannerTypeHtml || $params->get('bannertype') == Pap_Common_Banner_Factory::BannerTypePromoEmail) { $couponConstant = $couponConstants->createRecord(); $couponConstant->set('id', 'coupon_' . $couponBannerData->get('id')); $couponConstant->set('name', $this->_($couponBannerData->get('name'))); $couponConstants->add($couponConstant); } $couponConstant = $couponConstants->createRecord(); $couponConstant->set('id', 'couponcode_' . $couponBannerData->get('id')); $couponConstant->set('name', $this->_($couponBannerData->get('name')) . ' ' . $this->_('(only coupon code)')); $couponConstants->add($couponConstant); } return $couponConstants; }
/** * Returns parent affiliates plus current affiliate * * @service affiliate_tree read * @param $itemId * @return Gpf_Data_RecordSet */ public function loadParents(Gpf_Rpc_Params $params) { $result = new Gpf_Data_RecordSet(); $user = new Pap_Affiliates_User(); $result->setHeader(array_keys($user->toArray())); $result->addColumn("subaffiliates", 1); $this->addUserToRecordSet($result, $params->get('itemId')); return $result; }
private function init(Gpf_Rpc_Params $params) { $filtersArray = $params->get("filters"); if (!is_array($filtersArray)) { return; } foreach ($filtersArray as $filterArray) { $this->add($filterArray); } }
/** * @return Gpf_SqlBuilder_SelectBuilder */ protected function createBannersSelect(Gpf_Rpc_Params $params) { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('b.'.Pap_Db_Table_Banners::ID, self::ID); $selectBuilder->select->add('b.'.Pap_Db_Table_Banners::NAME, self::VALUE); $selectBuilder->from->add(Pap_Db_Table_Banners::getName(), 'b'); $cond = new Gpf_SqlBuilder_CompoundWhereCondition(); $cond->add('b.'.Pap_Db_Table_Banners::STATUS, '=', 'A'); $cond->add('b.'.Pap_Db_Table_Banners::STATUS, '=', 'H','OR'); $selectBuilder->where->addCondition($cond,'AND'); if ($params->get('campaignid') != '') { $selectBuilder->where->add('b.'.Pap_Db_Table_Banners::CAMPAIGN_ID, '=', $params->get('campaignid')); } Gpf_Plugins_Engine::extensionPoint('PostAffiliate.BannerListbox.getBannerSelect', $selectBuilder); return $selectBuilder; }
/** * @service * @anonym * * @param $gridcode */ public function getActiveView(Gpf_Rpc_Params $params) { $view = new Gpf_Data_RecordSet(); $view->setHeader(array("id")); try { $view->add(array($this->getActiveViewId($params->get('gridcode')))); } catch (Exception $e) { $view->add(array("default")); } return $view; }
/** * @service pdf read * @param Gpf_Rpc_Params $params */ public function generatePdfFromHtml(Gpf_Rpc_Params $params) { if ($params->exists('html')) { $html = $params->get('html'); } else { throw new Gpf_Exception($this->_("Html data is not defined")); } if ($params->exists('fileName')) { $fileName = $params->get('fileName'); } else { throw new Gpf_Exception($this->_("File name is not defined")); } $html = htmlspecialchars_decode($html); $this->generatePDF($html); return new Pap_Common_Banner_PdfGeneratorResponse($fileName, $this->pdf); }
/** * @service * @anonym * @return Gpf_Data_RecordSet */ public function getRow(Gpf_Rpc_Params $params) { $select = $this->createCountriesSelect(); $select->where->add(Gpf_Db_Table_Countries::COUNTRY_CODE, '=', $params->get(self::SEARCH)); $select->limit->set(0, 1); $recordset = $select->getAllRows(); foreach ($recordset as $record) { $record->set('name', $this->_localize($record->get('name'))); } return $recordset; }
/** * Load list of template variables for template specified in input parameter templateId * * @service mail_template read * @param Gpf_Rpc_Params $params */ public function getTemplateVariables(Gpf_Rpc_Params $params) { $dbRow = $this->loadMailTemplate($params->get("templateId")); $recordSet = new Gpf_Data_RecordSet(); $recordSet->setHeader(array('code', 'name')); $className = $dbRow->get(Gpf_Db_Table_MailTemplates::CLASS_NAME); $objTemplate = new $className(); foreach ($objTemplate->getTemplateVariables() as $code => $name) { $recordSet->add(array($code, $name)); } return $recordSet; }
/** * @service * @anonym * * @param $name */ public function getImage(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $lenght = self::TEXT_LENGTH; if (strlen($form->getFieldValue('length'))) { $lenght = $form->getFieldValue('length'); } $text = $this->generateText($lenght); Gpf_Session::getInstance()->setVar(self::SESSION_PREFIX . $form->getFieldValue('name'), $text); $captchaGenerator = new Gpf_Common_Captcha_ImageGenerator($text); $height = 50; $width = self::TEXT_LENGTH * 30; if (strlen($params->get('height'))) { $height = $params->get('height'); } if (strlen($params->get('width'))) { $height = $params->get('width'); } $captchaGenerator->setSize($width, $height); return $captchaGenerator; }
protected function createFilterCollection(Gpf_Rpc_Params $params) { $this->filterCollection = new Gpf_Rpc_FilterCollection($params); if ($params->get('itemId') == '') { if ($this->filterCollection->isFilter('affiliate') && $this->filterCollection->getFilterValue('affiliate') != '') { $params->set('itemId', $this->getAffiliateIds($this->filterCollection->getFilterValue('affiliate'))); } if ($this->filterCollection->isFilter('onlyTopAffiliates') && $this->filterCollection->getFilterValue('onlyTopAffiliates') == Gpf::YES) { $this->onlyTopAffiliates = true; } } $this->removeAffiliateFilter(); }
/** * Gets template names for template name suggestion oracle * * @service template read * @param $search */ public function getTemplateNames(Gpf_Rpc_Params $params) { $searchString = $params->get('search'); $this->loadTemplates(); $result = new Gpf_Data_RecordSet(); $result->setHeader(array('id', 'name')); foreach ($this->templates as $templateName) { if ($searchString == "" || strstr($templateName, $searchString) !== false) { $result->add(array($templateName, $templateName . '.tpl')); } } return $result; }
/** * 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; }
/** * Get list of roles * * @service * @anonym * @param Gpf_Rpc_Params $parmas */ public function getRolesList(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_Db_Table_Roles', 'getRolesList'); } $sql = new Gpf_SqlBuilder_SelectBuilder(); $sql->from->add(Gpf_Db_Table_Roles::getName()); $sql->select->addAll(Gpf_Db_Table_Roles::getInstance()); $accountCondition = new Gpf_SqlBuilder_CompoundWhereCondition(); if (Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Gpf_Privileges::P_READ)) { $accountCondition->add(Gpf_Db_Table_Accounts::ID, '!=', '', 'OR'); } else { $accountCondition->add(Gpf_Db_Table_Accounts::ID, '=', Gpf_Session::getInstance()->getAuthUser()->getAccountId(), 'OR'); } $accountCondition->add(Gpf_Db_Table_Accounts::ID, '=', null, 'OR'); $sql->where->addCondition($accountCondition); if ($params->exists('roleTypes') && $params->get('roleTypes') !== '') { $sql->where->add(Gpf_Db_Table_Roles::TYPE, 'IN', explode(',', $params->get('roleTypes'))); } $sql->orderBy->add(Gpf_Db_Table_Accounts::ID); $sql->orderBy->add(Gpf_Db_Table_Roles::NAME); return $sql->getAllRows(); }
public function __construct(Gpf_Rpc_Params $params = null) { $this->fields = new Gpf_Data_IndexedRecordSet(self::FIELD_NAME); $header = new Gpf_Data_RecordHeader(); $header->add(self::FIELD_NAME); $header->add(self::FIELD_VALUE); $header->add(self::FIELD_VALUES); $header->add(self::FIELD_ERROR); $this->fields->setHeader($header); $this->validator = new Gpf_Rpc_Form_Validator_FormValidatorCollection($this); if ($params) { $this->loadFieldsFromArray($params->get("fields")); } }
/** * * @param $message * @param $simulation * @return Gpf_Rpc_Form */ private function action(Gpf_Rpc_Params $params, $message = '', $simulation = false) { $data = new Gpf_Rpc_Data($params); $filters = new Gpf_Rpc_FilterCollection($params); if ($filters->getFilterValue('reachedCondition') == Gpf::YES) { $data->setValue('message', $message); return $data; } $compressedCommissionProcesor = new Pap_Features_CompressedCommissionPlacementModel_Processor(); $output = $compressedCommissionProcesor->recalculate($params->get('filters'), $simulation); $data->setValue('message', $output); return $data; }