Esempio n. 1
0
 function breadcrumbsForDocument($oDocument, $aOptions = null, $iFolderId = null)
 {
     $bFinal = KTUtil::arrayGet($aOptions, 'final', true, false);
     $aOptions = KTUtil::meldOptions($aOptions, array('final' => false));
     if ($iFolderId == null) {
         $iFolderId = $oDocument->getFolderId();
     }
     $aBreadcrumbs = KTBrowseUtil::breadcrumbsForFolder($iFolderId, $aOptions);
     $sAction = KTUtil::arrayGet($aOptions, 'documentaction');
     $url = KTUtil::addQueryStringSelf('fDocumentId=' . $oDocument->getId());
     if (!empty($sAction)) {
         $url = generateControllerUrl($sAction, 'fDocumentId=' . $oDocument->getId());
     }
     if ($bFinal) {
         $aBreadcrumbs[] = array('name' => $oDocument->getName());
     } else {
         $aBreadcrumbs[] = array('url' => $url, 'name' => $oDocument->getName());
     }
     return $aBreadcrumbs;
 }
Esempio n. 2
0
 function loginRequired()
 {
     $oKTConfig =& KTConfig::getSingleton();
     if ($oKTConfig->get('allowAnonymousLogin', false)) {
         // anonymous logins are now allowed.
         // the anonymous user is -1.
         //
         // we short-circuit the login mechanisms, setup the session, and go.
         $oUser =& User::get(-2);
         if (PEAR::isError($oUser) || $oUser->getName() != 'Anonymous') {
             // do nothing - the database integrity would break if we log the user in now.
         } else {
             $session = new Session();
             $sessionID = $session->create($oUser);
             $this->sessionStatus = $this->session->verify();
             if ($this->sessionStatus === true) {
                 return;
             }
         }
     }
     $sErrorMessage = "";
     if (PEAR::isError($this->sessionStatus)) {
         $sErrorMessage = $this->sessionStatus->getMessage();
     }
     // check if we're in JSON mode - in which case, throw error
     // but JSON mode only gets set later, so gonna have to check action
     if (KTUtil::arrayGet($_REQUEST, 'action', '') == 'json') {
         //$this->bJSONMode) {
         $this->handleOutputJSON(array('error' => true, 'type' => 'kt.not_logged_in', 'alert' => true, 'message' => _kt('Your session has expired, please log in again.')));
         exit(0);
     }
     // redirect to login with error message
     if ($sErrorMessage) {
         // session timed out
         $url = generateControllerUrl("login", "errorMessage=" . urlencode($sErrorMessage));
     } else {
         $url = generateControllerUrl("login");
     }
     $redirect = urlencode(KTUtil::addQueryStringSelf($_SERVER["QUERY_STRING"]));
     if (strlen($redirect) > 1) {
         global $default;
         $default->log->debug("checkSession:: redirect url={$redirect}");
         // this session verification failure represents either the first visit to
         // the site OR a session timeout etc. (in which case we still want to bounce
         // the user to the login page, and then back to whatever page they're on now)
         $url = $url . urlencode("&redirect=" . urlencode($redirect));
     }
     $default->log->debug("checkSession:: about to redirect to {$url}");
     redirect($url);
     exit(0);
 }
Esempio n. 3
0
 function redirectToFolder($id)
 {
     $url = generateControllerUrl("browse", sprintf("fFolderId=%d", $id));
     printf('Go <a href="%s">here</a> to continue', $url);
     printf("</div></div>\n");
 }
Esempio n. 4
0
 function do_downloadZipFile()
 {
     $sCode = $this->oValidator->validateString($_REQUEST['exportcode']);
     $folderName = $this->oFolder->getName();
     $this->oZip = new ZipFolder($folderName);
     $res = $this->oZip->downloadZipFile($sCode);
     if (PEAR::isError($res)) {
         $this->addErrorMessage($res->getMessage());
         redirect(generateControllerUrl("browse", "fBrowseType=folder&fFolderId=" . $this->oFolder->getId()));
     }
     exit(0);
 }
 function providerVerify_return()
 {
     $url = KTUtil::arrayGet($_SESSION, 'providerVerifyReturnUrl');
     if (empty($url)) {
         $url = generateControllerUrl('login');
     }
     redirect($url);
     exit(0);
 }
Esempio n. 6
0
                $action = 'dashboard';
            }
        }
    } else {
        // session check fails, so default action should be the login form if no action was specified
        $oKTConfig = KTConfig::getSingleton();
        $dest = 'login';
        if ($oKTConfig->get('allowAnonymousLogin', false)) {
            $dest = 'dashboard';
        }
        if (!isset($action)) {
            $action = $dest;
        } elseif ($action != $dest) {
            // we have a controller link and auth has failed, so redirect to the login page
            // with the controller link as the redirect
            $url = generateControllerUrl('login');
            $redirect = urlencode($_SERVER[PHP_SELF] . '?' . $_SERVER['QUERY_STRING']);
            if (strlen($redirect) > 1) {
                $url = $url . '&redirect=' . $redirect;
            }
            if (PEAR::isError($ret)) {
                $url = $url . '&errorMessage=' . urlencode($ret->getMessage());
                session_start();
                $_SESSION['errormessage']['login'] = $ret->getMessage();
            }
            redirect($url);
            exit(0);
        }
    }
}
// we appear to have some encoding/decoding issues, so we need to force-check for %30 type situations