Skip to content

Commit

Permalink
front end fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
apavlune committed Aug 12, 2014
1 parent 268aded commit 19a9f1b
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 450 deletions.
214 changes: 76 additions & 138 deletions equipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,35 @@



define('EQUIPMENT_PLUGIN_VERSION',
'0.2');

define('EQUIPMENT_TABLE',
TABLE_PREFIX . 'equipment');
define('EQUIPMENT_CATEGORY_TABLE',
TABLE_PREFIX . 'equipment_category');
define('EQUIPMENT_STATUS_TABLE',
TABLE_PREFIX . 'equipment_status');
define('EQUIPMENT_TICKET_TABLE',
TABLE_PREFIX . 'equipment_ticket');
define('EQUIPMENT_PLUGIN_VERSION', '0.2');

define('EQUIPMENT_TABLE', TABLE_PREFIX . 'equipment');
define('EQUIPMENT_CATEGORY_TABLE', TABLE_PREFIX . 'equipment_category');
define('EQUIPMENT_STATUS_TABLE', TABLE_PREFIX . 'equipment_status');
define('EQUIPMENT_TICKET_TABLE', TABLE_PREFIX . 'equipment_ticket');
define('EQUIPMENT_TICKET_RECURRING__TABLE',
TABLE_PREFIX . 'equipment_ticket_recurring');
define('EQUIPMENT_TICKET_VIEW',
TABLE_PREFIX . 'EquipmentTicketView');

define('OST_WEB_ROOT',
osTicket::get_root_path(__DIR__));

define('EQUIPMENT_WEB_ROOT',
OST_WEB_ROOT . 'scp/dispatcher.php/equipment/');

define('OST_ROOT',
INCLUDE_DIR . '../');

define('PLUGINS_ROOT',
INCLUDE_DIR . 'plugins/');

define('EQUIPMENT_PLUGIN_ROOT',
__DIR__ . '/');
define('EQUIPMENT_INCLUDE_DIR',
EQUIPMENT_PLUGIN_ROOT . 'include/');
define('EQUIPMENT_MODEL_DIR',
EQUIPMENT_INCLUDE_DIR . 'model/');
define('EQUIPMENT_CONTROLLER_DIR',
EQUIPMENT_INCLUDE_DIR . 'controller/');

define('EQUIPMENT_APP_DIR',
EQUIPMENT_PLUGIN_ROOT . 'app/');
define('EQUIPMENT_ASSETS_DIR',
EQUIPMENT_PLUGIN_ROOT . 'assets/');
define('EQUIPMENT_VENDOR_DIR',
EQUIPMENT_PLUGIN_ROOT . 'vendor/');
define('EQUIPMENT_VIEWS_DIR',
EQUIPMENT_PLUGIN_ROOT . 'views/');
define('EQUIPMENT_STAFFINC_DIR',
EQUIPMENT_INCLUDE_DIR . 'staff/');
define('EQUIPMENT_CLIENTINC_DIR',
EQUIPMENT_INCLUDE_DIR . 'client/');
define('EQUIPMENT_TICKET_VIEW', TABLE_PREFIX . 'EquipmentTicketView');

define('OST_WEB_ROOT', osTicket::get_root_path(__DIR__));

define('EQUIPMENT_WEB_ROOT', OST_WEB_ROOT . 'scp/dispatcher.php/equipment/');

define('OST_ROOT', INCLUDE_DIR . '../');

define('PLUGINS_ROOT', INCLUDE_DIR . 'plugins/');

define('EQUIPMENT_PLUGIN_ROOT', __DIR__ . '/');
define('EQUIPMENT_INCLUDE_DIR', EQUIPMENT_PLUGIN_ROOT . 'include/');
define('EQUIPMENT_MODEL_DIR', EQUIPMENT_INCLUDE_DIR . 'model/');
define('EQUIPMENT_CONTROLLER_DIR', EQUIPMENT_INCLUDE_DIR . 'controller/');

define('EQUIPMENT_APP_DIR', EQUIPMENT_PLUGIN_ROOT . 'app/');
define('EQUIPMENT_ASSETS_DIR', EQUIPMENT_PLUGIN_ROOT . 'assets/');
define('EQUIPMENT_VENDOR_DIR', EQUIPMENT_PLUGIN_ROOT . 'vendor/');
define('EQUIPMENT_VIEWS_DIR', EQUIPMENT_PLUGIN_ROOT . 'views/');
define('EQUIPMENT_STAFFINC_DIR', EQUIPMENT_INCLUDE_DIR . 'staff/');
define('EQUIPMENT_CLIENTINC_DIR', EQUIPMENT_INCLUDE_DIR . 'client/');

require_once (EQUIPMENT_VENDOR_DIR . 'autoload.php');
spl_autoload_register(array('EquipmentPlugin', 'autoload'));
Expand All @@ -80,24 +60,15 @@ class EquipmentPlugin extends Plugin {
var $config_class = 'EquipmentConfig';

public static function autoload($className) {
$className = ltrim($className,
'\\');
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className,
'\\')) {
$namespace = substr($className,
0,
$lastNsPos);
$className = substr($className,
$lastNsPos + 1);
$fileName = str_replace('\\',
DIRECTORY_SEPARATOR,
$namespace) . DIRECTORY_SEPARATOR;
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_',
DIRECTORY_SEPARATOR,
$className) . '.php';
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
$fileName = 'include/' . $fileName;

if (file_exists(EQUIPMENT_PLUGIN_ROOT . $fileName)) {
Expand All @@ -118,16 +89,18 @@ function bootstrap() {

if ($config->get('equipment_backend_enable')) {
$this->createStaffMenu();

if ($config->get('equipment_frontend_enable')) {
$this->createFrontMenu();
}
}
Signal::connect('apps.scp',
array('EquipmentPlugin', 'callbackDispatch'));

if ($config->get('equipment_frontend_enable')) {
$this->createFrontMenu();
}

Signal::connect('apps.scp', array('EquipmentPlugin', 'callbackDispatch'));

Signal::connect('cron',
array('\controller\TicketRecurring', 'runRecurrance'));

//call it anyway, not sure if cron works like it is suppose to.
\controller\TicketRecurring::runRecurrance();
}

public static function getCustomForm() {
Expand All @@ -146,118 +119,84 @@ static public function callbackDispatch($object, $data) {
$categories_url = url('^/equipment.*categories/',
patterns(
'controller\EquipmentCategory',
url_get('^list$',
'listAction'),
url_get('^listJson$',
'listJsonAction'),
url_get('^view/(?P<id>\d+)$',
'viewAction'),
url_get('^list$', 'listAction'),
url_get('^listJson$', 'listJsonAction'),
url_get('^view/(?P<id>\d+)$', 'viewAction'),
url_get('^openTicketsJson/(?P<item_id>\d+)$',
'openTicketsJsonAction'),
url_get('^closedTicketsJson/(?P<item_id>\d+)$',
'closedTicketsJsonAction'),
url_get('^getItemsJson/(?P<category_id>\d+)$',
'categoryItemsJsonAction'),
url_post('^save',
'saveAction'),
url_post('^delete',
'deleteAction')
url_post('^save', 'saveAction'),
url_post('^delete', 'deleteAction')
));

$item_url = url('^/equipment.*item/',
patterns(
'controller\EquipmentItem',
url_get('^list$',
'listAction'),
url_get('^listJson$',
'listJsonAction'),
url_get('^view/(?P<id>\d+)$',
'viewAction'),
url_get('^new/(?P<category_id>\d+)$',
'newAction'),
url_post('^publish',
'publishAction'),
url_post('^activate',
'activateAction'),
url_post('^save',
'saveAction'),
url_get('^list$', 'listAction'),
url_get('^listJson$', 'listJsonAction'),
url_get('^view/(?P<id>\d+)$', 'viewAction'),
url_get('^new/(?P<category_id>\d+)$', 'newAction'),
url_post('^publish', 'publishAction'),
url_post('^activate', 'activateAction'),
url_post('^save', 'saveAction'),
url_get('^openTicketsJson/(?P<item_id>\d+)$',
'openTicketsJsonAction'),
url_get('^closedTicketsJson/(?P<item_id>\d+)$',
'closedTicketsJsonAction'),
url_get('^getDynamicForm/(?P<id>\d+)$',
'getDynamicForm'),
url_post('^delete',
'deleteAction')
url_get('^getDynamicForm/(?P<id>\d+)$', 'getDynamicForm'),
url_post('^delete', 'deleteAction')
));

$status_url = url('^/equipment.*status/',
patterns(
'controller\EquipmentStatus',
url_get('^list$',
'listAction'),
url_get('^view/(?P<id>\d+)$',
'viewAction'),
url_get('^new/(?P<category_id>\d+)$',
'newAction'),
url_get('^listJson$',
'listJsonAction'),
url_get('^list$', 'listAction'),
url_get('^view/(?P<id>\d+)$', 'viewAction'),
url_get('^new/(?P<category_id>\d+)$', 'newAction'),
url_get('^listJson$', 'listJsonAction'),
url_get('^getItemsJson/(?P<status_id>\d+)$',
'statusItemsJsonAction'),
url_post('^save',
'saveAction'),
url_post('^delete',
'deleteAction')
url_post('^save', 'saveAction'),
url_post('^delete', 'deleteAction')
));

$recurring_url = url('^/equipment.*recurring/',
patterns(
'controller\TicketRecurring',
url_get('^list$',
'listAction'),
url_get('^view/(?P<id>\d+)$',
'viewAction'),
url_get('^list$', 'listAction'),
url_get('^view/(?P<id>\d+)$', 'viewAction'),
url_get('^viewByTicket/(?P<id>\d+)$',
'viewByTicketAction'),
url_get('^addByTicket/(?P<id>\d+)$',
'addByTicketAction'),
url_get('^new/(?P<category_id>\d+)$',
'newAction'),
url_get('^listJson$',
'listJsonAction'),
url_get('^addByTicket/(?P<id>\d+)$', 'addByTicketAction'),
url_get('^new/(?P<category_id>\d+)$', 'newAction'),
url_get('^listJson$', 'listJsonAction'),
url_get('^getItemsJson/(?P<status_id>\d+)$',
'statusItemsJsonAction'),
url_get('^listTicketsJson$',
'listTicketsJson'),
url_get('^listEquipmentJson$',
'listEquipmentJson'),
url_post('^save',
'saveAction'),
url_post('^delete',
'deleteAction'),
url_get('^test',
'test')
url_get('^listTicketsJson$', 'listTicketsJson'),
url_get('^listEquipmentJson$', 'listEquipmentJson'),
url_post('^save', 'saveAction'),
url_post('^delete', 'deleteAction'),
url_get('^test', 'test')
));

$media_url = url('^/equipment.*assets/',
patterns(
'controller\MediaController',
url_get('^(?P<url>.*)$',
'defaultAction')))
url_get('^(?P<url>.*)$', 'defaultAction')))
;

$dashboard_url = url('^/equipment.*dashboard/',
patterns(
'controller\Dashboard',
url_get('.*',
'viewAction')))
'controller\Dashboard', url_get('.*', 'viewAction')))
;

$redirect_url = url('^/equipment.*ostroot/',
patterns(
'controller\MediaController',
url_get('^(?P<url>.*)$',
'redirectAction')))
url_get('^(?P<url>.*)$', 'redirectAction')))
;

$object->append($media_url);
Expand Down Expand Up @@ -285,8 +224,7 @@ function createStaffMenu() {
*/
function createFrontMenu() {
Application::registerClientApp('Equipment Status',
'equipment_front/index.php',
array(iconclass => 'equipment'));
'equipment_front/index.php', array(iconclass => 'equipment'));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions equipment_front/equipment.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
**********************************************************************/
define('ROOT_PATH','../');
require_once('../client.inc.php');
require_once(EQUIPMENT_INCLUDE_DIR.'class.equipment.php');
//require_once(EQUIPMENT_INCLUDE_DIR.'class.equipment.php');
/* Bail out if knowledgebase is disabled or if we have no public-published Equipment. */
if(!Equipment::countPublishedEquipment()) {
if(!\model\Equipment::countPublishedEquipment()) {
header('Location: ../');
exit;
}
Expand Down
11 changes: 5 additions & 6 deletions equipment_front/equipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require('equipment.inc.php');
require_once(EQUIPMENT_INCLUDE_DIR.'class.equipment.php');

$equipment=$category=$status=null;
if($_REQUEST['id'] && !($equipment=Equipment::lookup($_REQUEST['id'])))
if($_REQUEST['id'] && !($equipment=new \model\Equipment($_REQUEST['id'])))
$errors['err']='Unknown or invalid equpment';

if(!$equipment && $_REQUEST['cid'] && !($category=Equipment_Category::lookup($_REQUEST['cid'])))
if(!$equipment && $_REQUEST['cid'] && !($category=new \model\EquipmentCategory($_REQUEST['cid'])))
$errors['err']='Unknown or invalid equipment category';

if(!$equipment && $_REQUEST['status'] && !($status=Equipment_Status::lookup($_REQUEST['status'])))
if(!$equipment && $_REQUEST['status'] && !($status=new \model\EquipmentStatus($_REQUEST['status'])))
$errors['err']='Unknown or invalid equipment status';

$inc='equipment_list.inc.php'; //FAQs landing page.
if($equipment && $equipment->isPublished()) {
if($equipment && $equipment->getIspublished()) {
$inc='equipment.inc.php';
} elseif($category && $category->isPublic() && $_REQUEST['a']!='search') {
} elseif($category && $category->getIspublic() && $_REQUEST['a']!='search') {
$inc='equipment-category.inc.php';
} elseif ($status && $_REQUEST['a']!='search') {
$inc='equipment-status.inc.php';
Expand Down
Binary file added equipment_front/images/green_dot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added equipment_front/images/header-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added equipment_front/images/new_category.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added equipment_front/images/ost-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added equipment_front/images/red_dot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added equipment_front/images/yellow_dot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion equipment_front/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require('equipment.inc.php');
require_once(EQUIPMENT_INCLUDE_DIR.'class.equipment_category.php');
$inc='equipment_list.inc.php';
require(CLIENTINC_DIR.'header.inc.php');
require(EQUIPMENT_CLIENTINC_DIR.$inc);
Expand Down
10 changes: 5 additions & 5 deletions include/client/equipment-category.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
if(!defined('OSTCLIENTINC') || !$category || !$category->isPublic()) die('Access Denied');
if(!defined('OSTCLIENTINC') || !$category || !$category->getIspublic()) die('Access Denied');
?>
<h1><strong><?php echo $category->getName() ?></strong></h1>
<p>
<?php echo Format::safe_html($category->getDescription()); ?>
<?php echo \Format::safe_html($category->getDescription()); ?>
</p>
<hr>
<?php
$sql='SELECT equipment.equipment_id as equipment_id, equipment.name as Equipment,
$sql='SELECT equipment.equipment_id as equipment_id, equipment.asset_id as Equipment,
status.name as Status, status.image as Image'
.' FROM '.EQUIPMENT_TABLE.' equipment '
.' LEFT JOIN '.EQUIPMENT_STATUS_TABLE.' status ON(status.status_id=equipment.status_id) '
Expand All @@ -35,9 +35,9 @@
while($row=db_fetch_array($res)) {
echo sprintf('
<li>%s <a href="equipment.php?id=%d" >%s &nbsp;%s</a></li>',
'<img src="../images/'.$row['Image'].'" width="20" height="20"/>',
'<img src="images/'.$row['Image'].'" width="20" height="20"/>',
$row['equipment_id'],
Format::htmlchars($row['Equipment']), $row['Status']);
\Format::htmlchars($row['Equipment']), $row['Status']);
}
echo ' </ol>
</div>
Expand Down
Loading

0 comments on commit 19a9f1b

Please sign in to comment.