| // | Julien Casanova | // +---------------------------------------------------------------------------+ /** * User / Login Block2. * * Shows login form if not logged in, user data (username and "session started at") * if logged in * * @package block * @author Andrey Podshivalov * @author Julien Casanova */ class User_Block_Login2 { var $template = 'blockLogin.html'; var $templatePath = 'user'; function init(&$output, $block_id, &$aParams) { SGL::logMessage(null, PEAR_LOG_DEBUG); $this->uid = isset($output->loggedOnUserID) ? $output->loggedOnUserID : ''; return $this->getBlockContent($output, $aParams); } function getBlockContent(&$output, &$aParams) { SGL::logMessage(null, PEAR_LOG_DEBUG); $blockOutput = new SGL_Output(); $theme = isset( $_SESSION['aPrefs']['theme']) ? $_SESSION['aPrefs']['theme'] : 'default'; $blockOutput->theme = $theme; $imageDir = (isset($output->imagesDir)) ? $output->imagesDir : SGL_BASE_URL . '/themes/' . $theme . '/image' ; $blockOutput->imagesDir = $imageDir; $c = &SGL_Config::singleton(); $blockOutput->conf = $c->ensureModuleConfigLoaded('user'); if ($this->uid == SGL_GUEST) { // display login info if (array_key_exists('loginTemplate', $aParams)) { // set block params $this->template = $aParams['loginTemplate']; } if (!empty($output->conf['tuples']['demoMode'])) { $blockOutput->username = 'admin'; $blockOutput->password = 'admin'; } else { $blockOutput->username = ''; $blockOutput->password = ''; } } else { // user is logged in, display connection info if (array_key_exists('loginTemplate', $aParams)) { // set block params $this->template = $aParams['logoutTemplate']; } $blockOutput->loggedOnUserID = $this->uid; $blockOutput->loggedOnUser = isset($output->loggedOnUser) ? $output->loggedOnUser : ''; $blockOutput->loggedOnSince = isset($output->loggedOnSince) ? $output->loggedOnSince : ''; } return $this->process($blockOutput); } function process(&$output) { // use moduleName for template path setting $output->moduleName = $this->templatePath; $output->masterTemplate = $this->template; $view = new SGL_HtmlSimpleView($output); return $view->render(); } } ?>