Skip to content
Snippets Groups Projects
Commit fd97da77 authored by Jared Hancock's avatar Jared Hancock
Browse files

Add framework for pluggable applications

parent b0c1ab3a
No related branches found
No related tags found
No related merge requests found
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.*/apps)
RewriteRule ^(.*)$ %1/dispatcher.php/$1 [L]
</IfModule>
<?php
/*********************************************************************
dispatcher.php
Dispatcher for client applications
Jared Hancock <jared@osticket.com>
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2013 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
function clientLoginPage($msg='Unauthorized') {
Http::response(403,'Must login: '.Format::htmlchars($msg));
exit;
}
require('client.inc.php');
if(!defined('INCLUDE_DIR')) Http::response(500, 'Server configuration error');
require_once INCLUDE_DIR.'/class.dispatcher.php';
$dispatcher = patterns('',
);
Signal::send('ajax.client', $dispatcher);
print $dispatcher->resolve($ost->get_path_info());
<?php
/*********************************************************************
class.app.php
Application registration system
Apps, usually to be distributed as plugins, can register themselves
using this utility class, and navigation links will be added to the
staff and client interfaces.
Jared Hancock <jared@osticket.com>
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2014 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
class Application {
private static $client_apps;
private static $staff_apps;
private static $admin_apps;
function registerStaffApp($desc, $href, $info=array()) {
self::$staff_apps[] = array_merge($info,
array('desc'=>$desc, 'href'=>$href));
}
function getStaffApps() {
return self::$staff_apps;
}
function registerClientApp($desc, $href, $info=array()) {
self::$client_apps[] = array_merge($info,
array('desc'=>$desc, 'href'=>$href));
}
function getClientApps() {
return self::$client_apps;
}
function registerAdminApp($desc, $href, $info=array()) {
self::$admin_apps[] = array_merge($info,
array('desc'=>$desc, 'href'=>$href));
}
function getAdminApps() {
return self::$admin_apps;
}
}
......@@ -13,6 +13,7 @@
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require_once(INCLUDE_DIR.'class.app.php');
class StaffNav {
var $tabs=array();
......@@ -43,6 +44,10 @@ class StaffNav {
return (!$this->isAdminPanel());
}
function getRegisteredApps() {
return Application::getStaffApps();
}
function setTabActive($tab, $menu=''){
if($this->tabs[$tab]){
......@@ -100,8 +105,8 @@ class StaffNav {
$this->tabs['users'] = array('desc' => 'Users', 'href' => 'users.php', 'title' => 'User Directory');
$this->tabs['tickets'] = array('desc'=>'Tickets','href'=>'tickets.php','title'=>'Ticket Queue');
$this->tabs['kbase'] = array('desc'=>'Knowledgebase','href'=>'kb.php','title'=>'Knowledgebase');
// TODO: If at least one app is installed
$this->tabs['apps']=array('desc'=>'Applications','href'=>'apps.php','title'=>'Applications');
if (count($this->getRegisteredApps()))
$this->tabs['apps']=array('desc'=>'Applications','href'=>'apps.php','title'=>'Applications');
}
return $this->tabs;
......@@ -151,7 +156,8 @@ class StaffNav {
}
break;
case 'apps':
$subnav[]=array('desc'=>'Equipment', 'href'=>'apps?a=equipment','iconclass'=>'icon-bug');
foreach ($this->getRegisteredApps() as $app)
$subnav[] = $app;
break;
}
if($subnav)
......@@ -178,6 +184,10 @@ class AdminNav extends StaffNav{
parent::StaffNav($staff, 'admin');
}
function getRegisteredApps() {
return Application::getAdminApps();
}
function getTabs(){
......@@ -189,6 +199,8 @@ class AdminNav extends StaffNav{
$tabs['manage']=array('desc'=>'Manage','href'=>'helptopics.php','title'=>'Manage Options');
$tabs['emails']=array('desc'=>'Emails','href'=>'emails.php','title'=>'Email Settings');
$tabs['staff']=array('desc'=>'Staff','href'=>'staff.php','title'=>'Manage Staff');
if (count($this->getRegisteredApps()))
$tabs['apps']=array('desc'=>'Applications','href'=>'apps.php','title'=>'Applications');
$this->tabs=$tabs;
}
......@@ -239,6 +251,10 @@ class AdminNav extends StaffNav{
$subnav[]=array('desc'=>'Groups','href'=>'groups.php','iconclass'=>'groups');
$subnav[]=array('desc'=>'Departments','href'=>'departments.php','iconclass'=>'departments');
break;
case 'apps':
foreach ($this->getRegisteredApps() as $app)
$subnav[] = $app;
break;
}
if($subnav)
$submenus[$this->getPanel().'.'.strtolower($k)]=$subnav;
......@@ -263,6 +279,10 @@ class UserNav {
$this->setActiveNav($active);
}
function getRegisteredApps() {
return Application::getClientApps();
}
function setActiveNav($nav){
if($nav && $this->navs[$nav]){
......
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.*/apps)
RewriteRule ^(.*)$ %1/dispatcher.php/$1 [L]
</IfModule>
<?php
/*********************************************************************
dispatcher.php
Dispatcher for staff applications
Jared Hancock <jared@osticket.com>
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2013 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
# Override staffLoginPage() defined in staff.inc.php to return an
# HTTP/Forbidden status rather than the actual login page.
# XXX: This should be moved to the AjaxController class
function staffLoginPage($msg='Unauthorized') {
Http::response(403,'Must login: '.Format::htmlchars($msg));
exit;
}
require('staff.inc.php');
//Clean house...don't let the world see your crap.
ini_set('display_errors','0'); //Disable error display
ini_set('display_startup_errors','0');
//TODO: disable direct access via the browser? i,e All request must have REFER?
if(!defined('INCLUDE_DIR')) Http::response(500, 'Server configuration error');
require_once INCLUDE_DIR.'/class.dispatcher.php';
$dispatcher = patterns('',
);
Signal::send('apps.scp', $dispatcher);
# Call the respective function
print $dispatcher->resolve($ost->get_path_info());
......@@ -34,6 +34,16 @@
</conditions>
<action type="Rewrite" url="{R:1}pages/index.php/{R:2}"/>
</rule>
<rule name="Staff applications" stopProcessing="true">
<match url="^(.*/)?scp/apps/(.*)$" ignoreCase="true"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile"
ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory"
ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}scp/apps/dispatcher.php/{R:2}"/>
</rule>
</rules>
</rewrite>
<defaultDocument>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment