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 .= - '
'; - if (!empty($invoice['text_1'])){ - $html .= '

' . $invoice['text_1'] . '

'; - } - $html .= - ' + $html .= '
+
@@ -1382,12 +1399,8 @@ class Service implements InjectionAwareInterface $html .= ''; $html .= ''; $html .= ''; - $html .= '
# ProductTotal:' . $invoice['total'] . $currencyCode . '
'; - if (!empty($invoice['text_2'])){ - $html .= '

' . $invoice['text_2'] . '

'; - } - $html .= '
'; + $html .= ''; $html .= ' '; diff --git a/src/bb-modules/Order/Service.php b/src/bb-modules/Order/Service.php index e74012ff8..0477fd421 100644 --- a/src/bb-modules/Order/Service.php +++ b/src/bb-modules/Order/Service.php @@ -38,6 +38,28 @@ class Service implements InjectionAwareInterface return $this->di; } + public function getSettingsRoutes() + { + return array( + 'pending_setup' => array( + 'path' => '/order?status=pending_setup', + 'label' => 'Orders pending setup', + ), + 'active' => array( + 'path' => '/order?status=active', + 'label' => 'Active orders', + ), + 'suspended' => array( + 'path' => '/order?status=suspended', + 'label' => 'Suspended orders', + ), + 'all' => array( + 'path' => '/order', + 'label' => 'All orders', + ), + ); + } + public function counter() { $sql = ' diff --git a/src/bb-modules/Support/Service.php b/src/bb-modules/Support/Service.php index 5ea6e77f7..c2785a5a6 100644 --- a/src/bb-modules/Support/Service.php +++ b/src/bb-modules/Support/Service.php @@ -30,6 +30,28 @@ class Service implements \Box\InjectionAwareInterface return $this->di; } + public function getSettingsRoutes() + { + return array( + 'open' => array( + 'path' => '/support?status=open', + 'label' => 'Tickets waiting for staff reply', + ), + 'on_hold' => array( + 'path' => '/support?status=on_hold', + 'label' => 'Tickets waiting for client reply', + ), + 'closed' => array( + 'path' => '/support?status=closed', + 'label' => 'Resolved tickets', + ), + 'all' => array( + 'path' => '/support', + 'label' => 'All tickets', + ), + ); + } + public static function onAfterClientOpenTicket(\Box_Event $event) { $di = $event->getDi(); diff --git a/src/bb-modules/System/Service.php b/src/bb-modules/System/Service.php index 36fb24ca0..56681040c 100644 --- a/src/bb-modules/System/Service.php +++ b/src/bb-modules/System/Service.php @@ -28,6 +28,24 @@ class Service $this->di = $di; } + public function getSettingsRoutes() + { + return array( + 'report_bug' => array( + 'path' => 'https://github.com/FOSSBilling/FOSSBilling/issues/', + 'label' => 'Report a bug', + ), + 'activity' => array( + 'path' => 'activity', + 'label' => 'Event history', + ), + 'languages' => array( + 'path' => 'extension/languages', + 'label' => 'Languages', + ), + ); + } + /** * @param string $param * @param bool $default diff --git a/src/bb-themes/admin_default/html/mod_system_index.html.twig b/src/bb-themes/admin_default/html/mod_system_index.html.twig old mode 100644 new mode 100755 index 128230151..871825724 --- a/src/bb-themes/admin_default/html/mod_system_index.html.twig +++ b/src/bb-themes/admin_default/html/mod_system_index.html.twig @@ -9,32 +9,29 @@ {% block content %}
-
-
- {% include 'partial_search.html.twig' %} - - - {% for ext in admin.extension_get_list({ 'active': 1, 'has_settings': 1 }|merge(request)) %} - - - - - - {% endfor %} - -
- - {{ ext.name }} - - - {{ ext.name }} - - - - - - -
+
+

Settings

+
+
+
+ {% for ext in admin.extension_get_list({ 'active': 1, 'has_settings': 1 }|merge(request)) %} +
+ +
+
    + {% for route in ext.settings_routes %} +
  • + {{route.label}} +
  • + {% endfor %} +
+
+
+ {% endfor %}