protected function afterExecute(Gpf_Data_RecordSet $inputResult) { $inputResult->addColumn(Pap_Db_Table_Payouts::AMOUNT); $inputResult->addColumn('users'); $payoutHistoryIds = array(); foreach ($inputResult as $record) { $payoutHistoryIds[] = $record->get('id'); } $outputResult = $inputResult->toShalowRecordSet(); $payeeData = $this->getPayeeData($payoutHistoryIds); foreach ($inputResult as $record) { $payoutHistoryId = $record->get('id'); if(!isset($payeeData[$payoutHistoryId])) { $record->set(Pap_Db_Table_Payouts::AMOUNT, 0); $record->set("users", ""); } else { if (!$this->matchesSearchCriteria($record, $payeeData[$payoutHistoryId])) { $this->_count--; continue; } $record->set("amount", $payeeData[$payoutHistoryId]['amount']); $record->set("users", $payeeData[$payoutHistoryId]['usersCount'].' '. ($payeeData[$payoutHistoryId]['usersCount'] > 1 ? $this->_("payees") : $this->_("payee"))); } $outputResult->addRecord($record); } return $outputResult; }
/** * 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; }
/** * @return Gpf_Data_RecordSet */ public function getThemesNoRpc($panelName, $filterDisabled = false) { $response = new Gpf_Data_RecordSet(); $response->addColumn(Gpf_Desktop_Theme::ID); $response->addColumn(Gpf_Desktop_Theme::NAME); $response->addColumn(Gpf_Desktop_Theme::AUTHOR); $response->addColumn(Gpf_Desktop_Theme::URL); $response->addColumn(Gpf_Desktop_Theme::DESCRIPTION); $response->addColumn(Gpf_Desktop_Theme::THUMBNAIL); $response->addColumn(Gpf_Desktop_Theme::DESKTOP_MODE); $response->addColumn(Gpf_Desktop_Theme::ENABLED); $response->addColumn(Gpf_Desktop_Theme::BUILT_IN); $iterator = new Gpf_Io_DirectoryIterator(Gpf_Paths::getInstance()->getTopTemplatePath() . $panelName, '', false, true); foreach ($iterator as $fullName => $themeId) { if ($themeId == rtrim(Gpf_Paths::DEFAULT_THEME, '/')) { continue; } try { $theme = new Gpf_Desktop_Theme($themeId, $panelName); if ($filterDisabled && !$theme->isEnabled()) { continue; } $response->addRecord($theme->toRecord($response)); } catch (Gpf_Exception $e) { Gpf_Log::error($e->getMessage()); } } return $response; }
public function clearAvailableValues() { $this->availableValues = new Gpf_Data_RecordSet(); $this->availableValues->addColumn('id'); $this->availableValues->addColumn('name'); $this->setAvailableValues(""); }
/** * 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; }
protected function afterExecute(Gpf_Data_RecordSet $inputResult) { $inputResult->addColumn('default', Gpf::NO); $defaultCountry = Gpf_Settings::get(Gpf_Settings_Gpf::DEFAULT_COUNTRY); foreach ($inputResult as $country) { if ($country->get(Gpf_Db_Table_Countries::COUNTRY_CODE) == $defaultCountry) { $country->set('country', $this->_localize($country->get('country')) . ' ' . $this->_('(default)')); $country->set('default', Gpf::YES); continue; } $country->set('country', $this->_localize($country->get('country'))); } return $inputResult; }
/** * * @param Gpf_Data_RecordSet $inputResult * @return Gpf_Data_RecordSet */ protected function afterExecute(Gpf_Data_RecordSet $inputResult) { $inputResult->addColumn("size", null); foreach ($inputResult as $record) { $fileData = $this->getFileData($record->get(Gpf_Db_Table_Exports::FILENAME)); if (count($fileData) > 1) { $record->set("size", $fileData[1]); } else { $record->set(Gpf_Db_Table_Exports::FILENAME, $fileData[0]); $record->set("size", 0); } } return $inputResult; }
private function addCommissions(Gpf_Data_RecordSet $rs ) { $cTable = Pap_Db_Table_Commissions::getInstance(); $rsCommissions = $cTable->getAllCommissionsInCampaign('', ''); $rs->addColumn('commissions', 'N'); $newRs = new Gpf_Data_RecordSet(); $newRs->setHeader($rs->getHeader()); foreach ($rs as $record) { if($cTable->findCampaignInCommExistsRecords($record->get("id"), $rsCommissions)) { $record->set('commissions', $this->getCommissionsDescription($record->get("id"), $rsCommissions)); $newRs->addRecord($record); } } return $newRs; }
/** * * @param Gpf_Data_RecordSet $inputResult * @return Gpf_Data_RecordSet */ protected function afterExecute(Gpf_Data_RecordSet $inputResult) { $inputResult->addColumn('commissionOverview', 'N'); $cTable = Pap_Db_Table_Commissions::getInstance(); $rsCommissions = $cTable->getAllCommissionsInCampaign(); foreach ($inputResult as $record) { if($cTable->findCampaignInCommExistsRecords($record->get(Pap_Db_Table_Campaigns::ID), $rsCommissions)) { $record->set('commissionOverview', $cTable->getCommissionsDescription($record->get(Pap_Db_Table_Campaigns::ID), $rsCommissions, $record->get('id'))); } } return $inputResult; }
/** * Get recordset of all selected wallpaper * * @param Gpf_Rpc_Params $params * @return Gpf_Data_RecordSet */ public function loadSelectedWallpaperNoRpc() { $response = new Gpf_Data_RecordSet(); $response->addColumn(self::WALLPAPER_TYPE); $response->addColumn(self::WALLPAPER_POSITION); $response->addColumn(self::BACKGROUND_COLOR); $response->addColumn("fileId"); $response->addColumn("url"); $record = $response->createRecord(); try { Gpf_Db_Table_UserAttributes::getInstance()->loadAttributes(Gpf_Session::getAuthUser()->getAccountUserId()); $wallpaperType = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::WALLPAPER_TYPE, self::TYPE_THEME); $theme = new Gpf_Desktop_Theme(); $wallpaperId = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::WALLPAPER, $theme->getDefaultWallpaper()); $position = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::WALLPAPER_POSITION, $theme->getDefaultWallpaperPosition()); $color = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::BACKGROUND_COLOR, $theme->getDefaultBackgroundColor()); $record->set(self::WALLPAPER_POSITION, $position); $record->set(self::BACKGROUND_COLOR, $color); $record->set(self::WALLPAPER_TYPE, $wallpaperType); if ($wallpaperType == self::TYPE_THEME) { $record->set("url", Gpf_Paths::getInstance()->getResourceUrl($wallpaperId, Gpf_Paths::IMAGE_DIR . Gpf_Paths::WALLPAPER_DIR)); } else { if ($wallpaperType == self::TYPE_CUSTOM) { $wallpaper = new Gpf_Db_Wallpaper(); $wallpaper->setPrimaryKeyValue($wallpaperId); $wallpaper->load(); $record->set("fileId", $wallpaper->getFileId()); $record->set("url", $wallpaper->getUrl()); } } } catch (Gpf_Exception $e) { $theme = new Gpf_Desktop_Theme(); $record->set(self::WALLPAPER_POSITION, "S"); $record->set(self::BACKGROUND_COLOR, "#000000"); $record->set(self::WALLPAPER_TYPE, self::TYPE_NONE); $record->set("fileId", null); $record->set("url", ""); } $response->addRecord($record); return $response; }
protected function loadItems($itemId, $lastTier = false) { $result = new Gpf_Data_RecordSet(); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->addAll(Pap_Db_Table_Users::getInstance(), 'u'); $selectBuilder->select->add('au.username', 'username'); $selectBuilder->select->add('au.firstname', 'firstname'); $selectBuilder->select->add('au.lastname', 'lastname'); $selectBuilder->select->add('au.'.Gpf_Db_Table_AuthUsers::NOTIFICATION_EMAIL, Gpf_Db_Table_AuthUsers::NOTIFICATION_EMAIL); $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.rtype', '=', Pap_Application::ROLETYPE_AFFILIATE); $selectBuilder->limit->set(0, 50); $this->filterCollection->addTo($selectBuilder->where); $this->addWhereCondition($selectBuilder, $itemId); $result->load($selectBuilder); $result->addColumn("subaffiliates", 0); if (!$lastTier) { $record = $this->addSubaffiliatesCount($result); } return $result; }
/** * @return Gpf_Rpc_Form */ public function loadSideBarNoRpc() { $response = new Gpf_Data_RecordSet(); $response->addColumn("name"); $response->addColumn("value"); $record = $response->createRecord(); $record->set("name", "width"); $sideBarWidthValue = $this->getUserAttributeWithDefaultValue(self::SIDEBAR_WIDTH_SETTING_NAME, "200"); if ($sideBarWidthValue < 0) { $sideBarWidthValue = 200; } $record->set("value", $sideBarWidthValue); $response->add($record); $record = $response->createRecord(); $record->set("name", "hidden"); $record->set("value", $this->getUserAttributeWithDefaultValue(self::SIDEBAR_HIDDEN_SETTING_NAME, "N")); $response->add($record); $record = $response->createRecord(); $record->set("name", "onTop"); $record->set("value", $this->getUserAttributeWithDefaultValue(self::SIDEBAR_ONTOP_SETTING_NAME, Gpf_Settings::get(Gpf_Settings_Gpf::SIDEBAR_DEFAULT_ONTOP))); $response->add($record); return $response; }
/** * 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; }
private function addCampaignDetails(Gpf_Data_RecordSet $inputResult) { $inputResult->addColumn('campaigndetails'); $commissionsTable = Pap_Db_Table_Commissions::getInstance(); $allCommissions = $commissionsTable->getAllCommissionsInCampaign(); $campaignCommissions = array(); foreach ($inputResult as $record) { $campaignId = $record->get('campaignid'); if (!array_key_exists($campaignId, $campaignCommissions)) { $campaign = new Pap_Db_Campaign(); $campaign->setId($campaignId); $commissionGroupId = $campaign->checkUserIsInCampaign(Gpf_Session::getAuthUser()->getPapUserId()); if ($commissionGroupId == false) { $commissionGroupId = null; } $campaignCommissions[$campaignId] = $commissionsTable->getCommissionsDescription($campaignId,$allCommissions,$commissionGroupId); } $record->set('campaigndetails', $campaignCommissions[$campaignId]); } return $inputResult; }