Exemplo n.º 1
0
 function isVisible()
 {
     // check login
     $visit = UsermeetApplication::getVisit();
     if (empty($visit)) {
         return false;
     } else {
         return true;
     }
 }
Exemplo n.º 2
0
 function run(DevblocksHttpResponse $response, Smarty $tpl)
 {
     $path = $response->path;
     $callouts = UsermeetApplication::getTourCallouts();
     switch (array_shift($path)) {
         case 'welcome':
             $tour = array('title' => 'Welcome!', 'body' => "This assistant will help you become familiar with the application by following along and providing information about the current page.  You may follow the 'Points of Interest' links highlighted below to read tips about nearby functionality.", 'callouts' => array($callouts['tourHeaderMenu']));
             break;
         case "preferences":
             $tour = array('title' => 'Preferences', 'body' => 'This screen allows you to change the personal preferences on your account.');
             break;
         case "setup":
             $tour = array('title' => 'Setup', 'body' => '...');
             break;
         case NULL:
         case 'home':
             $tour = array('title' => 'Home', 'body' => '...', 'callouts' => array());
             break;
     }
     if (!empty($tour)) {
         $tpl->assign('tour', $tour);
     }
 }
Exemplo n.º 3
0
 function doNotificationsMarkReadAction()
 {
     $worker = UsermeetApplication::getActiveWorker();
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
     @($row_ids = DevblocksPlatform::importGPC($_REQUEST['row_id'], 'array', array()));
     if (is_array($row_ids) && !empty($row_ids)) {
         DAO_WorkerEvent::updateWhere(array(DAO_WorkerEvent::IS_READ => 1), sprintf("%s = %d AND %s IN (%s)", DAO_WorkerEvent::WORKER_ID, $worker->id, DAO_WorkerEvent::ID, implode(',', $row_ids)));
         DAO_WorkerEvent::clearCountCache($worker->id);
     }
     $myEventsView = Um_AbstractViewLoader::getView($view_id);
     $myEventsView->render();
 }
Exemplo n.º 4
0
 function doRecoverStep1Action()
 {
     $translate = DevblocksPlatform::getTranslationService();
     @($email = DevblocksPlatform::importGPC($_REQUEST['email'], 'string'));
     $worker = null;
     $results = DAO_Worker::getWhere(sprintf("%s = %s", DAO_Worker::EMAIL, Um_ORMHelper::qstr($email)));
     if (!empty($results)) {
         $worker = array_shift($results);
     }
     if (empty($email) || empty($worker)) {
         return;
     }
     $_SESSION[self::KEY_FORGOT_EMAIL] = $email;
     try {
         $code = UsermeetApplication::generatePassword(10);
         $_SESSION[self::KEY_FORGOT_SENTCODE] = $code;
         $to = $email;
         $subject = $translate->_('login.forgot.mail.subject');
         $body = vsprintf($translate->_('login.forgot.mail.body'), $code);
         UsermeetMail::quickSend($to, $subject, $body);
     } catch (Exception $e) {
         DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login', 'forgot', 'step1', 'failed')));
     }
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login', 'forgot', 'step2')));
 }
Exemplo n.º 5
0
 function handleRequest(DevblocksHttpRequest $request)
 {
     @set_time_limit(0);
     // no timelimit (when possible)
     $translate = DevblocksPlatform::getTranslationService();
     $stack = $request->path;
     array_shift($stack);
     // update
     $cache = DevblocksPlatform::getCacheService();
     /* @var $cache _DevblocksCacheManager */
     switch (array_shift($stack)) {
         case 'locked':
             if (!DevblocksPlatform::versionConsistencyCheck()) {
                 $url = DevblocksPlatform::getUrlService();
                 echo "<h1>Usermeet</h1>";
                 echo "The application is currently waiting for an administrator to finish upgrading. " . "Please wait a few minutes and then " . sprintf("<a href='%s'>try again</a>.<br><br>", $url->write('c=update&a=locked'));
                 echo sprintf("If you're an admin you may <a href='%s'>finish the upgrade</a>.", $url->write('c=update'));
             } else {
                 DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login')));
             }
             break;
         default:
             $path = APP_TEMP_PATH . DIRECTORY_SEPARATOR;
             $file = $path . 'umupdate_lock';
             $settings = DevblocksPlatform::getPluginSettingsService();
             $authorized_ips_str = $settings->get('usermeet.core', UsermeetSettings::AUTHORIZED_IPS);
             $authorized_ips = DevblocksPlatform::parseCrlfString($authorized_ips_str);
             $authorized_ip_defaults = DevblocksPlatform::parseCsvString(AUTHORIZED_IPS_DEFAULTS);
             $authorized_ips = array_merge($authorized_ips, $authorized_ip_defaults);
             // Is this IP authorized?
             $pass = false;
             foreach ($authorized_ips as $ip) {
                 if (substr($ip, 0, strlen($ip)) == substr($_SERVER['REMOTE_ADDR'], 0, strlen($ip))) {
                     $pass = true;
                     break;
                 }
             }
             if (!$pass) {
                 echo vsprintf($translate->_('update.ip_unauthorized'), $_SERVER['REMOTE_ADDR']);
                 return;
             }
             // Check requirements
             $errors = UsermeetApplication::checkRequirements();
             if (!empty($errors)) {
                 echo $translate->_('update.correct_errors');
                 echo "<ul style='color:red;'>";
                 foreach ($errors as $error) {
                     echo "<li>" . $error . "</li>";
                 }
                 echo "</ul>";
                 exit;
             }
             // If authorized, lock and attempt update
             if (!file_exists($file) || @filectime($file) + 600 < time()) {
                 // 10 min lock
                 touch($file);
                 //echo "Running plugin patches...<br>";
                 if (DevblocksPlatform::runPluginPatches('core.patches')) {
                     @unlink($file);
                     // [JAS]: Clear all caches
                     $cache->clean();
                     DevblocksPlatform::getClassLoaderService()->destroy();
                     // Clear compiled templates
                     $tpl = DevblocksPlatform::getTemplateService();
                     $tpl->clear_compiled_tpl();
                     // Reload plugin translations
                     DAO_Translation::reloadPluginStrings();
                     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login')));
                 } else {
                     @unlink($file);
                     echo "Failure!";
                     // [TODO] Needs elaboration
                 }
                 break;
             } else {
                 echo $translate->_('update.locked_another');
             }
     }
     exit;
 }
Exemplo n.º 6
0
 static function shouldLoadExtension(DevblocksExtensionManifest $extension_manifest)
 {
     // Always allow core
     if ("usermeet.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 = UsermeetApplication::getActiveWorker())) {
         return true;
     }
     // [TODO] ACL
     //return $active_worker->hasPriv('plugin.'.$extension_manifest->plugin_id);
     return true;
 }
Exemplo n.º 7
0
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('UM_DevblocksExtensionDelegate');
$session = DevblocksPlatform::getSessionService();
$settings = DevblocksPlatform::getPluginSettingsService();
$worker = UsermeetApplication::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/usermeet.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);
}
UsermeetApplication::processRequest($request, true);
exit;
Exemplo n.º 8
0
 private static function _save()
 {
     // persist
     $visit = UsermeetApplication::getVisit();
     $visit->set(self::VISIT_ABSTRACTVIEWS, self::$views);
 }
Exemplo n.º 9
0
 function saveAddLanguagePanelAction()
 {
     $active_worker = UsermeetApplication::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 Um_AbstractViewModel();
         $defaults->class_name = 'Um_TranslationView';
         $defaults->id = Um_TranslationView::DEFAULT_ID;
         // Clear the existing view
         $view = Um_AbstractViewLoader::getView(Um_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, '');
         }
         Um_AbstractViewLoader::setView($view->id, $view);
     }
     self::_clearCache();
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('setup', 'translations')));
 }
Exemplo n.º 10
0
 function showCalloutAction()
 {
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'string'));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $callouts = UsermeetApplication::getTourCallouts();
     $callout = array();
     if (isset($callouts[$id])) {
         $callout = $callouts[$id];
     }
     $tpl->assign('callout', $callout);
     $tpl->display('file:' . $this->_TPL_PATH . 'internal/tour/callout.tpl');
 }
Exemplo n.º 11
0
 function saveLicensesAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     $settings = DevblocksPlatform::getPluginSettingsService();
     $worker = UsermeetApplication::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('usermeet.core', UsermeetSettings::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 = UsermeetLicense::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.usermeet.com/
      */
     $license = $valid;
     $settings->set('usermeet.core', UsermeetSettings::LICENSE, serialize($license));
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings')));
 }
Exemplo n.º 12
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 = UsermeetApplication::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 Usermeet 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 UsermeetPageExtension */
     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', UsermeetLicense::getInstance());
     $tpl->assign('page_manifests', $page_manifests);
     $tpl->assign('page', $page);
     $tpl->assign('response_uri', implode('/', $response->path));
     $core_tpl = APP_PATH . '/features/usermeet.core/templates/';
     $tpl->assign('core_tpl', $core_tpl);
     // Prebody Renderers
     $preBodyRenderers = DevblocksPlatform::getExtensions('usermeet.renderer.prebody', true);
     if (!empty($preBodyRenderers)) {
         $tpl->assign('prebody_renderers', $preBodyRenderers);
     }
     // Postbody Renderers
     $postBodyRenderers = DevblocksPlatform::getExtensions('usermeet.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();
 }
Exemplo n.º 13
0
 function saveTabGeneralAction()
 {
     @($timezone = DevblocksPlatform::importGPC($_REQUEST['timezone'], 'string'));
     @($lang_code = DevblocksPlatform::importGPC($_REQUEST['lang_code'], 'string', 'en_US'));
     $worker = UsermeetApplication::getActiveWorker();
     $translate = DevblocksPlatform::getTranslationService();
     $tpl = DevblocksPlatform::getTemplateService();
     // Time
     $_SESSION['timezone'] = $timezone;
     @date_default_timezone_set($timezone);
     DAO_WorkerPref::set($worker->id, 'timezone', $timezone);
     // Language
     $_SESSION['locale'] = $lang_code;
     DevblocksPlatform::setLocale($lang_code);
     DAO_WorkerPref::set($worker->id, 'locale', $lang_code);
     @($new_password = DevblocksPlatform::importGPC($_REQUEST['change_pass'], 'string'));
     @($verify_password = DevblocksPlatform::importGPC($_REQUEST['change_pass_verify'], 'string'));
     //[mdf] if nonempty passwords match, update worker's password
     if ($new_password != "" && $new_password === $verify_password) {
         $session = DevblocksPlatform::getSessionService();
         $fields = array(DAO_Worker::PASS => md5($new_password));
         DAO_Worker::update($worker->id, $fields);
     }
     @($assist_mode = DevblocksPlatform::importGPC($_REQUEST['assist_mode'], 'integer', 0));
     DAO_WorkerPref::set($worker->id, 'assist_mode', $assist_mode);
     @($keyboard_shortcuts = DevblocksPlatform::importGPC($_REQUEST['keyboard_shortcuts'], 'integer', 0));
     DAO_WorkerPref::set($worker->id, 'keyboard_shortcuts', $keyboard_shortcuts);
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('preferences')));
 }