Пример #1
0
 protected function initializeForCommand()
 {
     // retrieve all Data for the About screen
     $stringArray = $this->getModuleArray('strings');
     $textArray = array('orgtext' => $this->getSiteAboutHTML(), 'abouttext' => $this->getAboutHTML(), 'orgname' => Kurogo::getSiteString('ORGANIZATION_NAME'), 'email' => Kurogo::getSiteString('FEEDBACK_EMAIL'), 'website' => Kurogo::getSiteString('COPYRIGHT_LINK'), 'copyright' => Kurogo::getSiteString('COPYRIGHT_NOTICE'));
     switch ($this->command) {
         case 'index':
             $dictionaryOfSections = $this->getModuleSections('api-index');
             $response = array();
             foreach ($dictionaryOfSections as $key => $value) {
                 $response[] = $value;
             }
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'about_site':
             $response = '<p>' . implode('</p><p>', $textArray['orgtext']) . '</p>';
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'about':
             $response = '<p>' . implode('</p><p>', $textArray['abouttext']) . '</p>';
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'credits':
             $response = $this->getCreditsHTML();
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'orgname':
         case 'orgtext':
         case 'abouttext':
         case 'copyright':
         case 'email':
         case 'website':
             $response = array($this->command => $textArray[$this->command]);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
             // Use 'alldata' to get everything in one API-CALL
         // Use 'alldata' to get everything in one API-CALL
         case 'alldata':
             $textArray['credits'] = $this->getCreditsHTML();
             $response = $textArray;
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         default:
             $this->invalidCommand();
             $this->setResponseVersion(1);
             break;
     }
 }
Пример #2
0
 protected function initializeForPage()
 {
     switch ($this->page) {
         case 'help':
             break;
         case 'index':
             if ($this->pagetype == 'tablet') {
                 $this->assign('modulePanes', $this->getTabletModulePanes($this->getModuleSection('tablet_panes')));
                 $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js');
                 $this->addOnOrientationChange('moduleHandleWindowResize();');
             } else {
                 $this->assign('modules', $this->getModuleNavList());
                 $this->assign('hideImages', $this->getOptionalModuleVar('HIDE_IMAGES', false));
             }
             if ($this->getOptionalModuleVar('SHOW_FEDERATED_SEARCH', true)) {
                 $this->assign('showFederatedSearch', true);
                 $this->assign('placeholder', $this->getLocalizedString("SEARCH_PLACEHOLDER", Kurogo::getSiteString('SITE_NAME')));
             }
             $this->assign('SHOW_DOWNLOAD_TEXT', DownloadWebModule::appDownloadText($this->platform));
             $this->assign('displayType', $this->getModuleVar('display_type'));
             break;
         case 'search':
             $searchTerms = $this->getArg('filter');
             $federatedResults = array();
             foreach ($this->getAllModuleNavigationData(self::EXCLUDE_DISABLED_MODULES) as $type => $modules) {
                 foreach ($modules as $id => $info) {
                     $module = self::factory($id);
                     if ($module->getModuleVar('search')) {
                         $results = array();
                         $total = $module->federatedSearch($searchTerms, 2, $results);
                         $federatedResults[] = array('title' => $info['title'], 'results' => $results, 'total' => $total, 'url' => $module->urlForFederatedSearch($searchTerms));
                         unset($module);
                     }
                 }
             }
             $this->assign('federatedResults', $federatedResults);
             $this->assign('searchTerms', $searchTerms);
             $this->setLogData($searchTerms);
             break;
     }
 }
Пример #3
0
 public function initializeForCommand()
 {
     switch ($this->command) {
         case 'hello':
             $allmodules = $this->getAllModules();
             $homeModuleData = $this->getModuleNavigationData();
             $homeModules = array('primary' => isset($homeModuleData['primary']) ? array_keys($homeModuleData['primary']) : array(), 'secondary' => isset($homeModuleData['secondary']) ? array_keys($homeModuleData['secondary']) : array());
             foreach ($allmodules as $moduleID => $module) {
                 if ($module->isEnabled()) {
                     $home = false;
                     if (($key = array_search($moduleID, $homeModules['primary'])) !== FALSE) {
                         $home = array('type' => 'primary', 'order' => $key, 'title' => $homeModuleData['primary'][$moduleID]);
                     } elseif (($key = array_search($moduleID, $homeModules['secondary'])) !== FALSE) {
                         $home = array('type' => 'secondary', 'order' => $key);
                     }
                     $modules[] = array('id' => $module->getID(), 'tag' => $module->getConfigModule(), 'title' => $module->getModuleVar('title', 'module'), 'access' => $module->getAccess(AccessControlList::RULE_TYPE_ACCESS), 'payload' => $module->getPayload(), 'bridge' => $module->getWebBridgeConfig(), 'vmin' => $module->getVmin(), 'vmax' => $module->getVmax(), 'home' => $home);
                 }
             }
             $response = array('timezone' => Kurogo::getSiteVar('LOCAL_TIMEZONE'), 'site' => Kurogo::getSiteString('SITE_NAME'), 'organization' => Kurogo::getSiteString('ORGANIZATION_NAME'), 'version' => KUROGO_VERSION, 'modules' => $modules, 'default' => Kurogo::defaultModule());
             $this->setResponse($response);
             $this->setResponseVersion(2);
             break;
         case 'classify':
             $userAgent = $this->getArg('useragent');
             if (!$userAgent) {
                 throw new KurogoException("useragent parameter not specified");
             }
             $response = Kurogo::deviceClassifier()->classifyUserAgent($userAgent);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         default:
             $this->invalidCommand();
             break;
     }
 }
Пример #4
0
 protected function initializeForPage()
 {
     $nativeApp = (bool) $this->getArg('nativeApp', false);
     $this->assign('nativeApp', $nativeApp);
     // Default args to pass through forms and urls
     $defaultArgs = array();
     if ($nativeApp) {
         $defaultArgs['nativeApp'] = 1;
     }
     // If this is a native app, use the native app GA id
     if ($nativeApp) {
         $this->assign('GOOGLE_ANALYTICS_ID', Kurogo::getOptionalSiteVar('GOOGLE_ANALYTICS_NATIVE_ID'));
     }
     if (!Kurogo::getSiteVar('AUTHENTICATION_ENABLED')) {
         throw new KurogoConfigurationException($this->getLocalizedString("ERROR_AUTHENTICATION_DISABLED"));
     }
     $session = $this->getSession();
     //return URL
     $urlArray = $this->extractModuleArray($this->args);
     //see if remain logged in is enabled by the administrator, then if the value has been passed (i.e. the user checked the "remember me" box)
     $allowRemainLoggedIn = Kurogo::getOptionalSiteVar('AUTHENTICATION_REMAIN_LOGGED_IN_TIME');
     if ($allowRemainLoggedIn) {
         $remainLoggedIn = $this->getArg('remainLoggedIn', 0);
     } else {
         $remainLoggedIn = 0;
     }
     // initialize
     $authenticationAuthorities = array('total' => 0, 'direct' => array(), 'indirect' => array(), 'auto' => array());
     $invalidAuthorities = array();
     // cycle through the defined authorities in the config
     foreach (AuthenticationAuthority::getDefinedAuthenticationAuthorities() as $authorityIndex => $authorityData) {
         // USER_LOGIN property determines whether the authority is used for logins (or just groups or oauth)
         $USER_LOGIN = $this->argVal($authorityData, 'USER_LOGIN', 'NONE');
         // trap the exception if the authority is invalid (usually due to misconfiguration)
         try {
             $authority = AuthenticationAuthority::getAuthenticationAuthority($authorityIndex);
             $authorityData['listclass'] = $authority->getAuthorityClass();
             $authorityData['title'] = $authorityData['TITLE'];
             $authorityData['url'] = $this->buildURL('login', array_merge($urlArray, array('authority' => $authorityIndex, 'remainLoggedIn' => $remainLoggedIn, 'startOver' => 1)));
             if ($USER_LOGIN == 'FORM') {
                 $authenticationAuthorities['direct'][$authorityIndex] = $authorityData;
                 $authenticationAuthorities['total']++;
             } elseif ($USER_LOGIN == 'LINK') {
                 $authenticationAuthorities['indirect'][$authorityIndex] = $authorityData;
                 $authenticationAuthorities['total']++;
             } elseif ($USER_LOGIN == 'AUTO') {
                 $authenticationAuthorities['auto'][$authorityIndex] = $authorityData;
                 $authenticationAuthorities['total']++;
             }
         } catch (KurogoConfigurationException $e) {
             Kurogo::log(LOG_WARNING, "Invalid authority data for %s: %s", $authorityIndex, $e->getMessage(), 'auth');
             $invalidAuthorities[$authorityIndex] = $e->getMessage();
         }
     }
     //see if we have any valid authorities
     if ($authenticationAuthorities['total'] == 0) {
         $message = $this->getLocalizedString("ERROR_NO_AUTHORITIES");
         if (count($invalidAuthorities) > 0) {
             $message .= sprintf(" %s invalid authorit%s found:\n", count($invalidAuthorities), count($invalidAuthorities) > 1 ? 'ies' : 'y');
             foreach ($invalidAuthorities as $authorityIndex => $invalidAuthority) {
                 $message .= sprintf("%s: %s\n", $authorityIndex, $invalidAuthority);
             }
         }
         //we don't
         throw new KurogoConfigurationException($message);
     }
     //assign template variables
     $this->assign('authenticationAuthorities', $authenticationAuthorities);
     $this->assign('allowRemainLoggedIn', $allowRemainLoggedIn);
     if ($forgetPasswordURL = $this->getOptionalModuleVar('FORGET_PASSWORD_URL')) {
         $this->assign('FORGET_PASSWORD_URL', $this->buildBreadcrumbURL('forgotpassword', array()));
         $this->assign('FORGET_PASSWORD_TEXT', $this->getOptionalModuleVar('FORGET_PASSWORD_TEXT', $this->getLocalizedString('FORGET_PASSWORD_TEXT')));
     }
     $multipleAuthorities = count($authenticationAuthorities['direct']) + count($authenticationAuthorities['indirect']) > 1;
     switch ($this->page) {
         case 'logoutConfirm':
             //this page is presented when a specific authority is chosen and the user is presented the option to actually log out.
             $authorityIndex = $this->getArg('authority');
             if (!$this->isLoggedIn($authorityIndex)) {
                 // they aren't logged in
                 $this->redirectTo('index', $defaultArgs);
             } elseif ($user = $this->getUser($authorityIndex)) {
                 $authority = $user->getAuthenticationAuthority();
                 $this->assign('message', $this->getLocalizedString('LOGIN_SIGNED_IN_SINGLE', Kurogo::getSiteString('SITE_NAME'), $authority->getAuthorityTitle(), $user->getFullName()));
                 $this->assign('url', $this->buildURL('logout', array('authority' => $authorityIndex)));
                 $this->assign('linkText', $this->getLocalizedString('SIGN_OUT'));
                 $this->setTemplatePage('message');
             } else {
                 //This honestly should never happen
                 $this->redirectTo('index', $defaultArgs);
             }
             break;
         case 'logout':
             $authorityIndex = $this->getArg('authority');
             //hard logouts attempt to logout of the indirect service provider (must be implemented by the authority)
             $hard = $this->getArg('hard', false);
             if (!$this->isLoggedIn($authorityIndex)) {
                 //not logged in
                 $this->redirectTo('index', $defaultArgs);
             } elseif ($authority = AuthenticationAuthority::getAuthenticationAuthority($authorityIndex)) {
                 $user = $this->getUser($authority);
                 //log them out
                 $result = $session->logout($authority, $hard);
             } else {
                 //This honestly should never happen
                 $this->redirectTo('index', $defaultArgs);
             }
             if ($result) {
                 $this->setLogData($user, $user->getFullName());
                 $this->logView();
                 //if they are still logged in return to the login page, otherwise go home.
                 if ($this->isLoggedIn()) {
                     $this->redirectTo('index', array_merge(array('logout' => $authorityIndex), $defaultArgs));
                 } else {
                     $this->redirectToModule($this->getHomeModuleID(), '', array('logout' => $authorityIndex));
                 }
             } else {
                 //there was an error logging out
                 $this->setTemplatePage('message');
                 $this->assign('message', $this->getLocalizedString("ERROR_SIGN_OUT"));
             }
             break;
         case 'forgotpassword':
             //redirect to forgot password url
             if ($forgetPasswordURL = $this->getOptionalModuleVar('FORGET_PASSWORD_URL')) {
                 Kurogo::redirectToURL($forgetPasswordURL);
             } else {
                 $this->redirectTo('index', $defaultArgs);
             }
             break;
         case 'login':
             //get arguments
             $login = $this->argVal($_POST, 'loginUser', '');
             $password = $this->argVal($_POST, 'loginPassword', '');
             $options = array_merge($urlArray, array('remainLoggedIn' => $remainLoggedIn), $defaultArgs);
             $session = $this->getSession();
             $session->setRemainLoggedIn($remainLoggedIn);
             $authorityIndex = $this->getArg('authority', '');
             if (!($authorityData = AuthenticationAuthority::getAuthenticationAuthorityData($authorityIndex))) {
                 //invalid authority
                 $this->redirectTo('index', $options);
             }
             if ($this->isLoggedIn($authorityIndex)) {
                 //we're already logged in
                 $this->redirectTo('index', $options);
             }
             $this->assign('authority', $authorityIndex);
             $this->assign('remainLoggedIn', $remainLoggedIn);
             $this->assign('authorityTitle', $authorityData['TITLE']);
             //if they haven't submitted the form and it's a direct login show the form
             if ($authorityData['USER_LOGIN'] == 'FORM' && empty($login)) {
                 if (!($loginMessage = $this->getOptionalModuleVar('LOGIN_DIRECT_MESSAGE'))) {
                     $loginMessage = $this->getLocalizedString('LOGIN_DIRECT_MESSAGE', Kurogo::getSiteString('SITE_NAME'));
                 }
                 $this->assign('LOGIN_DIRECT_MESSAGE', $loginMessage);
                 $this->assign('urlArray', array_merge($urlArray, $defaultArgs));
                 break;
             } elseif ($authority = AuthenticationAuthority::getAuthenticationAuthority($authorityIndex)) {
                 //indirect logins handling the login process themselves. Send a return url so the indirect authority can come back here
                 if ($authorityData['USER_LOGIN'] == 'LINK') {
                     $options['return_url'] = FULL_URL_BASE . $this->configModule . '/login?' . http_build_query(array_merge($options, array('authority' => $authorityIndex)));
                 }
                 $options['startOver'] = $this->getArg('startOver', 0);
                 $result = $authority->login($login, $password, $session, $options);
             } else {
                 $this->redirectTo('index', $options);
             }
             switch ($result) {
                 case AUTH_OK:
                     $user = $this->getUser($authority);
                     $this->setLogData($user, $user->getFullName());
                     $this->logView();
                     if ($urlArray) {
                         self::redirectToArray(array_merge($urlArray, $defaultArgs));
                     } else {
                         $this->redirectToModule($this->getHomeModuleID(), '', array('login' => $authorityIndex));
                     }
                     break;
                 case AUTH_OAUTH_VERIFY:
                     // authorities that require a manual oauth verification key
                     $this->assign('verifierKey', $authority->getVerifierKey());
                     $this->setTemplatePage('oauth_verify.tpl');
                     break 2;
                 default:
                     //there was a problem.
                     if ($authorityData['USER_LOGIN'] == 'FORM') {
                         $this->assign('message', $this->getLocalizedString('ERROR_LOGIN_DIRECT'));
                         break 2;
                     } else {
                         $this->redirectTo('index', array_merge(array('messagekey' => 'ERROR_LOGIN_INDIRECT'), $options, $defaultArgs));
                     }
             }
         case 'index':
             //sometimes messages are passed. This probably has some
             if ($messagekey = $this->getArg('messagekey')) {
                 $this->assign('messagekey', $this->getLocalizedString($messagekey));
                 try {
                     $message = $this->getLocalizedString($messagekey);
                     $this->assign('message', $message);
                 } catch (KurogoException $e) {
                 }
             }
             if ($this->isLoggedIn()) {
                 //if the url is set then redirect
                 if ($urlArray) {
                     self::redirectToArray(array_merge($urlArray, $defaultArgs));
                 }
                 //if there is only 1 authority then redirect to logout confirm
                 if (!$multipleAuthorities) {
                     $user = $this->getUser();
                     $this->redirectTo('logoutConfirm', array_merge(array('authority' => $user->getAuthenticationAuthorityIndex()), $defaultArgs));
                 }
                 //more than 1 authority. There could be 1 or more actual logged in users
                 $sessionUsers = $session->getUsers();
                 $users = array();
                 //cycle through the logged in users to build a list
                 foreach ($sessionUsers as $authorityIndex => $user) {
                     $authority = $user->getAuthenticationAuthority();
                     $users[] = array('class' => $authority->getAuthorityClass(), 'title' => count($sessionUsers) > 1 ? $this->getLocalizedString("SIGN_OUT_AUTHORITY", array($authority->getAuthorityTitle(), $user->getFullName())) : $this->getLocalizedString('SIGN_OUT'), 'subtitle' => count($sessionUsers) > 1 ? $this->getLocalizedString('SIGN_OUT') : '', 'url' => $this->buildBreadcrumbURL('logout', array('authority' => $authorityIndex), false));
                     //remove the authority from the list of available authorities (since they are logged in)
                     if (isset($authenticationAuthorities['direct'][$authorityIndex])) {
                         unset($authenticationAuthorities['direct'][$authorityIndex]);
                     }
                     if (isset($authenticationAuthorities['indirect'][$authorityIndex])) {
                         unset($authenticationAuthorities['indirect'][$authorityIndex]);
                     }
                 }
                 $this->assign('users', $users);
                 // navlist of users
                 $this->assign('authenticationAuthorities', $authenticationAuthorities);
                 //list of authorities not logged in
                 $this->assign('moreAuthorities', count($authenticationAuthorities['direct']) + count($authenticationAuthorities['indirect']));
                 //see if there are any left
                 if (count($sessionUsers) == 1) {
                     //there's only on logged in user
                     $user = current($sessionUsers);
                     $authority = $user->getAuthenticationAuthority();
                     $this->assign('LOGIN_SIGNED_IN_MESSAGE', $this->getLocalizedString('LOGIN_SIGNED_IN_SINGLE', Kurogo::getSiteString('SITE_NAME'), $authority->getAuthorityTitle(), $user->getFullName()));
                 } else {
                     //there are multiple logged in users
                     $this->assign('LOGIN_SIGNED_IN_MESSAGE', $this->getLocalizedString('LOGIN_SIGNED_IN_MULTIPLE', array(Kurogo::getSiteString('SITE_NAME'))));
                 }
                 //use loggedin.tpl
                 $this->setTemplatePage('loggedin');
             } else {
                 // not logged in
                 // if there is only 1 direct authority then redirect to the login page for that authority
                 if (!$multipleAuthorities && count($authenticationAuthorities['direct'])) {
                     $this->redirectTo('login', array_merge($urlArray, array('authority' => key($authenticationAuthorities['direct'])), $defaultArgs));
                 }
                 // if there is only 1 auto authority then redirect to the login page for that authority
                 if (!$multipleAuthorities && count($authenticationAuthorities['auto']) && !$messagekey) {
                     $this->redirectTo('login', array_merge($urlArray, array('authority' => key($authenticationAuthorities['auto'])), $defaultArgs));
                 }
                 // do we have any indirect authorities?
                 if (count($authenticationAuthorities['indirect'])) {
                     if (!($indirectMessage = $this->getOptionalModuleVar('LOGIN_INDIRECT_MESSAGE'))) {
                         $indirectMessage = $this->getLocalizedString('LOGIN_INDIRECT_MESSAGE', Kurogo::getSiteString('SITE_NAME'));
                     }
                     $this->assign('LOGIN_INDIRECT_MESSAGE', $indirectMessage);
                 }
                 // the site can create their own message at the top, or it will use the default message
                 if (!($loginMessage = $this->getOptionalModuleVar('LOGIN_INDEX_MESSAGE'))) {
                     if ($multipleAuthorities) {
                         $loginMessage = $this->getLocalizedString('LOGIN_INDEX_MESSAGE_MULTIPLE', Kurogo::getSiteString('SITE_NAME'));
                     } else {
                         $loginMessage = $this->getLocalizedString('LOGIN_INDEX_MESSAGE_SINGLE', Kurogo::getSiteString('SITE_NAME'));
                     }
                 }
                 $this->assign('LOGIN_INDEX_MESSAGE', $loginMessage);
             }
             break;
     }
 }
Пример #5
0
 private function setPageVariables()
 {
     $this->loadTemplateEngineIfNeeded();
     $this->loadPageConfig();
     // Set variables common to all modules
     $this->assign('moduleID', $this->id);
     $this->assign('configModule', $this->configModule);
     $this->assign('templateModule', $this->templateModule);
     $this->assign('moduleName', $this->moduleName);
     $this->assign('page', $this->page);
     $this->assign('isModuleHome', $this->page == 'index');
     $this->assign('request_uri', $_SERVER['REQUEST_URI']);
     $this->assign('hideFooterLinks', $this->hideFooterLinks);
     $this->assign('ajaxContentLoad', $this->ajaxContentLoad);
     $this->assign('charset', Kurogo::getCharset());
     $this->assign('webBridgeAjaxContentLoad', KurogoWebBridge::isAjaxContentLoad());
     // Font size for template
     $this->assign('fontsizes', $this->fontsizes);
     $this->assign('fontsize', $this->fontsize);
     $this->assign('fontsizeCSS', $this->getFontSizeCSS());
     $this->assign('fontSizeURLs', $this->getFontSizeURLs());
     // Minify URLs
     $this->assign('minify', $this->getMinifyUrls());
     // Google Analytics. This probably needs to be moved
     if ($gaID = Kurogo::getOptionalSiteVar('GOOGLE_ANALYTICS_ID')) {
         $this->assign('GOOGLE_ANALYTICS_ID', $gaID);
         $this->assign('GOOGLE_ANALYTICS_DOMAIN', Kurogo::getOptionalSiteVar('GOOGLE_ANALYTICS_DOMAIN'));
         $this->assign('gaImageURL', $this->googleAnalyticsGetImageUrl($gaID));
     }
     // Breadcrumbs
     $this->loadBreadcrumbs();
     // Tablet module nav list
     if ($this->pagetype == 'tablet' && $this->page != 'pane') {
         $this->addInternalJavascript('/common/javascript/lib/iscroll-4.1.9.js');
         $this->assign('moduleNavList', $this->getModuleNavlist());
     }
     if ($this->page == '__nativeWebTemplates') {
         $title = 'Error!';
         $message = '';
         try {
             if (!Kurogo::isLocalhost()) {
                 throw new KurogoException("{$this->page} command can only be run from localhost");
             }
             $platforms = array_filter(array_map('trim', explode(',', $this->getArg('platform', ''))));
             if (!$platforms) {
                 throw new KurogoException("No platforms specified");
             }
             foreach ($platforms as $platform) {
                 $this->buildNativeWebTemplatesForPlatform($platform);
             }
             $title = 'Success!';
             $message = 'Generated native web templates for ' . implode(' and ', $platforms);
         } catch (Exception $e) {
             $message = $e->getMessage();
         }
         $this->assign('contentTitle', $title);
         $this->assign('contentBody', $message);
     } else {
         if (KurogoWebBridge::useNativeTemplatePageInitializer()) {
             Kurogo::log(LOG_DEBUG, "Calling initializeForNativeTemplatePage for {$this->configModule} - {$this->page}", 'module');
             $this->initializeForNativeTemplatePage();
             //subclass behavior
             Kurogo::log(LOG_DEBUG, "Returned from initializeForNativeTemplatePage for {$this->configModule} - {$this->page}", 'module');
         } else {
             Kurogo::log(LOG_DEBUG, "Calling initializeForPage for {$this->configModule} - {$this->page}", 'module');
             $this->initializeForPage();
             //subclass behavior
             Kurogo::log(LOG_DEBUG, "Returned from initializeForPage for {$this->configModule} - {$this->page}", 'module');
         }
     }
     // Set variables for each page
     $this->assign('pageTitle', $this->pageTitle);
     // Variables which may have been modified by the module subclass
     $this->assign('inlineCSSBlocks', $this->inlineCSSBlocks);
     $this->assign('cssURLs', $this->cssURLs);
     $this->assign('inlineJavascriptBlocks', $this->inlineJavascriptBlocks);
     $this->assign('onOrientationChangeBlocks', $this->onOrientationChangeBlocks);
     $this->assign('onLoadBlocks', $this->onLoadBlocks);
     $this->assign('inlineJavascriptFooterBlocks', $this->inlineJavascriptFooterBlocks);
     $this->assign('javascriptURLs', $this->javascriptURLs);
     $this->assign('breadcrumbs', $this->breadcrumbs);
     $this->assign('breadcrumbArgs', $this->getBreadcrumbArgs());
     $this->assign('breadcrumbSamePageArgs', $this->getBreadcrumbArgs(false));
     $this->assign('moduleDebugStrings', $this->moduleDebugStrings);
     $this->assign('webBridgeOnPageLoadParams', KurogoWebBridge::getOnPageLoadParams($this->pageTitle, $this->breadcrumbTitle, $this->hasWebBridgePageRefresh));
     $this->assign('webBridgeConfig', KurogoWebBridge::getServerConfig($this->configModule, $this->page, $this->args));
     $moduleStrings = $this->getOptionalModuleSection('strings');
     $this->assign('moduleStrings', $moduleStrings);
     $this->assign('homeLink', $this->buildURLForModule($this->getHomeModuleID(), '', array()));
     $this->assign('homeModuleID', $this->getHomeModuleID());
     $this->assignLocalizedStrings();
     if ($this->page == 'help') {
         // Module Help
         $this->assign('hasHelp', false);
         $template = 'common/templates/' . $this->page;
     } else {
         if ($this->page == '__nativeWebTemplates') {
             $template = 'common/templates/staticContent';
         } else {
             if (KurogoWebBridge::useWrapperPageTemplate()) {
                 // Web bridge page wrapper
                 $template = 'common/templates/webBridge';
                 $this->assign('webBridgeJSLocalizedStrings', json_encode(Kurogo::getLocalizedStrings()));
             } else {
                 $this->assign('hasHelp', isset($moduleStrings['help']));
                 $this->assign('helpLink', $this->buildBreadcrumbURL('help', array()));
                 $this->assign('helpLinkText', $this->getLocalizedString('HELP_TEXT', $this->getModuleName()));
                 $template = 'modules/' . $this->templateModule . '/templates/' . $this->templatePage;
             }
         }
     }
     Kurogo::log(LOG_DEBUG, "Template file is {$template}", 'module');
     // Pager support
     if (isset($this->htmlPager)) {
         $this->assign('pager', $this->getPager());
     }
     // Tab support
     if (isset($this->tabbedView)) {
         $this->assign('tabbedView', $this->tabbedView);
     }
     $this->assign('imageExt', $this->imageExt);
     $this->assign($this->getThemeVars());
     // Access Key Start
     $accessKeyStart = count($this->breadcrumbs);
     if ($this->configModule != $this->getHomeModuleID()) {
         $accessKeyStart++;
         // Home link
     }
     $this->assign('accessKeyStart', $accessKeyStart);
     if (Kurogo::getSiteVar('AUTHENTICATION_ENABLED')) {
         Kurogo::includePackage('Authentication');
         $this->setCacheMaxAge(0);
         $session = $this->getSession();
         $this->assign('session', $session);
         $this->assign('session_isLoggedIn', $this->isLoggedIn());
         $this->assign('showLogin', Kurogo::getSiteVar('AUTHENTICATION_ENABLED') && $this->showLogin());
         if ($this->isLoggedIn()) {
             $user = $session->getUser();
             $authority = $user->getAuthenticationAuthority();
             $this->assign('session_userID', $user->getUserID());
             $this->assign('session_fullName', $user->getFullname());
             if (count($session->getUsers()) == 1) {
                 $this->assign('session_logout_url', $this->buildURLForModule($this->getLoginModuleID(), 'logout', array('authority' => $user->getAuthenticationAuthorityIndex())));
                 $this->assign('footerLoginLink', $this->buildURLForModule($this->getLoginModuleID(), '', array()));
                 $this->assign('footerLoginText', $this->getLocalizedString('SIGNED_IN_SINGLE', $authority->getAuthorityTitle(), $user->getFullName()));
                 $this->assign('footerLoginClass', $authority->getAuthorityClass());
             } else {
                 $this->assign('footerLoginClass', 'login_multiple');
                 $this->assign('session_logout_url', $this->buildURLForModule($this->getLoginModuleID(), 'logout', array()));
                 $this->assign('footerLoginLink', $this->buildURLForModule($this->getLoginModuleID(), 'logout', array()));
                 $this->assign('footerLoginText', $this->getLocalizedString('SIGNED_IN_MULTIPLE'));
             }
             if ($session_max_idle = intval(Kurogo::getOptionalSiteVar('AUTHENTICATION_IDLE_TIMEOUT', 0))) {
                 $this->setRefresh($session_max_idle + 2);
             }
         } else {
             $this->assign('footerLoginClass', 'noauth');
             $this->assign('footerLoginLink', $this->buildURLForModule($this->getLoginModuleID(), '', array()));
             $this->assign('footerLoginText', $this->getLocalizedString('SIGN_IN_SITE', Kurogo::getSiteString('SITE_NAME')));
         }
     }
     /* set cache age. Modules that present content that rarely changes can set this value
        to something higher */
     header(sprintf("Cache-Control: max-age=%d", $this->cacheMaxAge));
     header("Expires: " . gmdate('D, d M Y H:i:s', time() + $this->cacheMaxAge) . ' GMT');
     return $template;
 }
Пример #6
0
 protected function initializeForPage()
 {
     switch ($this->page) {
         case 'help':
             break;
         case 'index':
             $this->setPageTitle($this->getOptionalModuleVar('pageTitle', Kurogo::getSiteString('SITE_NAME'), 'index', 'pages'));
             if ($this->pagetype == 'tablet') {
                 $modulePanes = $this->getTabletModulePanes();
                 $this->assign('modulePanes', $modulePanes);
                 $this->addInlineJavascript('var homePortlets = {};');
                 $this->addOnLoad('loadModulePages(' . json_encode($modulePanes) . ');');
                 $this->addOnOrientationChange('moduleHandleWindowResize();');
             } else {
                 $this->assign('modules', $this->getAllModuleNavigationData(self::EXCLUDE_HIDDEN_MODULES));
                 $this->assign('hideImages', $this->getOptionalModuleVar('HIDE_IMAGES', false));
             }
             if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                 $noticeData = $this->getOptionalModuleSection('notice');
                 if ($noticeData) {
                     $bannerNotice = null;
                     // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                     if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                         $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                         $controller = WebModule::factory($moduleID);
                         $string = "Module {$moduleID}";
                     } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                         $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                     } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                         $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                     } else {
                         throw new KurogoConfigurationException("Banner alert not properly configured");
                     }
                     if (!$controller instanceof HomeAlertInterface) {
                         throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                     }
                     $bannerNotice = $controller->getHomeScreenAlert();
                     if ($bannerNotice) {
                         $this->assign('bannerNotice', $bannerNotice);
                         // is this necessary?
                         $bannerModule = $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice');
                         if ($bannerModule) {
                             $this->assign('bannerURL', $this->buildURLForModule($moduleID, 'index'));
                         }
                     }
                 }
             }
             if ($this->getOptionalModuleVar('SHOW_FEDERATED_SEARCH', true)) {
                 $this->assign('showFederatedSearch', true);
                 $this->assign('placeholder', $this->getLocalizedString("SEARCH_PLACEHOLDER", Kurogo::getSiteString('SITE_NAME')));
             }
             if ($this->getPlatform() == 'iphone' && $this->getOptionalModuleVar('ADD_TO_HOME', false)) {
                 $this->addInternalJavascript('/common/javascript/lib/add2homeConfig.js');
                 $this->addInternalJavascript('/common/javascript/lib/add2home.js');
                 $this->addInternalCSS('/common/css/add2home.css');
             }
             $this->assignUserContexts($this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true));
             $this->assign('SHOW_DOWNLOAD_TEXT', Kurogo::getOptionalSiteVar('downloadText', '', $this->platform, 'apps'));
             $homeModuleID = $this->getHomeModuleID();
             if ($iconSet = $this->getOptionalThemeVar('navigation_icon_set')) {
                 $iconSetSize = $this->getOptionalThemeVar('navigation_icon_size');
                 $downloadImgPrefix = "/common/images/iconsets/{$iconSet}/{$iconSetSize}/download";
             } else {
                 $downloadImgPrefix = "/modules/{$homeModuleID}/images/download";
             }
             $this->assign('downloadImgPrefix', $downloadImgPrefix);
             $this->assign('displayType', $this->getModuleVar('display_type'));
             break;
         case 'search':
             $searchTerms = $this->getArg('filter');
             $useAjax = $this->pagetype != 'basic';
             $searchModules = array();
             if ($this->getOptionalModuleVar('SHOW_FEDERATED_SEARCH', true)) {
                 $this->assign('showFederatedSearch', true);
                 foreach ($this->getAllModuleNavigationData(self::EXCLUDE_HIDDEN_MODULES) as $type => $modules) {
                     foreach ($modules as $id => $info) {
                         if ($id == 'customize') {
                             continue;
                         }
                         $module = self::factory($id);
                         if ($module->getOptionalModuleVar('search', false, 'module')) {
                             $searchModule = array('id' => $id, 'elementId' => 'federatedSearchModule_' . $id, 'title' => $info['title']);
                             if ($useAjax) {
                                 $searchModule['ajaxURL'] = FULL_URL_PREFIX . ltrim($this->buildURL('searchResult', array('id' => $id, 'filter' => $searchTerms)), '/');
                             } else {
                                 $searchModule['results'] = $this->runFederatedSearchForModule($module, $searchTerms);
                             }
                             $searchModules[] = $searchModule;
                         }
                     }
                 }
                 if ($useAjax) {
                     $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js');
                     $this->addInlineJavascript('var federatedSearchModules = ' . json_encode($searchModules) . ";\n");
                     $this->addOnLoad('runFederatedSearch(federatedSearchModules);');
                 }
             }
             $this->assign('federatedSearchModules', $searchModules);
             $this->assign('searchTerms', $searchTerms);
             $this->setLogData($searchTerms);
             break;
         case 'modules':
             $configModule = $this->getArg('configModule', $this->configModule);
             $this->assign('modules', $this->getAllModuleNavigationData(self::EXCLUDE_HIDDEN_MODULES));
             $this->assign('hideImages', $this->getOptionalModuleVar('HIDE_IMAGES', false));
             $this->assign('displayType', $this->getModuleVar('display_type'));
             if ($configModule == $this->configModule && $this->getOptionalModuleVar('SHOW_FEDERATED_SEARCH', true)) {
                 $this->assign('showFederatedSearch', true);
                 $this->assign('placeholder', $this->getLocalizedString("SEARCH_PLACEHOLDER", Kurogo::getSiteString('SITE_NAME')));
             }
             $this->assignUserContexts($this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true));
             break;
         case 'searchResult':
             $moduleID = $this->getArg('id');
             $searchTerms = $this->getArg('filter');
             $this->setLogData($searchTerms);
             $module = self::factory($moduleID);
             $this->assign('federatedSearchResults', $this->runFederatedSearchForModule($module, $searchTerms));
             break;
         case 'pane':
             // This wrapper exists so we can catch module errors and prevent redirection to the error page
             $moduleID = $this->getArg('id');
             try {
                 $module = self::factory($moduleID, 'pane', array(self::AJAX_PARAMETER => 1));
                 $content = $module->fetchPage();
             } catch (Exception $e) {
                 Kurogo::log(LOG_WARNING, $e->getMessage(), "home", $e->getTrace());
                 $content = '<p class="nonfocal">' . $this->getLocalizedString('ERROR_MODULE_PANE') . '</p>';
             }
             $this->assign('content', $content);
             break;
         case 'customize':
             $allowCustomize = $this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true);
             $this->assign('allowCustomize', $allowCustomize);
             if (!$allowCustomize) {
                 break;
             }
             $this->handleCustomizeRequest($this->args);
             $modules = $this->getModuleCustomizeList();
             $moduleIDs = array_keys($modules);
             switch ($this->pagetype) {
                 case 'compliant':
                 case 'tablet':
                     $this->addInlineJavascript('var MODULE_NAV_COOKIE = "' . self::MODULE_NAV_COOKIE . '";' . 'var MODULE_NAV_COOKIE_LIFESPAN = ' . Kurogo::getSiteVar('MODULE_NAV_COOKIE_LIFESPAN') . ';' . 'var COOKIE_PATH = "' . COOKIE_PATH . '";');
                     $this->addInlineJavascriptFooter('init();');
                     break;
                 case 'basic':
                     foreach ($moduleIDs as $index => $id) {
                         $modules[$id]['toggleVisibleURL'] = $this->buildBreadcrumbURL('index', array('action' => $modules[$id]['visible'] ? 'off' : 'on', 'module' => $id), false);
                         if ($index > 0) {
                             $modules[$id]['swapUpURL'] = $this->buildBreadcrumbURL('index', array('action' => 'swap', 'module1' => $id, 'module2' => $moduleIDs[$index - 1]), false);
                         }
                         if ($index < count($moduleIDs) - 1) {
                             $modules[$id]['swapDownURL'] = $this->buildBreadcrumbURL('index', array('action' => 'swap', 'module1' => $id, 'module2' => $moduleIDs[$index + 1]), false);
                         }
                     }
                     break;
                 default:
                     break;
             }
             // show user selectable context switching
             if ($contexts = Kurogo::sharedInstance()->getContexts()) {
                 $userContextList = $this->getUserContextListData('customizemodules', false);
                 $this->assign('customizeUserContextListDescription', $this->getLocalizedString('USER_CONTEXT_LIST_DESCRIPTION'));
                 if ($this->platform == 'iphone') {
                     $this->assign('customizeUserContextListDescriptionFooter', $this->getLocalizedString('USER_CONTEXT_LIST_DESCRIPTION_FOOTER_DRAG'));
                 } else {
                     $this->assign('customizeUserContextListDescriptionFooter', $this->getLocalizedString('USER_CONTEXT_LIST_DESCRIPTION_FOOTER'));
                 }
                 $this->assign('customizeUserContextList', $userContextList);
             } else {
                 $key = 'CUSTOMIZE_INSTRUCTIONS';
                 if ($this->pagetype == 'compliant' || $this->pagetype == 'tablet') {
                     $key = 'CUSTOMIZE_INSTRUCTIONS_' . strtoupper($this->pagetype);
                     if ($this->platform == 'iphone') {
                         $key .= '_DRAG';
                     }
                 }
                 $this->assign('customizeInstructions', $this->getLocalizedString($key));
             }
             $this->assign('modules', $modules);
             break;
         case 'customizemodules':
             $modules = $this->getModuleCustomizeList();
             $this->assign('modules', $modules);
             break;
     }
 }
Пример #7
0
 protected function getUserContextListData($reloadPage = 'modules', $includeCustom = true)
 {
     // show user selectable context switching
     if ($contexts = Kurogo::sharedInstance()->getContexts()) {
         $userContextList = array();
         $ajaxURLPrefix = Kurogo::getSiteVar('DEVICE_DEBUG') ? rtrim(URL_PREFIX, '/') : '';
         $activeCount = 0;
         $homeModuleID = $this->getHomeModuleID();
         $userCustomized = (bool) $this->getUserNavData();
         foreach ($contexts as $context) {
             if ($context->isManual()) {
                 $args = array_merge($context->getContextArgs(), array('resetUserNavData' => 1));
                 if ($this->pagetype == 'compliant' || $this->pagetype == 'tablet') {
                     $ajax = true;
                     $url = $ajaxURLPrefix . self::buildURLForModule($homeModuleID, $reloadPage, $args);
                 } else {
                     $ajax = false;
                     $url = self::buildURLForModule($homeModuleID, 'index', $args);
                 }
                 $userContextList[] = array('active' => $context->isActive() && !$userCustomized, 'context' => $context->getID(), 'ajax' => $ajax, 'title' => $context->getTitle(), 'url' => $url);
             }
         }
         if ($includeCustom && $userCustomized) {
             $userContextList[] = array('title' => Kurogo::getSiteString("USER_CONTEXT_CUSTOM"), 'active' => true, 'url' => $this->buildURLForModule($homeModuleID, 'customize'), 'ajax' => false);
         }
         return $userContextList;
     }
 }
Пример #8
0
 protected function initializeForPage()
 {
     switch ($this->page) {
         case 'help':
             break;
         case 'index':
             if ($this->pagetype == 'tablet') {
                 $modulePanes = $this->getTabletModulePanes($this->getModuleSection('tablet_panes'));
                 $this->assign('modulePanes', $modulePanes);
                 $this->addOnLoad('loadModulePages(' . json_encode($modulePanes) . ');');
                 $this->addOnOrientationChange('moduleHandleWindowResize();');
             } else {
                 $this->assign('modules', $this->getModuleNavlist());
                 $this->assign('hideImages', $this->getOptionalModuleVar('HIDE_IMAGES', false));
                 if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                     $noticeData = $this->getOptionalModuleSection('notice');
                     if ($noticeData) {
                         $bannerNotice = null;
                         // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                         if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                             $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                             $controller = WebModule::factory($moduleID);
                             $string = "Module {$moduleID}";
                         } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                             $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                             $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                         } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                             $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                             $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                         } else {
                             throw new KurogoConfigurationException("Banner alert not properly configured");
                         }
                         if (!$controller instanceof HomeAlertInterface) {
                             throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                         }
                         $bannerNotice = $controller->getHomeScreenAlert();
                         if ($bannerNotice) {
                             $this->assign('bannerNotice', $bannerNotice);
                             // is this necessary?
                             $bannerModule = $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice');
                             if ($bannerModule) {
                                 $this->assign('bannerURL', $this->buildURLForModule($moduleID, 'index'));
                             }
                         }
                     }
                 }
             }
             if ($this->getOptionalModuleVar('SHOW_FEDERATED_SEARCH', true)) {
                 $this->assign('showFederatedSearch', true);
                 $this->assign('placeholder', $this->getLocalizedString("SEARCH_PLACEHOLDER", Kurogo::getSiteString('SITE_NAME')));
             }
             if ($this->getPlatform() == 'iphone' && $this->getOptionalModuleVar('ADD_TO_HOME', false)) {
                 $this->addInternalJavascript('/common/javascript/lib/add2homeConfig.js');
                 $this->addInternalJavascript('/common/javascript/lib/add2home.js');
                 $this->addInternalCSS('/common/css/add2home.css');
             }
             $this->assign('SHOW_DOWNLOAD_TEXT', DownloadWebModule::appDownloadText($this->platform));
             $this->assign('displayType', $this->getModuleVar('display_type'));
             break;
         case 'search':
             $searchTerms = $this->getArg('filter');
             $useAjax = $this->pagetype != 'basic' && $this->pagetype != 'touch';
             $searchModules = array();
             foreach ($this->getAllModuleNavigationData(self::EXCLUDE_DISABLED_MODULES) as $type => $modules) {
                 foreach ($modules as $id => $info) {
                     $module = self::factory($id);
                     if ($module->getModuleVar('search')) {
                         $searchModule = array('id' => $id, 'elementId' => 'federatedSearchModule_' . $id, 'title' => $info['title']);
                         if ($useAjax) {
                             $searchModule['ajaxURL'] = FULL_URL_PREFIX . ltrim($this->buildURL('searchResult', array('id' => $id, 'filter' => $searchTerms)), '/');
                         } else {
                             $searchModule['results'] = $this->runFederatedSearchForModule($module, $searchTerms);
                         }
                         $searchModules[] = $searchModule;
                     }
                 }
             }
             if ($useAjax) {
                 $this->addInlineJavascript('var federatedSearchModules = ' . json_encode($searchModules) . ";\n");
                 $this->addOnLoad('runFederatedSearch(federatedSearchModules);');
             }
             $this->assign('federatedSearchModules', $searchModules);
             $this->assign('searchTerms', $searchTerms);
             $this->setLogData($searchTerms);
             break;
         case 'searchResult':
             $moduleID = $this->getArg('id');
             $searchTerms = $this->getArg('filter');
             $module = self::factory($moduleID);
             $this->assign('federatedSearchResults', $this->runFederatedSearchForModule($module, $searchTerms));
             break;
         case 'pane':
             // This wrapper exists so we can catch module errors and prevent redirection to the error page
             $moduleID = $this->getArg('id');
             try {
                 $module = self::factory($moduleID, 'pane', array('ajax' => 1));
                 $content = $module->fetchPage();
             } catch (Exception $e) {
                 Kurogo::log(LOG_WARNING, $e->getMessage(), "home", $e->getTrace());
                 $content = '<p class="nonfocal">' . $this->getLocalizedString('ERROR_MODULE_PANE') . '</p>';
             }
             $this->assign('content', $content);
             break;
     }
 }
Пример #9
0
 public function initializeForCommand()
 {
     switch ($this->command) {
         case 'hello':
             $allmodules = $this->getAllModules();
             if ($this->requestedVersion >= 3) {
                 $version = 3;
             } else {
                 $version = 2;
                 $homeModuleData = $this->getAllModuleNavigationData();
                 $homeModules = array('primary' => array_keys($homeModuleData['primary']), 'secondary' => array_keys($homeModuleData['secondary']));
             }
             $platform = $this->clientPlatform;
             if ($this->clientPagetype == 'tablet') {
                 $platform .= '-tablet';
             }
             foreach ($allmodules as $moduleID => $module) {
                 if ($module->isEnabled()) {
                     //home is deprecated in lieu of using the "modules" command of the home module
                     $home = false;
                     if ($version < 3) {
                         if (($key = array_search($moduleID, $homeModules['primary'])) !== FALSE) {
                             if (Kurogo::arrayVal($homeModuleData['primary'][$moduleID], 'visible', true)) {
                                 $title = Kurogo::arrayVal($homeModuleData['primary'][$moduleID], 'title', $module->getModuleVar('title'));
                                 $home = array('type' => 'primary', 'order' => $key, 'title' => $title);
                             }
                         } elseif (($key = array_search($moduleID, $homeModules['secondary'])) !== FALSE) {
                             if (Kurogo::arrayVal($homeModuleData['secondary'][$moduleID], 'visible', true)) {
                                 $title = Kurogo::arrayVal($homeModuleData['secondary'][$moduleID], 'title', $module->getModuleVar('title'));
                                 $home = array('type' => 'secondary', 'order' => $key, 'title' => $title);
                             }
                         }
                     }
                     $moduleResponse = array('id' => $module->getID(), 'tag' => $module->getConfigModule(), 'icon' => $module->getOptionalModuleVar('icon', $module->getConfigModule(), 'module'), 'title' => $module->getModuleVar('title', 'module'), 'access' => $module->getAccess(AccessControlList::RULE_TYPE_ACCESS), 'payload' => $module->getPayload(), 'bridge' => $module->getWebBridgeConfig($platform), 'vmin' => $module->getVmin(), 'vmax' => $module->getVmax());
                     if ($version < 3) {
                         $moduleResponse['home'] = $home;
                     }
                     $modules[] = $moduleResponse;
                 }
             }
             $contexts = array();
             foreach (Kurogo::sharedInstance()->getContexts() as $context) {
                 if ($context->isManual()) {
                     $contexts[] = array('id' => $context->getID(), 'title' => $context->getTitle(), 'description' => $context->getDescription());
                 }
             }
             $response = array('timezone' => Kurogo::getSiteVar('LOCAL_TIMEZONE'), 'site' => Kurogo::getSiteString('SITE_NAME'), 'organization' => Kurogo::getSiteString('ORGANIZATION_NAME'), 'version' => KUROGO_VERSION, 'modules' => $modules, 'default' => Kurogo::defaultModule(), 'home' => $this->getHomeModuleID(), 'contexts' => $contexts, 'contextsDisplay' => array('home' => Kurogo::getSiteVar('USER_CONTEXT_LIST_STYLE_NATIVE', 'contexts'), 'customize' => Kurogo::getSiteVar('USER_CONTEXT_LIST_STYLE_CUSTOMIZE', 'contexts')));
             if ($appData = Kurogo::getAppData($this->clientPlatform)) {
                 if ($version = Kurogo::arrayVal($appData, 'version')) {
                     if (version_compare($this->clientVersion, $version) < 0) {
                         $response['appdata'] = array('url' => Kurogo::arrayVal($appData, 'url'), 'version' => Kurogo::arrayVal($appData, 'version'));
                     }
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($version);
             break;
         case 'setcontext':
             $context = $this->getArg('context');
             $response = Kurogo::sharedInstance()->setUserContext($context);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'classify':
             $userAgent = $this->getArg('useragent');
             if (!$userAgent) {
                 throw new KurogoException("useragent parameter not specified");
             }
             $response = Kurogo::deviceClassifier()->classifyUserAgent($userAgent);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         default:
             $this->invalidCommand();
             break;
     }
 }
Пример #10
0
 private function setPageVariables()
 {
     $this->loadTemplateEngineIfNeeded();
     $this->loadPageConfig();
     // Set variables common to all modules
     $this->assign('moduleID', $this->id);
     $this->assign('configModule', $this->configModule);
     $this->assign('templateModule', $this->templateModule);
     $this->assign('moduleName', $this->moduleName);
     $this->assign('page', $this->page);
     $this->assign('isModuleHome', $this->page == 'index');
     $this->assign('request_uri', $_SERVER['REQUEST_URI']);
     $this->assign('hideFooterLinks', $this->hideFooterLinks);
     $this->assign('ajaxContentLoad', $this->ajaxContentLoad);
     $this->assign('charset', Kurogo::getCharset());
     // Font size for template
     $this->assign('fontsizes', $this->fontsizes);
     $this->assign('fontsize', $this->fontsize);
     $this->assign('fontsizeCSS', $this->getFontSizeCSS());
     $this->assign('fontSizeURLs', $this->getFontSizeURLs());
     // Minify URLs
     $this->assign('minify', $this->getMinifyUrls());
     // Google Analytics. This probably needs to be moved
     if ($gaID = Kurogo::getOptionalSiteVar('GOOGLE_ANALYTICS_ID')) {
         $this->assign('GOOGLE_ANALYTICS_ID', $gaID);
         $this->assign('GOOGLE_ANALYTICS_DOMAIN', Kurogo::getOptionalSiteVar('GOOGLE_ANALYTICS_DOMAIN'));
         $this->assign('gaImageURL', $this->googleAnalyticsGetImageUrl($gaID));
     }
     // Percent Mobile Analytics
     if ($pmID = Kurogo::getOptionalSiteVar('PERCENT_MOBILE_ID')) {
         $this->assign('PERCENT_MOBILE_ID', $pmID);
         $pmBASEURL = "http://assets.percentmobile.com/percent_mobile.js";
         $this->assign('PERCENT_MOBILE_URL', $pmBASEURL);
         //$this->assign('pmImageURLJS', $this->percentMobileAnalyticsGetImageUrlJS($pmID));
         $this->assign('pmImageURL', $this->percentMobileAnalyticsGetImageUrl($pmID));
     }
     // Breadcrumbs
     $this->loadBreadcrumbs();
     // Tablet module nav list
     if ($this->pagetype == 'tablet' && $this->page != 'pane') {
         $this->addInternalJavascript('/common/javascript/lib/iscroll-4.0.js');
         $this->assign('moduleNavList', $this->getModuleNavlist());
     }
     Kurogo::log(LOG_DEBUG, "Calling initializeForPage for {$this->configModule} - {$this->page}", 'module');
     $this->initializeForPage();
     //subclass behavior
     Kurogo::log(LOG_DEBUG, "Returned from initializeForPage for {$this->configModule} - {$this->page}", 'module');
     // Set variables for each page
     $this->assign('pageTitle', $this->pageTitle);
     // Variables which may have been modified by the module subclass
     $this->assign('inlineCSSBlocks', $this->inlineCSSBlocks);
     $this->assign('cssURLs', $this->cssURLs);
     $this->assign('inlineJavascriptBlocks', $this->inlineJavascriptBlocks);
     $this->assign('onOrientationChangeBlocks', $this->onOrientationChangeBlocks);
     $this->assign('onLoadBlocks', $this->onLoadBlocks);
     $this->assign('inlineJavascriptFooterBlocks', $this->inlineJavascriptFooterBlocks);
     $this->assign('javascriptURLs', $this->javascriptURLs);
     $this->assign('breadcrumbs', $this->breadcrumbs);
     $this->assign('breadcrumbArgs', $this->getBreadcrumbArgs());
     $this->assign('breadcrumbSamePageArgs', $this->getBreadcrumbArgs(false));
     $this->assign('moduleDebugStrings', $this->moduleDebugStrings);
     $moduleStrings = $this->getOptionalModuleSection('strings');
     $this->assign('moduleStrings', $moduleStrings);
     $this->assign('homeLink', $this->buildURLForModule($this->getHomeModuleID(), '', array()));
     $this->assign('homeModuleID', $this->getHomeModuleID());
     $this->assignLocalizedStrings();
     // Module Help
     if ($this->page == 'help') {
         $this->assign('hasHelp', false);
         $template = 'common/templates/' . $this->page;
     } else {
         $this->assign('hasHelp', isset($moduleStrings['help']));
         $this->assign('helpLink', $this->buildBreadcrumbURL('help', array()));
         $this->assign('helpLinkText', $this->getLocalizedString('HELP_TEXT', $this->getModuleName()));
         $template = 'modules/' . $this->templateModule . '/templates/' . $this->templatePage;
     }
     Kurogo::log(LOG_DEBUG, "Template file is {$template}", 'module');
     // Pager support
     if (isset($this->htmlPager)) {
         $this->assign('pager', $this->getPager());
     }
     // Tab support
     if (isset($this->tabbedView)) {
         $this->assign('tabbedView', $this->tabbedView);
     }
     $this->assign('imageExt', $this->imageExt);
     $this->assign($this->getThemeVars());
     // Access Key Start
     $accessKeyStart = count($this->breadcrumbs);
     if ($this->configModule != $this->getHomeModuleID()) {
         $accessKeyStart++;
         // Home link
     }
     $this->assign('accessKeyStart', $accessKeyStart);
     if (Kurogo::getSiteVar('AUTHENTICATION_ENABLED')) {
         Kurogo::includePackage('Authentication');
         $this->setCacheMaxAge(0);
         $session = $this->getSession();
         $this->assign('session', $session);
         $this->assign('session_isLoggedIn', $this->isLoggedIn());
         $this->assign('showLogin', Kurogo::getSiteVar('AUTHENTICATION_ENABLED') && $this->showLogin());
         if ($this->isLoggedIn()) {
             $user = $session->getUser();
             $authority = $user->getAuthenticationAuthority();
             $this->assign('session_userID', $user->getUserID());
             $this->assign('session_fullName', $user->getFullname());
             if (count($session->getUsers()) == 1) {
                 $this->assign('session_logout_url', $this->buildURLForModule('login', 'logout', array('authority' => $user->getAuthenticationAuthorityIndex())));
                 $this->assign('footerLoginLink', $this->buildURLForModule('login', '', array()));
                 $this->assign('footerLoginText', $this->getLocalizedString('SIGNED_IN_SINGLE', $authority->getAuthorityTitle(), $user->getFullName()));
                 $this->assign('footerLoginClass', $authority->getAuthorityClass());
             } else {
                 $this->assign('footerLoginClass', 'login_multiple');
                 $this->assign('session_logout_url', $this->buildURLForModule('login', 'logout', array()));
                 $this->assign('footerLoginLink', $this->buildURLForModule('login', 'logout', array()));
                 $this->assign('footerLoginText', $this->getLocalizedString('SIGNED_IN_MULTIPLE'));
             }
             if ($session_max_idle = intval(Kurogo::getOptionalSiteVar('AUTHENTICATION_IDLE_TIMEOUT', 0))) {
                 $this->setRefresh($session_max_idle + 2);
             }
         } else {
             $this->assign('footerLoginClass', 'noauth');
             $this->assign('footerLoginLink', $this->buildURLForModule('login', '', array()));
             $this->assign('footerLoginText', $this->getLocalizedString('SIGN_IN_SITE', Kurogo::getSiteString('SITE_NAME')));
         }
     }
     /* set cache age. Modules that present content that rarely changes can set this value
        to something higher */
     header(sprintf("Cache-Control: max-age=%d", $this->cacheMaxAge));
     header("Expires: " . gmdate('D, d M Y H:i:s', time() + $this->cacheMaxAge) . ' GMT');
     return $template;
 }
Пример #11
0
 protected function initializeForCommand()
 {
     // retrieve all Data for the About screen
     $stringArray = $this->getModuleArray('strings');
     $textArray['siteAboutHTML'] = $stringArray[0]['SITE_ABOUT_HTML'];
     $textArray['aboutHTML'] = $stringArray[0]['ABOUT_HTML'];
     $textArray['orgName'] = Kurogo::getSiteString('ORGANIZATION_NAME');
     $textArray['email'] = Kurogo::getSiteString('FEEDBACK_EMAIL');
     $textArray['website'] = Kurogo::getSiteString('COPYRIGHT_LINK');
     $textArray['copyright'] = Kurogo::getSiteString('COPYRIGHT_NOTICE');
     $textArray['credits'] = file_get_contents(MODULES_DIR . "/{$this->id}/templates/credits_html.tpl");
     switch ($this->command) {
         case 'index':
             $dictionaryOfSections = $this->getModuleSections('api-index');
             $response = array();
             foreach ($dictionaryOfSections as $key => $value) {
                 $response[] = $value;
             }
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'about_site':
             $response = "<p>" . implode("</p><p>", $this->getModuleVar('SITE_ABOUT_HTML', 'strings')) . "</p>";
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'about':
             $response = "<p>" . implode("</p><p>", $this->getModuleVar('ABOUT_HTML', 'strings')) . "</p>";
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'credits':
             $response = file_get_contents(MODULES_DIR . "/{$this->id}/templates/credits_html.tpl");
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'orgname':
             $response = array('orgName' => $textArray['orgName']);
             //print_r($response);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'orgtext':
             $response = array('orgText' => $textArray['siteAboutHTML']);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'abouttext':
             $response = array('aboutText' => $textArray['aboutHTML']);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'copyright':
             $response = array('copyright' => $textArray['coyright']);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'email':
             $response = array('email' => $textArray['email']);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'website':
             $response = array('website' => $textArray['website']);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
             // Use 'alldata' to get everything in one API-CALL
         // Use 'alldata' to get everything in one API-CALL
         case 'alldata':
             $response = $textArray;
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         default:
             $this->invalidCommand();
             $this->setResponseVersion(1);
             break;
     }
 }
Пример #12
0
 protected function assignSites()
 {
     $sites = Kurogo::sharedInstance()->getSites();
     if (count($sites) > 1) {
         $currentSite = Kurogo::sharedInstance()->getSite();
         $siteLinks = array();
         foreach ($sites as $site) {
             if ($site->isEnabled()) {
                 $siteLinks[] = array('name' => $site->getName(), 'title' => $site->getTitle(), 'active' => $site->getName() == $currentSite->getName(), 'url' => $site->getURL());
             }
         }
         if ($this->pagetype == 'tablet') {
             $this->assign('siteLinksDescription', Kurogo::getSiteString('SITE_LINKS_DESCRIPTION_TABLET'));
             $siteLinksStyle = Kurogo::getSiteVar('SITES_LIST_STYLE_TABLET', 'sites');
         } else {
             $this->assign('siteLinksDescription', Kurogo::getSiteString('SITE_LINKS_DESCRIPTION_COMPLIANT'));
             $siteLinksStyle = Kurogo::getSiteVar('SITES_LIST_STYLE_COMPLIANT', 'sites');
         }
         $this->assign('siteLinks', $siteLinks);
         $this->assign('siteLinksStyle', $siteLinksStyle);
     }
 }
Пример #13
0
  protected function initializeForPage() {
    if (!Kurogo::getSiteVar('AUTHENTICATION_ENABLED')) {
        throw new Exception("Authentication is not enabled on this site");
    }
    
    $session = $this->getSession();
    $url = $this->getArg('url','');
    $allowRemainLoggedIn = Kurogo::getOptionalSiteVar('AUTHENTICATION_REMAIN_LOGGED_IN_TIME');
    if ($allowRemainLoggedIn) {
        $remainLoggedIn = $this->getArg('remainLoggedIn', 0);
    } else {
        $remainLoggedIn = 0;
    }
    
    $authenticationAuthorities = array(
        'direct'=>array(),
        'indirect'=>array()
    );
    
    $invalidAuthorities = array();
    
    foreach (AuthenticationAuthority::getDefinedAuthenticationAuthorities() as $authorityIndex=>$authorityData) {
        $USER_LOGIN = $this->argVal($authorityData, 'USER_LOGIN', 'NONE');
        
        try {
            $authority = AuthenticationAuthority::getAuthenticationAuthority($authorityIndex);
            $authorityData['listclass'] = $authority->getAuthorityClass();
            $authorityData['title'] = $authorityData['TITLE'];
            $authorityData['url'] = $this->buildURL('login', array(
                'authority'=>$authorityIndex,
                'url'=>$url,
                'remainLoggedIn'=>$remainLoggedIn,
                'startOver'=>1
            ));
            if ($USER_LOGIN=='FORM') {
                $authenticationAuthorities['direct'][$authorityIndex] = $authorityData;
            } elseif ($USER_LOGIN=='LINK') {
                $authenticationAuthorities['indirect'][$authorityIndex] = $authorityData;
            }
        } catch (Exception $e) {
            error_log(sprintf("Invalid authority data for %s: %s", $authorityIndex, $e->getMessage()));
            $invalidAuthorities[$authorityIndex] = $e->getMessage();
        }
    }
                    
    if (count($authenticationAuthorities['direct'])==0 && count($authenticationAuthorities['indirect'])==0) {
        $message = "No authentication authorities have been defined.";
        if (count($invalidAuthorities)>0) {
            $message .= sprintf(" %s invalid authorit%s found:\n", count($invalidAuthorities), count($invalidAuthorities)>1 ?'ies':'y');
            foreach ($invalidAuthorities as $authorityIndex=>$invalidAuthority) {
                $message .= sprintf("%s: %s\n", $authorityIndex, $invalidAuthority);
            }
        }
        throw new Exception($message);
        
    }
    
    $this->assign('authenticationAuthorities', $authenticationAuthorities);
    $this->assign('allowRemainLoggedIn', $allowRemainLoggedIn);
    if ($forgetPasswordURL = $this->getOptionalModuleVar('FORGET_PASSWORD_URL')) {
        $this->assign('FORGET_PASSWORD_URL', $this->buildBreadcrumbURL('forgotpassword', array()));
    }
    
    $multipleAuthorities = count($authenticationAuthorities['direct']) + count($authenticationAuthorities['indirect']) > 1;
    
    switch ($this->page)
    {
        case 'logoutConfirm':
            $authorityIndex = $this->getArg('authority');
            
            if (!$this->isLoggedIn($authorityIndex)) {
                $this->redirectTo('index', array());
            } elseif ($user = $this->getUser($authorityIndex)) {
                $authority = $user->getAuthenticationAuthority();
                $this->assign('message', sprintf("You are signed in to %s %s as %s", 
                    Kurogo::getSiteString('SITE_NAME'),
                    $multipleAuthorities ? "(using ". $authority->getAuthorityTitle() . ")" : '',
                    $user->getFullName()));
                $this->assign('url', $this->buildURL('logout', array('authority'=>$authorityIndex)));
                $this->assign('linkText', 'Sign out');
                $this->setTemplatePage('message');
            } else {
                $this->redirectTo('index', array());
            }
            
            break;
        case 'logout':
            $authorityIndex = $this->getArg('authority');
            $hard = $this->getArg('hard', false);

            if (!$this->isLoggedIn($authorityIndex)) {
                $this->redirectTo('index', array());
            } elseif ($authority = AuthenticationAuthority::getAuthenticationAuthority($authorityIndex)) {
                $result = $session->logout($authority, $hard);
            } else {
                $this->redirectTo('index', array());
            }
                
            if ($result) { 
                if ($this->isLoggedIn()) {
                    $this->redirectTo('index', array('logout'=>$authorityIndex));
                } else {
                    $this->redirectToModule('home','',array('logout'=>$authorityIndex));
                }
            } else {
                $this->setTemplatePage('message');
                $this->assign('message', 'Sign out failed');
            }
        
            break;

        case 'forgotpassword':
            if ($forgetPasswordURL = $this->getOptionalModuleVar('FORGET_PASSWORD_URL')) {
                header("Location: $forgetPasswordURL");
                exit();
            } else {
                $this->redirectTo('index', array());
            }
            break;            
            
        case 'login':
            $login          = $this->argVal($_POST, 'loginUser', '');
            $password       = $this->argVal($_POST, 'loginPassword', '');
            $options = array(
                'url'=>$url,
                'remainLoggedIn'=>$remainLoggedIn
            );
            
            $session  = $this->getSession();
            $session->setRemainLoggedIn($remainLoggedIn);

            $authorityIndex = $this->getArg('authority', '');
            if (!$authorityData = AuthenticationAuthority::getAuthenticationAuthorityData($authorityIndex)) {
                $this->redirectTo('index', $options);
            }

            if ($this->isLoggedIn($authorityIndex)) {
                $this->redirectTo('index', $options);
            }                    

            $this->assign('authority', $authorityIndex);
            $this->assign('remainLoggedIn', $remainLoggedIn);
            $this->assign('authorityTitle', $authorityData['TITLE']);

            if ($authorityData['USER_LOGIN']=='FORM' && empty($login)) {
                break;
            } elseif ($authority = AuthenticationAuthority::getAuthenticationAuthority($authorityIndex)) {
                $authority->setDebugMode(Kurogo::getSiteVar('DATA_DEBUG'));
                $result = $authority->login($login, $password, $session, $options);
            } else {
                $this->redirectTo('index', $options);
            }

            switch ($result)
            {
                case AUTH_OK:
                    if ($url) {
                        header("Location: $url");
                        exit();
                    } else {
                        $this->redirectToModule('home','',array('login'=>$authorityIndex));
                    }
                    break;

                case AUTH_OAUTH_VERIFY:
                    $this->assign('verifierKey',$authority->getVerifierKey());
                    $this->setTemplatePage('oauth_verify.tpl');
                    break;
                    
                default:
                    if ($authorityData['USER_LOGIN']=='FORM') {
                        $this->assign('message', "We're sorry, but there was a problem with your sign-in. Please check your username and password and try again.");
                        $this->setTemplatePage('index');
                    } else {
                        $this->redirectTo('index', array_merge(
                            array('message'=>"We're sorry, but there was a problem with your sign-in."),
                            $options));
                    }
            }
            
        case 'index':
            if ($message = $this->getArg('message')) {
                $this->assign('message', $message);
            }
            
            if ($this->isLoggedIn()) {
                
                if ($url) {
                    header("Location: $url");
                    exit();
                }

                if (!$multipleAuthorities) {
                    $user = $this->getUser();
                    $this->redirectTo('logoutConfirm', array('authority'=>$user->getAuthenticationAuthorityIndex()));
                }

                $sessionUsers = $session->getUsers();
                $users = array();

                foreach ($sessionUsers as $authorityIndex=>$user) {
                    $authority = $user->getAuthenticationAuthority();
                    $users[] = array(
                        'class'=>$authority->getAuthorityClass(),
                        'title'=>count($sessionUsers)>1 ? $authority->getAuthorityTitle() . " as " . $user->getFullName() : 'Sign out',
                        'subtitle'=>count($sessionUsers)>1 ? 'Sign out' : '',
                        'url'  =>$this->buildBreadcrumbURL('logout', array('authority'=>$authorityIndex), false)
                    );
                    if (isset($authenticationAuthorities['direct'][$authorityIndex])) {
                        unset($authenticationAuthorities['direct'][$authorityIndex]);
                    }

                    if (isset($authenticationAuthorities['indirect'][$authorityIndex])) {
                        unset($authenticationAuthorities['indirect'][$authorityIndex]);
                    }
                }
                
                $this->assign('users', $users);
                $this->assign('authenticationAuthorities', $authenticationAuthorities);
                $this->assign('moreAuthorities', count($authenticationAuthorities['direct']) + count($authenticationAuthorities['indirect']));
                $this->setTemplatePage('loggedin');
            } else {
                if (!$multipleAuthorities && count($authenticationAuthorities['direct'])) {
                    $this->redirectTo('login', array('authority'=>AuthenticationAuthority::getDefaultAuthenticationAuthorityIndex()));
                }
                $this->assign('multipleAuthorities', $multipleAuthorities);
            }
            break;
    }
  }