Skip to content

Commit

Permalink
Merge pull request #10 from davide-scola/1.x-support_osTicket_branch_…
Browse files Browse the repository at this point in the history
…1.17.x

[1.x] osTicket v1.17
  • Loading branch information
davide-scola authored Mar 30, 2023
2 parents 0ba6c8a + e9ba00b commit 00f1ce6
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 10 deletions.
21 changes: 21 additions & 0 deletions BitfinexStreamerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

/**
* Entry point class to bfx-ost-streamer plugin.
*
* @property array $ht
* A cached version of the plugin's configuration taken from the database.
*/
class BitfinexStreamerPlugin extends \Plugin {

Expand Down Expand Up @@ -55,6 +58,24 @@ public function bootstrap() {
}
}

/**
* {@inheritDoc}
*/
public function init() {
if (\method_exists(parent::class, 'init') === TRUE) {
parent::init();
}

$this->{'ht'}['name'] = $this->{'info'}['name'];
}

/**
* {@inheritDoc}
*/
public function isMultiInstance() {
return FALSE;
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,79 @@ public function getOptions() {
/**
* {@inheritDoc}
*/
public function renderCustomConfig() {
public function renderConfig() {
$options = [];
$form = $this->getForm();
include \BitfinexStreamerPlugin::PLUGIN_DIR . '/templates/configuration-form.tmpl.php';
}

/**
* {@inheritDoc}
*/
public function renderCustomConfig() {
$this->renderConfig();
}

/**
* {@inheritDoc}
*/
public function saveConfig() {
try {
$form = $this->getForm();

if ($form instanceof \Form && $form->isValid() === TRUE) {
$errors = [];
$values = $form->getClean();

$has_requirements = \is_array($values) === TRUE
&& $this->pre_save($values, $errors) === TRUE
&& \count($errors += $form->errors()) === 0;

if ($has_requirements) {
$data = [];

foreach ($values as $name => $value) {
$field = $form->getField($name);

if ($field instanceof \FormField) {
try {
$data[$name] = $field->to_database($value);
}

catch (\FieldUnchanged $ex) {
unset($data[$name]);
}
}
}

return $this->updateAll($data);
}
}
}

catch (\Throwable $ex) {
}

return FALSE;
}

/**
* {@inheritDoc}
*/
public function saveCustomConfig() {
$errors = [];
return $this->commitForm($errors);
if (($success = $this->saveConfig()) === TRUE) {
if (empty($GLOBALS['msg']) === TRUE) {
$GLOBALS['msg'] = \__('Instance Updated Successfully');
}
}

else {
if (empty($GLOBALS['errors']['err']) === TRUE) {
$GLOBALS['errors']['err'] = \__('Unable to update Plugin Instance.');
}
}

return $success;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,27 @@ protected static function getConfigAsTertiumNonDaturField(string $name) : Tertiu
* @phpstan-return T
*/
protected static function getConfigAsFormField(\FormField $field, string $name) : \FormField {
$plugin = \PluginManager::getInstance(
\sprintf('plugins/%s', \basename(\BitfinexStreamerPlugin::PLUGIN_DIR))
);
try {
$plugin = \PluginManager::getInstance(
\sprintf('plugins/%s', \basename(\BitfinexStreamerPlugin::PLUGIN_DIR))
);

if ($plugin instanceof \Plugin) {
if (\method_exists($plugin, 'getActiveInstances') === TRUE) {
$plugin = $plugin->getActiveInstances()->one();
}

if ($plugin instanceof \Plugin) {
$config = $plugin->getConfig();
$config = $plugin->getConfig();

if ($config instanceof \PluginConfig) {
$field->setValue($config->get($name));
if ($config instanceof \PluginConfig) {
$field->setValue($config->get($name));
}
}
}

catch (\Throwable $ex) {
}

return $field;
}

Expand Down
1 change: 1 addition & 0 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
return [
'id' => /* notrans */ 'bfx:ost:streamer',
'version' => '1.1.0',
'ost_version' => '1.10',
'name' => /* trans */ 'Bitfinex osTicket Streamer',
'author' => 'Davide Scola, Nicoletta Maia',
'description' => /* trans */ 'Adds the ability to stream data.',
Expand Down

0 comments on commit 00f1ce6

Please sign in to comment.