Last active
November 19, 2018 16:32
-
-
Save wdebusschere/0a170adf8e8078bb65a46f2f3c0f6969 to your computer and use it in GitHub Desktop.
Custom datasource Member roles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class datasourcedsRoles extends SectionDatasource | |
{ | |
public $dsParamROOTELEMENT = 'dsRoles'; | |
public $dsParamCACHE = -1; | |
public $dsParamFILTERS = array( | |
); | |
public $dsParamINCLUDEDELEMENTS = array( | |
); | |
public function __construct($env = null, $process_params = true) | |
{ | |
parent::__construct($env, $process_params); | |
$this->_dependencies = array(); | |
} | |
public function about() | |
{ | |
return array( | |
'name' => 'dsroles', | |
'author' => array( | |
'name' => 'Wannes Debusschere', | |
'website' => 'http://localhost/application', | |
'email' => '[email protected]'), | |
'version' => 'Symphony 2.7.6', | |
'release-date' => '2018-05-10T11:35:12+00:00' | |
); | |
} | |
public function getSource() | |
{ | |
} | |
public function allowEditorToParse() | |
{ | |
return false; | |
} | |
public function execute(array &$param_pool = null) | |
{ | |
$result = new XMLElement($this->dsParamROOTELEMENT); | |
$roles = Symphony::Database()->fetch(sprintf(" | |
SELECT * | |
FROM sym_members_roles | |
ORDER BY name ASC | |
")); | |
$pagination = new XMLElement('pagination', '', array( | |
'total-entries' => count($roles) )); | |
$result->appendChild($pagination); | |
foreach($roles as $role){ | |
$item = new XMLElement('entry', General::sanitize($role['name']), array( | |
'id' => $role['id'], | |
'handle' => $role['handle'] | |
)); | |
$result->appendChild($item); | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment