diff --git a/src/bb-library/Box/Mod.php b/src/bb-library/Box/Mod.php index 19280f8e3..9147fdd81 100644 --- a/src/bb-library/Box/Mod.php +++ b/src/bb-library/Box/Mod.php @@ -157,6 +157,38 @@ class Box_Mod return file_exists($this->_getModPath() . 'html_admin/mod_'.$this->mod.'_settings.html.twig'); } + public function hasSettingsRoutes() + { + if($this->hasService()) { + $s = $this->getService(); + if(method_exists($s, 'getSettingsRoutes')) { + return (count($s->getSettingsRoutes()) > 0); + } + } + + return false; + } + + public function getSettingsRoutes() + { + $result = array(); + + if ($this->hasSettingsRoutes()) { + foreach ($this->getService()->getSettingsRoutes() as $route) { + // Check if it is a valid external link + $filtered = filter_var(idn_to_ascii($route["path"]), FILTER_VALIDATE_URL); + + // If it's an external link, return it directly. Otherwise, return the internal link with the /admin prefix. + $route['path'] = $filtered ? $filtered : $this->di['url']->adminLink($route["path"], []); + $result[] = $route; + } + + return $result; + } else { + return array(); + } + } + public function hasAdminController() { return file_exists($this->_getModPath() . 'Controller/Admin.php'); diff --git a/src/bb-modules/Client/Service.php b/src/bb-modules/Client/Service.php index 2a0943d85..1dce749e4 100644 --- a/src/bb-modules/Client/Service.php +++ b/src/bb-modules/Client/Service.php @@ -38,6 +38,28 @@ class Service implements InjectionAwareInterface return $this->di; } + public function getSettingsRoutes() + { + return array( + 'active' => array( + 'path' => '/client?status=active', + 'label' => 'Active clients', + ), + 'suspended' => array( + 'path' => '/client?status=suspended', + 'label' => 'Suspended clients', + ), + 'canceled' => array( + 'path' => '/client?status=canceled', + 'label' => 'Canceled clients', + ), + 'all' => array( + 'path' => '/client', + 'label' => 'All clients', + ), + ); + } + public function approveClientEmailByHash($hash) { $db = $this->di['db']; diff --git a/src/bb-modules/Cron/Service.php b/src/bb-modules/Cron/Service.php index 7af9c4f17..964b5ceb3 100644 --- a/src/bb-modules/Cron/Service.php +++ b/src/bb-modules/Cron/Service.php @@ -33,6 +33,16 @@ class Service return $this->di; } + public function getSettingsRoutes() + { + return array( + 'exec' => array( + 'path' => BB_URL . 'bb-cron.php', + 'label' => 'Execute now', + ), + ); + } + public function getCronInfo() { $service = $this->di['mod_service']('system'); diff --git a/src/bb-modules/Email/Service.php b/src/bb-modules/Email/Service.php index 3e6d61529..2905060ff 100644 --- a/src/bb-modules/Email/Service.php +++ b/src/bb-modules/Email/Service.php @@ -30,6 +30,16 @@ class Service implements \Box\InjectionAwareInterface return $this->di; } + public function getSettingsRoutes() + { + return array( + 'history' => array( + 'path' => 'email/history', + 'label' => 'Email history', + ), + ); + } + public function getSearchQuery($data) { $query = 'SELECT * FROM activity_client_email'; diff --git a/src/bb-modules/Example/Service.php b/src/bb-modules/Example/Service.php index 1f72295cf..48d089640 100644 --- a/src/bb-modules/Example/Service.php +++ b/src/bb-modules/Example/Service.php @@ -35,6 +35,25 @@ class Service $this->di = $di; } + /** + * This method returns an array of custom links to be displayed in the settings page of the admin area. + * + * @return array + */ + public function getSettingsRoutes() + { + return array( + 'source' => array( + 'path' => 'https://github.com/FOSSBilling/example', // An example external link + 'label' => 'View source code', + ), + 'example' => array( + 'path' => 'extension/settings/example', // An example internal link. Internal links are relative to the custom admin panel path. + 'label' => 'This is an example!', + ), + ); + } + /** * Method to install module. In most cases you will provide your own * database table or tables to store extension related data. diff --git a/src/bb-modules/Extension/Service.php b/src/bb-modules/Extension/Service.php index c391691e6..6cb612868 100644 --- a/src/bb-modules/Extension/Service.php +++ b/src/bb-modules/Extension/Service.php @@ -133,6 +133,8 @@ class Service implements InjectionAwareInterface $manifest = $m->getManifest(); $manifest['status'] = 'core'; $manifest['has_settings'] = $m->hasSettingsPage(); + $manifest['has_settings_routes'] = $m->hasSettingsRoutes(); + $manifest['settings_routes'] = $m->hasSettingsRoutes() ? $m->getSettingsRoutes() : array(); $result[] = $manifest; } } @@ -147,10 +149,10 @@ class Service implements InjectionAwareInterface $manifest['version'] = $im['version']; $manifest['status'] = $im['status']; - if ('mod' == $im['type'] && 'installed' == $im['status'] && $m->hasSettingsPage()) { - $manifest['has_settings'] = true; - } else { - $manifest['has_settings'] = false; + if ('mod' == $im['type'] && 'installed' == $im['status']) { + $manifest['has_settings'] = $m->hasSettingsPage(); + $manifest['has_settings_routes'] = $m->hasSettingsRoutes(); + $manifest['settings_routes'] = $m->hasSettingsRoutes() ? $m->getSettingsRoutes() : array(); } $result[] = $manifest; @@ -173,6 +175,8 @@ class Service implements InjectionAwareInterface $manifest = $m->getManifest(); $manifest['status'] = null; $manifest['has_settings'] = false; + $manifest['has_settings_routes'] = false; + $manifest['settings_routes'] = array(); $result[] = $manifest; } diff --git a/src/bb-modules/Invoice/Service.php b/src/bb-modules/Invoice/Service.php index f677af9f6..c35ff43fb 100644 --- a/src/bb-modules/Invoice/Service.php +++ b/src/bb-modules/Invoice/Service.php @@ -42,6 +42,28 @@ class Service implements InjectionAwareInterface return $this->di; } + public function getSettingsRoutes() + { + return array( + 'unpaid' => array( + 'path' => '/invoice?status=unpaid', + 'label' => 'Unpaid invoices', + ), + 'paid' => array( + 'path' => '/invoice?status=paid', + 'label' => 'Paid invoices', + ), + 'refunded' => array( + 'path' => '/invoice?status=refunded', + 'label' => 'Refunded invoices', + ), + 'all' => array( + 'path' => '/invoice', + 'label' => 'All invoices', + ), + ); + } + public function getSearchQuery($data) { $sql = 'SELECT p.* @@ -1274,7 +1296,7 @@ class Service implements InjectionAwareInterface div.Breakdown{ position: absolute; width: 100%; - top: 405px; + top: 400px; } table { border-collapse: collapse; @@ -1337,13 +1359,8 @@ class Service implements InjectionAwareInterface $html .= '
Phone: ' . $invoice['buyer']['phone'] . '
'; $html .= ''; - $html .= - '' . $invoice['text_1'] . '
'; - } - $html .= - '| # | Product | @@ -1382,12 +1399,8 @@ class Service implements InjectionAwareInterface $html .= 'Total: | '; $html .= '' . $invoice['total'] . $currencyCode . ' | '; $html .= '||
|---|---|---|---|---|---|
' . $invoice['text_2'] . '
'; - } - $html .= '