/** * 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; }
/** * @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 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 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); }
/** * 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)); }
/** * 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 existsParam($name) { return $this->params->exists($name); }
private function initPager(Gpf_Rpc_Params $params, $offset=0, $limit = 30) { if (!$params->exists('offset')) { $params->add('offset', $offset); } if (!$params->exists('limit')) { $params->add('limit', $limit); } }
/** * @service template write * @param $fields * @return Gpf_Rpc_Action */ public function createFile(Gpf_Rpc_Params $params) { $action = new Gpf_Rpc_Action($params); $templateName = $this->fixTemplateName($action->getParam("templatename")); $panelName = ''; if ($params->exists("panelname")) { $panelName = $action->getParam("panelname"); } if ($params->exists("theme") && $action->getParam("theme") != null && $action->getParam("theme") != "") { $theme = $action->getParam("theme"); } else { throw new Gpf_Exception("Theme not set"); } $commonTemplate = new Gpf_Templates_Template($templateName, $panelName, Gpf_Templates_Template::FETCH_FILE, trim(Gpf_Paths::DEFAULT_THEME, '/')); $commonTemplate->getTemplateSource(); $paths = Gpf_Paths::getInstance()->clonePaths($theme); $templatePaths = $paths->getTemplateSearchPaths($panelName); $filePath = $templatePaths[0] . $templateName; $templateFile = new Gpf_Io_File($filePath); try { $templateFile->open('w'); } catch (Gpf_Exception $e) { if (!$this->createDirectory($filePath)) { $action->setErrorMessage('Unable to create directory: ' . $directory); $action->addError(); return $action; } $templateFile->open('w'); } $templateFile->write($commonTemplate->getTemplateSource()); $action->setInfoMessage($this->_("File added")); $action->addOk(); return $action; }
private function addPostParams(Gpf_Rpc_Params $params) { if ($params->exists('fields')) { $json = new Gpf_Rpc_Json(); foreach ($params->get('fields') as $field) { if (!$params->exists($field[0])) { $decodedItem = $json->decode($field[1]); if ($decodedItem !== null || $decodedItem != '') { $params->add($field[0], $decodedItem); } else { $params->add($field[0], $field[1]); } } } } }
/** * Load list of payout data * * @service payout_option read * @param userid */ public function getFields(Gpf_Rpc_Params $params) { if (!$params->exists('userid')) { throw new Gpf_Exception('User id is missing'); } return parent::getFields($params); }