コード例 #1
0
ファイル: setup.php プロジェクト: jstanden/portsensor
 function saveLicensesAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     $settings = DevblocksPlatform::getPluginSettingsService();
     $worker = PortSensorApplication::getActiveWorker();
     if (!$worker || !$worker->is_superuser) {
         echo $translate->_('common.access_denied');
         return;
     }
     @($key = DevblocksPlatform::importGPC($_POST['key'], 'string', ''));
     @($email = DevblocksPlatform::importGPC($_POST['email'], 'string', ''));
     @($do_delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0));
     if (!empty($do_delete)) {
         $settings->set('portsensor.core', PortSensorSettings::LICENSE, '');
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings')));
         return;
     }
     if (empty($key) || empty($email)) {
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings', 'empty')));
         return;
     }
     if (null == ($valid = PortSensorLicense::validate($key, $email)) || 5 != count($valid)) {
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings', 'invalid')));
         return;
     }
     /*
      * [IMPORTANT -- Yes, this is simply a line in the sand.]
      * You're welcome to modify the code to meet your needs, but please respect 
      * our licensing.  Buy a legitimate copy to help support the project!
      * http://www.portsensor.com/
      */
     $license = $valid;
     $settings->set('portsensor.core', PortSensorSettings::LICENSE, serialize($license));
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings')));
 }
コード例 #2
0
ファイル: home.php プロジェクト: jstanden/portsensor
 function showTabSensorsAction()
 {
     $visit = PortSensorApplication::getVisit();
     $translate = DevblocksPlatform::getTranslationService();
     $active_worker = PortSensorApplication::getActiveWorker();
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     // Select tab
     //		$visit->set(PortSensorVisit::KEY_HOME_SELECTED_TAB, 'sensors');
     // My Notifications
     $sensorsView = Ps_AbstractViewLoader::getView(self::VIEW_ACTIVE_SENSORS);
     //		$title = vsprintf($translate->_('home.my_notifications.view.title'), $active_worker->getName());
     if (null == $sensorsView) {
         $sensorsView = new Ps_SensorView();
         $sensorsView->id = self::VIEW_ACTIVE_SENSORS;
         //			$sensorsView->name = $title;
         $sensorsView->renderLimit = 25;
         $sensorsView->renderPage = 0;
         $sensorsView->renderSortBy = SearchFields_Sensor::NAME;
         $sensorsView->renderSortAsc = 1;
     }
     // Overload criteria
     $sensorsView->name = 'Active Sensors';
     $sensorsView->params = array(SearchFields_Sensor::IS_DISABLED => new DevblocksSearchCriteria(SearchFields_Sensor::IS_DISABLED, '=', 0));
     /*
      * [TODO] This doesn't need to save every display, but it was possible to 
      * lose the params in the saved version of the view in the DB w/o recovery.
      * This should be moved back into the if(null==...) check in a later build.
      */
     Ps_AbstractViewLoader::setView($sensorsView->id, $sensorsView);
     $tpl->assign('view', $sensorsView);
     $tpl->display('file:' . $this->_TPL_PATH . 'home/tabs/sensors/index.tpl');
 }
コード例 #3
0
ファイル: ajax.php プロジェクト: jstanden/portsensor
<?php

require getcwd() . '/framework.config.php';
require DEVBLOCKS_PATH . 'Devblocks.class.php';
require APP_PATH . '/api/Application.class.php';
header("Content-type: text/html; charset=" . LANG_CHARSET_CODE);
$request = DevblocksPlatform::readRequest();
DevblocksPlatform::init();
DevblocksPlatform::setExtensionDelegate('PS_DevblocksExtensionDelegate');
$session = DevblocksPlatform::getSessionService();
$settings = DevblocksPlatform::getPluginSettingsService();
$worker = PortSensorApplication::getActiveWorker();
// Localization
DevblocksPlatform::setLocale(isset($_SESSION['locale']) && !empty($_SESSION['locale']) ? $_SESSION['locale'] : 'en_US');
if (isset($_SESSION['timezone'])) {
    @date_default_timezone_set($_SESSION['timezone']);
}
$tpl = DevblocksPlatform::getTemplateService();
$tpl->assign('translate', DevblocksPlatform::getTranslationService());
$tpl->assign('session', $_SESSION);
$tpl->assign('visit', $session->getVisit());
$tpl->assign('active_worker', $worker);
$tpl->assign('settings', $settings);
$tpl->assign('core_tpl', APP_PATH . '/features/portsensor.core/templates/');
if (!empty($worker)) {
    //	$active_worker_memberships = $worker->getMemberships();
    //	$tpl->assign('active_worker_memberships', $active_worker_memberships);
    //	$keyboard_shortcuts = intval(DAO_WorkerPref::get($worker->id,'keyboard_shortcuts', 1));
    //	$tpl->assign('pref_keyboard_shortcuts', $keyboard_shortcuts);
}
PortSensorApplication::processRequest($request, true);
コード例 #4
0
ファイル: sensors.php プロジェクト: jstanden/portsensor
 function saveSensorPeekAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     $active_worker = PortSensorApplication::getActiveWorker();
     // [TODO] ACL
     // return;
     @($id = DevblocksPlatform::importGPC($_POST['id'], 'integer'));
     @($view_id = DevblocksPlatform::importGPC($_POST['view_id'], 'string'));
     @($name = DevblocksPlatform::importGPC($_POST['name'], 'string'));
     @($extension_id = DevblocksPlatform::importGPC($_POST['extension_id'], 'string'));
     @($disabled = DevblocksPlatform::importGPC($_POST['is_disabled'], 'integer', 0));
     @($delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0));
     // [TODO] The superuser set bit here needs to be protected by ACL
     if (empty($name)) {
         $name = "New Sensor";
     }
     if (!empty($id) && !empty($delete)) {
         DAO_Sensor::delete($id);
     } else {
         $fields = array(DAO_Sensor::NAME => $name, DAO_Sensor::EXTENSION_ID => $extension_id, DAO_Sensor::IS_DISABLED => $disabled);
         if (empty($id)) {
             $id = DAO_Sensor::create($fields);
         } else {
             DAO_Sensor::update($id, $fields);
         }
         // Save sensor extension config
         if (!empty($extension_id)) {
             if (null != ($ext = DevblocksPlatform::getExtension($extension_id, true))) {
                 if (null != ($sensor = DAO_Sensor::get($id)) && $ext instanceof Extension_Sensor) {
                     $ext->saveConfig($sensor);
                 }
             }
         }
         // Custom field saves
         @($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
         DAO_CustomFieldValue::handleFormPost(PsCustomFieldSource_Sensor::ID, $id, $field_ids);
     }
     if (!empty($view_id)) {
         $view = Ps_AbstractViewLoader::getView($view_id);
         $view->render();
     }
 }
コード例 #5
0
ファイル: internal.php プロジェクト: jstanden/portsensor
 function doStopTourAction()
 {
     //		$request = DevblocksPlatform::getHttpRequest();
     $worker = PortSensorApplication::getActiveWorker();
     DAO_WorkerPref::set($worker->id, 'assist_mode', 0);
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('home')));
     //		DevblocksPlatform::redirect(new DevblocksHttpResponse($request->path, $request->query));
 }
コード例 #6
0
ファイル: login.php プロジェクト: jstanden/portsensor
 function signoutAction()
 {
     $session = DevblocksPlatform::getSessionService();
     $visit = $session->getVisit();
     if (null != ($worker = PortSensorApplication::getActiveWorker())) {
         DAO_Worker::logActivity($worker->id, new Model_Activity(null));
     }
     $session->clear();
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login')));
 }
コード例 #7
0
ファイル: App.php プロジェクト: jstanden/portsensor
 function saveAddLanguagePanelAction()
 {
     $active_worker = PortSensorApplication::getActiveWorker();
     // Make sure we're an active worker
     if (empty($active_worker) || empty($active_worker->id)) {
         return;
     }
     $codes = DAO_Translation::getDefinedLangCodes();
     @($add_lang_code = DevblocksPlatform::importGPC($_REQUEST['add_lang_code'], 'string', ''));
     @($copy_lang_code = DevblocksPlatform::importGPC($_REQUEST['copy_lang_code'], 'string', ''));
     @($del_lang_ids = DevblocksPlatform::importGPC($_REQUEST['del_lang_ids'], 'array', array()));
     if (!empty($del_lang_ids)) {
         if (is_array($del_lang_ids)) {
             foreach ($del_lang_ids as $lang_id) {
                 DAO_Translation::deleteByLangCodes($lang_id);
             }
         }
     }
     // Don't add blanks or the same language twice.
     if (!empty($add_lang_code) && !isset($codes[$add_lang_code])) {
         // English reference strings (to know our scope)
         $english_strings = DAO_Translation::getMapByLang('en_US');
         $copy_strings = array();
         // If we have a desired source language for defaults, load it.
         if (!empty($copy_lang_code)) {
             if (0 == strcasecmp('en_US', $copy_lang_code)) {
                 $copy_strings = $english_strings;
             } else {
                 $copy_strings = DAO_Translation::getMapByLang($copy_lang_code);
             }
         }
         // Loop through English strings for new language
         if (is_array($english_strings)) {
             foreach ($english_strings as $string_id => $src_en) {
                 /* @var $src_en Model_Translation */
                 $override = '';
                 // If we have a valid source, copy its override or its default (in that order)
                 @($copy_string = $copy_strings[$string_id]);
                 if (is_a($copy_string, 'Model_Translation')) {
                     $override = !empty($copy_string->string_override) ? $copy_string->string_override : $copy_string->string_default;
                 }
                 // Insert the new string as an override.  Only official translations are defaults
                 $fields = array(DAO_Translation::STRING_ID => $string_id, DAO_Translation::LANG_CODE => $add_lang_code, DAO_Translation::STRING_DEFAULT => '', DAO_Translation::STRING_OVERRIDE => $override);
                 DAO_Translation::create($fields);
             }
         }
     }
     // If we added a new language then change the view to display it
     if (!empty($add_lang_code)) {
         $defaults = new Ps_AbstractViewModel();
         $defaults->class_name = 'Ps_TranslationView';
         $defaults->id = Ps_TranslationView::DEFAULT_ID;
         // Clear the existing view
         $view = Ps_AbstractViewLoader::getView(Ps_TranslationView::DEFAULT_ID, $defaults);
         $view->doResetCriteria();
         // Set search to untranslated strings that aren't English
         $view->renderSortBy = SearchFields_Translation::STRING_ID;
         $view->renderSortAsc = true;
         $view->params = array(SearchFields_Translation::LANG_CODE => new DevblocksSearchCriteria(SearchFields_Translation::LANG_CODE, DevblocksSearchCriteria::OPER_EQ, $add_lang_code));
         /*
          * If we didn't copy from another language, only show empty strings 
          * which makes it easier to translate in the GUI.
          */
         if (empty($copy_lang_code)) {
             $view->params[SearchFields_Translation::STRING_OVERRIDE] = new DevblocksSearchCriteria(SearchFields_Translation::STRING_OVERRIDE, DevblocksSearchCriteria::OPER_EQ, '');
         }
         Ps_AbstractViewLoader::setView($view->id, $view);
     }
     self::_clearCache();
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('setup', 'translations')));
 }
コード例 #8
0
ファイル: Model.class.php プロジェクト: jstanden/portsensor
 /**
  * Enter description here...
  *
  * @param string $class Ps_AbstractView
  * @param string $view_label ID
  * @return Ps_AbstractView instance
  */
 static function getView($view_label, Ps_AbstractViewModel $defaults = null)
 {
     $active_worker = PortSensorApplication::getActiveWorker();
     if (is_null(self::$views)) {
         self::_init();
     }
     if (self::exists($view_label)) {
         $model = self::$views[$view_label];
         return self::unserializeAbstractView($model);
     } else {
         // See if the worker has their own saved prefs
         @($prefs = unserialize(DAO_WorkerPref::get($active_worker->id, 'view' . $view_label)));
         // Sanitize
         if (!empty($prefs) && $prefs instanceof Ps_AbstractViewModel && !empty($prefs->class_name)) {
             if (!class_exists($prefs->class_name)) {
                 DAO_WorkerPref::delete($active_worker->id, 'view' . $view_label);
             }
             $prefs = null;
         }
         // If no worker prefsd, check if we're passed defaults
         if (!$prefs instanceof Ps_AbstractViewModel && !empty($defaults)) {
             $prefs = $defaults;
         }
         // Create a default view if it doesn't exist
         if ($prefs instanceof Ps_AbstractViewModel) {
             if (!empty($prefs->class_name) || class_exists($prefs->class_name)) {
                 $view = new $prefs->class_name();
                 $view->id = $view_label;
                 if (!empty($prefs->view_columns)) {
                     $view->view_columns = $prefs->view_columns;
                 }
                 if (!empty($prefs->renderLimit)) {
                     $view->renderLimit = $prefs->renderLimit;
                 }
                 if (null !== $prefs->renderSortBy) {
                     $view->renderSortBy = $prefs->renderSortBy;
                 }
                 if (null !== $prefs->renderSortAsc) {
                     $view->renderSortAsc = $prefs->renderSortAsc;
                 }
                 self::setView($view_label, $view);
                 return $view;
             }
         }
     }
     return null;
 }
コード例 #9
0
ファイル: preferences.php プロジェクト: jstanden/portsensor
 function saveAlertPeekAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     @($view_id = DevblocksPlatform::importGPC($_POST['view_id'], 'string'));
     @($active_worker = PortSensorApplication::getActiveWorker());
     /*****************************/
     @($name = DevblocksPlatform::importGPC($_POST['name'], 'string', ''));
     @($is_disabled = DevblocksPlatform::importGPC($_POST['is_disabled'], 'integer', 0));
     @($worker_id = DevblocksPlatform::importGPC($_POST['worker_id'], 'integer', 0));
     @($rules = DevblocksPlatform::importGPC($_POST['rules'], 'array', array()));
     @($do = DevblocksPlatform::importGPC($_POST['do'], 'array', array()));
     @($delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0));
     if (!empty($id) && !empty($delete)) {
         DAO_Alert::delete($id);
     } else {
         if (empty($name)) {
             $name = $translate->_('Alert');
         }
         $criterion = array();
         $actions = array();
         // Custom fields
         $custom_fields = DAO_CustomField::getAll();
         $alert_criteria_exts = DevblocksPlatform::getExtensions('portsensor.alert.criteria', false);
         // Criteria
         if (is_array($rules)) {
             foreach ($rules as $rule) {
                 $rule = DevblocksPlatform::strAlphaNumDash($rule);
                 @($value = DevblocksPlatform::importGPC($_POST['value_' . $rule], 'string', ''));
                 // [JAS]: Allow empty $value (null/blank checking)
                 $criteria = array('value' => $value);
                 // Any special rule handling
                 switch ($rule) {
                     case 'dayofweek':
                         // days
                         $days = DevblocksPlatform::importGPC($_REQUEST['value_dayofweek'], 'array', array());
                         if (in_array(0, $days)) {
                             $criteria['sun'] = 'Sunday';
                         }
                         if (in_array(1, $days)) {
                             $criteria['mon'] = 'Monday';
                         }
                         if (in_array(2, $days)) {
                             $criteria['tue'] = 'Tuesday';
                         }
                         if (in_array(3, $days)) {
                             $criteria['wed'] = 'Wednesday';
                         }
                         if (in_array(4, $days)) {
                             $criteria['thu'] = 'Thursday';
                         }
                         if (in_array(5, $days)) {
                             $criteria['fri'] = 'Friday';
                         }
                         if (in_array(6, $days)) {
                             $criteria['sat'] = 'Saturday';
                         }
                         unset($criteria['value']);
                         break;
                     case 'timeofday':
                         $from = DevblocksPlatform::importGPC($_REQUEST['timeofday_from'], 'string', '');
                         $to = DevblocksPlatform::importGPC($_REQUEST['timeofday_to'], 'string', '');
                         $criteria['from'] = $from;
                         $criteria['to'] = $to;
                         unset($criteria['value']);
                         break;
                     case 'event':
                         @($events = DevblocksPlatform::importGPC($_REQUEST['value_event'], 'array', array()));
                         if (is_array($events)) {
                             foreach ($events as $event) {
                                 $criteria[$event] = true;
                             }
                         }
                         unset($criteria['value']);
                         break;
                     case 'alert_last_ran':
                         @($from = DevblocksPlatform::importGPC($_REQUEST['value_alert_last_ran_from'], 'string', ''));
                         @($to = DevblocksPlatform::importGPC($_REQUEST['value_alert_last_ran_to'], 'string', ''));
                         $criteria['from'] = $from;
                         $criteria['to'] = $to;
                         unset($criteria['value']);
                         break;
                     case 'sensor_name':
                         break;
                     case 'sensor_fail_count':
                         $oper = DevblocksPlatform::importGPC($_REQUEST['oper_sensor_fail_count'], 'string', '=');
                         $criteria['oper'] = $oper;
                         break;
                     case 'sensor_type':
                         @($types = DevblocksPlatform::importGPC($_REQUEST['value_sensor_types'], 'array', array()));
                         if (is_array($types)) {
                             foreach ($types as $type) {
                                 $criteria[$type] = true;
                             }
                         }
                         unset($criteria['value']);
                         break;
                     default:
                         // ignore invalids // [TODO] Very redundant
                         // Custom fields
                         if ("cf_" == substr($rule, 0, 3)) {
                             $field_id = intval(substr($rule, 3));
                             if (!isset($custom_fields[$field_id])) {
                                 continue;
                             }
                             // [TODO] Operators
                             switch ($custom_fields[$field_id]->type) {
                                 case 'S':
                                     // string
                                 // string
                                 case 'T':
                                     // clob
                                 // clob
                                 case 'U':
                                     // URL
                                     @($oper = DevblocksPlatform::importGPC($_REQUEST['value_cf_' . $field_id . '_oper'], 'string', 'regexp'));
                                     $criteria['oper'] = $oper;
                                     break;
                                 case 'D':
                                     // dropdown
                                 // dropdown
                                 case 'M':
                                     // multi-dropdown
                                 // multi-dropdown
                                 case 'X':
                                     // multi-checkbox
                                 // multi-checkbox
                                 case 'W':
                                     // worker
                                     @($in_array = DevblocksPlatform::importGPC($_REQUEST['value_cf_' . $field_id], 'array', array()));
                                     $out_array = array();
                                     // Hash key on the option for quick lookup later
                                     if (is_array($in_array)) {
                                         foreach ($in_array as $k => $v) {
                                             $out_array[$v] = $v;
                                         }
                                     }
                                     $criteria['value'] = $out_array;
                                     break;
                                 case 'E':
                                     // date
                                     @($from = DevblocksPlatform::importGPC($_REQUEST['value_cf_' . $field_id . '_from'], 'string', '0'));
                                     @($to = DevblocksPlatform::importGPC($_REQUEST['value_cf_' . $field_id . '_to'], 'string', 'now'));
                                     $criteria['from'] = $from;
                                     $criteria['to'] = $to;
                                     unset($criteria['value']);
                                     break;
                                 case 'N':
                                     // number
                                     @($oper = DevblocksPlatform::importGPC($_REQUEST['value_cf_' . $field_id . '_oper'], 'string', '='));
                                     $criteria['oper'] = $oper;
                                     $criteria['value'] = intval($value);
                                     break;
                                 case 'C':
                                     // checkbox
                                     $criteria['value'] = intval($value);
                                     break;
                             }
                         } elseif (isset($alert_criteria_exts[$rule])) {
                             // Extensions
                             // Save custom criteria properties
                             try {
                                 $crit_ext = $alert_criteria_exts[$rule]->createInstance();
                                 /* @var $crit_ext Extension_AlertCriteria */
                                 $criteria = $crit_ext->saveConfig();
                             } catch (Exception $e) {
                                 // print_r($e);
                             }
                         } else {
                             continue;
                         }
                         break;
                 }
                 $criterion[$rule] = $criteria;
             }
         }
         $alert_action_exts = DevblocksPlatform::getExtensions('portsensor.alert.action', false);
         // Actions
         if (is_array($do)) {
             foreach ($do as $act) {
                 $action = array();
                 switch ($act) {
                     // Forward a copy to...
                     case 'email':
                         @($emails = DevblocksPlatform::importGPC($_REQUEST['do_email'], 'array', array()));
                         if (!empty($emails)) {
                             $action = array('to' => $emails);
                         }
                         break;
                         // Watcher notification
                     // Watcher notification
                     case 'notify':
                         //@$emails = DevblocksPlatform::importGPC($_REQUEST['do_email'],'array',array());
                         //if(!empty($emails)) {
                         $action = array();
                         //}
                         break;
                     default:
                         // ignore invalids
                         // Custom fields
                         if ("cf_" == substr($act, 0, 3)) {
                             $field_id = intval(substr($act, 3));
                             if (!isset($custom_fields[$field_id])) {
                                 continue;
                             }
                             $action = array();
                             switch ($custom_fields[$field_id]->type) {
                                 case 'S':
                                     // string
                                 // string
                                 case 'T':
                                     // clob
                                 // clob
                                 case 'U':
                                     // URL
                                 // URL
                                 case 'D':
                                     // dropdown
                                 // dropdown
                                 case 'W':
                                     // worker
                                     $value = DevblocksPlatform::importGPC($_REQUEST['do_cf_' . $field_id], 'string', '');
                                     $action['value'] = $value;
                                     break;
                                 case 'M':
                                     // multi-dropdown
                                 // multi-dropdown
                                 case 'X':
                                     // multi-checkbox
                                     $in_array = DevblocksPlatform::importGPC($_REQUEST['do_cf_' . $field_id], 'array', array());
                                     $out_array = array();
                                     // Hash key on the option for quick lookup later
                                     if (is_array($in_array)) {
                                         foreach ($in_array as $k => $v) {
                                             $out_array[$v] = $v;
                                         }
                                     }
                                     $action['value'] = $out_array;
                                     break;
                                 case 'E':
                                     // date
                                     $value = DevblocksPlatform::importGPC($_REQUEST['do_cf_' . $field_id], 'string', '');
                                     $action['value'] = $value;
                                     break;
                                 case 'N':
                                     // number
                                 // number
                                 case 'C':
                                     // checkbox
                                     $value = DevblocksPlatform::importGPC($_REQUEST['do_cf_' . $field_id], 'string', '');
                                     $action['value'] = intval($value);
                                     break;
                             }
                         } elseif (isset($alert_action_exts[$act])) {
                             // Save custom action properties
                             try {
                                 $action_ext = $alert_action_exts[$act]->createInstance();
                                 $action = $action_ext->saveConfig();
                             } catch (Exception $e) {
                                 // print_r($e);
                             }
                         } else {
                             continue;
                         }
                         break;
                 }
                 $actions[$act] = $action;
             }
         }
         $fields = array(DAO_Alert::NAME => $name, DAO_Alert::IS_DISABLED => $is_disabled, DAO_Alert::WORKER_ID => $worker_id, DAO_Alert::CRITERIA_JSON => json_encode($criterion), DAO_Alert::ACTIONS_JSON => json_encode($actions));
         // Create
         if (empty($id)) {
             $fields[DAO_Alert::POS] = 0;
             $id = DAO_Alert::create($fields);
             // Update
         } else {
             DAO_Alert::update($id, $fields);
         }
     }
     if (!empty($view_id)) {
         $view = Ps_AbstractViewLoader::getView($view_id);
         $view->render();
     }
 }
コード例 #10
0
 public function writeResponse(DevblocksHttpResponse $response)
 {
     $path = $response->path;
     // [JAS]: Ajax? // [TODO] Explore outputting whitespace here for Safari
     //	    if(empty($path))
     //			return;
     $tpl = DevblocksPlatform::getTemplateService();
     $session = DevblocksPlatform::getSessionService();
     $settings = DevblocksPlatform::getPluginSettingsService();
     $translate = DevblocksPlatform::getTranslationService();
     $active_worker = PortSensorApplication::getActiveWorker();
     $visit = $session->getVisit();
     $page_manifests = $this->_getAllowedPages();
     $controller = array_shift($path);
     // Default page [TODO] This is supposed to come from framework.config.php
     if (empty($controller)) {
         $controller = 'home';
     }
     // [JAS]: Require us to always be logged in for PortSensor pages
     if (empty($visit) && 0 != strcasecmp($controller, 'login')) {
         $query = array();
         if (!empty($response->path)) {
             $query = array('url' => urlencode(implode('/', $response->path)));
         }
         DevblocksPlatform::redirect(new DevblocksHttpRequest(array('login'), $query));
     }
     $page_id = $this->_getPageIdByUri($controller);
     @($page = DevblocksPlatform::getExtension($page_id, true));
     /* @var $page PortSensorPageExtension */
     if (empty($page)) {
         header("Status: 404");
         return;
         // [TODO] 404
     }
     // [JAS]: Listeners (Step-by-step guided tour, etc.)
     $listenerManifests = DevblocksPlatform::getExtensions('devblocks.listener.http');
     foreach ($listenerManifests as $listenerManifest) {
         /* @var $listenerManifest DevblocksExtensionManifest */
         $inst = $listenerManifest->createInstance();
         /* @var $inst DevblocksHttpRequestListenerExtension */
         $inst->run($response, $tpl);
     }
     $tpl->assign('active_worker', $active_worker);
     $tour_enabled = false;
     if (!empty($visit) && !is_null($active_worker)) {
         $tour_enabled = intval(DAO_WorkerPref::get($active_worker->id, 'assist_mode', 1));
         $keyboard_shortcuts = intval(DAO_WorkerPref::get($active_worker->id, 'keyboard_shortcuts', 1));
         $tpl->assign('pref_keyboard_shortcuts', $keyboard_shortcuts);
         //	    	$active_worker_memberships = $active_worker->getMemberships();
         //	    	$tpl->assign('active_worker_memberships', $active_worker_memberships);
         $unread_notifications = DAO_WorkerEvent::getUnreadCountByWorker($active_worker->id);
         $tpl->assign('active_worker_notify_count', $unread_notifications);
         DAO_Worker::logActivity($active_worker->id, $page->getActivity());
     }
     $tpl->assign('tour_enabled', $tour_enabled);
     // [JAS]: Variables provided to all page templates
     $tpl->assign('settings', $settings);
     $tpl->assign('session', $_SESSION);
     $tpl->assign('translate', $translate);
     $tpl->assign('visit', $visit);
     $tpl->assign('license', PortSensorLicense::getInstance());
     $tpl->assign('page_manifests', $page_manifests);
     $tpl->assign('page', $page);
     $tpl->assign('response_uri', implode('/', $response->path));
     $core_tpl = APP_PATH . '/features/portsensor.core/templates/';
     $tpl->assign('core_tpl', $core_tpl);
     // Prebody Renderers
     $preBodyRenderers = DevblocksPlatform::getExtensions('portsensor.renderer.prebody', true);
     if (!empty($preBodyRenderers)) {
         $tpl->assign('prebody_renderers', $preBodyRenderers);
     }
     // Postbody Renderers
     $postBodyRenderers = DevblocksPlatform::getExtensions('portsensor.renderer.postbody', true);
     if (!empty($postBodyRenderers)) {
         $tpl->assign('postbody_renderers', $postBodyRenderers);
     }
     // Timings
     $tpl->assign('render_time', microtime(true) - DevblocksPlatform::getStartTime());
     if (function_exists('memory_get_usage') && function_exists('memory_get_peak_usage')) {
         $tpl->assign('render_memory', memory_get_usage() - DevblocksPlatform::getStartMemory());
         $tpl->assign('render_peak_memory', memory_get_peak_usage() - DevblocksPlatform::getStartPeakMemory());
     }
     $tpl->display($core_tpl . 'border.tpl');
     //		$cache = DevblocksPlatform::getCacheService();
     //		$cache->printStatistics();
 }
コード例 #11
0
 static function shouldLoadExtension(DevblocksExtensionManifest $extension_manifest)
 {
     // Always allow core
     if ("portsensor.core" == $extension_manifest->plugin_id) {
         return true;
     }
     // [TODO] This should limit to just things we can run with no session
     // Community Tools, Cron/Update.  They are still limited by their own
     // isVisible() otherwise.
     if (null == ($active_worker = PortSensorApplication::getActiveWorker())) {
         return true;
     }
     // [TODO] ACL
     //return $active_worker->hasPriv('plugin.'.$extension_manifest->plugin_id);
     return true;
 }